/* Munshi10 Mobile — design system for the static mock.
   ===================================================================
   Conformance targets (see claude-notes/munshi10-mobile-app.md §3.4):
     · Apple HIG      — 17pt body, 15pt secondary, 13pt footnote,
                        11pt tab labels (floor), 44pt minimum touch target,
                        3–5 tabs, ~25pt tab icons, system font, Dynamic Type.
     · Material 3     — 48dp touch target, tonal surface-container ladder,
                        named colour roles, 16sp body floor, shape scale.
     · WCAG 2.2 AA    — 4.5:1 body text, 3:1 UI-component boundaries,
                        visible focus, respects reduced-motion & more-contrast.
   Every colour pair below was measured, not eyeballed; the numbers are in
   the comments and reproduced on design.html.

   Type is in rem so the OS/browser text-size setting scales the whole UI —
   the web equivalent of Dynamic Type. Never set a px font-size.
   =================================================================== */

/* ---------- type scale (Apple's ladder, rem-based) ---------- */
:root {
  --t-display:     2.75rem;   /* 44 — hero figure only */
  --t-large-title: 2.125rem;  /* 34 */
  --t-title2:      1.375rem;  /* 22 */
  --t-title3:      1.25rem;   /* 20 */
  --t-headline:    1.0625rem; /* 17 semibold — row titles, buttons */
  --t-body:        1.0625rem; /* 17 */
  --t-callout:     1rem;      /* 16 — Material body-large floor */
  --t-subhead:     0.9375rem; /* 15 — secondary line */
  --t-footnote:    0.8125rem; /* 13 — captions, section headers */
  --t-caption:     0.75rem;   /* 12 — badges */
  --t-caption2:    0.6875rem; /* 11 — tab labels ONLY; nothing smaller */

  --w-regular: 400;
  --w-medium:  500;
  --w-semi:    600;
  --w-bold:    700;

  /* shape scale (Material 3 corner tokens) */
  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 28px;

  /* minimum hit area: Apple 44pt / Material 48dp — take the larger */
  --tap: 48px;

  --bar-h:  56px;
  --tabs-h: 64px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- colour roles: light ---------- */
:root {
  color-scheme: light;

  --brand:        #1a6ae3;  /* 4.98:1 on white — passes AA as text + as fill */
  --brand-strong: #1a5fc9;
  --brand-soft:   #e8f0fc;
  --on-brand-soft:#1a5fc9;  /* 5.19:1 on brand-soft */
  --brand-ink:    #ffffff;  /* 4.98:1 on brand */

  /* Material-3-style surface ladder */
  --plane:        #f4f5f7;
  --surface:      #ffffff;
  --surface-2:    #f7f8fa;
  --surface-3:    #eef0f4;

  --hairline:     rgba(17, 17, 26, 0.12);   /* decorative dividers */
  --hairline-2:   rgba(17, 17, 26, 0.07);
  --edge:         #8a909d;                   /* 3.20:1 — control boundaries */

  --ink:          #14151a;  /* 18.2:1 */
  --ink-2:        #4a4d57;  /*  8.4:1 */
  --ink-muted:    #666a75;  /*  5.4:1 surface · 5.1:1 surface-2 · 4.7:1 surface-3 */

  --good: #16a34a; --good-soft: #e7f7ed; --good-ink: #0f7a37;  /* 4.9:1 */
  /* aliases — first-generation token names still used in page markup */
  --critical: var(--crit); --warning: var(--warn); --serious: var(--warn);
  --warn: #f59e0b; --warn-soft: #fdf3e0; --warn-ink: #8a5a06;  /* 5.4:1 */
  --crit: #dc2626; --crit-soft: #fdeaea; --crit-ink: #b42318;  /* 5.7:1 */
  /* info = the brand blue family (blue is the info convention; one blue only) */
  --info: var(--brand); --info-soft: var(--brand-soft); --info-ink: var(--on-brand-soft);

  /* chart series — validated with the dataviz palette validator */
  --series-1: #1a6ae3;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid:     #e6e8ee;
  --baseline: #b9bec9;

  --hero-a: #1a6ae3; --hero-b: #174fae;   /* white on these: 5.0 / 7.6:1 — theme-invariant */
  --shadow:    0 1px 2px rgba(17,17,26,.05), 0 4px 14px rgba(17,17,26,.05);
  --shadow-sm: 0 1px 2px rgba(17,17,26,.08);
  --shadow-up: 0 -0.5px 0 var(--hairline);
}

/* ---------- colour roles: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --brand: #4f95ef; --brand-strong: #6aa6f3; --brand-soft: #182640; --brand-ink: #0d0e14;
    --on-brand-soft: #7fb2f5;  /* 6.9:1 on dark brand-soft */
    --plane: #0c0d11; --surface: #16181d; --surface-2: #1d2027; --surface-3: #242832;
    --hairline: rgba(255,255,255,0.14); --hairline-2: rgba(255,255,255,0.08);
    --edge: #646b7c;                                  /* 3.33:1 on surface */
    --ink: #f2f3f6; --ink-2: #b9bec9; --ink-muted: #949aa6;  /* 6.3:1 / 5.8:1 */
    --good: #22c55e; --good-soft: #13291b; --good-ink: #4ade80;
    --warn: #f59e0b; --warn-soft: #2b2110; --warn-ink: #fbbf24;
    --crit: #ef4444; --crit-soft: #2d1414; --crit-ink: #f87171;
    --series-1: #4f95ef; --series-2: #d95926; --series-3: #199e70;
    --grid: #262a33; --baseline: #454c5b;
    --shadow: 0 1px 2px rgba(0,0,0,.5); --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #4f95ef; --brand-strong: #6aa6f3; --brand-soft: #182640; --brand-ink: #0d0e14;
    --on-brand-soft: #7fb2f5;  /* 6.9:1 on dark brand-soft */
  --plane: #0c0d11; --surface: #16181d; --surface-2: #1d2027; --surface-3: #242832;
  --hairline: rgba(255,255,255,0.14); --hairline-2: rgba(255,255,255,0.08);
  --edge: #646b7c;
  --ink: #f2f3f6; --ink-2: #b9bec9; --ink-muted: #949aa6;
  --good: #22c55e; --good-soft: #13291b; --good-ink: #4ade80;
  --warn: #f59e0b; --warn-soft: #2b2110; --warn-ink: #fbbf24;
  --crit: #ef4444; --crit-soft: #2d1414; --crit-ink: #f87171;
  --series-1: #4f95ef; --series-2: #d95926; --series-3: #199e70;
  --grid: #262a33; --baseline: #454c5b;
  --shadow: 0 1px 2px rgba(0,0,0,.5); --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
}

