/* Design system (docs/design.md, D18): variant A "calm" shapes and spacing, variant B "soft"
   colours. Every colour pair is measured with the `contrast` CLI (WCAG), ratio beside the value.
   Floors: text 7:1, muted text 4.5:1, button text 7:1, borders and filled controls 3:1 (UI).
   Dark follows prefers-color-scheme and is tuned for evening use, not inverted. */
:root {
  color-scheme: light dark;
  --bg: #fff7ef;
  --surface: #ffffff;
  --chip: #f4e6d8;
  --text: #2b1d14;   /* bg 15.37, surface 16.30, chip 13.31 */
  --muted: #66503f;  /* bg 7.11, surface 7.54, chip 6.16 */
  --border: #876f5d; /* UI: bg 4.44, surface 4.71, chip 3.85 */
  --ache: #a02a18;   /* as text: bg 6.98, surface 7.40; filled control vs bg 6.98 */
  --on-ache: #ffffff; /* on ache 7.40 */
  --food: #285f49;   /* as text: bg 7.01, surface 7.44; filled control vs bg 7.01 */
  --on-food: #ffffff; /* on food 7.44 */
  --sel: #5b3a24;    /* filled control vs bg 9.54, chip 8.27, surface 10.12 */
  --on-sel: #ffffff; /* on sel 10.12 */
  /* Shapes from variant A. */
  --tap: 52px; --tap-lg: 64px; --r-card: 14px; --r-ctl: 14px; --r-chip: 12px; --bd: 1px; --gap: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1410;
    --surface: #261c16;
    --chip: #36291f;
    --text: #f8ede3;   /* bg 15.78, surface 14.45, chip 12.19 */
    --muted: #c9b4a3;  /* bg 9.13, surface 8.37, chip 7.06 */
    --border: #9a8270; /* UI: bg 5.03, surface 4.60, chip 3.88 */
    --ache: #f2a090;   /* as text: bg 8.84, surface 8.10; filled control vs bg 8.84 */
    --on-ache: #3a0d06; /* on ache 8.23 */
    --food: #92d1b4;   /* as text: bg 10.40, surface 9.52; filled control vs bg 10.40 */
    --on-food: #0a2a1c; /* on food 8.82 */
    --sel: #f8ede3;    /* filled control vs bg 15.78, chip 12.19, surface 14.45 */
    --on-sel: #1b1410; /* on sel 15.78 */
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; }
main { max-width: 34rem; margin: 0 auto; padding: 1rem 1rem 0; min-height: 100vh; display: flex; flex-direction: column; gap: 22px; }
main > * { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.15; margin: 0; }
h2, .lbl { font-size: 1rem; font-weight: 700; margin: 0 0 var(--gap); }
a { color: var(--food); }
:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
button, input, textarea, .button { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small-print { font-size: .8rem; color: var(--muted); } /* muted on bg 7.11 */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grow { flex: 1; }

/* Top of a screen: title, date navigation, one quiet status line. */
.top { display: flex; align-items: center; gap: var(--gap); }
.top h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.date { color: var(--muted); font-size: .9rem; }
.arrow { flex: none; width: 48px; height: 48px; padding: 0; border: var(--bd) solid var(--border); border-radius: var(--r-ctl); background: var(--chip); font-size: 1.4rem; line-height: 1; }
.arrow:disabled { opacity: .4; cursor: default; } /* a disabled control is exempt from the floor */
.status { min-height: 1.4em; font-size: .8rem; color: var(--muted); }
.status button { border: 0; background: none; text-decoration: underline; min-height: 48px; padding: 0 8px; margin: -14px 0; }
.outbox { font-size: .8rem; }
.banner { padding: .8rem 1rem; border-radius: var(--r-card); background: var(--ache); color: var(--on-ache); }

/* Primary actions sit last in the DOM and stick to the bottom edge, in thumb reach. */
.actions { position: sticky; bottom: 0; margin: auto -1rem 0; padding: 12px 1rem calc(12px + env(safe-area-inset-bottom)); display: grid; gap: var(--gap); background: var(--bg); }
.actions .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.btn { display: flex; align-items: center; justify-content: center; min-height: var(--tap-lg); padding: 0 20px; border: 0; border-radius: var(--r-ctl); font-size: 1.2rem; font-weight: 700; text-align: center; text-decoration: none; background: var(--sel); color: var(--on-sel); }
.btn.ache { background: var(--ache); color: var(--on-ache); }
.btn.food { background: var(--food); color: var(--on-food); }
.btn.quiet { min-height: var(--tap); background: var(--chip); color: var(--text); border: var(--bd) solid var(--border); font-size: 1rem; font-weight: 600; }
.btn:active, .chip:active, .row:active, .face:active { transform: scale(.98); }
@media (prefers-reduced-motion: no-preference) { .btn, .chip, .row, .face { transition: transform .12s; } }
@media (prefers-reduced-motion: reduce) { .btn:active, .chip:active, .row:active, .face:active { transform: none; } }

/* Chips: 52px, tonal fill plus outline; selected = sel fill and weight (never colour alone).
   Dashed outline = an unconfirmed pre-fill, or "add your own". */
.chips { display: flex; flex-wrap: wrap; gap: var(--gap); }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.6rem, 1fr)); gap: var(--gap); }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); max-width: 100%; padding: 6px 16px; border: var(--bd) solid var(--border); border-radius: var(--r-chip); background: var(--chip); line-height: 1.2; text-align: center; overflow-wrap: break-word; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--sel); color: var(--on-sel); border-color: var(--sel); font-weight: 600; }
.chip.guess { background: none; border-style: dashed; }
.chip.add { background: none; border-style: dashed; }
.chip .x { margin-left: 2px; font-size: 1.3rem; line-height: 1; }
.chips.faces, .faces { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.chip.face { flex-direction: column; min-height: 92px; padding: 10px 6px; border-radius: var(--r-card); font-size: .9rem; }
.chip .emoji { font-size: 2rem; line-height: 1; }

/* A time with a one-tap suggestion: dashed until tapped, filled once confirmed. */
.field { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; }
.field .lbl { margin: 0; flex: 1; min-width: 6rem; }
.time { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 7.5rem; min-height: var(--tap); padding: 4px 14px; line-height: 1.15; border: var(--bd) solid var(--border); border-radius: var(--r-ctl); background: var(--chip); }
.time b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.time span { font-size: .75rem; color: var(--muted); } /* muted on chip 6.16 */
.time.guess { border-style: dashed; background: none; }
.time.guess span { color: var(--muted); } /* muted on bg 7.11 */
.time.ok { background: var(--food); border-color: var(--food); color: var(--on-food); }
.time.ok span { color: var(--on-food); }
.linkbtn { min-height: 48px; padding: 0 10px; border: 0; background: none; text-decoration: underline; color: var(--text); }
.pick { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Inputs */
input[type="text"], input[type="time"], input[type="date"], textarea { width: 100%; min-height: var(--tap); padding: 0 14px; margin: 0; border: var(--bd) solid var(--border); border-radius: var(--r-ctl); background: var(--surface); color: var(--text); }
textarea { padding: 12px 14px; min-height: 5.5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; } /* muted on surface 7.54 */
input[type="time"], input[type="date"] { width: auto; max-width: 100%; }
.codein { font-size: 1.6rem; letter-spacing: .15em; text-transform: uppercase; }
.code { font-size: 2rem; font-weight: 700; letter-spacing: .2em; overflow-wrap: anywhere; }
label { display: block; }
label > input, label > textarea { margin-top: var(--gap); }
.suggest { margin-top: var(--gap); }

/* List rows: the whole row is the target, no chevron. */
.list { list-style: none; margin: 0; padding: var(--gap); display: flex; flex-direction: column; border-radius: var(--r-card); background: var(--surface); }
.list li { display: flex; align-items: center; gap: var(--gap); }
.list li > .row { flex: 1; }
.list li + li { border-top: 1px solid var(--chip); }
.row { width: 100%; min-width: 0; display: grid; grid-template-columns: 3.1rem 1fr auto; gap: 12px; align-items: baseline; min-height: var(--tap); padding: 12px 6px; border: 0; border-radius: var(--r-ctl); background: none; text-align: left; color: inherit; text-decoration: none; }
.row .t { font-variant-numeric: tabular-nums; font-weight: 600; }
.row .what { min-width: 0; overflow-wrap: anywhere; }
.row .what b { display: block; font-weight: 600; }
.row .what span { display: block; color: var(--muted); font-size: .9rem; } /* muted on surface 7.54 */
.row .src { color: var(--muted); font-size: .8rem; }
.row.guess { border: var(--bd) dashed var(--border); margin: 4px 0; }
.small { min-height: 48px; padding: 0 12px; border: var(--bd) solid var(--border); border-radius: var(--r-chip); background: var(--chip); }
.badge { padding: 2px 10px; border-radius: var(--r-chip); background: var(--ache); color: var(--on-ache); font-size: .8rem; font-weight: 600; } /* on ache 7.40 */

/* Evening check-in */
.group > .lbl + .muted { margin-top: -4px; }
.note-row { display: grid; gap: var(--gap); }
.tagnote { display: grid; gap: 6px; padding: 10px 12px; border: var(--bd) solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.tagnote b { font-weight: 600; }
.tagnote .head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.row-aja { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); width: 100%; min-height: var(--tap); padding: 4px 14px; border: var(--bd) solid var(--border); border-radius: var(--r-card); background: var(--surface); font-weight: 600; }
.row-aja .aja-open { flex: 1 1 8rem; display: flex; align-items: center; gap: var(--gap); min-height: var(--tap); padding: 0; border: 0; background: none; text-align: left; font-weight: 600; color: inherit; }
.aja-state { color: var(--muted); font-size: .9rem; font-weight: 400; } /* muted on surface 7.54 */
.row-aja .aja-faces { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.row-aja .aja-face { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 8px; border: var(--bd) solid var(--border); border-radius: var(--r-chip); background: var(--chip); color: var(--text); font-size: .8rem; } /* text on chip 13.31; border on chip 3.85 */
.row-aja .aja-face[aria-pressed="true"] { background: var(--sel); color: var(--on-sel); border-color: var(--sel); } /* on sel 10.12 */
.row-aja .aja-note { flex: 1 1 100%; display: grid; gap: 4px; padding-bottom: 10px; font-weight: 400; }
.glance-face { width: 1.7rem; height: 1.7rem; flex: none; }
.glance-none { display: inline-block; width: 1.7rem; height: 1.7rem; flex: none; box-sizing: border-box; border: 2px dashed var(--border); border-radius: 50%; } /* border on surface 4.71, bg 4.44 */

/* Admin: lunch pick */
.pick-day { display: grid; gap: var(--gap); padding: 12px; border-radius: var(--r-card); background: var(--surface); }
.pick-day .opt { display: grid; gap: 2px; justify-items: start; min-height: var(--tap); padding: 8px 14px; border: var(--bd) solid var(--border); border-radius: var(--r-chip); background: var(--chip); text-align: left; overflow-wrap: anywhere; }
.pick-day .opt[aria-pressed="true"] { background: var(--sel); color: var(--on-sel); border-color: var(--sel); font-weight: 600; }
.pick-day .opt small { font-size: .8rem; font-weight: 400; }

details > summary { min-height: var(--tap); display: flex; align-items: center; font-weight: 600; cursor: pointer; }
dt { color: var(--muted); margin-top: 1rem; }
dd { margin: .2rem 0 0; font-size: 1.2rem; }
.footer { margin: 0; }
.footer a { display: inline-flex; align-items: center; min-height: 48px; }
