* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); font-family: var(--font); color: var(--navy);
       display: flex; justify-content: center; min-height: 100dvh; }
.phone { width: min(var(--screen-w), 100vw); background: var(--bg);
         min-height: 100dvh; display: flex; flex-direction: column; }

/* the phone's scrolling content area — everything below the header */
.body { flex: 1; overflow-y: auto; }

/* ---- landing: header band ---- */
.hdr {
  background: var(--surface);
  flex: none;
  padding: 30px var(--screen-pad) 24px;
  text-align: center;
}
.hdr h1 {
  font-size: var(--text-title);
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  line-height: 1;
}
.hdr p {
  margin-top: 10px;
  font-size: var(--text-body);
  color: var(--navy);
}

/* ---- landing: content sections ---- */
.content { padding: 22px var(--screen-pad) 32px; }

.section { margin-bottom: 28px; }
.section:last-child { margin-bottom: 0; }
.section h2 {
  font-size: var(--text-heading);
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.section p {
  font-size: var(--text-body);
  color: var(--navy);
  line-height: 1.5;
  margin-bottom: 10px;
}
.section p:last-child { margin-bottom: 0; }

/* ---- landing: doors (the three doors + feedback) ---- */
.doors { list-style: none; padding: 0; }
.door {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 14px 15px;
  margin-bottom: var(--gap-card);
  text-decoration: none;
}
.door:last-child { margin-bottom: 0; }
.door .dt {
  display: block;
  font-size: var(--text-card);
  font-weight: 700;
  color: var(--purple-bright);
  text-transform: uppercase;
}
.door .ds {
  display: block;
  font-size: var(--text-body);
  color: var(--navy);
  margin-top: 5px;
}
.door.disabled { opacity: 0.55; }
.door.disabled .dt { color: var(--navy); }

/* ============================================================
   APP SHELL — home tile grid + documents (upload, archive, detail)
   Class names and structure follow prototype/index.html's archetypes
   (GRID, LIST, DETAIL) for visual fidelity; kept under `.screenhdr` rather
   than reusing `.hdr` above so the landing/feedback/admin banner header
   (centered h1+p) is untouched.
   ============================================================ */

/* ---- shared header chrome ---- */
.screenhdr { background: var(--surface); flex: none; padding: 16px 18px 0; position: relative; }
.screenhdr.short { min-height: var(--h-header); }
.screenhdr.short.bare {
  min-height: var(--h-header-bare);
  display: flex; flex-direction: column; justify-content: center;
  padding-top: 0; padding-bottom: 0;
}
.screenhdr.tall { height: var(--h-header-home); padding-bottom: 0; display: flex; flex-direction: column; }

.topline { display: flex; align-items: center; }
.slot { flex: none; width: 36px; }
.back { flex: none; width: 36px; height: 36px; padding: 0; color: var(--navy); text-decoration: none; display: block; }
.back svg { display: block; width: 100%; height: 100%; }
.title {
  flex: 1; min-width: 0; text-align: center;
  font-size: var(--text-title); font-weight: 700; color: var(--purple);
  text-transform: uppercase; line-height: 1;
}
/* A title too long for one line at full size ("FOLLOW-UP NOTES") takes two,
   a size down, so both fit the header with room above and below. */
.title.long { font-size: min(var(--text-title), 8vw); }
.title.appname { font-size: 52px; text-transform: none; }
.title.appname sup { font-size: .5em; vertical-align: super; }

/* the band is a FIXED height in both states (home.py's `alert_rows`
   present or not) — .screenhdr.tall already sets a fixed `height`, and the
   dropdown below is taken out of flow with `position:absolute`, so opening
   it can never push the tile grid down. */
.alertwrap { flex: 1; display: flex; align-items: center; padding-bottom: 4px; }
.alertbar {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; padding: 0; font-family: var(--font); text-align: left;
}
.alertbar .aword { font-size: var(--text-heading); font-weight: 700; color: var(--purple); text-transform: uppercase; }
summary.alertbar.tappable { cursor: pointer; list-style: none; }
summary.alertbar.tappable::-webkit-details-marker { display: none; }
.alertdrop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5;
  background: var(--bg); padding: 4px var(--screen-pad) 14px;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--navy) 28%, transparent);
  max-height: 60vh; overflow-y: auto;
}
.arow {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--radius-card);
  padding: 13px 15px; margin-bottom: 10px;
}
.arow:last-child { margin-bottom: 0; }
.arow .alink { flex: 1; min-width: 0; display: block; text-decoration: none; }
.arow .at { font-size: var(--text-card); font-weight: 700; color: var(--purple-bright); text-transform: uppercase; }
.arow .as { font-size: var(--text-body); color: var(--navy); margin-top: 4px; }
/* overdue reads as a dark navy box with lighter text — the strongest
   contrast reversal available in the palette (the iOS treatment, see
   ios/ICUHelper/Components/AlertsBand.swift), so it cannot be skimmed past */
.arow.overdue { background: var(--navy); }
.arow.overdue .at { color: var(--lavender); }
.arow.overdue .as { color: var(--lavender); opacity: .88; }
/* a medicine dose that has passed without a tick: the app's one yellow,
   black text on it, kept until it is ticked (services/med_reminders.py) */
.arow.missed { background: var(--missed); }
.arow.missed .at, .arow.missed .as { color: var(--on-missed); }
.arow.missed .acheck { border-color: var(--on-missed); color: var(--on-missed); }
/* an appointment already ticked: still listed, quieter */
.arow.ticked .alink { opacity: .7; }

/* The check mark beside an alert or a reminder (routes/acknowledge.py): an
   empty ring to tap, filled once ticked. */
.ackform { flex: none; margin: 0; }
.acheck {
  flex: none; width: 44px; height: 44px; padding: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 2.5px solid var(--navy); border-radius: var(--radius-round);
  color: var(--navy);
}
.acheck svg { display: block; width: 100%; height: 100%; }
.acheck.done { background: var(--navy); color: var(--lavender); }
.acheck:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.arow.overdue .acheck { border-color: var(--lavender); color: var(--lavender); }
/* the band itself while a dose is missed: the word on a yellow pill, since
   yellow text on the light blue header would barely show */
summary.alertbar.missed .aword {
  background: var(--missed); color: var(--on-missed);
  border-radius: var(--radius-pill); padding: 3px 10px 0;
}

.proposedbanner {
  display: block; background: var(--purple); color: var(--lavender); text-align: center;
  padding: 12px var(--screen-pad); font-size: var(--text-body); font-weight: 700;
  text-transform: uppercase; text-decoration: none;
}

/* ---- home: the water reminders band (routes/water.py). --surface while
   it is only naming the next one; the navy/lavender flip of a chosen pick
   or an overdue alert once one is due, so "now" reads from across a room. */
.waterbanner {
  background: var(--surface); color: var(--navy);
  padding: 12px var(--screen-pad); text-align: center;
}
.waterbanner .wline {
  display: block; color: var(--purple-bright); text-decoration: none;
  font-size: var(--text-body); font-weight: 700; text-transform: uppercase;
}
.waterbanner .wnote { margin-top: 6px; font-size: var(--text-tab); line-height: 1.4; }
.waterbanner.due { background: var(--navy); color: var(--lavender); }
.waterbanner.due .wline { color: var(--lavender); }
.waterbanner .wrow { display: flex; align-items: center; justify-content: center; gap: 14px; }
.waterbanner .wrow .wline { flex: 0 1 auto; }
.waterbanner.due .acheck { border-color: var(--lavender); color: var(--lavender); }
/* the ⓘ when the reminders were changed to fit the papers, and the reason
   it opens, laid over the grid below like the alerts dropdown so the band
   itself never grows */
