/* ==========================================================================
   winnie.css — Dear Winnie Staff Assistant design system
   Calm iPad-app feel drawn from the Dear Winnie lobby: warm white walls,
   oak, white fluted desk, navy/slate lettering, olive trees, white roses.
   No external fonts, no CDNs, no JavaScript required by any component.
   Class vocabulary: design/COMPONENTS.md · Showcase: design/components.html
   Contrast of every token pair: python3 design/tools/contrast.py
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* surfaces */
  --bg: #FBF8F3;            /* warm white wall */
  --bg-sidebar: #F6F1E9;
  --surface: #FFFFFF;       /* cards (the white desk) */
  --surface-raised: #FFFFFF;/* sheets, toasts */
  --fill: #F3EEE5;          /* inset areas inside cards */
  --track: #EBE4D8;         /* segmented control track */
  --seg-on: #FFFFFF;        /* selected segment */
  --hairline: rgba(31, 42, 68, 0.10);
  --border-ctl: #8B8F86;    /* text-field borders (3:1 on white) */

  /* text */
  --ink: #1F2A44;           /* navy */
  --ink-2: #4A5568;         /* slate */
  --ink-3: #5F6878;         /* quiet labels, still AA */

  /* brand */
  --olive: #6B7A4B;         /* primary action */
  --olive-hover: #5F6E41;
  --olive-press: #54623A;
  --on-olive: #FFFFFF;
  --olive-ink: #536135;     /* olive used as text / links */
  --olive-tint: #E5EBD8;
  --oak: #D9BC94;
  --oak-dark: #8A6A4A;
  --oak-tint: #F2E5D1;
  --rose: #F3E6E3;
  --rose-ink: #6A3A33;

  /* status (background / text pairs) */
  --pending-bg: #ECEEF2;  --pending-ink: #3D4860;
  --mary-bg: #FBEBC6;     --mary-ink: #734A00;   --mary-line: #E2B85A;
  --urgent-bg: #F7DEDA;   --urgent-ink: #8C2B22; --urgent-line: #C97C72;
  --approved-bg: #E5EBD8; --approved-ink: #3F4B27;
  --edited-bg: #E0E8F1;   --edited-ink: #2B4468;
  --rejected-bg: #EEE6E3; --rejected-ink: #6A443D;
  --sent-bg: #F2E5D1;     --sent-ink: #674A2C;
  --banner-bg: #F4E9D8;   --banner-ink: #5B4226;
  --danger: #A63A2E;      --on-danger: #FFFFFF;  --danger-tint: #F7DEDA;
  --toast-bg: #1F2A44;    --toast-ink: #FBF8F3;

  --focus: #536135;
  --scrim: rgba(31, 42, 68, 0.32);
  --shadow-card: 0 1px 2px rgba(74, 52, 24, 0.05), 0 8px 24px rgba(74, 52, 24, 0.06);
  --shadow-raised: 0 2px 6px rgba(31, 42, 68, 0.08), 0 24px 60px rgba(31, 42, 68, 0.18);
  --shadow-seg: 0 1px 2px rgba(31, 42, 68, 0.12), 0 2px 8px rgba(31, 42, 68, 0.06);

  /* type — iOS text styles */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --t-large: 2.125rem;   /* 34 large title */
  --t-title1: 1.75rem;   /* 28 */
  --t-title2: 1.375rem;  /* 22 */
  --t-title3: 1.25rem;   /* 20 */
  --t-body: 1.0625rem;   /* 17 */
  --t-callout: 1rem;     /* 16 */
  --t-sub: 0.9375rem;    /* 15 */
  --t-foot: 0.8125rem;   /* 13 */
  --t-cap: 0.75rem;      /* 12 */

  /* space (4-pt grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* shape */
  --r-card: 20px; --r-ctl: 14px; --r-field: 12px; --r-sheet: 26px; --r-pill: 999px;
  --tap: 44px;              /* minimum touch target */
  --ctl-h: 50px;            /* buttons and fields */
  --ease: 150ms ease;

  /* shell */
  --sidebar-w: 260px;
  --tabbar-h: 62px;
  --gutter: var(--s-4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171D;
    --bg-sidebar: #181B22;
    --surface: #1D2129;
    --surface-raised: #232833;
    --fill: #272C36;
    --track: #2A2F3A;
    --seg-on: #454D5E;
    --hairline: rgba(242, 237, 228, 0.12);
    --border-ctl: #7C8494;
    --ink: #F2EDE4;
    --ink-2: #BCC2CE;
    --ink-3: #9299A8;
    --olive: #A9B885;
    --olive-hover: #B7C592;
    --olive-press: #C3D0A1;
    --on-olive: #161B0C;
    --olive-ink: #B7C592;
    --olive-tint: #2B341F;
    --oak: #C9A57F;
    --oak-dark: #C9A57F;
    --oak-tint: #3A2E1F;
    --rose: #3A2826;
    --rose-ink: #F0CFC9;
    --pending-bg: #2C323E;  --pending-ink: #CDD3DF;
    --mary-bg: #40300F;     --mary-ink: #F3CE85;   --mary-line: #8A6A22;
    --urgent-bg: #48211D;   --urgent-ink: #F6B5AC; --urgent-line: #9B4F46;
    --approved-bg: #2B341F; --approved-ink: #C5D3A3;
    --edited-bg: #223247;   --edited-ink: #B4CBEA;
    --rejected-bg: #352B29; --rejected-ink: #DDBDB6;
    --sent-bg: #3A2E1F;     --sent-ink: #E3C9A4;
    --banner-bg: #33291B;   --banner-ink: #EBD6B4;
    --danger: #E08E82;      --on-danger: #2A0E0A;  --danger-tint: #48211D;
    --toast-bg: #F2EDE4;    --toast-ink: #1F2A44;
    --focus: #B7C592;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-card: 0 0 0 1px rgba(242, 237, 228, 0.06);
    --shadow-raised: 0 0 0 1px rgba(242, 237, 228, 0.10), 0 24px 60px rgba(0, 0, 0, 0.5);
    --shadow-seg: 0 0 0 1px rgba(242, 237, 228, 0.08), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body)/1.47 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
