/* ───────────────────────── Comeback — design system ───────────────────────── */
:root {
  --h: 340;            /* accent hue — set from her theme */
  --s: 68%;            /* accent saturation */
  --font-ui: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;

  --bg: hsl(var(--h) 45% 97.5%);
  --bg-2: hsl(calc(var(--h) + 40) 50% 96%);
  --surface: hsl(0 0% 100% / .78);
  --surface-solid: #fff;
  --surface-2: hsl(var(--h) 40% 96%);
  --text: hsl(var(--h) 22% 15%);
  --text-2: hsl(var(--h) 10% 38%);
  --muted: hsl(var(--h) 8% 55%);
  --line: hsl(var(--h) 25% 90%);
  --line-2: hsl(var(--h) 25% 84%);
  --accent: hsl(var(--h) var(--s) 58%);
  --accent-2: hsl(calc(var(--h) + 35) var(--s) 64%);
  --accent-soft: hsl(var(--h) var(--s) 94%);
  --accent-ink: hsl(var(--h) var(--s) 34%);
  --on-accent: #fff;
  --good: hsl(152 52% 40%);
  --good-soft: hsl(152 50% 93%);
  --warn: hsl(34 90% 48%);
  --warn-soft: hsl(38 95% 92%);
  --bad: hsl(356 70% 54%);
  --bad-soft: hsl(356 80% 95%);
  --shadow-sm: 0 1px 2px hsl(var(--h) 30% 30% / .06), 0 2px 8px hsl(var(--h) 30% 30% / .05);
  --shadow: 0 2px 6px hsl(var(--h) 30% 30% / .06), 0 12px 32px hsl(var(--h) 40% 30% / .08);
  --shadow-lg: 0 24px 60px hsl(var(--h) 40% 20% / .18);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar: 252px;
  --tabbar: 68px;
  color-scheme: light;
}

[data-mode="dark"] {
  --bg: hsl(var(--h) 18% 8%);
  --bg-2: hsl(calc(var(--h) + 40) 20% 10%);
  --surface: hsl(var(--h) 14% 13% / .82);
  --surface-solid: hsl(var(--h) 14% 13%);
  --surface-2: hsl(var(--h) 14% 17%);
  --text: hsl(var(--h) 20% 93%);
  --text-2: hsl(var(--h) 10% 74%);
  --muted: hsl(var(--h) 8% 58%);
  --line: hsl(var(--h) 12% 21%);
  --line-2: hsl(var(--h) 12% 28%);
  --accent: hsl(var(--h) var(--s) 66%);
  --accent-2: hsl(calc(var(--h) + 35) var(--s) 68%);
  --accent-soft: hsl(var(--h) 40% 20%);
  --accent-ink: hsl(var(--h) var(--s) 80%);
  --on-accent: hsl(var(--h) 30% 10%);
  --good: hsl(152 50% 58%);
  --good-soft: hsl(152 35% 17%);
  --warn: hsl(38 90% 62%);
  --warn-soft: hsl(38 40% 17%);
  --bad: hsl(356 80% 68%);
  --bad-soft: hsl(356 40% 18%);
  --shadow-sm: 0 1px 2px #0005;
  --shadow: 0 2px 6px #0004, 0 12px 32px #0005;
  --shadow-lg: 0 24px 60px #000a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 100% -10%, hsl(var(--h) var(--s) 70% / .14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, hsl(calc(var(--h) + 40) var(--s) 70% / .12), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--accent-ink); }
::selection { background: hsl(var(--h) var(--s) 70% / .35); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 6px } .mt-2 { margin-top: 12px } .mt-3 { margin-top: 20px } .mt-4 { margin-top: 32px }
.mb-1 { margin-bottom: 6px } .mb-2 { margin-bottom: 12px } .mb-3 { margin-bottom: 20px }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ───────── layout ───────── */
.app { min-height: 100%; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.app > div { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line);
  background: hsl(var(--h) 40% 99% / .55);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
}
[data-mode="dark"] .sidebar { background: hsl(var(--h) 16% 9% / .6); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 17px;
  box-shadow: 0 6px 16px hsl(var(--h) var(--s) 50% / .35);
}
.brand-name { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14.5px;
  transition: background .2s var(--ease), color .2s;
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 12px; }

.main { min-width: 0; padding: 30px 40px 60px; }
.page { max-width: 1120px; margin: 0 auto; animation: pageIn .45s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 32px; font-weight: 500; letter-spacing: -.025em; }
.page-sub { color: var(--muted); margin-top: 4px; }

.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 8px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: hsl(var(--h) 40% 98% / .8); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
  }
  [data-mode="dark"] .topbar { background: hsl(var(--h) 16% 8% / .8); }
  .topbar .brand { padding: 0; }
  .topbar .brand-name { font-size: 19px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: hsl(var(--h) 40% 99% / .88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
  }
  [data-mode="dark"] .tabbar { background: hsl(var(--h) 16% 9% / .9); }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; border: 0; background: none;
  }
  .tab svg { width: 23px; height: 23px; }
  .tab.active { color: var(--accent-ink); }
  .tab.active svg { transform: translateY(-1px); }
  .page-title { font-size: 26px; }
  .page-head { margin: 10px 0 16px; }
  body { font-size: 15.5px; }
}

