:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d9d9de;
  --accent: #0a7d4f;
  --accent-soft: #e3f4ec;
  --accent-text: #ffffff;
  --danger: #c4261d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --surface: #1c1c1f;
    --text: #f2f2f4;
    --muted: #9a9aa2;
    --line: #34343a;
    --accent: #3ccf91;
    --accent-soft: #15332a;
    --accent-text: #06241a;
    --danger: #ff6b62;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 0 0 28px; }

/* ---------- menu ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}

a.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
a.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.tile .icon { font-size: 30px; line-height: 1; }
.tile .name, .tile .hint { display: block; }
.tile .name { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.tile .hint { color: var(--muted); font-size: 14px; margin-top: 2px; }

.tile.off { opacity: .55; box-shadow: none; border-style: dashed; cursor: default; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--line);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- quiz ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.back { color: var(--muted); text-decoration: none; font-size: 15px; }
.back:hover { color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { font-weight: 600; }

.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper output { min-width: 36px; text-align: center; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.btn-round {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 22px; line-height: 1;
}
.btn-round:hover:not(:disabled) { border-color: var(--accent); }
.btn-round:disabled { opacity: .35; cursor: default; }

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.field input {
  width: 100%;
  font: inherit;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.field input.bad { border-color: var(--danger); }
.field input::placeholder { color: var(--line); }

.total {
  width: 100%;
  display: block;
  text-align: center;
  padding: 28px 16px 22px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.total:hover { filter: brightness(.98); }
.total:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.total .cap { display: block; font-size: 14px; color: var(--muted); }
.total .num {
  display: block;
  font-size: 84px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.total .status { display: block; margin-top: 8px; min-height: 22px; font-size: 15px; color: var(--muted); }
.total.done .status { color: var(--accent); font-weight: 600; }

kbd {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:hover { filter: brightness(.96); }

.opts { display: grid; gap: 12px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt small { color: var(--muted); display: block; }

.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 6px 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.keys { color: var(--muted); font-size: 14px; line-height: 2; }

@media (max-width: 480px) {
  .total .num { font-size: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