.waterbanner { position: relative; }
.waterwhy summary {
  list-style: none; cursor: pointer; display: flex; padding: 8px;
}
.waterwhy summary::-webkit-details-marker { display: none; }
.waterwhy summary:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.waterwhy .infodot { width: 24px; height: 24px; font-size: 14px; }
.waterbanner.due .waterwhy .infodot { border-color: var(--lavender); }
.whytext {
  position: absolute; left: var(--screen-pad); right: var(--screen-pad); top: calc(100% - 4px);
  z-index: 6; background: var(--bg); color: var(--navy); text-align: left;
  border-radius: var(--radius-card); padding: 14px 16px;
  font-size: var(--text-body); line-height: 1.5; text-transform: none; font-weight: 400;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--navy) 28%, transparent);
}
.waterallow {
  margin-top: 10px; background: var(--purple); color: var(--lavender);
  border: none; border-radius: var(--radius-card); padding: 10px 16px;
  font-family: var(--font); font-size: var(--text-body); text-transform: uppercase; cursor: pointer;
}
.waterallow:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

/* the banner app.js raises over any page when a reminder comes round */
.waterpop {
  position: fixed; z-index: 50; top: 12px; left: 50%; transform: translateX(-50%);
  width: calc(min(var(--screen-w), 100vw) - 2 * var(--screen-pad));
  display: flex; align-items: center; gap: 12px;
  background: var(--navy); color: var(--lavender);
  border-radius: var(--radius-card); padding: 14px 16px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--navy) 35%, transparent);
}
.waterpop[hidden] { display: none; }
.waterpop .wt { font-size: var(--text-body); font-weight: 700; text-transform: uppercase; }
.waterpop .ws { font-size: var(--text-tab); margin-top: 2px; }
.waterpop .wbody { flex: 1; min-width: 0; }
.waterpop .acheck { border-color: var(--lavender); color: var(--lavender); }

/* ---- segmented control: tabs (documents, journal, recordings, sections) ---- */
.seg { display: flex; justify-content: center; gap: 20px; margin: 0; padding: 14px 0 12px; }
.seg a {
  font-family: var(--font); font-size: var(--text-tab); font-weight: 400;
  text-transform: uppercase; color: var(--navy); text-decoration: none;
  display: inline-flex; align-items: center;
  /* all-caps text has no descenders, but the font still reserves descent
     space below the baseline — symmetric padding makes caps ride high in
     the pill, so the top gets the descent's worth back */
  padding: 8px 13px 5px; border-radius: var(--radius-pill); line-height: 1;
}
.seg a.on { background: var(--navy); color: var(--lavender); }

/* ---- grid (home) ---- */
/* Three fixed-width tiles per row, exactly as the mock's grid — but laid
   out as centred flex rows rather than a 3-column grid, so the last row
   centres itself whatever it holds. The grid needed `.tile.solo`
   (grid-column: 2) to centre a lone tenth tile; with the eleventh (Sleep)
   that trick stops working, and two tiles cannot be centred in three
   fixed columns at all. Full rows measure identically either way. */
.tiles {
  display: flex; flex-wrap: wrap; justify-content: center;
  column-gap: var(--gap-tile-x); row-gap: 16px;
  padding: 18px 0;
}
.body.grid { display: flex; flex-direction: column; justify-content: center; }
/* As wide as the icon or the label's longest word, whichever is wider: a
   two-word label ("FOLLOW-UP NOTES") wraps under its icon instead of
   widening the tile and pushing it onto a row of its own. */
.tile { display: block; width: min-content; text-decoration: none; text-align: center; font-family: var(--font); }
.tile img {
  width: var(--size-tile); height: var(--size-tile); border-radius: var(--radius-tile);
  display: block; background: var(--navy); padding: 20px;
}
.tile span {
  display: block; margin-top: 9px; font-size: var(--text-label); font-weight: 400;
  color: var(--label-blue); text-transform: uppercase;
}

/* ---- search bar (documents archive) ---- */
.search {
  background: var(--purple); min-height: var(--h-search); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 18px; color: var(--lavender);
}
.search svg { width: 26px; height: 26px; flex: none; }
.search form { flex: 1; display: flex; min-width: 0; }
.search input {
  flex: 1; min-width: 0; background: none; border: none; outline: none; padding: 0;
  font-family: var(--font); font-size: var(--text-body); color: var(--lavender);
}
.search input::placeholder { color: var(--lavender); opacity: .7; text-transform: uppercase; }

/* ---- list (documents archive rows) ---- */
.list { padding: 12px var(--screen-pad) 20px; }
.card {
  display: block; background: var(--surface); border-radius: var(--radius-card);
  min-height: var(--h-card); margin-bottom: var(--gap-card); padding: 13px 15px;
  text-decoration: none;
}
.card .ct { font-size: var(--text-card); font-weight: 700; color: var(--purple-bright); text-transform: uppercase; }
.card .cs { font-size: var(--text-body); color: var(--navy); margin-top: 5px; }
.card .cs.docstatus { color: var(--purple-bright); font-weight: 700; }
.noresults { padding: 26px 4px; font-size: var(--text-body); color: var(--navy); line-height: 1.5; }

/* ---- documents: upload ---- */
/* A short, secondary guidance line near a form control — same muted
   treatment as .audiohint/.recnote, under a neutral name since this one
   sits above the upload control rather than being audio-specific. */
.formnote { font-size: var(--text-body); color: var(--navy); opacity: .8; margin: 4px 0 14px; }

.uploadform { margin-top: 14px; }
.uploadbox {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 2px solid var(--navy);
  border-radius: var(--radius-card);
  padding: 14px 16px; cursor: pointer;
}
.uploadbox input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.uploadbox svg { width: 30px; height: 30px; flex: none; color: var(--navy); }
.uploadbox svg .lens { fill: var(--bg); }
.uploadlabel { flex: 1; font-size: var(--text-body); color: var(--navy); text-transform: uppercase; line-height: 1.3; }
.uploadcount { flex: none; font-size: var(--text-body); font-weight: 700; color: var(--purple-bright); white-space: nowrap; }
.uploador {
  margin: 8px 0; text-align: center; font-size: var(--text-body);
  color: var(--navy); opacity: .7; text-transform: uppercase;
}
/* A picker holding files: the navy/lavender flip a chosen intro answer
   gets, so "these are in" reads from across a room (documents_new.html). */
.uploadbox.chosen { background: var(--navy); }
.uploadbox.chosen .uploadlabel, .uploadbox.chosen .uploadcount, .uploadbox.chosen svg { color: var(--lavender); }
.uploadbox.chosen svg .lens { fill: var(--navy); }
/* the line above SAVE once something is chosen */
.uploadready {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-card);
  background: var(--surface); color: var(--purple-bright);
  font-size: var(--text-body); font-weight: 700; line-height: 1.4;
}
.uploadready + .savebtn { margin-top: 10px; }
/* Quiet until there is something to save, then the brightest thing on the
   screen. Only ever set by the page's script: without it the button is
   the ordinary one. */