/* ───────── surfaces ───────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card.pad-lg { padding: 26px; }
.card.flat { box-shadow: none; }
.card.tint { background: linear-gradient(140deg, var(--accent-soft), var(--surface) 70%); }
.card-title { font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card-title .muted { font-weight: 500; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
a.card, button.card { display: block; text-decoration: none; color: inherit; text-align: left; width: 100%; transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s; }
a.card:hover, button.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
  .card { padding: 16px; border-radius: 20px; }
  .grid { gap: 12px; }
}
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ───────── buttons & inputs ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface-solid); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14.5px; line-height: 1.2;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s; text-decoration: none; white-space: nowrap;
  user-select: none; -webkit-user-select: none;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), hsl(calc(var(--h) + 18) var(--s) 56%)); color: var(--on-accent); border-color: transparent;
  box-shadow: 0 6px 18px hsl(var(--h) var(--s) 50% / .3);
}
[data-mode="dark"] .btn.primary { color: hsl(var(--h) 30% 8%); }
.btn.primary:hover { box-shadow: 0 8px 24px hsl(var(--h) var(--s) 50% / .4); }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.good { background: var(--good); color: #fff; border-color: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { padding: 9px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface-solid); outline: none; transition: border-color .2s, box-shadow .2s;
  font-size: 16px; /* prevents iOS zoom */
}
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px hsl(var(--h) var(--s) 60% / .15); }
.input.sm { padding: 8px 10px; font-size: 14px; }