h1, h2, h3, h4 { font-size: inherit; font-weight: inherit; }  /* headings take their look from classes only */
fieldset { border: 0; min-width: 0; }
ul[class], ol[class] { list-style: none; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--olive-ink); text-underline-offset: 3px; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--olive-tint); color: var(--ink); }
[hidden] { display: none !important; }

/* 3. Type ------------------------------------------------------------------ */
.page-title { font-size: var(--t-large); line-height: 1.2; font-weight: 700; letter-spacing: -0.022em; text-wrap: balance; }
.page-lede { color: var(--ink-2); margin-top: var(--s-1); max-width: 56ch; }
.title-2 { font-size: var(--t-title2); line-height: 1.27; font-weight: 700; letter-spacing: -0.012em; }
.title-3 { font-size: var(--t-title3); line-height: 1.3; font-weight: 600; letter-spacing: -0.008em; }
.headline { font-size: var(--t-body); font-weight: 600; }
.subhead { font-size: var(--t-sub); color: var(--ink-2); }
.footnote { font-size: var(--t-foot); line-height: 1.4; color: var(--ink-3); }
.eyebrow { font-size: var(--t-foot); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }

/* 4. Icons — files in ../img/icons, tinted with currentColor through a mask - */
.icon {
  display: inline-block; flex: none; width: 24px; height: 24px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
          mask: var(--icon) center / contain no-repeat;
}
.icon--sm { width: 18px; height: 18px; }
.icon--lg { width: 32px; height: 32px; }
.icon--home { --icon: url("../img/icons/home.svg"); }
.icon--pencil { --icon: url("../img/icons/pencil.svg"); }
.icon--chat { --icon: url("../img/icons/chat.svg"); }
.icon--inbox { --icon: url("../img/icons/inbox.svg"); }
.icon--clock { --icon: url("../img/icons/clock.svg"); }
.icon--flask { --icon: url("../img/icons/flask.svg"); }
.icon--book { --icon: url("../img/icons/book.svg"); }
.icon--people { --icon: url("../img/icons/people.svg"); }
.icon--megaphone { --icon: url("../img/icons/megaphone.svg"); }
.icon--paw { --icon: url("../img/icons/paw.svg"); }
.icon--check { --icon: url("../img/icons/check.svg"); }
.icon--copy { --icon: url("../img/icons/copy.svg"); }
.icon--chevron { --icon: url("../img/icons/chevron-right.svg"); }
.icon--close { --icon: url("../img/icons/close.svg"); }
.icon--alert { --icon: url("../img/icons/alert.svg"); }
.icon--more { --icon: url("../img/icons/more.svg"); }