.savebtn.waiting { opacity: .45; }
.savebtn.ready {
  background: var(--purple-bright); padding: 18px;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--purple-bright);
}
/* the Documents tab's own words, a size up from the app's body text */
.docadd p { font-size: 19px; }
/* what the screen leads with until anything has been scanned */
.startcard {
  background: var(--navy); color: var(--lavender); border-radius: var(--radius-card);
  padding: 16px 18px; margin-bottom: 24px;
  font-size: 19px; line-height: 1.5;
}
.startcard .startlead {
  font-size: var(--text-card); font-weight: 700; text-transform: uppercase; margin-bottom: 6px;
}
.savebtn {
  display: block; width: 100%; margin-top: 16px; background: var(--purple);
  color: var(--lavender); border: none; border-radius: var(--radius-card);
  padding: 15px; font-family: var(--font); font-size: var(--text-card); font-weight: 700;
  text-transform: uppercase; cursor: pointer;
}

/* ---- detail (document) ---- */
.detail.pad { padding: 22px var(--screen-pad) 30px; }
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero { font-size: var(--text-card); font-weight: 700; color: var(--purple-bright); text-transform: uppercase; }
.docmeta { font-size: var(--text-tab); color: var(--navy); text-transform: uppercase; margin: 6px 0 18px; line-height: 1.5; }

.pageblock { margin-bottom: 22px; }
.pageblock:last-child { margin-bottom: 0; }
.pageimg { display: block; width: 100%; border-radius: var(--radius-card); margin-bottom: 10px; }
.pagetext { font-size: var(--text-body); color: var(--navy); line-height: 1.55; white-space: pre-wrap; }
.pagetext.hint { color: var(--navy); opacity: .7; text-transform: uppercase; font-size: var(--text-tab); }

/* ---- document detail: extraction suggestion line (Task 5) ---- */
.suggestline {
  display: block; font-size: var(--text-body); line-height: 1.5; margin: 0 0 18px;
}
a.suggestline { color: var(--purple-bright); font-weight: 700; text-decoration: none; }
.suggestline.hint { color: var(--navy); opacity: .8; }
/* in-progress states get three dancing dots, not just static text — the
   chat convention everyone already reads as "it's working on it". Both
   assistant flows (typed and voice) use these; nothing else does yet. */
.dots { display: inline-flex; align-items: center; gap: 5px; flex: none; }
.dots span {
  width: 7px; height: 7px; border-radius: var(--radius-round);
  background: var(--navy);
  animation: dot 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: .16s; }
.dots span:nth-child(3) { animation-delay: .32s; }
@keyframes dot {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
/* Motion is decoration here — the words carry the meaning — so it stops
   dead for anyone who asks the OS for less of it, same as #micbtn.working
   below. Worth more than usual on a screen built for people recovering
   from intensive care. */
@media (prefers-reduced-motion: reduce) {
  .dots span { animation: none; opacity: .6; }
}
/* per-page raw text hides behind a small disclosure */
.pagetext-toggle summary {
  list-style: none; cursor: pointer; font-size: var(--text-tab);
  font-weight: 700; color: var(--navy); opacity: .75; text-transform: uppercase;
  margin-top: 8px;
}
.pagetext-toggle summary::-webkit-details-marker { display: none; }
.pagetext-toggle .pagetext { margin-top: 8px; }
.retryform { margin: 0 0 18px; }
.retrybtn {
  background: var(--purple); color: var(--lavender); border: none;
  border-radius: var(--radius-card); padding: 12px 20px; font-family: var(--font);
  font-size: var(--text-body); font-weight: 700; text-transform: uppercase; cursor: pointer;
}

/* ---- rename (edit-popup pattern, via <details> since there is no client JS state here) ---- */
.pencil-btn { flex: none; width: 26px; height: 26px; color: var(--purple); cursor: pointer; list-style: none; }
.pencil-btn::-webkit-details-marker { display: none; }
.pencil-btn svg { display: block; width: 100%; height: 100%; }
.editform {
  margin-top: 12px; background: var(--bg); border-radius: var(--radius-card);
  padding: 16px; box-shadow: 0 22px 55px color-mix(in srgb, var(--navy) 20%, transparent);
}
.editform input {
  width: 100%; background: var(--surface); border: none; border-radius: var(--radius-card);
  padding: 15px 16px; outline: none; font-family: var(--font); font-size: var(--text-body); color: var(--navy);
}
.editform button {
  margin-top: 12px; background: var(--purple); color: var(--lavender); border: none;
  border-radius: var(--radius-card); padding: 12px 20px; font-family: var(--font);
  font-size: var(--text-body); font-weight: 700; text-transform: uppercase; cursor: pointer;
}

/* ---- sections (medication/diet/terminology/exercise/emergency lists) ---- */
.addrow {
  display: block; text-align: center; background: color-mix(in srgb, var(--surface) 50%, transparent);
  border-radius: var(--radius-card); min-height: 44px; line-height: 44px;
  margin-bottom: var(--gap-card); font-size: var(--text-card); font-weight: 700;
  color: var(--purple-bright); text-transform: uppercase; text-decoration: none;
}
.card.static { cursor: default; }
.cardrow { display: flex; align-items: center; gap: 10px; margin-bottom: var(--gap-card); }
/* emergency contacts: inert card + deliberate-press CALL/EMAIL buttons */
.contactcard { cursor: default; }
.contactline { word-break: break-word; }
.contactactions { display: flex; gap: 10px; margin-top: 12px; }
.callbtn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--navy); color: var(--lavender); border-radius: var(--radius-card);
  padding: 13px; font-size: var(--text-body); font-weight: 700;
  text-transform: uppercase; text-decoration: none;
}
.callbtn svg { width: 18px; height: 18px; }
.emailbtn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--navy); color: var(--navy); background: none;
  border-radius: var(--radius-card); padding: 11px; font-size: var(--text-body);
  font-weight: 700; text-transform: uppercase; text-decoration: none;
}
.cardrow .card.nogap { margin-bottom: 0; flex: 1; min-width: 0; }
.pencil-link { flex: none; width: 24px; height: 24px; color: var(--navy); }
.pencil-link svg { display: block; width: 100%; height: 100%; }