/* users who ask for more contrast get firmer edges and darker secondary ink */
@media (prefers-contrast: more) {
  :root { --ink-muted: #55585f; --hairline: rgba(17,17,26,.30); --edge: #5f636d; }
  :root[data-theme="dark"], :root:where(:not([data-theme="light"])) {
    --ink-muted: #c3c8d2; --hairline: rgba(255,255,255,.34); --edge: #8b93a4;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* let OS text-size scale, don't cap it */
  background: var(--plane);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.47;                 /* Apple's ~1.4–1.5 for 17pt body */
  font-weight: var(--w-regular);
  letter-spacing: -0.011em;          /* SF Pro Text optical tracking at 17 */
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--plane);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
body.no-tabs { padding-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: var(--w-bold); letter-spacing: -0.021em; text-wrap: balance; }
p { text-wrap: pretty; }

/* visible focus for keyboard and switch-control users (WCAG 2.4.7/2.4.13) */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* desktop: phone-width column. Never set overflow on <body> — a non-visible
   value there propagates to the viewport and stops the page scrolling. */
@media (min-width: 720px) {
  body {
    max-width: 420px; margin: 0 auto; min-height: 100vh;
    border-left: 1px solid var(--hairline);
    border-right: 1px solid var(--hairline);
    box-shadow: 0 0 60px rgba(17,17,26,.10);
  }
  .appbar, .tabbar, .submitbar { max-width: 420px; margin-inline: auto; }
}

/* ---------- top app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 2px;
  padding-inline: 4px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--hairline);
}
.appbar__btn {
  flex: 0 0 auto;
  width: var(--tap); height: var(--tap);      /* 48px — clears 44pt and 48dp */
  display: grid; place-items: center;
  border: 0; background: none; cursor: pointer;
  color: var(--ink); border-radius: 50%;
}
.appbar__btn:active { background: var(--surface-3); }
.appbar__title {
  flex: 1 1 auto; min-width: 0; padding-inline: 4px;
  font-size: var(--t-headline); font-weight: var(--w-bold); letter-spacing: -0.021em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar__sub {
  display: block;
  font-size: var(--t-footnote); font-weight: var(--w-regular);
  color: var(--ink-muted); letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar__dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--crit); box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- bottom tab bar (Apple: 3–5 tabs, ~25pt icons, 11pt labels) ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  min-height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 0.5px solid var(--hairline);
  box-shadow: var(--shadow-up);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: var(--tap);
  font-size: var(--t-caption2); font-weight: var(--w-medium); letter-spacing: 0;
  color: var(--ink-muted); text-decoration: none;
}
.tabbar a .ic { line-height: 0; }
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: var(--w-semi); }

