:root {
  --bg: #f7f7fb; --surface: #ffffff; --surface-2: #f1f1f7; --text: #16161d; --muted: #62627a; --border: #e3e3ee;
  --accent: #4f46e5; --accent-text: #ffffff; --accent-soft: #eef0ff;
  --danger: #c81e1e; --danger-soft: #fdecec; --warn: #a15c00; --warn-soft: #fff4e0; --ok: #15803d; --ok-soft: #e8f7ee;
  --radius: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111117; --surface: #1a1a22; --surface-2: #23232e; --text: #ececf3; --muted: #9d9db3; --border: #2e2e3b;
    --accent: #8b85ff; --accent-text: #0f0f17; --accent-soft: #24234a;
    --danger: #ff7a7a; --danger-soft: #3a1d22; --warn: #ffb547; --warn-soft: #3a2c16; --ok: #5ad48a; --ok-soft: #173225;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); } .small { font-size: 13px; }
[hidden] { display: none !important; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
header.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
header.top h1 { font-size: 22px; }
main { flex: 1; padding: 4px 16px calc(env(safe-area-inset-bottom) + 84px); display: grid; gap: 14px; align-content: start; }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border);
}
nav.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600; display: grid; justify-items: center; gap: 2px; padding: 6px 0; }
nav.tabs button .ico { font-size: 20px; line-height: 1; }
nav.tabs button.on { color: var(--accent); }

button, .btn {
  font: inherit; font-weight: 600; font-size: 15px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 11px; padding: 10px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; min-height: 44px;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.icon { min-height: 40px; min-width: 40px; padding: 0; font-size: 20px; }
button:disabled { opacity: .5; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.danger { background: var(--danger-soft); color: var(--danger); } .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.accent { background: var(--accent-soft); color: var(--accent); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .spacer { flex: 1; }
.label { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 6px; contain: inline-size; } /* long links shrink to "…" instead of widening the card */
.links a { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 14px; background: var(--warn-soft); color: var(--warn); }

/* Do-this-next deck: native scroll snap */
.deck { display: grid; gap: 8px; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; gap: 12px; scroll-padding: 0 16px; }
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; display: grid; gap: 10px; align-content: start; }
.slide h2 { font-size: 21px; overflow-wrap: anywhere; }
.carousel { align-items: start; }
.sheet h2, .item .t { overflow-wrap: anywhere; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.dots { display: flex; justify-content: center; gap: 5px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.dots span.on { background: var(--accent); }
.progress { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.count { text-align: center; padding: 12px 6px; }
.count b { display: block; font-size: 26px; line-height: 1.1; }
.count.danger b { color: var(--danger); }

section h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 4px 2px 6px; }
.list { display: grid; gap: 6px; }
.item { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; font-weight: 400; padding: 12px 14px; min-height: 0; }
.item .t { font-weight: 650; }
.item .chev { color: var(--muted); font-size: 20px; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.grade { font-size: 30px; font-weight: 800; min-width: 44px; }

/* Bottom sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; animation: fade .15s ease; }
.sheet { width: 100%; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px); display: grid; gap: 12px; animation: up .2s ease; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 2px auto 4px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.instr { white-space: pre-wrap; font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; max-height: 220px; overflow: auto; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.steps { display: grid; gap: 2px; }
.step { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px; border-radius: 10px; font-size: 15px; }
.step input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); }
.step.current { background: var(--accent-soft); font-weight: 600; }
.step.done span { text-decoration: line-through; color: var(--muted); }

input.field, textarea.field { font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); width: 100%; }
textarea.field { resize: vertical; }
.segs { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.seg.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.empty { text-align: center; padding: 28px 16px; }
.setup ol { padding-left: 20px; margin: 0; display: grid; gap: 6px; }