/* ---- section add/edit form (bare field list + save, reuses .content/.section/.savebtn) ---- */
.fieldform { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.formfield { display: flex; flex-direction: column; gap: 6px; }
.formfield span { font-size: var(--text-tab); color: var(--navy); text-transform: uppercase; }
.formfield input {
  background: var(--surface); border: none; border-radius: var(--radius-card);
  padding: 13px 15px; outline: none; font-family: var(--font); font-size: var(--text-body); color: var(--navy);
}

/* ---- profile ---- */
/* Rows stretch to the column's full width; only the avatar is centred.
   `align-items: center` here used to shrink every child to its own
   content, which left the six editable rows ragged — each `.fieldbox` is
   a <summary> inside a <details class="editpop">, and it is the <details>
   that is the flex item, so `.fieldbox`'s own `width: 100%` only filled
   an already-shrunken box. (`.deletewrap` carried a `width: 100%` to work
   around exactly this; it no longer needs one, and `.editpop` is shared
   with the document detail screen so it must not be widened globally.) */
.detail.pad.profile { display: flex; flex-direction: column; gap: var(--gap-card); }
.avatar {
  align-self: center;
  width: 96px; height: 96px; border-radius: var(--radius-round); background: var(--navy);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
/* The icon is already drawn in --lavender, the colour every glyph on navy
   takes. It used to be inverted here, which turned it a dark olive green. */
.avatar img { width: 60%; height: 60%; object-fit: contain; }
.hero.center { text-align: center; }
.fieldbox {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 54px; background: var(--surface); border-radius: var(--radius-card);
  padding: 12px; list-style: none; cursor: default;
}
.fieldbox::-webkit-details-marker { display: none; }
.pencil-summary { cursor: pointer; }

/* the Diet section's restrictions banner — the rule the lists below have
   to satisfy, so it reads before them, not as one of them */
.restrictions .cs.unset { opacity: .7; }

/* the one-shot "N suggestions accepted" line ACCEPT ALL redirects with —
   a confirmation, so it reads quietly rather than competing with the
   PROPOSED banner it sits above */
.acceptedbanner {
  margin: 0 0 var(--gap-card); padding: 12px 14px;
  background: var(--surface); border-radius: var(--radius-card);
  font-size: var(--text-body); font-weight: 700; color: var(--purple-bright);
}

/* the Profile's "YOUR DAY" divider, separating the intro's answers from
   the name/age/height rows above them — centred explicitly, since the
   column stretches its children rather than centring them */
.dayhead {
  margin: 8px 0 0; text-align: center;
  font-size: var(--text-tab); font-weight: 700;
  letter-spacing: .06em; color: var(--purple-bright); text-transform: uppercase;
}
.fieldbox .fk { font-size: var(--text-card); font-weight: 700; color: var(--purple-bright); text-transform: uppercase; }
.fieldbox .fv { flex: 1; text-align: right; font-size: var(--text-body); color: var(--navy); }
.fieldbox .pencil { flex: none; width: 20px; height: 20px; color: var(--navy); }
.deletewrap { margin-top: var(--gap-tile-y); }
/* Opening swaps the button for the confirm panel in place, rather than
   unfolding underneath it: this sits at the bottom of a long Profile, and
   the box you have to type into was opening off the bottom of the screen.
   Hiding the summary also stops two identical DELETE EVERYTHING buttons
   stacking — the one in the panel is the real one, and CANCEL is the way
   back out. */
.deletewrap[open] .deletebtn { display: none; }
.confirmrow { display: flex; gap: 10px; align-items: stretch; }
.confirmrow form { flex: 1; margin: 0; }
.confirmrow form button { width: 100%; }
/* the held-copy card leads the document screen — nothing below it has
   been read yet, so it is the state of the page, not a footnote */
.heldcopy { margin-bottom: var(--gap-card); }
.heldcopy .cs { margin-bottom: 12px; }
/* Stacked, not side by side: these two labels are long enough to wrap at
   half a phone's width, and a wrapped button next to an unwrapped one is
   what made this card look broken. Full width also matches every other
   primary button in the app. */
.heldcopy .confirmrow { flex-direction: column; }
/* `.savebtn` sizes by padding and `.cancelbtn` by min-height, which reads
   as a wobble once they are stacked — pinned equal here rather than
   changing `.savebtn`, which ACCEPT ALL also uses. */
.heldcopy .confirmrow button { min-height: 54px; }
/* `.cancelbtn` is --surface, which is this card's own background — inside
   here it needs the page colour instead, or the secondary action reads as
   plain text with no button under it. (It is --surface elsewhere because
   the profile's panel sits on --bg.) */
.heldcopy .confirmrow .cancelbtn { background: var(--bg); }
/* the reset disclosure inside the mismatch card: its summary is the
   second step, and the panel replaces it exactly as the profile's does */
.mismatchreset { margin-top: 10px; }
.mismatchreset > summary { background: var(--bg); }
.mismatchreset[open] > summary { display: none; }
.mismatchreset .deleteform { margin-top: 0; }
/* The panel is `.editform`, which paints itself --bg — so CANCEL needs
   --surface in here, the opposite of what it needs on the card outside.
   Third time this app's two background tokens have caught a reused
   button; the rule is that a control must never inherit the colour of
   whatever it was dropped into. */
.mismatchreset .confirmrow { flex-direction: row; }
.mismatchreset .confirmrow .cancelbtn { background: var(--surface); }
.mismatchreset .confirmrow button { margin-top: 0; }
.confirmrow button { flex: 1; }
/* Used on both an <a> (the profile panel's CANCEL) and a <button> (the
   held-copy card), so it has to carry the button resets too — without
   them a <button> keeps its default border and the system UI font, and
   sits next to its slab-serif neighbour looking like a different app. */
.cancelbtn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--navy); text-decoration: none;
  border: none; border-radius: var(--radius-card); min-height: 54px;
  padding: 0 14px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  font-family: var(--font); font-size: var(--text-card); font-weight: 700;
  text-transform: uppercase; text-align: center;
}
.deletebtn {
  display: block; text-align: center; background: var(--navy); color: var(--lavender);
  border-radius: var(--radius-card); min-height: 54px; line-height: 54px;
  font-size: var(--text-card); font-weight: 700; text-transform: uppercase;
  cursor: pointer; list-style: none;
}
.deletebtn::-webkit-details-marker { display: none; }
.deleteform p { font-size: var(--text-tab); color: var(--navy); opacity: .8; line-height: 1.5; margin-bottom: 14px; }
.confirmlabel { display: block; font-size: var(--text-body); color: var(--navy); margin-bottom: 12px; }
/* --surface, not --bg: this panel sits directly on the page background,
   so a --bg field was the same colour as everything around it — an
   invisible box you are nonetheless required to type into. */
.confirmlabel input {
  display: block; width: 100%; margin-top: 8px; background: var(--surface); border: none;
  border-radius: var(--radius-card); padding: 13px 15px; outline: none;
  font-family: var(--font); font-size: var(--text-body); color: var(--navy);
}