/* ---------- layout ---------- */
main { padding: 16px 16px 32px; }
.stack > * + * { margin-top: 14px; }
.section-label {
  margin: 26px 2px 10px;
  font-size: var(--t-footnote); font-weight: var(--w-semi); letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
}
main > .section-label:first-child { margin-top: 4px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card__hd { display: flex; align-items: center; gap: 10px; padding: 15px 16px 0; }
.card__hd h2 { font-size: var(--t-title3); flex: 1 1 auto; font-weight: var(--w-bold); }
.card__hd .more { font-size: var(--t-subhead); font-weight: var(--w-semi); flex: 0 0 auto; padding: 6px 0; }
.card__ic {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: var(--t-subhead);
  background: var(--brand-soft); color: var(--on-brand-soft);
}
.card__bd { padding: 15px 16px; }
.card__ft {
  padding: 12px 16px; background: var(--surface-2);
  border-top: 1px solid var(--hairline-2);
  font-size: var(--t-footnote); line-height: 1.4; color: var(--ink-2);
}

.grouphd {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-2);
  font-size: var(--t-footnote); font-weight: var(--w-semi); letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
}
.grouphd .count { margin-left: auto; letter-spacing: 0; }

/* ---------- hero ---------- */
.hero {
  border-radius: var(--r-xl);
  padding: 20px 20px 22px;
  background: linear-gradient(145deg, var(--hero-a) 0%, var(--hero-b) 100%);
  color: #fff;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--hero-b) 30%, transparent);
}
.hero__eyebrow { font-size: var(--t-footnote); opacity: .88; font-weight: var(--w-semi); letter-spacing: .04em; text-transform: uppercase; }
.hero__fig { font-size: var(--t-display); font-weight: var(--w-bold); letter-spacing: -0.035em; margin-top: 4px; line-height: 1.04; }
.hero__unit { font-size: var(--t-title2); font-weight: var(--w-semi); opacity: .85; margin-left: 4px; letter-spacing: -0.02em; }
.hero__meta { font-size: var(--t-subhead); opacity: .92; margin-top: 6px; }
.hero__split {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,.26); padding-top: 14px;
}
.hero__split div { text-align: center; }
.hero__split b { display: block; font-size: var(--t-title3); font-weight: var(--w-bold); letter-spacing: -0.02em; }
.hero__split span { font-size: var(--t-footnote); opacity: .88; }