.seg { display: inline-flex; padding: 4px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.seg button.on { background: var(--surface-solid); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
button.chip { cursor: pointer; }
button.chip.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 99px; display: inline-block; flex: none; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }

/* ───────── stats & progress ───────── */
.stat-num { font-family: var(--font-display); font-size: 34px; font-weight: 500; letter-spacing: -.03em; line-height: 1.05; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .8s var(--ease); }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring circle { transition: stroke-dashoffset 1s var(--ease); }

/* ───────── lists ───────── */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
a.list-item, button.list-item { text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; border-radius: 0; }
a.list-item:hover, button.list-item:hover { background: var(--surface-2); }
.check {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2); display: grid; place-items: center;
  flex: none; background: var(--surface-solid); transition: all .2s var(--ease); padding: 0;
}
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.check svg { width: 14px; height: 14px; }
.strike { text-decoration: line-through; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty .em-icon { font-size: 32px; margin-bottom: 6px; }

/* ───────── modal / sheet / toast ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: hsl(var(--h) 30% 10% / .38);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px; animation: fadeIn .2s ease;
}
.modal {
  background: var(--surface-solid); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  width: min(560px, 100%); max-height: min(86vh, 900px); overflow: auto; padding: 24px; animation: popIn .3s var(--ease);
}
.modal.wide { width: min(860px, 100%); }
.modal h3 { font-size: 20px; margin-bottom: 6px; }
@media (max-width: 860px) {
  .overlay { place-items: end center; padding: 0; }
  .modal { border-radius: 24px 24px 0 0; width: 100%; max-height: 92vh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheetUp .35s var(--ease); }
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

.toasts { position: fixed; z-index: 200; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
@media (max-width: 860px) { .toasts { top: auto; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); left: 14px; right: 14px; } }
.toast {
  pointer-events: auto; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: 14px; padding: 12px 16px; display: flex; gap: 10px; align-items: center; max-width: 380px;
  animation: popIn .3s var(--ease); font-weight: 500;
}
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .3s; }

/* ───────── rich text (questions/answers) ───────── */
.rt { line-height: 1.65; }
.rt p { margin: 0 0 .7em; }
.rt h4 { font-size: 15px; margin: 1em 0 .45em; color: var(--accent-ink); }
.rt ul, .rt ol { margin: .3em 0 .8em; padding-left: 1.3em; }
.rt li { margin: .25em 0; }
.rt strong { font-weight: 700; }
.rt code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.rt .tbl-wrap { overflow-x: auto; margin: .5em 0 1em; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.rt table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.rt th, .rt td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rt th { background: var(--surface-2); font-weight: 650; font-size: 13px; }
.rt tr:last-child td { border-bottom: 0; }
.rt td.num, .rt th.num { text-align: right; white-space: nowrap; }
.rt blockquote { margin: .6em 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }

/* ───────── welcome ───────── */
.welcome {
  position: fixed; inset: 0; z-index: 150; overflow-y: auto;
  background:
    radial-gradient(800px 600px at 15% 10%, hsl(var(--h) var(--s) 75% / .45), transparent 60%),
    radial-gradient(700px 600px at 90% 90%, hsl(calc(var(--h) + 45) var(--s) 72% / .4), transparent 60%),
    var(--bg);
  display: grid; place-items: center; padding: 32px 20px;
}
.welcome-inner { width: min(640px, 100%); text-align: center; }
.welcome .w-date { color: var(--text-2); font-weight: 600; letter-spacing: .04em; font-size: 13px; text-transform: uppercase; }
.welcome .w-hello { font-family: var(--font-display); font-size: clamp(38px, 7vw, 60px); font-weight: 500; letter-spacing: -.035em; margin: 10px 0 6px; line-height: 1.05; }
.welcome .w-hello em { font-style: italic; color: var(--accent-ink); }
.welcome .w-msg { font-family: var(--font-display); font-size: clamp(20px, 3.2vw, 26px); line-height: 1.4; margin: 26px auto 10px; max-width: 34ch; font-weight: 400; }
.welcome .w-sign { color: var(--muted); font-size: 14px; }
.w-stats { display: flex; justify-content: center; gap: 12px; margin: 28px 0 10px; flex-wrap: wrap; }
.w-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 18px; min-width: 120px; backdrop-filter: blur(10px); }
.w-stat b { display: block; font-family: var(--font-display); font-size: 26px; font-weight: 500; }
.w-stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.w-why { margin: 22px auto 0; max-width: 46ch; padding: 14px 18px; border-radius: 16px; background: var(--surface); border: 1px dashed var(--line-2); color: var(--text-2); font-size: 14.5px; }
.w-letter { margin: 22px auto 0; text-align: left; background: var(--surface-solid); border-radius: 20px; padding: 22px 24px; box-shadow: var(--shadow); border: 1px solid var(--line); max-width: 520px; }
.w-letter .from { font-family: var(--font-display); font-style: italic; color: var(--accent-ink); margin-top: 10px; }
.reveal { opacity: 0; animation: rise .8s var(--ease) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.bloom { font-size: 42px; display: inline-block; animation: bloom 2.4s ease-in-out infinite; }
@keyframes bloom { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.08) rotate(8deg); } }

/* ───────── onboarding ───────── */
.onb { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.onb-card { width: min(620px, 100%); }
.onb-steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 22px; }
.onb-steps span { width: 28px; height: 5px; border-radius: 99px; background: var(--line-2); transition: all .3s var(--ease); }
.onb-steps span.on { background: var(--accent); width: 44px; }
.onb h2 { font-family: var(--font-display); font-weight: 500; font-size: 30px; letter-spacing: -.02em; margin-bottom: 6px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.swatch { border: 2px solid transparent; border-radius: 16px; padding: 10px; background: var(--surface-solid); text-align: center; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-sm); }
.swatch .sw { height: 44px; border-radius: 11px; margin-bottom: 7px; }
.swatch.on { border-color: var(--accent); }

