/* Layout: one phone-width column of rounded cards on warm cream, a fixed tab bar, the circular mood grid as the one loud element.
   Palette and type follow the ILA brand guidelines: deep plum, soft lavender, warm cream, muted sage, antique gold, charcoal. */
:root {
  --bg: #F5F0E7;
  --surface: #FFFDF9;
  --surface-2: #EFE8DC;
  --ink: #37333A;
  --ink-2: #5B5560;
  --muted: #746D79;
  --line: #E2D9CC;
  --accent: #4D2F59;
  --on-accent: #FFFFFF;
  --accent-soft: #EAE2EF;
  --gold: #C5A56A;
  --danger: #A3372F;
  --q-hu: #C46A6A;
  --q-hp: #C9A24F;
  --q-lu: #8F86C2;
  --q-lp: #8CA283;
  --s1: #6F4482;
  --s2: #B58A3A;
  --grid: #EBE3D8;
  --axis: #C9BFB3;
  --font-display: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1420; --surface: #261C2D; --surface-2: #30243A; --ink: #F3EDF2; --ink-2: #CABFD0;
    --muted: #A297AA; --line: #3D2F48; --accent: #CDB9DC; --on-accent: #2A1832; --accent-soft: #432E50;
    --gold: #D2B47C; --danger: #F09088; --q-hu: #CF7A7A; --q-hp: #CDA95C; --q-lu: #9C93CF; --q-lp: #93AB8A;
    --s1: #9A6FC4; --s2: #B8862B; --grid: #33273D; --axis: #55445F; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1420; --surface: #261C2D; --surface-2: #30243A; --ink: #F3EDF2; --ink-2: #CABFD0;
  --muted: #A297AA; --line: #3D2F48; --accent: #CDB9DC; --on-accent: #2A1832; --accent-soft: #432E50;
  --gold: #D2B47C; --danger: #F09088; --q-hu: #CF7A7A; --q-hp: #CDA95C; --q-lu: #9C93CF; --q-lp: #93AB8A;
  --s1: #9A6FC4; --s2: #B8862B; --grid: #33273D; --axis: #55445F; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-body); margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.greeting { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; color: var(--accent); text-align: center; }
p { margin: 0; }

.app { max-width: 600px; margin: 0 auto; padding-inline: 16px; padding-block: 12px 108px; display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 2px solid var(--gold); }
.brand { display: flex; align-items: baseline; gap: 2px 10px; flex-wrap: wrap; min-width: 0; }
.org { flex: 1 0 100%; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.tag { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; flex: none; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
svg.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sync { font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.view, .stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.help { font-size: 14px; color: var(--ink-2); max-width: 62ch; }
.muted { color: var(--muted); font-size: 14px; }
.label, label, legend { font-size: 14px; font-weight: 700; color: var(--ink); }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="email"], textarea, select { width: 100%; background: var(--surface); border: 1px solid var(--axis); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; min-height: 64px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
::placeholder { color: var(--muted); }

.btn { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 10px 16px; min-height: 44px; cursor: pointer; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 7px 13px; min-height: 38px; cursor: pointer; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.chip small { color: var(--ink-2); font-weight: 400; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 8px 10px; min-height: 40px; cursor: pointer; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

/* mood grid */
.grid-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 8px; max-width: 340px; align-self: center; width: 100%; }
.grid-y { writing-mode: vertical-rl; transform: rotate(180deg); display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grid-x { grid-column: 2; display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.affect { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.cell { aspect-ratio: 1; border: 0; border-radius: 50%; cursor: pointer; padding: 0; display: grid; place-items: center; background: color-mix(in oklab, var(--q) calc(var(--m) * 1%), var(--surface)); }
.cell.hu { --q: var(--q-hu); } .cell.hp { --q: var(--q-hp); } .cell.lu { --q: var(--q-lu); } .cell.lp { --q: var(--q-lp); }
.cell[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: 1px; }
.cell[aria-pressed="true"]::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.readout { font-weight: 700; text-align: center; }
.emo-groups { display: flex; flex-direction: column; gap: 12px; }
.emo-group { display: flex; flex-direction: column; gap: 6px; }
.qdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--q, var(--axis)); margin-right: 6px; flex: none; }
.qdot.hu { --q: var(--q-hu); } .qdot.hp { --q: var(--q-hp); } .qdot.lu { --q: var(--q-lu); } .qdot.lp { --q: var(--q-lp); }
.small-label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; }

/* today */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav .mid { text-align: center; min-width: 0; }
.daynav strong { font-size: 18px; display: block; }
.habit { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 10px; border-top: 1px solid var(--line); }
.habit:first-of-type { border-top: 0; padding-top: 0; }
.habit .what { min-width: 0; flex: 1 1 110px; }
.habit .what span { display: block; font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 44px; height: 44px; border: 1px solid var(--axis); background: var(--surface); border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; }
.stepper output { min-width: 78px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper output small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.habit .full { flex: 1 1 100%; }

/* entries */
.entries { display: flex; flex-direction: column; gap: 8px; }
details.entry { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
details.entry > summary { list-style: none; cursor: pointer; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
details.entry > summary::-webkit-details-marker { display: none; }
.entry .when { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.entry .gist { display: flex; align-items: center; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.entry .body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 2px 12px; font-size: 14px; padding-top: 8px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.entry .snip { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
dl { margin: 0; }
.empty { text-align: center; color: var(--ink-2); padding: 14px 6px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* insights */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .v { font-family: var(--font-body); font-size: 24px; font-weight: 700; line-height: 1.15; }
.tile .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.tile .l { font-size: 13px; color: var(--ink-2); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; margin-top: 6px; }
.spark i { flex: 1 1 0; background: var(--axis); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark i.none { background: var(--grid); }
.spark i.last { background: var(--s1); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 14px; height: 4px; border-radius: 2px; background: var(--c); }
.key i.sq { width: 10px; height: 10px; border-radius: 3px; }
.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; touch-action: pan-y; }
.plot text { font-family: var(--font-body); font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.35; white-space: nowrap; }
.caption { font-size: 12px; color: var(--muted); }
.bars { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; font-size: 14px; }
.bars .name { overflow-wrap: anywhere; } .bars .name small { display: block; color: var(--muted); font-size: 12px; }
.bars .track { height: 14px; display: flex; }
.bars .bar { background: var(--s1); border-radius: 0 4px 4px 0; height: 100%; min-width: 3px; }
.bars .n { font-variant-numeric: tabular-nums; font-weight: 700; }
.stackbar { display: flex; gap: 2px; height: 16px; }
.stackbar div { border-radius: 3px; min-width: 4px; background: var(--c); }
.counts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.counts b { font-variant-numeric: tabular-nums; }
.rangebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rangebar .seg { flex: 1 1 220px; }

.part { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.part:first-child { border-top: 0; padding-top: 0; }
.part .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.part .nm { font-weight: 700; overflow-wrap: anywhere; }
.switch { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; font-size: 16px; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.error { color: var(--danger); font-weight: 700; font-size: 14px; }
.notice { border-color: var(--gold); }
.notice ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.mail { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; overflow-wrap: anywhere; }
.mail .meta { font-size: 13px; color: var(--ink-2); }
.mock { border: 1px dashed var(--axis); border-radius: 999px; padding: 9px 16px; color: var(--ink-2); font-size: 14px; align-self: flex-start; }
.code { font-size: 32px; font-weight: 700; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.seg.col { flex-direction: column; }
.crisis { font-size: 13px; color: var(--ink-2); text-align: center; }
a { color: var(--accent); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.prose { gap: 10px; }
.prose h3 { margin-top: 10px; color: var(--ink); font-size: 16px; }
.prose p, .prose li { font-size: 15px; max-width: 65ch; }
.prose ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.invite { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.invite:first-of-type { border-top: 0; padding-top: 0; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 5; }
.tabs .in { max-width: 600px; margin: 0 auto; display: flex; }
.tabs button { flex: 1 1 0; min-width: 0; border: 0; background: none; padding: 8px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--ink-2); cursor: pointer; border-top: 3px solid transparent; }
.tabs button[aria-current="page"] { color: var(--ink); font-weight: 700; border-top-color: var(--gold); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 6; max-width: calc(100% - 32px); text-align: center; }
@media (prefers-reduced-motion: no-preference) { .chip, .seg button, .cell { transition: background-color .12s ease; } }
