/* Comeback — one stylesheet for the app and admin.
   Night is the default theme; [data-theme="day"] switches to Day. */

:root {
  --bg: #140F24;
  --card: #1E1733;
  --soft: #2B2148;
  --ink: #F7F2FF;
  --muted: #B9AED6;
  --line: #33284F;
  --primary: #A08CFF;
  --on-primary: #140F24;
  --sunset: #FF9B6E;
  --ink-dark: #1A1230;
  --mint: #A6EBCB;
  --butter: #FFE6B8;
  --lilac: #CBB8FF;
  --peach: #FFC09C;
  --care: #FF9A8A;
  --b1: #A6EBCB; --b2: #CBB8FF; --b3: #FFE6B8; --b4: #FFC09C; --b5: #FF9B6E;
  --glow: 0 0 60px rgba(160, 140, 255, 0.35);
  --display: 'Bricolage Grotesque', 'Arial Black', system-ui, sans-serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-lg: 24px;
  --r-md: 18px;
  color-scheme: dark;
}
:root[data-theme="day"] {
  --bg: #FFF7EC; --card: #FFFFFF; --soft: #F1E9FF; --ink: #1A1230; --muted: #5B5175;
  --line: #E6DCF5; --primary: #5B3FD9; --on-primary: #FFFFFF; --sunset: #F07A4A; --care: #B23A2B;
  --glow: 0 0 50px rgba(91, 63, 217, 0.2);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #FFF7EC; --card: #FFFFFF; --soft: #F1E9FF; --ink: #1A1230; --muted: #5B5175;
    --line: #E6DCF5; --primary: #5B3FD9; --on-primary: #FFFFFF; --sunset: #F07A4A; --care: #B23A2B;
    --glow: 0 0 50px rgba(91, 63, 217, 0.2);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { --top: env(safe-area-inset-top, 0px); }
/* On an iPhone home screen the app draws under the clock and camera.
   Keep at least 50px clear there, even if the phone doesn't report it. */
@media (display-mode: standalone) { :root { --top: max(env(safe-area-inset-top, 0px), 50px); } }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App frame ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: calc(20px + var(--top)) calc(20px + env(safe-area-inset-right)) 120px calc(20px + env(safe-area-inset-left)); }
.screen.no-tabs { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 999px; text-decoration: none; }
.spacer { flex: 1; }