/* ───────── focus timer ───────── */
.timer-wrap { display: grid; place-items: center; padding: 10px 0 0; }
.timer-face { position: relative; width: min(340px, 78vw); aspect-ratio: 1; }
.timer-face svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.timer-time { font-family: var(--font-display); font-size: clamp(52px, 13vw, 76px); font-weight: 400; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.timer-sub { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin-top: 8px; }
.focus-full { position: fixed; inset: 0; z-index: 140; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.breath { width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, var(--accent-2), var(--accent)); opacity: .85; transform: scale(.55); box-shadow: 0 0 80px hsl(var(--h) var(--s) 60% / .5); }

/* ───────── exam ───────── */
.exam-shell { position: fixed; inset: 0; z-index: 120; background: var(--bg); display: grid; grid-template-rows: auto 1fr auto; }
.exam-top { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 20px 12px; border-bottom: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(14px); }
.exam-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; padding: 7px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); }
.exam-clock.low { background: var(--bad-soft); color: var(--bad); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.exam-body { overflow-y: auto; display: grid; grid-template-columns: 1fr 260px; gap: 0; min-height: 0; }
.exam-q { padding: 28px 32px 40px; max-width: 860px; width: 100%; margin: 0 auto; }
.exam-side { border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; background: var(--surface); }
.exam-bottom { display: flex; gap: 10px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(14px); }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.pq { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-solid); font-weight: 700; font-size: 13px; display: grid; place-items: center; position: relative; padding: 0; }
.pq.ans { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.pq.wr { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.pq.sk { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.pq.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.pq.flag::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 9px; background: var(--bad); }
.opt {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1.5px solid var(--line-2); background: var(--surface-solid); margin-bottom: 10px; transition: all .18s var(--ease); line-height: 1.5;
}
.opt:hover { border-color: var(--accent); }
.opt .ol { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 13px; flex: none; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .ol { background: var(--accent); color: var(--on-accent); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .ol { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .ol { background: var(--bad); color: #fff; }
.paper-note { border: 1.5px dashed var(--line-2); border-radius: 16px; padding: 18px; display: flex; gap: 14px; align-items: center; color: var(--text-2); background: var(--surface); }
.paper-note .pn-icon { font-size: 28px; }
@media (max-width: 860px) {
  .exam-body { grid-template-columns: 1fr; }
  .exam-side { display: none; }
  .exam-side.open { display: block; position: fixed; inset: auto 0 0 0; max-height: 70vh; z-index: 130; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .exam-q { padding: 18px 16px 30px; }
  .exam-top { padding-left: 14px; padding-right: 14px; }
  .exam-bottom { padding-left: 12px; padding-right: 12px; }
  .exam-bottom .btn { padding: 11px 12px; font-size: 14px; }
}

/* scheme (self-evaluation) */
.scheme-step { display: flex; gap: 12px; align-items: flex-start; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; background: var(--surface-solid); cursor: pointer; }
.scheme-step.on { border-color: var(--good); background: var(--good-soft); }
.scheme-step .pts { margin-left: auto; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--surface-solid); }
.stepper button { border: 0; background: none; width: 40px; height: 40px; font-size: 20px; font-weight: 600; color: var(--accent-ink); }
.stepper .val { min-width: 74px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ───────── flashcards ───────── */
.fc-stage { perspective: 1400px; width: min(620px, 100%); margin: 0 auto; }
.fc {
  position: relative; width: 100%; min-height: 340px; transform-style: preserve-3d; transition: transform .6s var(--ease);
  cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.fc.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 26px; padding: 30px 28px; display: flex; flex-direction: column; justify-content: center;
  background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); overflow-y: auto;
}
.fc-face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--accent-soft), var(--surface-solid) 60%); }
.fc-front-text { font-family: var(--font-display); font-size: clamp(21px, 3.4vw, 27px); line-height: 1.35; text-align: center; font-weight: 450; }
.fc-tag { position: absolute; top: 16px; left: 20px; right: 20px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }
.fc-hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.grade-row .btn { flex-direction: column; gap: 2px; padding: 12px 6px; }
.grade-row .btn small { font-weight: 500; font-size: 11px; color: var(--muted); }

/* ───────── calendar ───────── */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-h { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; letter-spacing: .05em; }
.cal-d {
  min-height: 92px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-solid); padding: 7px 8px; text-align: left;
  display: flex; flex-direction: column; gap: 3px; position: relative; transition: border-color .2s, transform .2s var(--ease);
}
.cal-d:hover { border-color: var(--accent); }
.cal-d.out { opacity: .35; }
.cal-d.today { border: 2px solid var(--accent); }
.cal-d.sel { background: var(--accent-soft); }
.cal-d .n { font-weight: 700; font-size: 13px; }
.cal-d .exam { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-d .hrs { font-size: 11px; color: var(--muted); margin-top: auto; }
.cal-d .tdots { display: flex; gap: 3px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .cal { gap: 4px; }
  .cal-d { min-height: 58px; padding: 5px; border-radius: 10px; }
  .cal-d .exam { font-size: 9px; padding: 1px 3px; }
  .cal-d .hrs { display: none; }
}
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; gap: 4px; }
.heat span { width: 15px; height: 15px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }

/* ───────── charts ───────── */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }
.hbar { display: grid; grid-template-columns: 120px 1fr 64px; align-items: center; gap: 12px; margin: 9px 0; font-size: 14px; }
.hbar .track { height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; transition: width .9s var(--ease); }
@media (max-width: 860px) { .hbar { grid-template-columns: 86px 1fr 52px; font-size: 13px; } }

.paper-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.paper-tile { position: relative; overflow: hidden; }
.paper-tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--pc, var(--accent)); }
.mood-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mood { font-size: 26px; width: 52px; height: 52px; border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--surface-solid); display: grid; place-items: center; transition: transform .15s var(--ease); padding: 0; }
.mood.on { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.08); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.kbd { font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--muted); }
.sync-dot { width: 8px; height: 8px; border-radius: 9px; background: var(--good); display: inline-block; }
.sync-dot.off { background: var(--warn); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 860px) { .hide-sm { display: none; } }
details > summary::-webkit-details-marker { display: none; }
.card > svg:first-child { width: 22px; height: 22px; color: var(--accent-ink); }
.brand-mark svg { width: 21px; height: 21px; }