/* ---- assistant (new chat: sent bubble, passage cards, composer) ---- */
.chatlist { padding: 12px var(--screen-pad) 20px; }
.bubble.sent {
  max-width: 78%; margin-left: auto; margin-bottom: var(--gap-card);
  background: var(--purple); color: var(--lavender);
  border-radius: var(--radius-card); padding: 13px 15px;
  font-size: var(--text-body); line-height: 1.4;
}
.card.nopassage { color: var(--navy); font-size: var(--text-body); line-height: 1.5; }
/* what the assistant is for, atop the Today's chat tab */
.card.assistantabout {
  min-height: auto; background: var(--navy); color: var(--lavender);
  font-size: var(--text-body); line-height: 1.5;
}
.assistantabout ul { margin: 8px 0 0; padding-left: 22px; }
.assistantabout li { margin-top: 4px; font-style: italic; }
/* one question and its answers, within a day's chat */
.chatturn { scroll-margin-top: 12px; }
.chatturn + .chatturn { margin-top: 22px; }
/* the day a saved chat was, atop it */
.chatday {
  margin: 4px 0 14px; text-align: center; font-size: var(--text-tab); font-weight: 700;
  color: var(--purple-bright); text-transform: uppercase;
}
.chatback { padding: 0 var(--screen-pad) 16px; }
.chatback .savebtn { text-align: center; text-decoration: none; margin-top: 0; }
.composer {
  background: var(--purple); min-height: var(--h-search); flex: none;
  display: flex; align-items: center; gap: 10px;
  margin: 0 var(--screen-pad) 16px; padding: 0 14px;
  border-radius: var(--radius-pill);
}
.composer input {
  flex: 1; min-width: 0; background: none; border: none; outline: none; padding: 0;
  font-family: var(--font); font-size: var(--text-tab); color: var(--lavender);
  text-transform: uppercase;
}
.composer input::placeholder { color: var(--lavender); opacity: .7; }
.composer button {
  flex: none; width: 26px; height: 26px; padding: 0; background: none; border: none;
  color: var(--lavender); cursor: pointer;
}
.composer button svg { display: block; width: 100%; height: 100%; }

/* ---- journal: compose (typed entry) ---- */
.compose { display: flex; flex-direction: column; height: 100%; }
.noterow { display: flex; align-items: center; justify-content: space-between; padding: 12px var(--screen-pad) 0; }
.circ {
  border-radius: var(--radius-round); display: flex; align-items: center; justify-content: center;
  color: var(--navy); background: var(--surface); border: none; cursor: pointer; flex: none;
  text-decoration: none;
}
.circ.sm { width: 62px; height: 62px; }
.circ.sm svg { width: 28px; height: 28px; }
.switchbtn {
  background: var(--purple); color: var(--lavender); border: none;
  font-family: var(--font); font-size: var(--text-body); text-transform: uppercase;
  padding: 9px 17px; border-radius: var(--radius-card); cursor: pointer; line-height: 1.3;
  max-width: 150px;
}
.switchbtn.disabled { opacity: 0.55; cursor: not-allowed; }
.notepad {
  display: block; box-sizing: border-box;
  margin: 14px var(--screen-pad); width: calc(100% - 2 * var(--screen-pad));
  background: var(--purple); color: var(--lavender);
  border: none; outline: none; resize: vertical;
  border-radius: var(--radius-card); padding: 16px; font-size: var(--text-body);
  font-family: var(--font); line-height: 1.5; flex: 1; min-height: 180px;
}
.notepad::placeholder { color: var(--lavender); opacity: 0.7; }

/* ---- recordings: new tab (recorder + upload) ---- */
.record { display: flex; flex-direction: column; align-items: center; padding: 8px 0 4px; }
.micbig {
  width: 140px; height: 140px; border-radius: var(--radius-round); flex: none;
  border: 6px solid var(--navy); background: none; color: var(--navy);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.micbig svg { width: 64px; height: 64px; display: block; }
.micbig[data-state="recording"] { border-color: var(--purple-bright); color: var(--purple-bright); }
.micbig:disabled { opacity: .6; cursor: default; }
.michint { margin-top: 16px; font-size: var(--text-tab); color: var(--navy); text-transform: uppercase; }
.recclock { margin-top: 8px; font-size: var(--text-heading); font-weight: 700; color: var(--navy); }
.recnote { margin-top: 10px; font-size: var(--text-body); color: var(--navy); text-align: center; opacity: .8; }
.recerror { margin-top: 10px; font-size: var(--text-body); color: var(--purple-bright); text-align: center; }

/* ---- recordings: detail (player + transcript) ---- */
.player { display: block; width: 100%; margin: 4px 0 18px; }
.audiohint { font-size: var(--text-body); color: var(--navy); opacity: .8; margin: 4px 0 18px; }
.swapform { margin: 4px 0 18px; text-align: right; }
.swapbtn {
  background: var(--surface); color: var(--navy); border: none;
  border-radius: var(--radius-pill); padding: 8px 16px; font-family: var(--font);
  font-size: var(--text-body); text-transform: uppercase; cursor: pointer;
}
.transcript.full { display: block; }
.transcript.full .pagetext { margin-bottom: 14px; }
.transcript.full .pagetext:last-child { margin-bottom: 0; }

/* ---- recordings: two-sided transcript (clinician/patient turns, once
   diarization succeeds — see recordings.py's `_turn_html_two_sided`) ---- */
.transcript.full .turn { margin-bottom: 14px; }
.transcript.full .turn:last-child { margin-bottom: 0; }
.turn .who {
  font-size: var(--text-tab); color: var(--navy); opacity: .7;
  text-transform: uppercase; margin-bottom: 4px;
}
.turn.you { text-align: right; }
.bubble.you {
  display: inline-block; text-align: left; max-width: 78%;
  background: var(--surface); color: var(--navy);
  border-radius: var(--radius-card); padding: 13px 15px;
  font-size: var(--text-body); line-height: 1.4;
}

/* ---- journal: detail (a journal entry read in full) ---- */
.entry { padding: 22px var(--screen-pad) 30px; }
.entry-date {
  font-size: var(--text-card); font-weight: 700; color: var(--purple-bright);
  text-transform: uppercase; margin-bottom: 14px;
}
.entry p { font-size: var(--text-body); color: var(--navy); line-height: 1.55; margin-bottom: 14px; }
.entry p:last-child { margin-bottom: 0; }
/* read-aloud: the typed entry's equivalent of a play button */
.readbtn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: none; border-radius: var(--radius-card);
  padding: 14px 16px; margin: 2px 0 20px; cursor: pointer;
  font-family: var(--font); color: var(--navy);
  font-size: var(--text-body); text-transform: uppercase; line-height: 1;
}
.readbtn svg { width: 27px; height: 27px; flex: none; }
.readbtn .t { position: relative; top: .15em; }

/* ---- proposals (review inbox: verify-then-confirm) ---- */
.reviewintro { font-size: var(--text-body); color: var(--navy); line-height: 1.5; margin-bottom: 18px; }
.proposalcard {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 15px; margin-bottom: var(--gap-card);
}
.proposalcard blockquote {
  margin: 0 0 10px; padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-card); font-size: var(--text-body); color: var(--navy);
  font-style: italic; line-height: 1.4;
}
/* a factual per-card problem line (e.g. an unparseable hand-edited due_at)
   — same accent color `.recerror` uses for its own factual failure line */
.fielderror { margin: 0 0 12px; font-size: var(--text-body); color: var(--purple-bright); line-height: 1.4; }
/* Proposal-card fields sit on a --surface card, so the section-form
   input's --surface background would vanish into it — flip to --bg (the
   same contrast move the card's blockquote makes) and tighten the rhythm
   so a five-field card stays one screen tall. */
.proposalcard .fieldform { margin-top: 10px; gap: 10px; }
.proposalcard .formfield { gap: 4px; }
.proposalcard .formfield input { background: var(--bg); padding: 10px 12px; }
.proposalfoot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px;
}
.doclink {
  display: inline-block; font-size: var(--text-tab);
  color: var(--purple-bright); text-transform: uppercase; text-decoration: none;
}
.proposalactions { display: flex; justify-content: flex-end; gap: 12px; }
.acceptbtn, .dismissbtn {
  width: 44px; height: 44px; padding: 0; border-radius: var(--radius-round);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-family: var(--font);
}
.acceptbtn { background: var(--navy); color: var(--lavender); border: none; }
.acceptbtn svg { width: 22px; height: 22px; }
.dismissbtn { background: var(--surface); color: var(--navy); border: 2px solid var(--navy); }
.dismissbtn svg { width: 18px; height: 18px; }