h1, .h1 { font-family: var(--display); font-weight: 800; font-size: 36px; line-height: 0.95; letter-spacing: -0.045em; margin: 0; }
h2, .h2 { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.07em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
p { margin: 0; }

/* ---------- Buttons ---------- */
.btn { min-height: 54px; padding: 0 22px; border-radius: 999px; border: 0; font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; width: 100%; }
.btn-sunset { background: var(--sunset); color: var(--ink-dark); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-dark { background: var(--ink-dark); color: #F7F2FF; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-small { min-height: 44px; font-size: 15px; padding: 0 16px; width: auto; }
.btn-danger { background: transparent; color: var(--care); border: 1.5px solid var(--care); }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 700; min-height: 44px; padding: 0 4px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.block { border-radius: var(--r-lg); padding: 18px; color: var(--ink-dark); display: flex; flex-direction: column; gap: 10px; }
.rescue { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--sunset); color: var(--ink-dark); border-radius: 28px; padding: 20px 22px; text-decoration: none; border: 0; width: 100%; text-align: left; }
.rescue strong { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -0.03em; line-height: 1; display: block; }
.row { display: flex; align-items: center; gap: 12px; }
.list-item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; color: var(--ink); text-decoration: none; }
.list-item .grow { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-item b { font-size: 15px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--ink); white-space: nowrap; }
.badge.dark { background: var(--ink-dark); color: var(--butter); }
.crisis { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font-size: 14px; line-height: 1.5; }
.crisis strong:first-child { color: var(--care); }
.notice { background: var(--soft); border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; }

/* ---------- Burnout meter ---------- */
.meter { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.meter button, .meter a { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; text-align: center; line-height: 1.15; }
.lvl { width: 54px; height: 54px; border-radius: 999px; display: flex; align-items: center; justify-content: center; transition: box-shadow 0.15s; }
.meter [aria-pressed="true"] .lvl { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--ink); }
.meter [aria-pressed="true"] { color: var(--ink); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chip.tall { min-height: 64px; border-radius: var(--r-md); flex-direction: column; gap: 4px; font-size: 12px; padding: 6px 4px; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.seg { display: flex; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; font-size: 14px; padding: 0 12px; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- Tiles (library / match) ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { border-radius: 22px; padding: 14px; min-height: 124px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; color: var(--ink-dark); text-decoration: none; }
.tile .k { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; display: flex; justify-content: space-between; gap: 6px; }
.tile .t { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.08; letter-spacing: -0.02em; }
.tile .m { font-size: 12px; font-weight: 600; }
.k-breathe { background: var(--primary); color: var(--on-primary); }
:root:not([data-theme="day"]) .k-breathe { color: var(--ink-dark); }
.k-meditate, .k-rest { background: var(--lilac); }
.k-flow { background: var(--peach); }
.k-nature { background: var(--mint); }
.k-move, .k-connect, .k-write, .k-words { background: var(--butter); }
.k-unplug { background: var(--sunset); }
.best { background: var(--primary); color: var(--on-primary); border-radius: 28px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
:root:not([data-theme="day"]) .best { color: var(--ink-dark); }

/* ---------- Tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1.5px solid var(--line); padding: 8px 6px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
.tabbar nav { max-width: 480px; margin: 0 auto; display: flex; justify-content: space-around; }
.tabbar a { min-width: 60px; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--sunset); font-weight: 700; }

/* ---------- Players ---------- */
.player { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.orb-wrap { flex: 1; width: 100%; min-height: 320px; display: flex; align-items: center; justify-content: center; position: relative; }
.orb-ring { position: absolute; width: 290px; height: 290px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--line); }
.orb { position: relative; width: 240px; height: 240px; border-radius: 999px; background: var(--primary); box-shadow: var(--glow); display: flex; align-items: center; justify-content: center; transform: scale(0.62); transition-property: transform; transition-timing-function: ease-in-out; }
.orb-core { width: 128px; height: 128px; border-radius: 999px; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.orb-core .num { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; }
.progress { width: 100%; height: 6px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--sunset); border-radius: 999px; transition: width 1s linear; }
.steps { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.step { border: 0; text-align: left; width: 100%; background: var(--card); border: 1.5px solid var(--line); color: var(--ink); border-radius: var(--r-md); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.step .dot { width: 30px; height: 30px; border-radius: 999px; border: 1.5px solid var(--line); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.step[aria-pressed="true"] .dot { background: var(--mint); border-color: var(--mint); color: var(--ink-dark); }
.step b { display: block; }
.timer-bar { width: 100%; background: var(--ink-dark); color: #F7F2FF; border-radius: 28px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.timer-bar .clock { font-family: var(--display); font-weight: 800; font-size: 38px; letter-spacing: -0.04em; min-width: 96px; text-align: left; }
.flow-stage { position: fixed; inset: 0; z-index: 0; transition: background-color 6s ease-in-out; overflow: hidden; }
.flow-stage i { position: absolute; border-radius: 999px; transition: background-color 6s ease-in-out, transform 12s ease-in-out; opacity: 0.85; }
.flow-ui { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; color: #F7F2FF; }
.glass { background: rgba(20, 15, 36, 0.6); color: #F7F2FF; border-radius: 28px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.glass .seg button[aria-pressed="true"] { background: #F7F2FF; color: #140F24; }
.reading { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 16px; font-size: 17px; line-height: 1.6; text-align: left; white-space: pre-line; width: 100%; }

/* ---------- Patterns ---------- */
.dots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; min-height: 120px; }
.dots .col { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.dots .col span { width: 18px; height: 18px; border-radius: 999px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar .label { width: 84px; font-weight: 600; }
.bar .track { flex: 1; height: 12px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--sunset); border-radius: 999px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.input { min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); padding: 0 14px; font-size: 16px; width: 100%; }
textarea.input { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; z-index: 50; max-width: 90vw; }

/* ---------- Admin ---------- */
.admin { display: flex; flex-wrap: wrap; min-height: 100dvh; max-width: none; }
.admin aside { flex: 1 1 220px; max-width: 260px; padding: 24px 16px; border-right: 1.5px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.admin aside a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 10px 12px; border-radius: 12px; }
.admin aside a[aria-current="page"] { background: var(--soft); color: var(--ink); font-weight: 700; }
.admin main { flex: 999 1 560px; min-width: 0; padding: 32px clamp(16px, 4vw, 40px); display: flex; flex-direction: column; gap: 20px; }
.table-wrap { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
th { text-align: left; font-size: 12px; letter-spacing: 0.05em; color: var(--muted); padding: 14px 12px; }
td { padding: 12px; border-top: 1.5px solid var(--line); vertical-align: middle; }
.cov { display: grid; grid-template-columns: 160px repeat(5, minmax(0, 1fr)); gap: 6px; align-items: center; min-width: 600px; }
.cov .cell { min-height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--ink-dark); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi .v { font-family: var(--display); font-weight: 800; font-size: 34px; letter-spacing: -0.04em; line-height: 1; }
.two { display: flex; flex-wrap: wrap; gap: 16px; }
.two > * { flex: 1 1 320px; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  .orb, .flow-stage, .flow-stage i, .progress > i { transition: none !important; }
}

/* ---------- Insights ("Comeback noticed…") ---------- */
.insight { border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1.5px solid var(--line); }
.insight .eyebrow { display: flex; align-items: center; gap: 6px; }
.insight .eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--lilac); }
.insight p { font-size: 15px; color: var(--muted); line-height: 1.45; }
.insight.win { background: var(--mint); border-color: transparent; color: var(--ink-dark); }
.insight.win p, .insight.win .eyebrow { color: var(--ink-dark); opacity: .85; }
.insight.win .eyebrow::before { background: var(--ink-dark); }
.insight.care { border-color: var(--care); }
.insight.care .eyebrow::before { background: var(--care); }
.insight .acts { display: flex; flex-direction: column; gap: 4px; }
.insight .btn { min-height: 46px; font-size: 15px; }
.insight.win .btn { background: var(--ink-dark); color: #F7F2FF; }
.insight .link-btn { text-align: left; padding: 0; min-height: 40px; }
.insight.win .link-btn { color: var(--ink-dark); }
.insight .crisis-line { font-size: 13px; color: var(--muted); }
.insight .crisis-line strong { color: var(--care); }
.getting { display: flex; gap: 6px; }
.getting i { flex: 1; height: 8px; border-radius: 999px; background: var(--soft); }
.getting i.on { background: var(--lilac); }

/* ---------- Article preview in admin ---------- */
.md-preview .md { display: flex; flex-direction: column; gap: 14px; font-size: 16px; line-height: 1.65; }
.md-preview .md h2 { font-size: 24px; margin-top: 8px; }
.md-preview .md h3 { font-size: 19px; }
.md-preview .md ul, .md-preview .md ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.md-preview .md blockquote { margin: 0; border-radius: 16px; background: var(--soft); padding: 14px 18px; font-family: var(--display); font-weight: 700; font-size: 18px; }
.md-preview .md img { max-width: 100%; border-radius: 14px; }
.md-preview .md figure { margin: 0; }
.md-preview .md p { margin: 0; }