.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,.28); overflow: hidden; margin-top: 15px; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: #fff; }
.meter-scale { display: flex; justify-content: space-between; font-size: var(--t-caption); opacity: .88; margin-top: 6px; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tiles--3 { grid-template-columns: repeat(3, 1fr); }
.tile {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.tile__k { font-size: var(--t-footnote); font-weight: var(--w-semi); letter-spacing: .03em; text-transform: uppercase; color: var(--ink-muted); }
.tile__v { font-size: 1.75rem; font-weight: var(--w-bold); letter-spacing: -0.03em; margin-top: 4px; line-height: 1.1; }
.tiles--3 .tile__v { font-size: var(--t-title2); }
.tile__d { font-size: var(--t-footnote); font-weight: var(--w-semi); margin-top: 3px; }

.stat {
  background: var(--surface);
  border: 2px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 13px 14px 14px;
}
.stat__top { display: flex; align-items: center; gap: 6px; }
.stat__k { flex: 1 1 auto; font-size: var(--t-footnote); font-weight: var(--w-semi); letter-spacing: .03em; text-transform: uppercase; color: var(--ink-muted); }
.stat__ic { flex: 0 0 auto; font-size: var(--t-callout); line-height: 1; }
.stat__v { font-size: 1.75rem; font-weight: var(--w-bold); letter-spacing: -0.03em; margin-top: 3px; line-height: 1.1; }
.stat__s { font-size: var(--t-footnote); color: var(--ink-muted); margin-top: 2px; }
.stat--info { border-color: var(--info); }  .stat--info .stat__ic { color: var(--info); }
.stat--good { border-color: var(--good); }  .stat--good .stat__ic { color: var(--good); }
.stat--warn { border-color: var(--warn); }  .stat--warn .stat__ic { color: var(--warn); }
.stat--crit { border-color: var(--crit); }  .stat--crit .stat__ic { color: var(--crit); }

.up { color: var(--good-ink); } .down { color: var(--crit-ink); } .flat { color: var(--ink-muted); }

/* ---------- list rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--hairline-2); }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap);
  padding: 13px 16px; color: inherit; text-decoration: none;
}
.row:active { background: var(--surface-2); }
.row__ic {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: var(--t-subhead); font-weight: var(--w-bold);
  background: var(--surface-3); color: var(--ink-2);
}
.row__main { flex: 1 1 auto; min-width: 0; }
.row__t { display: block; font-size: var(--t-headline); font-weight: var(--w-semi); letter-spacing: -0.015em; }
.row__s { display: block; font-size: var(--t-subhead); color: var(--ink-muted); margin-top: 2px; }
.row__v { flex: 0 0 auto; text-align: right; }
.row__v b { display: block; font-size: var(--t-headline); font-weight: var(--w-bold); font-variant-numeric: tabular-nums; letter-spacing: -0.015em; }
.row__v span { font-size: var(--t-footnote); font-weight: var(--w-semi); }
.row__chev { flex: 0 0 auto; color: var(--ink-muted); font-size: var(--t-title3); }

.row--doc { align-items: flex-start; }
.row__ref { font-size: var(--t-subhead); color: var(--brand); font-weight: var(--w-semi); }
.row__desc { display: block; font-size: var(--t-subhead); color: var(--ink-muted); margin-top: 4px; }
.row--doc .row__v { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 2px; }

/* ---------- data table ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-subhead); }
table.tbl th, table.tbl td { padding: 11px 16px; text-align: right; white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl thead th {
  font-size: var(--t-footnote); text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-muted); font-weight: var(--w-semi);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-2);
}
table.tbl td { border-bottom: 1px solid var(--hairline-2); font-variant-numeric: tabular-nums; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tr.total td { font-weight: var(--w-bold); background: var(--surface-2); }
table.tbl th.now, table.tbl td.now { background: var(--brand-soft); }
table.tbl th.now { color: var(--brand); }

/* ---------- chips & pills ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 44px;                 /* Apple's floor */
  padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--edge);                    /* 3:1 — it is a control */
  background: var(--surface);
  font-family: inherit; font-size: var(--t-subhead); font-weight: var(--w-semi);
  color: var(--ink-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: var(--t-caption); font-weight: var(--w-bold);
  border: 1px solid transparent;
  background: var(--surface-3); color: var(--ink-2);
}
.badge--good     { background: var(--good-soft); color: var(--good-ink); }
.badge--warning, .badge--serious { background: var(--warn-soft); color: var(--warn-ink); }
.badge--critical { background: var(--crit-soft); color: var(--crit-ink); }
.badge--info     { background: var(--info-soft); color: var(--info-ink); }
.badge--brand    { background: var(--brand-soft); color: var(--on-brand-soft); }

/* ---------- segmented control ---------- */
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-3);
  border-radius: var(--r);
}
.seg a, .seg button {
  flex: 1 1 0; min-height: 44px; text-align: center; padding: 10px 8px;
  border: 0; background: none; font-family: inherit;
  font-size: var(--t-subhead); font-weight: var(--w-semi); color: var(--ink-2);
  border-radius: var(--r-sm); text-decoration: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg a[aria-current="page"], .seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
}

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; }
.searchbar {
  flex: 1 1 auto; display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 10px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--edge);
}
.searchbar input { flex: 1 1 auto; min-width: 0; border: 0; background: none; font: inherit; color: var(--ink); outline: none; }
.iconbtn {
  flex: 0 0 auto; width: var(--tap); height: var(--tap); border-radius: var(--r);
  display: grid; place-items: center; border: 0; cursor: pointer;
  background: var(--surface-3); color: var(--ink-2);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 13px 18px;
  border-radius: var(--r); border: 1px solid transparent;
  font-family: inherit; font-size: var(--t-headline); font-weight: var(--w-semi);
  letter-spacing: -0.01em; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 2px 10px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn--primary:active { background: var(--brand-strong); }
.btn--ghost   { background: var(--surface); color: var(--ink); border-color: var(--edge); }
.btn--filter  { background: var(--surface-3); color: var(--ink-2); }
.btn--danger  { background: var(--surface); color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 55%, transparent); }
.btn--block   { display: flex; width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1 1 0; }

