/* Curio — dark, playful, iPhone-first. One fixed theme so the iOS home-screen strip
   (painted with the manifest background) always matches the docked tab bar. */

:root {
  --bg: #0e0f13;
  --surface: #17191f;
  --surface-2: #1f222a;
  --surface-3: #2a2e38;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f1f2f5;
  --muted: #9aa1ae;
  --faint: #6b7280;
  --accent: #9d8cff;
  --accent-strong: #8b78ff;
  --accent-ink: #14102e;
  --accent-soft: rgba(157, 140, 255, 0.14);
  --good: #4ade9a;
  --good-soft: rgba(74, 222, 154, 0.13);
  --bad: #ff6b7a;
  --bad-soft: rgba(255, 107, 122, 0.13);
  --flame: #ffb547;
  --flame-soft: rgba(255, 181, 71, 0.14);
  --blue: #5cc8ff;
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Inter, Roboto, sans-serif;
  --font-round: ui-rounded, 'SF Pro Rounded', -apple-system, 'Segoe UI', 'Nunito', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }
svg:not([width]) { width: 20px; height: 20px; flex-shrink: 0; }
h1, h2, h3, h4 { font-family: var(--font-round); margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 21px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0 0 0.75em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13.5px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.lg { gap: 20px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ shell */

#app { min-height: 100dvh; }
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  animation: page-in 0.28s ease both;
}
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; min-height: 44px; }
.topbar .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; padding: 8px 8px 8px 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  transition: color 0.15s;
}
.tabbar a svg { width: 25px; height: 25px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { color: var(--accent); }
.brand { display: none; }

@media (min-width: 900px) {
  .tabbar {
    top: 0; right: auto; width: 232px; height: auto;
    grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px;
    padding: 28px 14px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; padding: 11px 14px; border-radius: 12px; }
  .tabbar a.on { background: var(--surface); }
  .tabbar a svg { width: 22px; height: 22px; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 14px 22px; font-family: var(--font-round); font-weight: 800; font-size: 22px; }
  .page { margin-left: max(232px, calc(50vw - 360px + 116px)); padding-top: 36px; padding-bottom: 60px; }
}

/* ------------------------------------------------------------------ cards & controls */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}
.card.tap { transition: transform 0.12s ease, background 0.15s; cursor: pointer; }
.card.tap:active { transform: scale(0.985); background: var(--surface-2); }
.card.glow { position: relative; overflow: hidden; }
.card.glow::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 100% 0%, hsla(var(--hue, 250), 90%, 70%, 0.18), transparent 60%);
}
.card.glow > * { position: relative; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }
.section-title h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-family: var(--font); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 750; font-size: 16.5px; letter-spacing: 0.005em;
  transition: transform 0.1s ease, filter 0.15s, opacity 0.15s;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.99); filter: brightness(0.95); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.good { background: var(--good); color: #062716; }
.btn.bad { background: var(--bad); color: #2e0409; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14.5px; border-radius: 12px; }
.btn.link { background: none; box-shadow: none; color: var(--accent); padding: 0 6px; min-height: 40px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.icon-btn svg { width: 20px; height: 20px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--text);
}
.chip.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.flame { background: var(--flame-soft); border-color: transparent; color: var(--flame); }
.chip.good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.chip.acc { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip svg { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13.5px; font-weight: 650; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px;
  padding: 13px 14px; font-size: 16px; outline: none; transition: border-color 0.15s, background 0.15s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); background: var(--surface-3); }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }

.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 40px; border-radius: 10px; font-weight: 650; color: var(--muted); font-size: 14.5px; }
.seg button.on { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.5s ease; }
.bar.good > i { background: var(--good); }
.bar.flame > i { background: var(--flame); }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; border: 1px solid var(--line-2); }

.empty { text-align: center; padding: 34px 16px; }
.empty .big { font-size: 52px; margin-bottom: 8px; }

/* ------------------------------------------------------------------ today */