/* Round tinted holder for an icon (list rows, action cards, empty states) */
.bubble {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--olive-tint); color: var(--olive-ink);
}
.bubble--oak { background: var(--oak-tint); color: var(--sent-ink); }
.bubble--mary { background: var(--mary-bg); color: var(--mary-ink); }
.bubble--urgent { background: var(--urgent-bg); color: var(--urgent-ink); }
.bubble--slate { background: var(--pending-bg); color: var(--pending-ink); }
.bubble--lg { width: 72px; height: 72px; }

/* 5. Brand ----------------------------------------------------------------- */
/* logo.png is slate lettering on white: multiply drops the white onto any
   light surface; in dark mode it is inverted and screened onto the dark one. */
.brand-logo { display: block; height: 34px; width: auto; mix-blend-mode: multiply; }
.brand-logo--lg { height: 58px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 0 0 1px var(--hairline); }
@media (prefers-color-scheme: dark) {
  .brand-logo { filter: invert(1) hue-rotate(180deg) brightness(1.15); mix-blend-mode: screen; }
}
/* Fluted band — a nod to the white fluted front desk */
.flute {
  height: 14px;
  background: repeating-linear-gradient(90deg, transparent 0 7px, var(--hairline) 7px 8px);
  border-block: 1px solid var(--hairline);
}

/* 6. Shell: sidebar (iPad / desktop) · top bar + tab bar (phone) ----------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s-6)); }
.page { padding: var(--s-4) var(--gutter) var(--s-8); max-width: 1080px; margin-inline: auto; }
.page--narrow { max-width: 720px; }
.page > * + * { margin-top: var(--s-5); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-header__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.section { display: grid; gap: var(--s-3); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding-inline: var(--s-1); }
.section__link { font-size: var(--t-sub); font-weight: 600; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: calc(env(safe-area-inset-top, 0px) + var(--s-3)) var(--gutter) var(--s-2);
}
.topbar .brand-logo { height: 30px; }
.topbar .avatar { width: var(--tap); height: var(--tap); }

.sidebar { display: none; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--hairline);
}
.tabbar__item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 50px; padding: 4px 2px; border-radius: 12px;
  color: var(--ink-3); text-decoration: none;
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.005em; white-space: nowrap;
  transition: color var(--ease);
}
.tabbar__item[aria-current="page"], .tabbar__item.is-active { color: var(--olive-ink); }
.tabbar__badge, .nav__count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  display: inline-grid; place-items: center;
  background: var(--mary-bg); color: var(--mary-ink);
  font-size: var(--t-cap); font-weight: 700; font-variant-numeric: tabular-nums;
}
.tabbar__badge { position: absolute; top: 0; left: calc(50% + 9px); box-shadow: 0 0 0 2px var(--surface); }

.nav { display: grid; gap: 2px; }
.nav__label { margin: var(--s-5) var(--s-3) var(--s-1); }
.nav__item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 46px; padding: 0 var(--s-3); border-radius: 12px;
  color: var(--ink-2); font-size: var(--t-callout); font-weight: 500; text-decoration: none;
  transition: background-color var(--ease), color var(--ease);
}
.nav__item:hover { background: var(--hairline); color: var(--ink); }
.nav__item[aria-current="page"], .nav__item.is-active { background: var(--olive-tint); color: var(--olive-ink); font-weight: 600; }
.nav__item > span:not(.icon):not(.nav__count) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__count { margin-left: auto; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--oak-tint); color: var(--sent-ink);
  font-size: var(--t-sub); font-weight: 700; letter-spacing: 0.02em; text-decoration: none;
}
.user-chip { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.user-chip__name { font-size: var(--t-sub); font-weight: 600; line-height: 1.25; }
.user-chip__role { font-size: var(--t-foot); color: var(--ink-3); }

@media (min-width: 768px) {
  :root { --gutter: var(--s-8); }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--s-5);
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
    padding: var(--s-6) var(--s-3) var(--s-4);
    background: var(--bg-sidebar); border-right: 1px solid var(--hairline);
  }
  .sidebar__brand { padding: 0 var(--s-3); display: flex; align-items: center; min-height: var(--tap); }
  .sidebar__brand .brand-logo { width: 100%; max-width: 200px; height: auto; }
  .sidebar__foot { margin-top: auto; padding: var(--s-3); border-top: 1px solid var(--hairline); display: grid; gap: var(--s-2); }
  .topbar, .tabbar { display: none; }
  .main { padding-bottom: var(--s-8); }
  .page { padding-top: var(--s-8); }
  .page > * + * { margin-top: var(--s-6); }
  .only-phone { display: none !important; }
}
@media (max-width: 767.98px) { .only-wide { display: none !important; } }
@media (min-width: 768px) and (max-width: 1023.98px) { :root { --gutter: var(--s-6); } }

/* 7. TEST banner — always visible, never dismissible ----------------------- */
.banner-test {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px var(--gutter);
  background: var(--banner-bg); color: var(--banner-ink);
  border-bottom: 1px solid var(--hairline);
  font-size: var(--t-foot); line-height: 1.35; font-weight: 500; text-align: center; text-wrap: balance;
}
.banner-test strong { font-weight: 700; }
.banner-test__tag {
  flex: none; padding: 2px 8px; border-radius: 6px;
  background: var(--banner-ink); color: var(--banner-bg);
  font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.08em;
}

