/* Anchor — calm, mobile-first. Visual language: deep forest green, frosted-glass
   cards, pale-sage pill buttons, serif display type, thin line icons.
   No framework, no build step. Everything here is hand-written and commented
   so the next person (or AI) can extend it easily. */

:root {
  --bg:        #0e1713;
  --bg-2:      #1a2a21;
  --surface:   rgba(255, 255, 255, .055);   /* glass card */
  --surface-2: rgba(255, 255, 255, .075);   /* inputs, tiles inside cards */
  --solid:     #16221c;                     /* opaque fallback (menus, overlays) */
  --text:      #eaf1eb;
  --muted:     #9fb3a6;
  --line:      rgba(255, 255, 255, .11);
  --accent:    #b7d2a1;   /* pale sage */
  --accent-2:  #8fb17c;
  --accent-ink:#14221a;
  --sos:       #b0786b;   /* warm clay — distinct, never alarming */
  --sos-2:     #6f4a43;
  --glow:      0 10px 30px rgba(0, 0, 0, .28);
  --sleep:     #8fb3cc;   /* Oura sleep bars: soft blue, distinct from the sage mood line */

  /* mood scale colors, 1 (low) → 5 (good) — muted, earthy, never harsh */
  --m1: #a56a7a;
  --m2: #b98a6b;
  --m3: #c2b06a;
  --m4: #8fb583;
  --m5: #6fae8f;

  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino", Georgia, serif;
  --radius: 22px;
  --tap: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);

  /* soft leaf shadows behind everything */
  --leaves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 800'%3E%3Cdefs%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='14'/%3E%3C/filter%3E%3C/defs%3E%3Cg filter='url(%23b)' fill='%23cfe6c0'%3E%3Cpath opacity='.13' d='M330 40c90 60 110 190 40 300-40-120-110-170-180-190 40-70 90-110 140-110z'/%3E%3Cpath opacity='.09' d='M-40 470c110-40 230 10 270 120-120-10-200 40-250 110-40-70-50-160-20-230z'/%3E%3Cpath opacity='.08' d='M260 640c70-10 140 40 160 120-80-20-140 0-190 40-10-60 0-120 30-160z'/%3E%3C/g%3E%3C/svg%3E");
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:#e9efe7; --bg-2:#f6f8f3; --surface:rgba(255,255,255,.72); --surface-2:rgba(255,255,255,.9);
    --solid:#f4f7f1;
    --text:#1b2a21; --muted:#5b6e61; --line:rgba(28,60,40,.12);
    --accent:#4c7a59; --accent-2:#3b6447; --accent-ink:#ffffff;
    --sos:#b06e60; --sos-2:#8a4f45;
    --glow: 0 10px 30px rgba(30, 60, 40, .10);
    --sleep: #4f7590;
    --leaves: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The [hidden] attribute must always win, even over display:flex/grid rules
   (e.g. .lock, .overlay). Without this, hidden elements can still show. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Fixed backdrop (background-attachment: fixed is unreliable on iOS). */
body::before, .overlay::before, .lock::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    var(--leaves) right top / 100% auto no-repeat,
    radial-gradient(120% 70% at 85% 0%, var(--bg-2), transparent 60%),
    radial-gradient(90% 60% at 0% 100%, var(--bg-2), transparent 65%),
    var(--bg);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 18px calc(var(--safe-bot) + 130px);
}

h1, h2, .episode-btn__label, .rules-section h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }
h1 { font-size: 34px; line-height: 1.15; margin: 8px 0 4px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-weight: 600; }
.muted { color: var(--muted); }
.date { color: var(--muted); margin: 0 0 18px; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Home ---------- */
.home-head { margin-bottom: 6px; display: flex; align-items: center; gap: 12px; }
.home-head .mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: var(--accent); background: var(--surface); border: 1px solid var(--line); }
.home-head .mark .icon { width: 24px; height: 24px; }
.home-head h1 { margin: 0; }
.home-head .date { margin: 0; font-size: 14px; }