.submitbar {
  position: fixed; left: 0; right: 0; z-index: 45;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 12px 16px;
  background: var(--surface);
  border-top: 0.5px solid var(--hairline);
}
body.no-tabs .submitbar { bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.submitbar__note { font-size: var(--t-subhead); color: var(--ink-muted); margin: 0 0 10px; display: flex; justify-content: space-between; gap: 12px; }
.submitbar__note b { color: var(--ink); font-variant-numeric: tabular-nums; }
.has-submitbar main { padding-bottom: 140px; }

/* ---------- forms ---------- */
.formsec {
  margin: 26px 2px 10px;
  font-size: var(--t-footnote); font-weight: var(--w-semi); letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-muted);
}
.field { display: block; }
.field + .field { margin-top: 16px; }
.field > label { display: block; font-size: var(--t-subhead); font-weight: var(--w-semi); color: var(--ink-2); margin-bottom: 7px; }
.field .req { color: var(--crit-ink); }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; min-height: var(--tap); padding: 13px 14px;
  font-family: inherit; font-size: var(--t-body);   /* 17 — never below 16, or
                                                       iOS Safari zooms on focus */
  color: var(--ink);
  background: var(--surface); border: 1px solid var(--edge);
  border-radius: var(--r); appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  padding-right: 38px;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline-offset: -1px; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-muted); }
.field .hint { font-size: var(--t-footnote); color: var(--ink-muted); margin: 6px 0 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row > .field { min-width: 0; }
.field-row .field + .field { margin-top: 0; }
.field-row--3 { grid-template-columns: 1fr 1fr 1fr; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: var(--t-body); font-weight: var(--w-medium); }
.check input { width: 24px; height: 24px; accent-color: var(--brand); flex: 0 0 auto; }

.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 13px 16px; }
.switch__main { flex: 1 1 auto; }
.switch__t { font-size: var(--t-body); font-weight: var(--w-medium); }
.switch__s { font-size: var(--t-subhead); color: var(--ink-muted); }
.switch input { flex: 0 0 auto; width: 48px; height: 28px; accent-color: var(--brand); }

.dashed {
  border: 1.5px dashed var(--edge); border-radius: var(--r-lg);
  padding: 18px 16px; background: var(--surface-2);
  display: flex; align-items: center; gap: 12px;
  font-size: var(--t-subhead); color: var(--ink-2);
}
.dashed .fmt { margin-left: auto; font-size: var(--t-footnote); color: var(--ink-muted); white-space: nowrap; }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 13px 16px; border-radius: var(--r-lg);
  background: var(--crit-soft); color: var(--crit-ink);
  font-size: var(--t-subhead); font-weight: var(--w-semi);
}
.banner a { margin-left: auto; color: inherit; text-decoration: underline; font-weight: var(--w-bold); white-space: nowrap; }
.banner--warn { background: var(--warn-soft); color: var(--warn-ink); }
.banner--info { background: var(--brand-soft); color: var(--on-brand-soft); }