/* 8. Cards and grouped lists ---------------------------------------------- */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: var(--s-5); }
.card > * + * { margin-top: var(--s-4); }
.card--flush { padding: 0; overflow: hidden; }
.card--tint { background: var(--fill); box-shadow: none; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.card__foot { padding-top: var(--s-4); border-top: 1px solid var(--hairline); }

/* iOS grouped inset list */
.list { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
.list__item {
  position: relative; display: flex; align-items: center; gap: var(--s-3);
  min-height: 60px; padding: var(--s-3) var(--s-4);
  color: inherit; text-decoration: none; transition: background-color var(--ease);
}
.list__item + .list__item::before { content: ""; position: absolute; top: 0; right: 0; left: var(--s-4); border-top: 1px solid var(--hairline); }
.list__item--icon + .list__item--icon::before { left: calc(var(--s-4) + 44px + var(--s-3)); }
a.list__item:hover, button.list__item:hover { background: var(--fill); }
.list__body { flex: 1; min-width: 0; }
.list__title { font-weight: 600; line-height: 1.3; }
.list__sub { font-size: var(--t-sub); color: var(--ink-2); line-height: 1.35; margin-top: 2px; }
.list__trail { display: flex; align-items: center; gap: var(--s-2); flex: none; color: var(--ink-3); font-size: var(--t-sub); }
.list__chevron { color: var(--ink-3); opacity: 0.7; width: 18px; height: 18px; }
/* Phone: a trailing pill drops under the text instead of squeezing the title */
@media (max-width: 559.98px) {
  .list__item { flex-wrap: wrap; row-gap: var(--s-2); }
  .list__trail { flex-basis: 100%; }
  .list__item--icon .list__trail { padding-left: calc(44px + var(--s-3)); }
  .list__trail .list__chevron { display: none; }
}
.clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }

/* Big action card (Home: "Write an update" / "Answer a family") */
.actions { display: grid; gap: var(--s-3); }
/* two-up on wide phones and on desktop; stacked on portrait iPad, where the sidebar takes the room */
@media (min-width: 560px) and (max-width: 767.98px), (min-width: 1024px) { .actions { grid-template-columns: 1fr 1fr; } }
.action {
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 88px; padding: var(--s-5);
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease);
}
.action:hover { transform: translateY(-1px); box-shadow: var(--shadow-card), 0 0 0 2px var(--olive-tint); }
.action:active { transform: scale(0.99); }
.action__body { flex: 1; min-width: 0; }
.action__title { font-size: var(--t-title3); font-weight: 600; letter-spacing: -0.008em; line-height: 1.25; }
.action__sub { font-size: var(--t-sub); color: var(--ink-2); margin-top: 2px; }
.action--primary { background: var(--olive); color: var(--on-olive); }
.action--primary .action__sub { color: inherit; opacity: 0.92; }
.action--primary .bubble { background: color-mix(in srgb, var(--on-olive) 18%, transparent); color: inherit; }
.action--primary .list__chevron { color: inherit; opacity: 0.9; }