/* ---- about-this-medicine (FDA-label enrichment, from druginfo.lookup —
   renders only on a lookup hit, as a collapsed <details> disclosure: a
   tappable ⓘ row that slides the label text open. The indication is stored
   with newlines (bulleted lists, see build_druginfo.format_indication), so
   `.abouttext` renders with `white-space: pre-line`. */
details.aboutmed summary {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  list-style: none; font-size: var(--text-tab); font-weight: 700;
  color: var(--navy); text-transform: uppercase;
}
details.aboutmed summary::-webkit-details-marker { display: none; }
.infodot {
  flex: none; width: 21px; height: 21px; border: 2px solid var(--navy);
  border-radius: var(--radius-round); display: flex; align-items: center;
  justify-content: center; font-style: italic; font-size: 13px; font-weight: 700;
}
.aboutbody { padding-top: 9px; }
.aboutmed .abouttext {
  font-size: var(--text-body); color: var(--navy); line-height: 1.5;
  white-space: pre-line;
}
.aboutmed .aboutnote,
.aboutmed .aboutsrc {
  font-size: var(--text-tab); color: var(--navy); opacity: .8; margin-top: 6px; line-height: 1.4;
}

/* Medication section: the medicine's row and its About disclosure share
   ONE card (`.medgroup` carries the background the inner .card/.cardrow
   drop), so each medicine reads as a clearly-bounded unit — the earlier
   sibling-card layout made adjacent medicines blend together. */
.medgroup {
  background: var(--surface); border-radius: var(--radius-card);
  margin-bottom: var(--gap-card); padding-bottom: 12px;
}
.medgroup .cardrow { margin-bottom: 0; }
.medgroup > .card, .medgroup .cardrow .card { background: none; margin-bottom: 0; }
.medgroup details.aboutmed {
  margin: 0 15px;
  border-top: 2px solid var(--bg); padding-top: 11px;
}

/* Proposal card: same disclosure; the opened body sits in a --bg panel so
   it doesn't vanish into the card's own --surface (the same contrast flip
   the blockquote and fieldform inputs above make). */
.proposalcard details.aboutmed { margin-top: 12px; }
.proposalcard .aboutbody {
  background: var(--bg); border-radius: var(--radius-card);
  padding: 10px 12px; margin-top: 9px;
}

/* the one-press bulk confirmation atop the review inbox */
.acceptallform { margin-bottom: 18px; }
.acceptallform .savebtn { margin-top: 0; }

/* ---- assistant: the composed answer (grounded, above its passages) ---- */
.answercard { background: var(--navy); }
.answercard .ct { color: var(--lavender); }
.answertext { color: var(--lavender); font-size: var(--text-body); line-height: 1.5; margin-top: 6px; }
.answerquote {
  margin: 10px 0 0; padding: 8px 12px; background: color-mix(in srgb, var(--lavender) 14%, transparent);
  border-left: 3px solid var(--lavender); color: var(--lavender);
  font-style: italic; font-size: var(--text-tab); line-height: 1.45; border-radius: 6px;
}
.answernote { color: var(--lavender); opacity: .75; font-size: var(--text-tab); margin-top: 10px; line-height: 1.4; }
.wardlink { color: var(--lavender); font-weight: 700; }

/* composer: growing textarea + voice */
.composer { padding-top: 10px; padding-bottom: 10px; }
/* The words show as typed — no uppercase transform — so the box matches
   the question that is sent and the bubble it becomes. Only the
   placeholder keeps the app's capitals. */