/* ---------- charts ---------- */
.chart { display: block; width: 100%; height: auto; }
.chart .grid     { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
/* px inside a viewBox is a user-space unit that scales with the chart,
   not a CSS pixel — this is the one correct place for px type. */
.chart .lbl      { fill: var(--ink-muted); font-size: 10px; font-family: var(--font); }
.chart .val      { fill: var(--ink); font-size: 10.5px; font-weight: 700; font-family: var(--font); }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .s3 { fill: var(--series-3); }
.chart .line   { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .line-f { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-dasharray: 4 3; stroke-linecap: round; }
.chart .dot    { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: var(--t-footnote); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li + li { margin-top: 14px; }
.hbar__top { display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-subhead); margin-bottom: 6px; }
.hbar__top b { font-weight: var(--w-bold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar__track { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.hbar__fill  { height: 100%; border-radius: 5px; background: var(--series-1); }

/* ---------- misc ---------- */
.meta { margin: 18px 2px 0; font-size: var(--t-footnote); color: var(--ink-muted); text-align: center; }
.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 14px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--hairline-2);
  font-size: var(--t-subhead); line-height: 1.45; color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.notice .ic { font-size: var(--t-callout); line-height: 1.3; color: var(--ink-muted); }
.notice--warn { border-left: 4px solid var(--warn); }
.notice--crit { border-left: 4px solid var(--crit); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--on-brand-soft);
  font-size: var(--t-subhead); font-weight: var(--w-bold);
}
.empty { text-align: center; padding: 40px 20px; color: var(--ink-muted); font-size: var(--t-subhead); }
.empty .ic { font-size: 2rem; display: block; margin-bottom: 12px; opacity: .5; }
.empty b { display: block; color: var(--ink); font-size: var(--t-title3); margin-bottom: 6px; }

.thread { padding: 15px 16px; }
.msg { padding: 13px 14px; border-radius: var(--r); background: var(--surface-2); font-size: var(--t-subhead); line-height: 1.45; }
.msg + .msg { margin-top: 12px; }
.msg--mine { background: var(--brand-soft); }
.msg__who { font-size: var(--t-footnote); font-weight: var(--w-bold); color: var(--ink-2); margin-bottom: 4px; }
.msg__when { font-size: var(--t-footnote); color: var(--ink-muted); margin-top: 7px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: var(--t-subhead); }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; text-align: right; font-weight: var(--w-semi); font-variant-numeric: tabular-nums; }
.kv--wide { grid-template-columns: 40% 1fr; }
.kv--wide dd { text-align: left; font-weight: var(--w-medium); }

.fab {
  position: fixed; right: 18px; z-index: 40;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px);
  width: 56px; height: 56px; border-radius: var(--r-lg);   /* M3 FAB shape */
  border: 0; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 45%, transparent);
}
@media (min-width: 720px) { .fab { right: calc(50vw - 210px + 18px); } }

/* ---------- progressive disclosure ---------- */
details.disclose {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
details.disclose > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 14px 16px;
  font-size: var(--t-headline); font-weight: var(--w-semi);
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary .sub { flex: 1 1 auto; font-size: var(--t-subhead); font-weight: var(--w-regular); color: var(--ink-muted); }
details.disclose > summary .chev { flex: 0 0 auto; color: var(--ink-muted); transition: transform .15s; }
details.disclose[open] > summary { border-bottom: 1px solid var(--hairline-2); }
details.disclose[open] > summary .chev { transform: rotate(90deg); }
details.disclose > .disclose__bd { padding: 15px 16px; }

/* ---------- design.html only ---------- */
.swatch { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.swatch__chip { width: 44px; height: 44px; border-radius: var(--r-sm); flex: 0 0 auto; border: 1px solid var(--hairline); }
.swatch__main { flex: 1 1 auto; min-width: 0; }
.swatch__name { font-size: var(--t-subhead); font-weight: var(--w-semi); }
.swatch__hex { font-size: var(--t-footnote); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.specimen { padding: 4px 16px 16px; }
.specimen > div { padding: 9px 0; border-bottom: 1px solid var(--hairline-2); }
.specimen > div:last-child { border-bottom: 0; }
.specimen .note { font-size: var(--t-footnote); color: var(--ink-muted); font-weight: var(--w-regular); text-transform: none; letter-spacing: 0; margin-top: 2px; }