/* 9. Stat tiles ------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat {
  display: flex; flex-direction: column; gap: var(--s-1);
  min-height: 124px; padding: var(--s-4) var(--s-4) var(--s-3);
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
}
.stat__label { font-size: var(--t-sub); font-weight: 600; color: var(--ink-2); line-height: 1.25; }
.stat__value { font-size: 2.5rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: auto; }
.stat__unit { font-size: var(--t-title3); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.stat__hint { font-size: var(--t-foot); color: var(--ink-3); line-height: 1.3; }
.stat--mary { background: var(--mary-bg); box-shadow: none; }
.stat--mary .stat__label, .stat--mary .stat__hint { color: var(--mary-ink); }
.stat--urgent { background: var(--urgent-bg); box-shadow: none; }
.stat--urgent .stat__label, .stat--urgent .stat__hint { color: var(--urgent-ink); }

/* 10. Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--ctl-h); padding: 0 var(--s-5);
  border: 1px solid transparent; border-radius: var(--r-ctl);
  background: transparent; color: var(--ink);
  font-size: var(--t-body); font-weight: 600; line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.btn:focus-visible { border-radius: var(--r-ctl); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--olive); color: var(--on-olive); }
.btn--primary:hover { background: var(--olive-hover); }
.btn--primary:active { background: var(--olive-press); }
.btn--secondary { background: var(--surface); border-color: var(--border-ctl); }
.btn--secondary:hover { background: var(--fill); }
.btn--quiet { color: var(--olive-ink); padding-inline: var(--s-3); }
.btn--quiet:hover { background: var(--olive-tint); }
.btn--danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-tint); }
.btn--danger-solid { background: var(--danger); color: var(--on-danger); }
.btn--lg { min-height: 56px; font-size: 1.125rem; border-radius: 16px; }
.btn--sm { min-height: var(--tap); padding: 0 var(--s-4); font-size: var(--t-sub); border-radius: 12px; }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--tap); min-height: var(--tap); padding: 0; border-radius: 50%; color: var(--ink-2); }
.btn--icon:hover { background: var(--fill); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.btn-row--end { justify-content: flex-end; }
@media (max-width: 559.98px) {
  .btn-row--stack { flex-direction: column; align-items: stretch; }
  .btn-row--stack .btn { width: 100%; }
  .btn-row--stack.btn-row--end { flex-direction: column-reverse; }  /* primary (last in the DOM) lands on top */
  .btn-row--stack > .grow { display: none; }
}

/* 11. Segmented control — radios + labels, no JavaScript ------------------- */
/* <fieldset class="seg"> <input class="seg__input" type="radio" id> <label class="seg__option" for> … */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
  padding: 3px; border-radius: 13px; background: var(--track);
}
.seg__input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg__option {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 4px var(--s-3); border-radius: 10px;
  color: var(--ink-2); font-size: var(--t-sub); font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.seg__option:hover { color: var(--ink); }
.seg__input:checked + .seg__option, .seg__option[aria-current], .seg__option.is-active {
  background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-seg);
}
.seg__input:focus-visible + .seg__option { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg__input:disabled + .seg__option { opacity: 0.45; cursor: not-allowed; }
.seg--inline { display: inline-grid; }
.seg--scroll { grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; }
.seg--scroll::-webkit-scrollbar { display: none; }
.seg--scroll .seg__option { padding-inline: var(--s-4); }
.seg__count { font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* 12. Form fields ---------------------------------------------------------- */
.form { display: grid; gap: var(--s-5); }
.field { display: grid; gap: var(--s-2); }
.field__label, .field > legend { font-size: var(--t-sub); font-weight: 600; color: var(--ink); padding: 0; }
.field > legend { margin-bottom: var(--s-2); }
.field__optional { font-weight: 400; color: var(--ink-3); }
.field__hint { font-size: var(--t-foot); color: var(--ink-3); line-height: 1.4; }
.field__error { font-size: var(--t-foot); color: var(--danger); font-weight: 600; }
.input, .textarea, .select {
  display: block; width: 100%; min-height: var(--ctl-h); padding: 12px 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-ctl); border-radius: var(--r-field);
  font-size: var(--t-body); line-height: 1.4;    /* 17px: no zoom-on-focus in iOS */
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.textarea { min-height: 148px; resize: vertical; line-height: 1.5; }
.textarea--tall { min-height: 220px; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-2); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--olive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--olive) 30%, transparent);
}
.select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 15px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
}
.field--error .input, .field--error .textarea { border-color: var(--danger); }
.form-grid { display: grid; gap: var(--s-5); }
@media (min-width: 560px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }

/* Checkbox / confirm row */
.check { display: flex; align-items: flex-start; gap: var(--s-3); min-height: var(--tap); padding: 10px 0; cursor: pointer; font-weight: 500; }
.check__input {
  -webkit-appearance: none; appearance: none; flex: none; width: 26px; height: 26px; margin: 0;
  border: 1.5px solid var(--border-ctl); border-radius: 8px; background: var(--surface);
  display: grid; place-items: center; transition: background-color var(--ease), border-color var(--ease);
}
.check__input::after { content: ""; width: 16px; height: 16px; background: var(--on-olive); -webkit-mask: url("../img/icons/check.svg") center / contain no-repeat; mask: url("../img/icons/check.svg") center / contain no-repeat; opacity: 0; }
.check__input:checked { background: var(--olive); border-color: var(--olive); }
.check__input:checked::after { opacity: 1; }