/* The hard-time button: a slim translucent pill, easy to spot, calm to look at. */
.episode-btn {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--sos) 55%, transparent);
  border-radius: 999px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--sos) 38%, transparent), color-mix(in srgb, var(--sos-2) 22%, transparent));
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--text);
  padding: 8px 18px 8px 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  margin-bottom: 18px;
}
.episode-btn:active { transform: scale(.99); }
.episode-btn__icon { grid-row: span 2; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--sos) 45%, transparent); border: 1px solid color-mix(in srgb, var(--sos) 60%, transparent); }
.episode-btn__icon .icon { width: 20px; height: 20px; }
.episode-btn__label { font-size: 18px; line-height: 1.2; }
.episode-btn__sub { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.episode-btn__sub .icon { width: 14px; height: 14px; stroke-width: 2; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--glow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* mood scale 1–5: glass tiles, like category buttons */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.scale button {
  height: 58px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: 500 22px/1 var(--serif);
  cursor: pointer;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.scale button[aria-pressed="true"] {
  color: #10161f;
  border-color: rgba(255, 255, 255, .35);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .25);
}
.scale button[data-m="1"][aria-pressed="true"] { background: var(--m1); }
.scale button[data-m="2"][aria-pressed="true"] { background: var(--m2); }
.scale button[data-m="3"][aria-pressed="true"] { background: var(--m3); }
.scale button[data-m="4"][aria-pressed="true"] { background: var(--m4); }
.scale button[data-m="5"][aria-pressed="true"] { background: var(--m5); }
.scale-label { text-align: center; color: var(--muted); margin: 10px 0 14px; min-height: 1.2em; }

.note {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  padding: 14px;
  font: inherit;
  resize: none;
  margin-bottom: 12px;
}
.note:focus, .field:focus, .tag-input:focus { outline: none; border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: .8; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.chip--add { border-style: dashed; color: var(--accent); }
.chip--removable span { opacity: .6; margin-left: 4px; }

.add-tag-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tag-input, .field {
  flex: 1; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 16px; color: var(--text); padding: 13px 14px; font: inherit;
}
.field { margin-bottom: 10px; }

.btn {
  border: none; border-radius: 999px; padding: 14px 20px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn--primary {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn--primary:disabled { opacity: .35; box-shadow: none; }
.btn--soft { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--arrow { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn--arrow .icon { width: 18px; height: 18px; stroke-width: 2; }
.saved-msg { text-align: center; color: var(--m5); margin: 12px 0 0; font-weight: 600; }
.today-entries { color: var(--muted); font-size: 14px; text-align: center; }

/* nudge */
.nudge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.nudge p { margin: 0 0 12px; }
.nudge__actions { display: flex; gap: 10px; }

/* ---------- Trend ---------- */
#chart-wrap svg { width: 100%; height: auto; display: block; }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.log-list li:last-child { border-bottom: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.log-when { color: var(--muted); font-size: 13px; width: 92px; flex: none; }
.log-note { flex: 1; }
.log-del {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.log-del:active { background: var(--surface-2); }
.data-tools { display: flex; gap: 12px; justify-content: center; margin-top: 8px; }

/* ---------- Rules ---------- */
.rules-tagline {
  font: italic 19px/1.45 var(--serif); color: var(--muted);
  border-left: 2px solid var(--accent); padding-left: 14px; margin: 4px 0 22px;
}
.rules-section { margin-bottom: 22px; }
.rules-section h2 { color: var(--accent); }
.rules-section ul { margin: 0; padding: 0; list-style: none; }
.rules-section li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; margin-bottom: 10px;
}
.rules-section[data-tone="crisis"] li { font-size: 19px; font-weight: 600; }

/* ---------- Episode overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  isolation: isolate;
  padding-bottom: calc(var(--safe-bot) + 24px);
}
.overlay__bar {
  position: sticky; top: 0;
  display: flex; justify-content: flex-end;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
}
.overlay__close {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--text); font-size: 18px; cursor: pointer;
}
.overlay__content { max-width: 640px; margin: 0 auto; padding: 0 18px; }

/* ---------- Tab bar: floating glass pill ---------- */
.tabbar {
  position: fixed; z-index: 40;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bot) + 10px);
  width: min(620px, calc(100% - 28px));
  display: flex; justify-content: space-around;
  background: rgba(22, 34, 28, .72);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 8px 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
}
@media (prefers-color-scheme: light) { .tabbar { background: rgba(255, 255, 255, .78); box-shadow: 0 12px 32px rgba(30, 60, 40, .14); } }
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font: 600 11px/1.2 inherit; font-family: inherit; padding: 2px 4px; cursor: pointer;
  display: grid; justify-items: center; gap: 4px;
}
.tab .icon { width: 40px; height: 40px; padding: 9px; border-radius: 50%; transition: background .15s, color .15s; }
.tab.is-active { color: var(--accent); }
.tab.is-active .icon { background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }

.view header { margin-bottom: 10px; }

/* ---------- Settings ---------- */
.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0;
}
.row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 50px; height: 30px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  position: relative; cursor: pointer; flex: none; transition: background .15s;
}
.row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--muted);
  transition: transform .15s, background .15s;
}
.row input[type="checkbox"]:checked { background: var(--accent); border-color: transparent; }
.row input[type="checkbox"]:checked::after { transform: translateX(20px); background: var(--accent-ink); }