.hello h1 { font-size: 30px; }
.hello .date { color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 2px; text-transform: capitalize; }
.stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.anchor-line { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px dashed var(--line-2); color: var(--muted); font-size: 14px; margin-top: 12px; }
.anchor-line b { color: var(--text); font-weight: 650; }

.lesson-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.lesson-card .emoji { font-size: 34px; line-height: 1; }
.lesson-card .meta { font-size: 13px; color: var(--muted); font-weight: 600; }
.lesson-card h2 { font-size: 20px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: middle; }
.building { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14.5px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex-shrink: 0; }
.spinner.lg { width: 44px; height: 44px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

.habit-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.habit-row .emoji { font-size: 26px; width: 34px; text-align: center; }
.habit-row .name { font-weight: 650; }
.habit-row .cue { font-size: 13px; color: var(--muted); }
.check {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  border: 2px solid var(--line-2); color: transparent; transition: all 0.2s cubic-bezier(0.3, 1.6, 0.6, 1);
  font-weight: 800; font-size: 14px;
}
.check svg { width: 22px; height: 22px; }
.check.done { background: var(--good); border-color: var(--good); color: #062716; transform: scale(1.04); }
.check.partial { border-color: var(--good); color: var(--good); }
.week-dots { display: flex; gap: 5px; margin-top: 6px; }
.week-dots i { width: 9px; height: 9px; border-radius: 3px; background: var(--surface-3); }
.week-dots i.on { background: var(--good); }
.week-dots i.off { background: transparent; border: 1px solid var(--surface-3); }

.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; font-weight: 800; font-family: var(--font-round); }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------ learn / topic */

.topic-card { display: flex; gap: 14px; align-items: flex-start; }
.topic-card .emoji { font-size: 30px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface-2); border-radius: 14px; flex-shrink: 0; }
.path { position: relative; display: flex; flex-direction: column; gap: 6px; }
.unit-head { margin: 22px 0 8px; }
.unit-head .n { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.path-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; }
.path-item .node {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); border: 2px solid var(--line-2); font-size: 14px; font-weight: 800; color: var(--faint);
}
.path-item.done .node { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.path-item.current { background: var(--surface); border: 1px solid var(--accent); }
.path-item.current .node { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 5px var(--accent-soft); }
.path-item.locked { opacity: 0.55; }
.path-item .t { font-weight: 600; font-size: 15px; }
.path-item .o { font-size: 12.5px; color: var(--muted); }
.notes { font-size: 14.5px; }
.notes p { margin-bottom: 0.4em; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stat-grid.four { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat .v { font-family: var(--font-round); font-weight: 800; font-size: 24px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------------ lesson player */

.player {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column;
  animation: page-in 0.25s ease both;
}
.player-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px; max-width: 760px; width: 100%; margin: 0 auto;
}
.progress-segs { flex: 1; display: flex; gap: 4px; }
.progress-segs i { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-3); transition: background 0.3s; }
.progress-segs i.done { background: var(--accent); }
.progress-segs i.now { background: linear-gradient(90deg, var(--accent) 50%, var(--surface-3) 50%); }
.player-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.player-inner { max-width: 680px; margin: 0 auto; padding: 14px 18px 150px; }
.player-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  padding: 12px 16px calc(var(--safe-bottom) + 12px);
  background: var(--bg); border-top: 1px solid var(--line);
}
.player-foot .inner { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; }
.player-foot .inner > .btn { flex: 1; }

.step-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.step-kicker.good { color: var(--good); }
.step-kicker.flame { color: var(--flame); }
.step-kicker.blue { color: var(--blue); }
.step-title { font-size: 24px; margin-bottom: 14px; }
.q { font-family: var(--font-round); font-size: 21px; font-weight: 700; line-height: 1.3; margin-bottom: 18px; }

.md { font-size: 17px; line-height: 1.62; }
.md p { margin: 0 0 0.85em; }
.md strong { color: #fff; font-weight: 700; background: linear-gradient(transparent 62%, rgba(157, 140, 255, 0.28) 62%); }
.md ul, .md ol { padding-left: 1.3em; margin: 0 0 0.85em; }
.md li { margin: 0.25em 0; }
.md code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.88em; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 0.85em; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.md h3, .md h4 { margin: 1em 0 0.5em; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.md table { border-collapse: collapse; margin: 0 0 1em; font-size: 15px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; }

.keyidea { margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--accent-soft); border: 1px solid rgba(157, 140, 255, 0.35); display: flex; gap: 12px; }
.keyidea .i { font-size: 20px; }
.keyidea .txt { font-weight: 650; }
.diagram { margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.diagram img { width: 100%; display: block; }

.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; min-height: 56px; border-radius: 16px;
  background: var(--surface); border: 2px solid var(--line-2);
  font-size: 16.5px; font-weight: 550; line-height: 1.35;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.opt:active { transform: translateY(1px); }
.opt .k { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font-size: 13px; font-weight: 800; color: var(--muted); flex-shrink: 0; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .k { background: var(--accent); color: var(--accent-ink); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .k { background: var(--good); color: #062716; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); color: #2e0409; }
.opt.dim { opacity: 0.5; }
.opt.idk { border-style: dashed; color: var(--muted); box-shadow: none; }
.options.locked .opt { pointer-events: none; }

.confidence { margin-top: 18px; }
.confidence .lbl { font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 8px; }

.numeric-row { display: flex; align-items: center; gap: 10px; }
.numeric-row .input { font-size: 22px; font-weight: 700; text-align: center; font-family: var(--font-round); }
.numeric-row .unit { color: var(--muted); font-weight: 650; }

.order-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.order-slot { min-height: 52px; border-radius: 14px; border: 2px dashed var(--line-2); display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--faint); }
.order-slot.filled { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; cursor: pointer; }
.order-slot.right { border-color: var(--good); background: var(--good-soft); }
.order-slot.wrong { border-color: var(--bad); background: var(--bad-soft); }
.order-slot .n { font-weight: 800; color: var(--accent); width: 20px; }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.order-pool .opt { width: auto; min-height: 48px; }

.ex-step { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.ex-step:first-child { border-top: 0; }
.ex-step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 13px; font-weight: 800; flex-shrink: 0; margin-top: 2px; }
.reveal { width: 100%; padding: 14px; border-radius: 14px; border: 2px dashed var(--accent); color: var(--accent); font-weight: 700; background: var(--accent-soft); text-align: center; }

.video { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; margin: 4px 0 14px; }
.video iframe, .video img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.video .play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.25); }
.video .play span { width: 68px; height: 68px; border-radius: 50%; background: rgba(255, 255, 255, 0.95); display: grid; place-items: center; color: #111; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.video .play svg { width: 28px; height: 28px; margin-left: 4px; }

.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 42;
  padding: 18px 16px calc(var(--safe-bottom) + 14px);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  animation: slide-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
  max-height: 72dvh; overflow-y: auto;
}
.feedback .inner { max-width: 680px; margin: 0 auto; }
.feedback.good { background: #12281f; border-top: 2px solid var(--good); }
.feedback.bad { background: #2c1519; border-top: 2px solid var(--bad); }
.feedback.info { background: var(--surface-2); border-top: 2px solid var(--accent); }
.feedback h3 { font-size: 21px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.feedback.good h3 { color: var(--good); }
.feedback.bad h3 { color: var(--bad); }
.feedback .md { font-size: 15.5px; }
.feedback .actions { display: flex; gap: 10px; margin-top: 14px; }
.feedback .actions .btn { flex: 1; }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }

.intro { text-align: center; padding-top: 6vh; }
.intro .emoji { font-size: 76px; line-height: 1; margin-bottom: 18px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.intro .hook { font-size: 18px; line-height: 1.55; margin-top: 16px; color: var(--text); text-align: left; background: var(--surface); padding: 16px; border-radius: 16px; border: 1px solid var(--line); }

.celebrate { text-align: center; padding-top: 8vh; }
.celebrate .big { font-size: 84px; animation: pop 0.6s cubic-bezier(0.3, 1.8, 0.5, 1) both; }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } }
.xp-count { font-family: var(--font-round); font-weight: 900; font-size: 48px; color: var(--flame); }

/* ------------------------------------------------------------------ sheets, toasts, loaders */

.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); animation: fade 0.2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-top-left-radius: 24px; border-top-right-radius: 24px;
  border-top: 1px solid var(--line-2);
  animation: slide-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  padding-bottom: var(--safe-bottom);
}
@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 5vh; border-radius: 24px; border: 1px solid var(--line-2); animation: fade 0.2s both; max-height: 86vh; }
}
.sheet .grab { width: 38px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 9px auto 0; flex-shrink: 0; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px 6px; }
.sheet .sheet-body { overflow-y: auto; padding: 8px 18px 18px; -webkit-overflow-scrolling: touch; }