/* 13. Status pills --------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 3px 11px; border-radius: var(--r-pill);
  background: var(--pending-bg); color: var(--pending-ink);
  font-size: var(--t-foot); font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.75; flex: none; }
.pill--plain::before { display: none; }
.pill--pending { background: var(--pending-bg); color: var(--pending-ink); }
.pill--pending::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.pill--mary, .pill--ask { background: var(--mary-bg); color: var(--mary-ink); }
.pill--urgent { background: var(--urgent-bg); color: var(--urgent-ink); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; font-size: var(--t-cap); }
.pill--approved, .pill--confirmed { background: var(--approved-bg); color: var(--approved-ink); }
.pill--edited { background: var(--edited-bg); color: var(--edited-ink); }
.pill--rejected { background: var(--rejected-bg); color: var(--rejected-ink); }
.pill--rejected::before { border-radius: 1px; height: 2px; width: 9px; }
.pill--sent { background: var(--sent-bg); color: var(--sent-ink); }
.pill--test { background: transparent; color: var(--banner-ink); box-shadow: inset 0 0 0 1.5px var(--oak-dark); font-weight: 800; letter-spacing: 0.08em; font-size: 0.6875rem; min-height: 22px; padding: 1px 8px; }
.pill--test::before { display: none; }
.tag { font-size: var(--t-foot); font-weight: 600; color: var(--ink-3); }

/* 14. Notes (gentle alerts) ------------------------------------------------ */
.note { display: flex; gap: var(--s-3); padding: var(--s-4); border-radius: 16px; background: var(--fill); color: var(--ink); font-size: var(--t-callout); line-height: 1.45; }
.note > .icon { margin-top: 1px; color: var(--ink-2); }
.note__body { flex: 1; min-width: 0; }
.note__body > * + * { margin-top: var(--s-2); }
.note__title { font-weight: 700; }
.note--rose { background: var(--rose); }
.note--rose > .icon, .note--rose .note__title { color: var(--rose-ink); }
.note--mary { background: var(--mary-bg); }
.note--mary > .icon, .note--mary .note__title { color: var(--mary-ink); }
.note--urgent { background: var(--urgent-bg); }
.note--urgent > .icon, .note--urgent .note__title { color: var(--urgent-ink); }
.note--ok { background: var(--olive-tint); }
.note--ok > .icon, .note--ok .note__title { color: var(--approved-ink); }

/* 15. Results: draft · clarify · OWNER REVIEW REQUIRED --------------------- */
.result { display: grid; gap: var(--s-4); }
.result__head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.result__title { font-size: var(--t-title3); font-weight: 600; flex: 1; min-width: 12ch; }

/* The words a family would read. Always looks like a letter, never like UI. */
.draft { border-radius: 16px; background: var(--fill); border-left: 4px solid var(--oak); padding: var(--s-4) var(--s-5); }
.draft__label { font-size: var(--t-foot); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--s-2); }
.draft__body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.draft__body p + p { margin-top: 0.8em; }
.draft--edit { padding: 0; border-left: 0; background: transparent; }
.draft--edit .textarea { min-height: 240px; field-sizing: content; background: var(--fill); border-left: 4px solid var(--oak); line-height: 1.55; }

.clarify { display: grid; gap: var(--s-4); counter-reset: q; }
.clarify__item { display: grid; gap: var(--s-2); counter-increment: q; }
.clarify__q { display: flex; gap: var(--s-3); font-weight: 600; line-height: 1.35; }
.clarify__q::before {
  content: counter(q); flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--olive-tint); color: var(--olive-ink);
  font-size: var(--t-foot); font-weight: 700;
}

.review { border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--mary-line); overflow: hidden; }
.review__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); background: var(--mary-bg); color: var(--mary-ink); }
.review__title { font-size: var(--t-sub); font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; flex: 1; }
.review__body { padding: var(--s-5); display: grid; gap: var(--s-4); }
.review__note { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; line-height: 1.5; }
.review__head .pill { background: var(--surface); }
.review--urgent { box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--urgent-line); }
.review--urgent .review__head { background: var(--urgent-bg); color: var(--urgent-ink); }