.composer textarea {
  flex: 1; min-width: 0; background: none; border: none; outline: none; padding: 0;
  font-family: var(--font); font-size: var(--text-body); color: var(--lavender);
  resize: none; line-height: 1.45; max-height: 120px;
}
.composer textarea::placeholder { color: var(--lavender); opacity: .7; text-transform: uppercase; font-size: var(--text-tab); }
#micbtn.recording { color: #FF8A8A; animation: micpulse 1.1s ease-in-out infinite; }
@keyframes micpulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { #micbtn.recording { animation: none; } }
.answerhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.speakbtn {
  flex: none; width: 26px; height: 26px; padding: 0; background: none; border: none;
  color: var(--lavender); cursor: pointer;
}
.speakbtn svg { display: block; width: 100%; height: 100%; }

.answersources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sourcechip {
  display: inline-block; background: color-mix(in srgb, var(--lavender) 16%, transparent);
  color: var(--lavender); border: 1.5px solid var(--lavender); border-radius: var(--radius-pill);
  padding: 5px 12px; font-size: var(--text-tab); font-weight: 700; text-decoration: none;
}
#micbtn.working svg { animation: micspin 1s linear infinite; }
@keyframes micspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #micbtn.working svg { animation: none; } }

.thinkingcard {
  display: flex; align-items: center; gap: 12px;
  font-size: var(--text-tab); font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0;
  /* Scoped override of --h-card (108px), which sizes the document list
     cards this shares a class with — a title and a snippet. One line of
     status text left the dots floating in an otherwise empty box. Only
     this card opts out; every other .card keeps the token. */
  min-height: auto;
}

.answerrow { display: flex; align-items: flex-start; gap: 10px; }
.answerrow .answertext { flex: 1; margin-top: 0; }

/* ---- assistant: the food check (services/food_check.py, _food_card.html) ----
   A --surface card rather than the navy answer card: its numbers are
   reference data, not the patient's own papers — the same subordinate
   treatment the FDA-label block on medication cards gets. The verdict
   reads from its words and its mark (✓ ! ✕ ?), never from colour alone:
   the palette has no green or red, by design (design/tokens.css). */
.foodcard { color: var(--navy); min-height: auto; }
.foodhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.verdictpill {
  display: inline-block; background: var(--navy); color: var(--lavender);
  border: 2px solid var(--navy); border-radius: var(--radius-pill);
  padding: 4px 12px; font-size: var(--text-tab); font-weight: 700;
}
/* Nothing was judged: an outline, not a filled verdict. */
.verdict-partly .verdictpill, .verdict-none .verdictpill, .verdict-suggest .verdictpill {
  background: none; color: var(--navy);
}
.foodcard .speakbtn { color: var(--navy); }
.foodheadline { font-size: var(--text-body); font-weight: 700; line-height: 1.45; margin-top: 10px; }
.foodfacts, .foodalt {
  background: var(--bg); border-radius: var(--radius-card); padding: 10px 12px; margin-top: 10px;
}
.foodname, .altname { font-size: var(--text-body); font-weight: 700; }
.foodline, .altline { font-size: var(--text-tab); line-height: 1.45; margin-top: 4px; }
.foodchecks { list-style: none; margin: 10px 0 0; padding: 0; }
.foodchecks li {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 8px;
  font-size: var(--text-tab); line-height: 1.45;
}
.checkmark {
  flex: none; width: 21px; height: 21px; border: 2px solid var(--navy);
  border-radius: var(--radius-round); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
}
.check-no .checkmark, .check-caution .checkmark { background: var(--navy); color: var(--lavender); }
.foodsection { margin-top: 14px; border-top: 2px solid var(--bg); padding-top: 10px; }
.foodsectiontitle { font-size: var(--text-tab); font-weight: 700; }
.foodrule { margin-top: 8px; }
.foodrule q { display: block; font-size: var(--text-tab); font-style: italic; line-height: 1.45; }
.foodfrom, .altchip {
  display: inline-block; border: 1.5px solid var(--navy); border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; color: var(--navy); text-decoration: none;
}
.foodfrom { margin-top: 5px; padding: 3px 10px; }
.foodwhy { font-size: var(--text-tab); line-height: 1.45; margin-top: 6px; }
/* the words a diet rule was read from, behind an ⓘ (_food_card.html) */
details.snips > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
details.snips > summary::-webkit-details-marker { display: none; }
details.snips > summary:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.snipline { margin-top: 6px; font-size: 12px; font-weight: 700; }
details.snips > q { display: block; margin-top: 6px; font-size: var(--text-tab); font-style: italic; line-height: 1.45; }
.altmeta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
/* A food the patient has in their Follow-up Notes (services/taste.py): an
   asterisk on its name and a line saying why, never colour alone. */
.notedmark { margin-left: 3px; color: var(--purple-bright); }
.notedline { font-size: var(--text-tab); font-weight: 700; line-height: 1.45; margin-top: 5px; }
.altchip { padding: 2px 9px; }
.altrecipe { margin-top: 6px; font-size: var(--text-tab); }
.altrecipe summary { cursor: pointer; font-weight: 700; }
.altrecipe p { margin: 5px 0 0; line-height: 1.45; }
.foodnote, .foodsrc { font-size: var(--text-tab); line-height: 1.4; margin-top: 12px; opacity: .8; }
.foodsrc { margin-top: 4px; }
.foodsrc a { color: var(--navy); font-weight: 700; }

/* ---- the Follow-up Notes question (routes/followup.py, _followup_prompt.html),
   under a journal entry or an answer. It sits on a --surface card, so its
   input and its NO button flip to --bg, as the proposal card's fields do. */
.followprompt { min-height: auto; color: var(--navy); }
.followlead { font-size: var(--text-body); line-height: 1.45; }
.followquote { display: block; margin-top: 8px; font-size: var(--text-tab); font-style: italic; line-height: 1.45; }
.followq {
  margin: 14px 0 12px; font-size: var(--text-body); font-weight: 700;
  color: var(--purple-bright); line-height: 1.35;
}
.followprompt .formfield { margin-bottom: 12px; }
.followprompt .formfield input, .followprompt .introbtn.alt { background: var(--bg); }
.followadded {
  min-height: auto; font-size: var(--text-tab); font-weight: 700;
  color: var(--navy); text-transform: uppercase;
}

/* recording controls show a STOP square while recording — same convention
   on the recordings screen (data-state) and the assistant mic (.recording) */
.micbig .icon-stop, #micbtn .icon-stop { display: none; }
.micbig[data-state="recording"] .icon-stop { display: block; }
.micbig[data-state="recording"] .icon-mic { display: none; }
#micbtn.recording .icon-stop { display: block; }
#micbtn.recording .icon-mic { display: none; }

/* ============================================================
   INTRO — the welcome/onboarding flow (routes/intro.py, three screens).
   No header band: the sketches are bare paper, so these screens carry
   only a back chevron and let the page background run edge to edge.
   Everything else is the app's existing vocabulary — purple display type,
   --surface option rows, and the navy/lavender contrast flip for
   "selected" that .seg a.on and .arow.overdue already use.
   ============================================================ */

/* `.body` is a flex item with a definite height, so the screen's column
   can stretch to it and pin the button to the bottom on a tall phone
   without scrolling on a short one. */
.body:has(> .intro) { display: flex; }
.intro {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 0 var(--screen-pad) 24px;
  /* The intro's smaller words, a step or two above the app's body and tab
     sizes: the gap between them and the purple display type was wide
     enough that the explanation read as small print under a headline. */
  --intro-small: 21px;
  --intro-hint: 18px;
}
.introtop { display: flex; align-items: center; padding-top: 10px; }

/* the welcome/basics screens: one centred block of display type */
.intromid {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  text-align: center; padding: 10px 0 30px;
}
.introtitle {
  /* A little under --text-title, so the words under it are not dwarfed;
     below the 440px design width it tracks the screen so a long line
     ("LET'S GET STARTED WITH THE BASICS") still breaks where the sketch
     breaks it rather than overflowing. */
  font-size: min(34px, 8.5vw);
  font-weight: 700; color: var(--purple);
  text-transform: uppercase; line-height: 1.08;
}
/* "pH²" is a name, not a word: the title's uppercase transform would
   make it PH2, so the name opts out and keeps the home header's
   superscript treatment (.title.appname). */
.introtitle .appname { text-transform: none; font-size: 1.35em; }
.introtitle .appname sup { font-size: .5em; vertical-align: super; }
.introsub {
  margin-top: 18px; font-size: var(--intro-small); color: var(--navy); line-height: 1.45;
}
/* the disclaimers that used to be the front page are one tap from it */
.introabout {
  margin-left: auto; font-size: var(--text-body); text-transform: uppercase;
  color: var(--navy); opacity: .7; text-decoration: none;
}
/* "About pH²": the name keeps its case, as in the title */
.introabout .appname { text-transform: none; }
.introabout .appname sup { font-size: .6em; vertical-align: super; }

/* the footer: progress dots + the one forward action */
.introfoot { flex: none; margin-top: auto; padding-top: 24px; }
.steps { display: flex; justify-content: center; gap: 10px; list-style: none; padding: 0; margin: 0 0 16px; }
.steps li {
  width: 9px; height: 9px; border-radius: var(--radius-round);
  background: color-mix(in srgb, var(--navy) 25%, transparent);
}
.steps li.on { background: var(--purple); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.introbtn {
  display: block; width: 100%; background: var(--purple); color: var(--lavender);
  border: none; border-radius: var(--radius-card); padding: 16px;
  font-family: var(--font); font-size: var(--text-card); font-weight: 700; text-transform: uppercase;
  text-align: center; text-decoration: none; cursor: pointer;
}
.introskip {
  display: block; text-align: center; margin-top: 14px;
  font-size: var(--text-body); text-transform: uppercase;
  color: var(--navy); opacity: .75; text-decoration: none;
}

/* ---- intro: the multi-select question ---- */
.intro-form { flex: 1; display: flex; flex-direction: column; }
.introask { text-align: center; padding: 14px 0 20px; }
.introq {
  font-size: var(--text-heading); font-weight: 700; color: var(--purple);
  text-transform: uppercase; line-height: 1.15;
}
.introhint {
  margin-top: 8px; font-size: var(--intro-hint, var(--text-tab)); color: var(--navy);
  opacity: .8; text-transform: uppercase;
}

.picks { display: flex; flex-direction: column; gap: var(--gap-card); }
.pickgroup { display: flex; flex-direction: column; }
.pick {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-card);
  min-height: 54px; padding: 12px 15px; cursor: pointer;
}
/* the real checkbox stays in the page (so the form posts and the keyboard
   reaches it) but out of sight — same trick as .uploadbox's file input */
.pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pick .pl {
  flex: 1; font-size: var(--text-card); font-weight: 700;
  color: var(--purple-bright); text-transform: uppercase;
}
.pick .tick { flex: none; width: 22px; height: 22px; color: var(--lavender); opacity: 0; }
/* selected = the navy/lavender flip, not a tick alone: it survives being
   glanced at across a room, on a low-brightness phone, and in greyscale */
.pick:has(input:checked) { background: var(--navy); }
.pick:has(input:checked) .pl { color: var(--lavender); }
.pick:has(input:checked) .tick { opacity: 1; }
.pick:has(input:focus-visible) { outline: 3px solid var(--purple); outline-offset: 2px; }

.picksubs summary {
  list-style: none; cursor: pointer; display: flex; align-items: center;
  padding: 8px 15px 0 18px;
  font-size: var(--text-tab); font-weight: 700; color: var(--navy);
  opacity: .7; text-transform: uppercase;
}
.picksubs summary::-webkit-details-marker { display: none; }
/* a chevron drawn from borders rather than an inline SVG — it is the same
   glyph in every group and has to flip on open, which CSS can do and a
   template-repeated <svg> cannot */
.picksubs summary::after {
  content: ""; flex: none; width: 7px; height: 7px; margin: -3px 0 0 8px;
  border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor;
  transform: rotate(45deg);
}
.picksubs[open] summary::after { margin-top: 2px; transform: rotate(-135deg); }
.subpicks { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 0 18px; }
.pick.sub { min-height: 46px; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.pick.sub .pl { font-size: var(--text-body); font-weight: 400; color: var(--navy); }
.pick.sub:has(input:checked) .pl { color: var(--lavender); }
.pick.sub .tick { width: 19px; height: 19px; }

/* ---- intro: the time question (a native <select>, so the phone gives
   its own wheel rather than a bespoke picker that has to be learned) ---- */
/* one question and one control, centred like the welcome screens rather
   than stranded at the top of an empty screen */
.introcenter { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: 24px; }
.timepick { position: relative; display: block; margin-top: 4px; }
.timepick select {
  appearance: none; -webkit-appearance: none;
  display: block; width: 100%;
  background: var(--surface); border: none; border-radius: var(--radius-card);
  min-height: 64px; padding: 14px 52px 14px 18px;
  font-family: var(--font); font-size: var(--text-card); font-weight: 700;
  color: var(--purple-bright); text-transform: uppercase;
  outline: none; cursor: pointer;
}
.timepick select:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.timepick .caret {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: var(--navy); pointer-events: none;
}

/* the custom row and the long list it reveals — one flex column so the
   revealed <select> picks up the same gap as the buttons above it */
.customslot { display: flex; flex-direction: column; gap: var(--gap-card); }
.customslot .timepick { display: none; margin-top: 0; }
.customslot:has(input:checked) .timepick { display: block; }

/* ---- intro: the water question — the ask, the why under it, and its
   two answers side by side as the screen's buttons ---- */
.introlead {
  margin-top: 16px; font-size: var(--intro-small); color: var(--navy); line-height: 1.45;
}
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-card); }