.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 11px 14px; border-radius: 18px; max-width: 92%; font-size: 15.5px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; font-weight: 550; }
.bubble.ai { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.bubble.ai .md { font-size: 15.5px; }
.chat-input { display: flex; gap: 8px; padding-top: 10px; }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); transform: translateX(-50%); z-index: 90;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--text);
  padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); max-width: calc(100vw - 32px);
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.toast.bad { border-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }

.loader { min-height: 60dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 24px; }
.loader .msg { font-weight: 650; font-size: 17px; min-height: 1.5em; animation: page-in 0.4s both; }
.orb {
  width: 92px; height: 92px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--blue), var(--good), var(--flame), var(--accent));
  filter: blur(0.5px); animation: spin 2.4s linear infinite, breathe 2.4s ease-in-out infinite;
  mask: radial-gradient(circle, transparent 52%, #000 54%);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
}
@keyframes breathe { 50% { transform: scale(1.08) rotate(180deg); } }

/* ------------------------------------------------------------------ habits & charts */

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); }
.heat i.l1 { background: rgba(74, 222, 154, 0.35); }
.heat i.l2 { background: rgba(74, 222, 154, 0.6); }
.heat i.l3 { background: var(--good); }
.heat i.x { background: transparent; }
.heat.acc i.l1 { background: rgba(157, 140, 255, 0.35); }
.heat.acc i.l2 { background: rgba(157, 140, 255, 0.62); }
.heat.acc i.l3 { background: var(--accent); }
.days-pick { display: flex; gap: 6px; }
.days-pick button { flex: 1; height: 42px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); font-weight: 700; color: var(--muted); font-size: 14px; }
.days-pick button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; background: var(--surface-2); border: 1px solid var(--line); }
.emoji-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper button { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 20px; font-weight: 700; }
.stepper b { min-width: 24px; text-align: center; font-size: 18px; }

.calib-row { display: grid; grid-template-columns: 92px 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.chart svg { width: 100%; height: auto; display: block; }

.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px); max-width: 440px; margin: 0 auto; }
.logo-mark { width: 84px; height: 84px; border-radius: 26px; background: linear-gradient(140deg, #a998ff, #6b5cff 55%, #3fd2ff); display: grid; place-items: center; font-size: 44px; box-shadow: 0 16px 50px rgba(120, 100, 255, 0.35); margin-bottom: 26px; }
.gbtn { background: #fff; color: #1f1f1f; box-shadow: none; }
.gbtn svg { width: 20px; height: 20px; }
.science li { margin-bottom: 10px; }
.science b { color: var(--text); }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin: 8px 0 22px; }
.onb-dots i { width: 7px; height: 7px; border-radius: 9px; background: var(--surface-3); transition: width 0.3s; }
.onb-dots i.on { width: 22px; background: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