.kv { display: grid; grid-template-columns: minmax(96px, max-content) 1fr; gap: var(--s-2) var(--s-4); font-size: var(--t-callout); }
.kv dt { color: var(--ink-3); font-size: var(--t-sub); }
.kv dd { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* 16. Loading — "Writing…" ------------------------------------------------- */
.writing { display: grid; gap: var(--s-4); }
.writing__head { display: flex; align-items: center; gap: var(--s-3); }
.writing__title { font-size: var(--t-title3); font-weight: 600; }
.writing__paw { animation: winnie-breathe 1.8s ease-in-out infinite; }
.skeleton { display: grid; gap: 12px; }
.skeleton__line {
  height: 14px; border-radius: 7px;
  background: linear-gradient(90deg, var(--track) 0%, var(--track) 35%, var(--fill) 50%, var(--track) 65%, var(--track) 100%);
  background-size: 300% 100%; animation: winnie-shimmer 1.8s linear infinite;
}
.skeleton__line:nth-child(3n + 2) { width: 92%; }
.skeleton__line:nth-child(3n) { width: 64%; }
@keyframes winnie-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes winnie-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* 17. Queue ("Waiting for Mary") ------------------------------------------ */
.queue { display: grid; gap: var(--s-3); }
@media (min-width: 1100px) { .queue--grid { grid-template-columns: 1fr 1fr; } }
.queue-item {
  display: grid; gap: var(--s-2); padding: var(--s-4) var(--s-5);
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease);
}
a.queue-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-card), 0 0 0 2px var(--olive-tint); }
.queue-item__top { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.queue-item__time { margin-left: auto; font-size: var(--t-foot); color: var(--ink-3); white-space: nowrap; }
.queue-item__title { font-weight: 600; font-size: 1.125rem; line-height: 1.3; letter-spacing: -0.005em; }
.queue-item__preview { color: var(--ink-2); font-size: var(--t-callout); line-height: 1.45; }
.queue-item__meta { font-size: var(--t-foot); color: var(--ink-3); }
.queue-item--urgent { box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--urgent-line); }
.queue-item--done { box-shadow: none; background: var(--fill); }

/* 18. Sheet — bottom sheet on phone, centred panel on iPad / desktop ------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.sheet {
  width: 100%; max-height: 94%; display: flex; flex-direction: column;
  background: var(--surface-raised); color: var(--ink);
  border: 0; padding: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-raised);
  animation: winnie-sheet-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet__grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--border-ctl); opacity: 0.5; margin: 8px auto 0; flex: none; }
.sheet__header { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--hairline); flex: none; }
.sheet__heading { flex: 1; min-width: 0; padding-top: 6px; display: grid; gap: var(--s-2); }
.sheet__title { font-size: var(--t-title2); font-weight: 700; letter-spacing: -0.012em; line-height: 1.25; }
.sheet__body { padding: var(--s-5); overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; gap: var(--s-5); align-content: start; }
.sheet__footer {
  flex: none; display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center;
  padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline); background: var(--surface-raised);
  border-radius: 0 0 var(--r-sheet) var(--r-sheet);
}
.sheet__footer .btn--primary { flex: 1 1 160px; }
.sheet__spacer { flex: 1; }
dialog.sheet { margin: auto auto 0; max-width: 100%; }
dialog.sheet::backdrop { background: var(--scrim); }
@media (min-width: 768px) {
  .sheet-backdrop { align-items: center; padding: var(--s-6); }
  .sheet { max-width: 680px; max-height: min(92%, 860px); border-radius: var(--r-sheet); }
  dialog.sheet { margin: auto; }
  .sheet__grabber { display: none; }
  .sheet__header { padding-top: var(--s-4); }
}
@keyframes winnie-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 19. Facts ---------------------------------------------------------------- */
.fact { display: grid; gap: var(--s-2); padding: var(--s-4); position: relative; }
.fact + .fact::before { content: ""; position: absolute; top: 0; right: 0; left: var(--s-4); border-top: 1px solid var(--hairline); }
.fact__top { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.fact__name { font-weight: 600; flex: 1; min-width: 14ch; line-height: 1.3; }
.fact__value { font-size: var(--t-body); line-height: 1.45; }
.fact__source { font-size: var(--t-foot); color: var(--ink-3); }
.fact__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding-top: var(--s-1); }
.fact--ask { background: color-mix(in srgb, var(--mary-bg) 45%, var(--surface)); }
.fact--ask .fact__value { font-weight: 500; }