/* ---------- Lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  isolation: isolate;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lock__box { text-align: center; max-width: 340px; width: 100%; padding: 32px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 28px;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.lock__icon { color: var(--accent); margin-bottom: 8px; }
.lock__icon .icon { width: 44px; height: 44px; stroke-width: 1.2; }
.lock__box .btn { margin-top: 12px; }
.lock__box .muted { margin-top: 14px; min-height: 1.2em; }

/* Rules editor (Settings) */
.rules-editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.card code { font-size: 0.9em; }

/* Account card */
.acct-form { margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.btn-row .btn { width: auto; flex: 1 1 auto; margin: 0; }
.link-btn {
  background: none; border: 0; padding: 6px 0; color: var(--accent);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline;
}
.link-btn--quiet { color: var(--muted); }
#acct-status:empty { display: none; }

/* Trend chart (time-based) */
.trend-range { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.trend-range .chip { padding: 7px 14px; font-size: 13px; }
#chart-wrap svg { width: 100%; height: auto; display: block; }
.trend-summary { margin: 8px 0 0; font-size: 13px; }

/* Passkeys */
.btn--block { display: block; width: 100%; margin: 4px 0 8px; }
.passkeys { margin: 12px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.passkeys h3 { margin: 0 0 4px; font-size: 15px; }
.passkey-list { list-style: none; margin: 0 0 10px; padding: 0; }
.passkey-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.passkey-list li:last-child { border-bottom: 0; }
.passkey-list .muted { font-size: 13px; }

/* Settings: storage mode */
.mode-options { display: grid; gap: 10px; margin-bottom: 8px; }
.mode-option {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); cursor: pointer;
}
.mode-option input { margin-top: 4px; accent-color: var(--accent); }
.mode-option > span { display: grid; gap: 4px; }
.mode-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.small { font-size: 13px; }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 16px; padding: 10px 12px; margin: 8px 0; }
.notice p { margin: 0 0 4px; }
.howto summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-bottom: 8px; }
details.advanced > summary { list-style: none; cursor: pointer; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary h2 { display: inline; }
details.advanced > summary::after { content: " ▸"; color: var(--muted); }
details.advanced[open] > summary::after { content: " ▾"; }
.card a { color: var(--accent); }

/* Reminders */
.notify-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.notify-opts label { display: grid; gap: 4px; }
select.field { appearance: none; -webkit-appearance: none; margin: 0; padding-right: 34px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239fb3a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 12px center / 16px no-repeat; }
select.field option { color: #1b2a21; }

/* Crisis line under the plan */
.crisis-line { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.crisis-line a { color: var(--accent); font-weight: 600; }

/* Welcome: a glass card floating over the leaves */
.welcome { z-index: 60; }
.welcome__content { max-width: 440px; margin: 0 auto; padding-top: calc(var(--safe-top) + 10vh); }
.welcome__content > section { background: var(--surface); border: 1px solid var(--line); border-radius: 30px;
  padding: 36px 24px 26px; box-shadow: var(--glow);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.welcome__content > section[data-step="1"] { text-align: center; padding-top: 44px; }
.welcome__content h1 { font-size: 30px; margin: 0 0 12px; }
.welcome__content > section[data-step="1"] h1 { font-size: 40px; }
.welcome__tag { color: var(--accent); font: 500 18px/1.3 var(--serif); margin: 0 0 14px; }
.welcome__content p { line-height: 1.55; }
.welcome__content .btn { width: 100%; margin-top: 10px; }
.welcome__icon { color: var(--accent); margin-bottom: 14px; }
.welcome__icon .icon { width: 56px; height: 56px; stroke-width: 1.1; }
.choice {
  display: grid; gap: 4px; width: 100%; text-align: left; margin: 0 0 12px; padding: 16px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 18px;
  font: inherit; cursor: pointer;
}
.choice span { color: var(--muted); font-size: 14px; }
.choice:hover, .choice:focus-visible { border-color: var(--accent); }
.welcome a { color: var(--accent); }

/* Trend: range row above all charts */
#view-trend > .trend-range { margin: 0 0 12px; }
.chart-sub { margin: -4px 0 12px; }

/* Horizontal bars (tags, mood spread). Single series → accent only, no legend;
   every value is written out, so nothing depends on color. */
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(84px, 38%) 1fr auto; align-items: center; gap: 10px; padding: 2px 0; }
.hbar__label { font-size: 14px; overflow-wrap: anywhere; }
.hbar__track { height: 16px; display: flex; align-items: center; }
.hbar__fill { height: 16px; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar__value { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.hbar__value .muted { font-size: 12px; margin-left: 6px; }
.hbar:hover .hbar__fill, .hbar:focus-visible .hbar__fill { filter: brightness(1.15); }
.hbar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Dot plot (time of day): position on a fixed 1–5 track */
.dotplot { display: grid; gap: 8px; }
.dot-row { display: grid; grid-template-columns: minmax(84px, 30%) 1fr auto; align-items: center; gap: 10px; }
.dot-row--axis .dot-track { border: 0; height: auto; }
.dot-track { position: relative; height: 24px; border-bottom: 1px solid var(--line); }
.dot-track .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.dot-track .tick-label { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.dot-track .dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--solid); }

/* Encryption */
.recovery-key { font: 600 18px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center;
  word-break: break-all; user-select: all; }
.acct-form h3, #acct-recovery h3 { margin: 0 0 6px; font-size: 16px; }

@media (prefers-reduced-transparency: reduce) {
  .card, .tabbar, .lock__box, .welcome__content > section { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--solid); }
}

/* ---------- Visibility helpers ---------- */
.only-desktop { display: none !important; }

/* ---------- Sign in / Create account switch ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.seg button { border: 0; border-radius: 999px; padding: 10px 12px; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#acct-signed-out .btn-row .btn { width: 100%; }

/* ---------- Sign-in page (first screen when nobody is signed in) ---------- */
.gate { z-index: 59; }
.gate__wrap { min-height: 100%; max-width: 1080px; margin: 0 auto; display: grid; align-content: start;
  padding: calc(var(--safe-top) + 6vh) 18px calc(var(--safe-bot) + 24px); gap: 22px; }
.gate__brand { text-align: center; }
.gate__mark { color: var(--accent); }
.gate__mark .icon { width: 52px; height: 52px; stroke-width: 1.1; }
.gate__brand h1 { font-size: 40px; margin: 6px 0 2px; }
.gate__tag { color: var(--accent); font: 500 18px/1.3 var(--serif); margin: 0; }
.gate__lede, .gate__points { display: none; }
.gate__card { max-width: 440px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 28px; padding: 22px 20px; box-shadow: var(--glow);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
/* the real account card, without its own chrome, inside the sign-in card */
.gate #account-card { background: none; border: 0; box-shadow: none; padding: 0; margin: 0;
  -webkit-backdrop-filter: none; backdrop-filter: none; }
.gate #account-card > h2 { display: none; }
.gate:has(#account-card:not([hidden]) #acct-signed-out[hidden]) .gate__alt { display: none; }
.gate__alt { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; }
.gate__alt .link-btn { font-size: 15px; font-weight: 600; text-decoration: none; }
.gate__alt p { margin: 4px 0 0; }
.gate a { color: var(--accent); }
body.is-gated .tabbar { display: none; }

/* ---------- Desktop ---------- */
.home-side .stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.stat strong { font: 500 26px/1.1 var(--serif); }
.stat span { font-size: 13px; }
.log-list--compact li { padding: 9px 0; gap: 10px; }
.log-list--compact .log-when { width: auto; text-align: right; }
.log-list--compact .log-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-side .btn--ghost { padding: 10px 0 0; }

@media (hover: hover) {
  .btn--primary:not(:disabled):hover { filter: brightness(1.06); }
  .btn--soft:hover, .chip:hover, .scale button:hover, .choice:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
  .btn--ghost:hover, .link-btn:hover { opacity: .85; }
  .tab:hover { color: var(--text); }
  .episode-btn:hover { border-color: var(--sos); }
}

@media (min-width: 960px) {
  .only-desktop { display: revert !important; }
  .only-mobile { display: none !important; }

  /* sidebar instead of the bottom tab bar */
  .tabbar {
    left: 20px; top: 20px; bottom: 20px; transform: none; width: 232px;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 20px 12px; border-radius: 28px;
  }
  .tabbar__brand { display: flex !important; align-items: center; gap: 12px; padding: 4px 8px 22px;
    font: 500 24px/1 var(--serif); color: var(--text); }
  .tabbar__brand .mark { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
    color: var(--accent); background: var(--surface-2); border: 1px solid var(--line); }
  .tabbar__brand .icon { width: 22px; height: 22px; }
  .tabbar__spacer { display: block !important; flex: 1; }
  .tab { flex: none; display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 18px;
    font-size: 15px; text-align: left; }
  .tab .icon { width: 36px; height: 36px; padding: 8px; }
  .tab.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .tab.is-active .icon { border: 0; background: transparent; }

  #app { max-width: 1180px; margin: 0 0 0 272px; padding: 40px 48px 56px; }
  h1 { font-size: 42px; }
  .view header { margin-bottom: 18px; }

  /* Home: check-in on the left, a glance at the week on the right */
  #view-home:not([hidden]) { display: grid; grid-auto-flow: row dense; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); column-gap: 24px; align-items: start; }
  #view-home > .home-head { grid-column: 1 / -1; }
  #view-home > .card, #view-home > .episode-btn, #view-home > .nudge { grid-column: 1; }
  #view-home > .today-entries { grid-column: 1; }
  .home-side { grid-column: 2; grid-row: span 2; display: grid !important; gap: 0; }
  .home-head .mark { display: none; }
  .home-head .date { font-size: 16px; }

  /* Trend: a dashboard grid */
  #view-trend:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  #view-trend > header, #view-trend > .trend-range, #view-trend > .data-tools { grid-column: 1 / -1; }
  #view-trend > .trend-range { margin: 0; }
  #view-trend > .card { margin: 0; }
  #view-trend > .card:first-of-type, #view-trend > #sleep-card { grid-column: 1 / -1; }

  /* Settings: two balanced columns of cards */
  #view-settings:not([hidden]) { columns: 2; column-gap: 20px; }
  #view-settings > header { column-span: all; }
  #view-settings > .card, #view-settings > details { break-inside: avoid; }

  #view-rules { max-width: 760px; }

  /* Sign-in page: brand on the left, form on the right */
  .gate__wrap { grid-template-columns: 1.1fr 1fr; align-items: center; align-content: center; gap: 64px;
    padding: 48px 56px; min-height: 100vh; }
  .gate__brand { text-align: left; }
  .gate__brand h1 { font-size: 64px; margin-top: 18px; }
  .gate__mark .icon { width: 64px; height: 64px; }
  .gate__tag { font-size: 24px; }
  .gate__lede { display: block; font-size: 18px; color: var(--muted); max-width: 30em; margin: 22px 0 28px; line-height: 1.6; }
  .gate__points { display: grid; gap: 16px; list-style: none; padding: 0; margin: 0; }
  .gate__points li { display: flex; gap: 14px; align-items: flex-start; }
  .gate__points .icon { width: 42px; height: 42px; padding: 10px; border-radius: 14px; color: var(--accent);
    background: var(--surface); border: 1px solid var(--line); }
  .gate__points strong { display: block; font-weight: 600; }
  .gate__points span { color: var(--muted); font-size: 15px; }
  .gate__points strong { color: var(--text); }
  .gate__card { width: 100%; max-width: 460px; padding: 32px 30px; border-radius: 32px; }

  .overlay__content { max-width: 760px; }
}

/* Sleep (Oura) charts */
#sleep-chart svg, #sleep-scatter svg { width: 100%; height: auto; display: block; }
#sleep-insight { margin: 10px 0 0; }

/* ---------- Add to Home Screen guide (phones, first visit) ---------- */
.install { z-index: 61; }
.install__wrap { max-width: 420px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column;
  align-items: center; text-align: center; padding: calc(var(--safe-top) + 26px) 20px 8px; }
.install__eyebrow { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; margin: 0 0 6px; }
.install__wrap h2 { font: 500 27px/1.2 var(--serif); margin: 0 0 6px; }
.install__why { margin: 0 0 16px; font-size: 15px; }
.install__stage { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 28px;
  padding: 18px 18px 20px; box-shadow: var(--glow); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.install__art svg { display: block; width: auto; height: min(250px, 32vh); margin: 0 auto 10px; }
.install__count { color: var(--muted); font-size: 13px; margin: 0 0 2px; }
.install__step h3 { font-size: 19px; margin: 0 0 6px; }
.install__step p#install-text { margin: 0; font-size: 15px; line-height: 1.45; }
.install__step .btn { margin-top: 14px; }
.install__dots { display: flex; gap: 2px; justify-content: center; margin: 12px 0 4px; }
.install__dots button { width: 28px; height: 28px; border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; place-items: center; }
.install__dots button::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line);
  transition: width .2s, background .2s; }
.install__dots button[aria-current="step"]::after { width: 20px; border-radius: 4px; background: var(--accent); }
.install__nav { display: flex; gap: 10px; width: 100%; margin: 4px 0 6px; }
.install__nav .btn { flex: 1; width: auto; }
.install__nav .btn[hidden] { display: block; visibility: hidden; }
.install .link-btn { margin-top: auto; padding: 12px; font-size: 14px; }

/* phone illustrations */
.ia-frame { fill: var(--bg-2); stroke: var(--muted); stroke-opacity: .5; stroke-width: 2; }
.ia-dim { fill: var(--line); }
.ia-bar { fill: var(--surface-2); }
.ia-ink { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ia-ink--on { stroke: var(--accent); }
.ia-dot { fill: var(--muted); }
.ia-sheet { fill: var(--bg-2); stroke: var(--line); }
.ia-scrim { fill: #000; opacity: .3; }
.ia-row { fill: var(--line); }
.ia-row--on { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 1.5; }
.ia-text { fill: var(--text); font: 600 10px/1 system-ui, -apple-system, sans-serif; }
.ia-text--muted { fill: var(--muted); font-weight: 500; }
.ia-text--on { fill: var(--accent); }
.ia-btn { fill: var(--accent); }
.ia-btn-text { fill: var(--accent-ink); font: 700 10px/1 system-ui, -apple-system, sans-serif; }
.ia-app { fill: var(--line); }
.ia-anchor { fill: #24402f; }
.ia-anchor-ink { fill: none; stroke: #b7d2a1; stroke-width: 2; stroke-linecap: round; }
.ia-pulse { fill: none; stroke: var(--accent); stroke-width: 2.5; transform-box: fill-box; transform-origin: center;
  animation: ia-pulse 1.6s ease-out infinite; }
.ia-pulse--row { animation-name: ia-pulse-row; }
@keyframes ia-pulse-row { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.08, 1.6); opacity: 0; } }
@keyframes ia-pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.ia-ring { fill: none; stroke: var(--accent); stroke-width: 2.5; }
@media (prefers-reduced-motion: reduce) { .ia-pulse { animation: none; opacity: .8; } }
