/* Mobile-first. Default look is Nat/hypnose. Other looks override the same tokens. */
:root {
  --bg: #10142a;
  --bg-2: #161b36;
  --card: #1b2142;
  --card-2: #222a52;
  --line: #6e7eb8;
  --text: #e9ecf8;
  --muted: #a3abd1;
  --accent: #9ec5ff;
  --accent-2: #f2c879;
  --good: #7fd6a4;
  --bad: #ff9a9a;
  --on-accent: #0d1330;
  --on-warm: #2a1d00;
  --on-good: #0d2a1a;
  --topbar: rgba(16, 20, 42, .92);
  --glow: #26306a;
  --hero: linear-gradient(135deg, #2a3576, #1b2142 70%);
  --radius: 16px;
  --tap: 46px;
  color-scheme: dark;
}
html[data-theme="moerk"] {
  --bg: #121417;
  --bg-2: #1b1e24;
  --card: #22262e;
  --card-2: #2b303a;
  --line: #7e8799;
  --text: #f4f6fa;
  --muted: #c8ced8;
  --accent: #9ec5ff;
  --accent-2: #f2c879;
  --good: #8ee0b0;
  --bad: #ffb4b4;
  --on-accent: #0d1330;
  --on-warm: #2a1d00;
  --on-good: #0d2a1a;
  --topbar: rgba(18, 20, 23, .92);
  --glow: #2a3344;
  --hero: linear-gradient(135deg, #2c3442, #22262e 70%);
  color-scheme: dark;
}
html[data-theme="lys"],
html[data-theme="system"] {
  --bg: #f3f5fb;
  --bg-2: #e6ebf6;
  --card: #ffffff;
  --card-2: #eef2fa;
  --line: #6d7896;
  --text: #161b2e;
  --muted: #3e4868;
  --accent: #0b4fad;
  --accent-2: #8a4b00;
  --good: #0b6b3a;
  --bad: #a11d1d;
  --on-accent: #ffffff;
  --on-warm: #fff8ee;
  --on-good: #ffffff;
  --topbar: rgba(243, 245, 251, .94);
  --glow: #d5def5;
  --hero: linear-gradient(135deg, #d9e4ff, #ffffff 70%);
  color-scheme: light;
}
html[data-theme="glad"] {
  --bg: #fff8ef;
  --bg-2: #ffedd6;
  --card: #fffdf9;
  --card-2: #fff1dc;
  --line: #7a5a32;
  --text: #2a1c0e;
  --muted: #5c4030;
  --accent: #9a3412;
  --accent-2: #7a3e0c;
  --good: #166534;
  --bad: #9f1239;
  --on-accent: #fff7ed;
  --on-warm: #fff7ed;
  --on-good: #f0fdf4;
  --topbar: rgba(255, 248, 239, .94);
  --glow: #ffd7a8;
  --hero: linear-gradient(135deg, #ffd7a8, #fffdf9 72%);
  color-scheme: light;
}
html[data-theme="rolig"] {
  --bg: #e8f4f5;
  --bg-2: #d4e8ea;
  --card: #f7fcfc;
  --card-2: #e5f3f4;
  --line: #3f656c;
  --text: #0e2a30;
  --muted: #3a555c;
  --accent: #0e5964;
  --accent-2: #8a4b08;
  --good: #0f6842;
  --bad: #9f1239;
  --on-accent: #f4fffe;
  --on-warm: #fff8ee;
  --on-good: #f0fdf4;
  --topbar: rgba(232, 244, 245, .94);
  --glow: #c5e4e6;
  --hero: linear-gradient(135deg, #c5e4e6, #f7fcfc 72%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #121417;
    --bg-2: #1b1e24;
    --card: #22262e;
    --card-2: #2b303a;
    --line: #7e8799;
    --text: #f4f6fa;
    --muted: #c8ced8;
    --accent: #9ec5ff;
    --accent-2: #f2c879;
    --good: #8ee0b0;
    --bad: #ffb4b4;
    --on-accent: #0d1330;
    --on-warm: #2a1d00;
    --on-good: #0d2a1a;
    --topbar: rgba(18, 20, 23, .92);
    --glow: #2a3344;
    --hero: linear-gradient(135deg, #2c3442, #22262e 70%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -200px, var(--glow) 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--bad); min-height: 1.2em; margin: .25rem 0; }
.ok { color: var(--good); }
.hidden { display: none !important; }
body:not(.care-mode) .care-only, .care-mode .weight-loss { display: none !important; }
.mt { margin-top: 1rem; }
code { background: var(--bg-2); padding: .05rem .35rem; border-radius: 6px; font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header + navigation */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 960px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; min-width: 0; }
.brand { display: flex; align-items: center; gap: .5rem; min-width: 0; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { width: 28px; height: 28px; flex: 0 0 auto; }
.topbar .spacer { flex: 1; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: .4rem; text-decoration: underline; white-space: nowrap; flex: 0 0 auto; }
.tabs { max-width: 960px; margin: 0 auto; display: flex; gap: .25rem; padding: 0 .5rem .5rem; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  flex: 0 0 auto; padding: .45rem .9rem; border-radius: 999px; text-decoration: none;
  color: var(--muted); border: 1px solid transparent; min-height: 36px; display: inline-flex; align-items: center;
}
.tabs a[aria-current="page"] { color: var(--text); background: var(--card-2); border-color: var(--line); }

main { max-width: 960px; margin: 0 auto; padding: 1rem; }
section[data-tab] { display: grid; gap: 1rem; }
footer { max-width: 960px; margin: 2rem auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .85rem; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.outbox-letter { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat { background: var(--card-2); border-radius: 12px; padding: .75rem; text-align: center; }
.stat .v { font-size: 1.35rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .8rem; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  main { padding: 1.5rem; }
}

/* Buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1.1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.warm { background: var(--accent-2); color: var(--on-warm); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 .75rem; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
label { display: block; font-size: .875rem; color: var(--muted); margin: .5rem 0 .25rem; }
input, select, textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: var(--tap); padding: .5rem .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; min-width: 0; max-width: 100%; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; min-width: 0; max-width: 100%; }
.form-row > *, .form-row-3 > *, .date-nav > * { min-width: 0; }
input[type="date"] { display: block; width: 100%; min-width: 0; max-width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; }
.key-gate { max-width: 460px; }
.key-gate .btn { margin-top: .75rem; width: 100%; }

/* Hypnosis home */
.hero { padding: 1.25rem; background: var(--hero); }
.hero h1 { font-size: 1.5rem; }
.hero .btn { margin-top: .5rem; }
.sessions { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .sessions { grid-template-columns: 1fr 1fr; } }
.session {
  display: grid; gap: .35rem; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
}
.session:hover { border-color: var(--accent); }
.session .meta { display: flex; gap: .5rem; align-items: center; color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); font-size: .75rem; color: var(--text); }
.badge.good { color: var(--good); border-color: #2f6a4b; }
.badge.warn { color: var(--accent-2); border-color: #6a5a2f; }
.badge.off { color: var(--muted); }
.note { border-left: 3px solid var(--accent-2); padding: .5rem .75rem; background: var(--bg-2); border-radius: 8px; font-size: .9rem; color: var(--muted); }
.key-list { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .5rem; }
.key-list li { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }

/* Steps */
.date-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }
.date-nav input { width: 100%; max-width: 100%; min-width: 0; text-align: start; }
.big-number { font-size: 3rem; font-weight: 800; line-height: 1; margin: .25rem 0; }
.progress { height: 14px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); width: 0; transition: width .4s; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; align-items: end; height: 150px; margin-top: .5rem; }
.chart .bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .25rem; }
.chart .bar { width: 100%; max-width: 36px; background: var(--card-2); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.chart .bar.goal { background: var(--good); }
.chart .bar.sel { outline: 2px solid var(--accent); }
.chart .lbl { font-size: .72rem; color: var(--muted); }

/* Food log */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.entries li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--card-2); border-radius: 10px; padding: .5rem .75rem; }
.entries .what { display: grid; }
.entries .what small { color: var(--muted); }
.proposal { border: 1px dashed var(--accent); }

/* Calculator */
.result-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.result-table td { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.result-table td:last-child { text-align: right; font-weight: 600; }

/* Player */
.player { display: grid; gap: 1rem; }
.play-btn { flex: 0 0 96px; width: 96px; height: 96px; padding: 0; border-radius: 50%; font-size: 1.1rem; }
.player-main { display: flex; align-items: center; gap: 1rem; }
.timeline { height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.timeline > div { height: 100%; width: 0; background: var(--accent); }
.choice { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice label { margin: 0; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer;
}
.choice input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.locked { opacity: .55; }
.locked-row { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.locked-row:last-child { border-bottom: 0; }

/* Voices */
.provider { display: grid; gap: .5rem; }
.provider-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.voice-row { display: grid; gap: .5rem; grid-template-columns: 1fr; align-items: center; background: var(--card-2); border-radius: 10px; padding: .6rem .75rem; }
.voice-row audio { width: 100%; height: 36px; }
.voice-row.selected { outline: 2px solid var(--accent-2); }
@media (min-width: 640px) { .voice-row { grid-template-columns: 1fr 2fr auto; } }

.skeleton { background: linear-gradient(90deg, var(--card-2), var(--card), var(--card-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; min-height: 80px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .progress > div, .gate-leaf { transition: none; } }
.live-form .choice, .live-form .btn-row, .live-form audio { margin-top: .75rem; }
.live-form p:empty { display: none; }
.live-form audio { width: 100%; }

/* Frida search and suggestions */
.search-row { display: flex; gap: .5rem; margin-top: .5rem; min-width: 0; max-width: 100%; }
.search-row input { flex: 1; min-width: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip {
  min-height: 36px; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; text-align: left;
}
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Plan breakdown */
.plan-row { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.plan-row summary { display: flex; justify-content: space-between; gap: .75rem; cursor: pointer; min-height: 36px; align-items: center; list-style: none; }
.plan-row summary::-webkit-details-marker { display: none; }
.plan-row summary::before { content: "▸"; color: var(--muted); margin-right: .25rem; }
.plan-row[open] summary::before { content: "▾"; }
.plan-row summary span { flex: 1; }
.plan-row h4 { margin: .5rem 0 .25rem; font-size: .85rem; color: var(--muted); }
.plan-row ul { margin: 0; padding-left: 1.1rem; }
.plan-total { display: flex; justify-content: space-between; gap: .75rem; padding: .75rem 0; }
.grid-2.compact { gap: .25rem 1rem; }

/* Weight chart and craving diary */
.weight-chart { width: 100%; height: auto; margin-top: .5rem; }
.weight-chart .grid-line { stroke: var(--line); stroke-width: 1; }
.weight-chart .axis { fill: var(--muted); font-size: 16px; }
.weight-chart .trend { fill: none; stroke: var(--good); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.weight-chart .dot { fill: var(--accent); }
.insights { margin: .75rem 0; padding-left: 1.1rem; }
.diary .chip-list { margin-top: 0; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { display: inline; }
details.card > summary::after { content: " ▸"; color: var(--muted); }
details.card[open] > summary::after { content: " ▾"; }

/* 21-day series */
.series-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; margin: .75rem 0; max-width: 360px; }
.series-dots span { aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); background: var(--card-2); display: grid; place-items: center; font-size: .7rem; color: var(--muted); }
.series-dots span.done { background: var(--good); border-color: var(--good); color: var(--on-good); font-weight: 700; }
.series-dots span.next { border: 2px solid var(--accent-2); color: var(--text); }
.series-phase { color: var(--muted); font-size: .8rem; margin: .5rem 0 0; }

/* Your data */
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.danger-zone { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.note.warn { border-left-color: #d9734e; color: var(--text, inherit); margin-bottom: .75rem; }
.screening-q { margin: 0 0 .75rem; }
.screening-q legend { margin-bottom: .35rem; }
.theme-picker span { width: 100%; min-height: 44px; justify-content: center; text-align: center; }
.help-line { color: var(--text); font-size: .95rem; margin: .75rem 0; }
.script-line { font-size: 1.15rem; line-height: 1.45; min-height: 3rem; margin: .75rem 0 0; }
main, .card, form { min-width: 0; max-width: 100%; }

/* Sliding entrances on the hypnosis page. The leaf is the gate; it moves aside when chosen. */
.hypnose { gap: 1.75rem; }
.hypnose-intro { max-width: 36rem; padding: .35rem .1rem 0; }
.hypnose-intro h1 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  font-weight: 560;
  letter-spacing: -0.02em;
  margin-bottom: .4rem;
}
.hypnose .lede { max-width: 34rem; color: var(--muted); font-size: 1.05rem; margin: 0; }
.hypnose .card { padding: 1.35rem 1.3rem 1.45rem; }
.hypnose .card h2 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-weight: 560;
  letter-spacing: -0.02em;
  font-size: 1.35rem;
}
.hypnose .session { background: transparent; }
.next-step { max-width: 36rem; }
#onboarding:not(.door-open) #onboard-session,
#onboarding:not(.door-open) #home-hint,
#onboarding:not(.door-open) #onboard-note,
#onboarding:not(.door-open) label[for="onboard-note"],
#onboarding:not(.door-open) #onboard-listen,
#onboarding:not(.door-open) .next-quiet { display: none; }
.next-step .btn { margin-top: .25rem; }
.next-quiet { margin: .85rem 0 0; }
.next-quiet .link-btn { padding-left: 0; }
.entrances { display: grid; gap: .85rem; }
.entrance { position: relative; margin: 0; display: block; }
.entrance input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gate {
  position: relative;
  display: block;
  min-height: 7.25rem;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
}
.gate-room {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 7.25rem;
  padding: 1.05rem 1.7rem 1.05rem 1.15rem;
}
.gate-line { display: block; max-width: 18rem; margin-top: .35rem; color: var(--muted); font-size: .92rem; }
.gate-leaf {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0 1rem 0 1.15rem;
  background: var(--card);
  box-shadow: inset -14px 0 0 var(--card-2);
  border-left: 1px solid var(--line);
  transform: translateX(0);
  transition: transform .55s cubic-bezier(.22, .8, .2, 1);
}
.gate-face { display: grid; gap: .15rem; min-width: 0; }
.gate-kicker { color: var(--muted); font-size: .75rem; letter-spacing: .04em; }
.gate-name {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 560;
  color: var(--text);
}
.gate-handle {
  width: 8px;
  height: 46px;
  border-radius: 99px;
  background: var(--accent);
  flex: 0 0 auto;
}
.entrance input:checked + .gate {
  border-color: var(--accent);
  box-shadow: inset -12px 0 0 var(--card);
}
.entrance input:checked + .gate .gate-leaf { transform: translateX(105%); }
.entrance input:checked + .gate .gate-room { padding-right: 1.6rem; }
.entrance input:focus-visible + .gate { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (min-width: 840px) {
  .entrances { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gate, .gate-room { min-height: 15.5rem; }
}

/* Date fields and two-column forms must stay inside a 320–430px screen.
   The header wraps earlier so the name and "log ud" stay on screen at 320px. */
@media (max-width: 520px) {
  .topbar-inner { padding: .45rem .65rem .35rem; }
  .topbar .spacer { flex: 1 0 100%; height: 0; }
  .tabs { padding: 0 .45rem .4rem; gap: .1rem; }
  .tabs a { padding: .4rem .5rem; font-size: .9rem; }
}
@media (max-width: 430px) {
  .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: 1fr; }
  .date-nav { grid-template-columns: auto auto; grid-template-areas: "prev next" "date date"; }
  .date-nav > :nth-child(1) { grid-area: prev; }
  .date-nav > :nth-child(2) { grid-area: date; }
  .date-nav > :nth-child(3) { grid-area: next; justify-self: end; }
}