/* 20. Test lab compare: actual vs ideal ------------------------------------ */
.compare { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
.compare__head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-4) var(--s-5); }
.compare__num { flex: none; min-width: 44px; height: 32px; padding: 0 10px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--fill); color: var(--ink-2); font-size: var(--t-sub); font-weight: 700; font-variant-numeric: tabular-nums; }
.compare__title { flex: 1; min-width: 14ch; font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.compare__prompt { padding: 0 var(--s-5) var(--s-4); color: var(--ink-2); font-size: var(--t-callout); }
.compare__cols { display: grid; border-top: 1px solid var(--hairline); }
.compare__col { padding: var(--s-4) var(--s-5); min-width: 0; display: grid; gap: var(--s-2); align-content: start; }
.compare__col + .compare__col { border-top: 1px solid var(--hairline); }
.compare__col--ideal { background: var(--fill); }
.compare__label { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-foot); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.compare__text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-callout); line-height: 1.5; }
.compare__foot { display: grid; gap: var(--s-4); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--hairline); }
@media (min-width: 768px) {
  .compare__cols { grid-template-columns: 1fr 1fr; }
  .compare__col + .compare__col { border-top: 0; border-left: 1px solid var(--hairline); }
  .compare__foot { grid-template-columns: 1fr minmax(260px, 0.8fr); align-items: start; }
}
.checks { display: grid; gap: 6px; font-size: var(--t-sub); }
.checks__item { display: flex; gap: var(--s-2); align-items: flex-start; line-height: 1.4; }
.checks__item .icon { width: 18px; height: 18px; margin-top: 1px; }
.checks__item--pass .icon { color: var(--olive-ink); }
.checks__item--fail { color: var(--danger); font-weight: 600; }

/* 21. Toast · empty state -------------------------------------------------- */
.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s-4));
  display: inline-flex; align-items: center; gap: var(--s-2);
  max-width: calc(100% - 2 * var(--s-4)); min-height: var(--tap); padding: 10px var(--s-5);
  background: var(--toast-bg); color: var(--toast-ink);
  border-radius: var(--r-pill); box-shadow: var(--shadow-raised);
  font-size: var(--t-sub); font-weight: 600;
  animation: winnie-toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 768px) { .toast { bottom: var(--s-8); } }
@keyframes winnie-toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty { display: grid; justify-items: center; gap: var(--s-3); text-align: center; padding: var(--s-12) var(--s-5); }
.empty__title { font-size: var(--t-title3); font-weight: 600; }
.empty__text { color: var(--ink-2); max-width: 36ch; }

/* 22. Login ---------------------------------------------------------------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.login__panel { width: 100%; max-width: 420px; display: grid; gap: var(--s-6); }
.login__brand { display: grid; justify-items: center; gap: var(--s-3); text-align: center; }
.login__card { background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-card); overflow: hidden; }
.login__form { padding: var(--s-6); display: grid; gap: var(--s-5); }
.login__foot { text-align: center; }

/* 23. Utilities ------------------------------------------------------------ */
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: grid; gap: var(--s-4); align-content: start; }
.stack--sm { gap: var(--s-2); }
.stack--lg { gap: var(--s-6); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* 23b. App integration additions (Claude, integration pass) ---------------- */
/* Small pieces the server-rendered app needs that the showcase did not cover. */
.preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }
/* A form wrapping a single button should lay out as if the button were a direct child. */
.btn-row > form, .sheet__footer > form, .page-header__actions > form, .fact__actions > form { display: contents; }
/* <details> used for "Reject this…" and fact "Edit": the summary looks like a quiet button. */
.disclosure > summary { list-style: none; width: fit-content; cursor: pointer; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure[open] > summary { margin-bottom: var(--s-3); }
.fact__actions .disclosure { flex-basis: 100%; }
.fact__actions .disclosure:not([open]) { flex-basis: auto; }
.note__body ul { padding-left: 1.2em; list-style: disc; }
/* Keep the page behind a detail sheet still. */
body:has(.sheet-backdrop) { overflow: hidden; }
.page-header .eyebrow a { color: inherit; text-decoration: none; }
.page-header .eyebrow a:hover { text-decoration: underline; }
.topbar > a { display: inline-flex; }
.sheet:focus { outline: none; }  /* focus is moved to the sheet itself on open */
.writing__slow { margin-top: var(--s-2); }

/* 24. Motion and contrast preferences -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .skeleton__line { background: var(--track); }
}
@media (prefers-contrast: more) {
  :root { --hairline: var(--border-ctl); --ink-3: var(--ink-2); }
  .card, .list, .stat, .queue-item, .action, .compare { box-shadow: inset 0 0 0 1px var(--border-ctl); }
}
@media print {
  .sidebar, .tabbar, .topbar, .toast, .btn { display: none !important; }
  .shell { display: block; }
}