.split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
@media (max-width: 860px) { .split { grid-template-columns: minmax(0, 1fr); } }
a.card.row, button.card.row, label.card.row { display: flex; }

/* ───────── loading screen, progress pill, login ───────── */
.splash {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(700px 500px at 15% 10%, hsl(var(--h) var(--s) 75% / .4), transparent 60%),
    radial-gradient(600px 500px at 90% 90%, hsl(calc(var(--h) + 45) var(--s) 72% / .35), transparent 60%),
    var(--bg);
  transition: opacity .5s var(--ease);
}
.splash.out { opacity: 0; pointer-events: none; }
.splash-inner { width: min(460px, 100%); text-align: center; }
.splash-mark { width: 64px; height: 64px; border-radius: 20px; font-size: 30px; margin: 0 auto; animation: bloom 2.4s ease-in-out infinite; }
.splash-name { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -.02em; margin-top: 14px; }
.splash-label { margin-top: 34px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.splash-fact { font-family: var(--font-display); font-size: clamp(18px, 3vw, 22px); line-height: 1.45; margin: 10px auto 0; max-width: 34ch; min-height: 4.4em; opacity: 0; transform: translateY(6px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.splash-fact.in { opacity: 1; transform: none; }
.load-pill {
  position: fixed; top: calc(16px + env(safe-area-inset-top)); right: 16px; width: 150px; height: 28px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-sm);
}
.load-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite; transition: width .35s var(--ease);
}
.load-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text); mix-blend-mode: normal; }
@keyframes shimmer { to { background-position: -200% 0; } }
.splash.auth .load-pill { display: none; }
.auth-card { margin-top: 26px; text-align: left; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; animation: popIn .4s var(--ease); }
.auth-card h2 { font-size: 24px; font-weight: 500; }
.auth-err { color: var(--bad); font-size: 13.5px; min-height: 1em; }
.topline { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 450; pointer-events: none; opacity: 0; transition: opacity .2s; background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.topline.on { opacity: 1; transition-delay: .12s; }