/* ---- intro: the taste note — a panel of plain words, nothing to pick ---- */
.intropanel {
  background: var(--surface); border-radius: var(--radius-card); padding: 22px 20px;
  font-size: var(--intro-small); color: var(--navy); line-height: 1.5;
}
.introbtn.alt { background: var(--surface); color: var(--navy); }
.introbtn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

/* ---- intro: the water setup — two labelled native <select>s ---- */
.introhint.plain { text-transform: none; line-height: 1.4; }
.waterpicks { display: flex; flex-direction: column; gap: 18px; }
.waterfield { display: block; }
.waterfield .flabel {
  display: block; margin-bottom: 8px;
  font-size: var(--intro-hint); color: var(--navy); text-transform: uppercase;
}
.waterfield .timepick { margin-top: 0; }
.waterlimit {
  margin-top: 12px; padding: 12px 14px; text-align: left;
  background: var(--navy); color: var(--lavender); border-radius: var(--radius-card);
  font-size: var(--intro-hint); line-height: 1.45;
}

/* ---- intro: the recap (the profile screen's field rows, made tappable
   so each one leads back to the question that filled it) ---- */
.recap { display: flex; flex-direction: column; gap: var(--gap-card); }
.recaprow { text-decoration: none; cursor: pointer; }
.recaprow .fv { margin-left: auto; }
.recaprow .fv.unset { opacity: .55; text-transform: uppercase; font-size: var(--text-body); }
.recaprow .pencil { margin-left: 10px; }
.introfoot form { margin: 0; }

/* ---- intro: the cuisine dropdown (a <details>, see intro_cuisine.html
   for why it is not a <select multiple>) ---- */
.dropdown { display: block; }
.dropdown summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--radius-card);
  min-height: 64px; padding: 14px 18px;
}
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown .dvalue {
  flex: 1; font-size: var(--text-card); font-weight: 700;
  color: var(--purple-bright); text-transform: uppercase; line-height: 1.25;
}
.dropdown .dvalue.empty { opacity: .7; }
.dropdown .caret { flex: none; width: 22px; height: 22px; color: var(--navy); }
.dropdown[open] .caret { transform: rotate(180deg); }
.dpanel { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* ---- sleep: the daily check-in's free-text box ---- */
.concerns { display: block; margin-top: 18px; }
.concerns .clabel {
  display: block; margin-bottom: 8px;
  font-size: var(--text-tab); color: var(--navy); text-transform: uppercase;
}
.concerns textarea {
  display: block; width: 100%; box-sizing: border-box;
  background: var(--surface); border: none; border-radius: var(--radius-card);
  padding: 14px 16px; outline: none; resize: vertical;
  font-family: var(--font); font-size: var(--text-body); color: var(--navy); line-height: 1.5;
}
.concerns textarea::placeholder { color: var(--navy); opacity: .55; }
.introhint.sitting { margin-bottom: 14px; text-transform: none; }

/* ---- sleep: the section's cards ---- */
.card .cs.concernline { margin-top: 8px; line-height: 1.5; white-space: pre-wrap; }

/* ---- demo mode: the refused-upload screen's list of accepted files ---- */
.demolist {
  margin: 6px 0 18px; padding-left: 20px;
  font-size: var(--text-body); color: var(--navy); line-height: 1.7;
}

/* ---- post-upload progress screen ---- */
.progressbar {
  height: 10px; margin: 24px 0 8px; overflow: hidden;
  border-radius: var(--radius-round);
  background: color-mix(in srgb, var(--navy) 14%, transparent);
}
.progressfill {
  height: 100%; width: 0; border-radius: var(--radius-round);
  background: var(--purple-bright);
  animation: progressfill 10s cubic-bezier(.25, .9, .3, 1) forwards;
}
/* Stops at nine tenths and holds there. The last tenth belongs to work that
   may genuinely still be running, and a bar sitting full while the screen is
   still waiting would be the one dishonest thing on it. */
@keyframes progressfill { from { width: 0; } to { width: 90%; } }
