/* Oak Forest Trust — oakforest-trust.com.
   Phone first: every control is at least 44px and nothing depends on hover. Wider screens
   get more room, not a different layout.

   History: this stylesheet started life as the 32 Mechanic Street punch list, so the
   checklist rules (.row / .check / .grip / .addbar) are still here. The home page no
   longer uses them; they are kept because the task API and its pages are unchanged. */

/* ---------------------------------------------------------------------------
   Themes.  Each is one block of the SAME token names, swapped by a data-theme
   attribute on :root (the house pattern — see timesheets/devicecycle). The bare
   :root IS Oak Forest, so a page with no attribute still themes correctly, and a
   dark theme just dims the backdrop via --backdrop-wash rather than swapping it.
   Non-colour tokens (--radius, --tap) live outside theming.
   --------------------------------------------------------------------------- */
:root {
  --radius: 14px;
  --tap: 46px;

  /* Oak Forest — the default: a foresty light theme. Deep oak-green is the accent (the
     token is still named --red, but every theme sets it to its own accent), warm acorn-brown
     carries the "Remember" notes, and the surfaces are a soft forest-parchment. The green
     ties to the cream-on-green app icon, which the old barn-red accent used to clash with. */
  --ink:        #1e2a1e;   /* deep forest near-black */
  --ink-soft:   #566a51;   /* moss grey-green */
  --line:       #d0dbc6;   /* soft sage border */
  --card:       rgba(250, 253, 246, 0.93);
  --card-solid: #f7faf1;
  --red:        #2e6b47;   /* accent: oak-forest green */
  --red-dark:   #1f5236;   /* button hover; matches the app icon's green */
  --green:      #357a4c;   /* done / progress / success */
  --amber:      #8a5a2b;   /* acorn brown — the note callouts and warnings */
  --bg:         #e7eede;   /* soft forest parchment */
  --backdrop-wash: rgba(230, 238, 222, 0.34); /* a green-tinted film over the backdrop */
  color-scheme: light;
}
:root[data-theme="oakforest"] { color-scheme: light; }

/* Acorn — warm dark. */
:root[data-theme="acorn"] {
  --ink: #ece3d4; --ink-soft: #a99d89; --line: #3b352c;
  --card: rgba(38, 33, 27, 0.90); --card-solid: #2b251e;
  --red: #d0623a; --red-dark: #b04d29; --green: #74c495; --amber: #e0ab4d;
  --bg: #1a1712; --backdrop-wash: rgba(18, 14, 9, 0.62); color-scheme: dark;
}
/* Autumn — warm light, rust accent. */
:root[data-theme="autumn"] {
  --ink: #3a2417; --ink-soft: #7c5c46; --line: #e6d3bf;
  --card: rgba(255, 248, 238, 0.94); --card-solid: #fff7ec;
  --red: #b4471f; --red-dark: #963714; --green: #5a7d3a; --amber: #b3781a;
  --bg: #f2e4d2; --backdrop-wash: rgba(255, 238, 214, 0.42); color-scheme: light;
}
/* Birch — high-key, cool light. */
:root[data-theme="birch"] {
  --ink: #24262a; --ink-soft: #666b73; --line: #e3e5e8;
  --card: rgba(255, 255, 255, 0.95); --card-solid: #ffffff;
  --red: #9a3128; --red-dark: #7f271f; --green: #2f7a55; --amber: #8a6417;
  --bg: #eef0f2; --backdrop-wash: rgba(255, 255, 255, 0.52); color-scheme: light;
}
/* Slate — cool dark. */
:root[data-theme="slate"] {
  --ink: #e6eaef; --ink-soft: #9aa4b1; --line: #333b45;
  --card: rgba(30, 36, 44, 0.90); --card-solid: #222932;
  --red: #d76a5a; --red-dark: #b84f40; --green: #63c39a; --amber: #d7b35a;
  --bg: #151a20; --backdrop-wash: rgba(12, 16, 22, 0.66); color-scheme: dark;
}
/* Forest Night — green dark. */
:root[data-theme="forest-night"] {
  --ink: #e2ecdf; --ink-soft: #9bb09c; --line: #2c3a2e;
  --card: rgba(24, 33, 26, 0.90); --card-solid: #1b2620;
  --red: #d8734a; --red-dark: #b85a36; --green: #79cf8f; --amber: #d9b458;
  --bg: #121a14; --backdrop-wash: rgba(9, 16, 11, 0.64); color-scheme: dark;
}
/* Blueprint — blue dark. */
:root[data-theme="blueprint"] {
  --ink: #dbe7f4; --ink-soft: #90a4bd; --line: #24344a;
  --card: rgba(20, 30, 45, 0.90); --card-solid: #172433;
  --red: #e07a5f; --red-dark: #c25f46;
  --green: #5fbfd0; --amber: #d9b45a; --bg: #0e1622;
  --backdrop-wash: rgba(8, 14, 26, 0.70); color-scheme: dark;
}
/* High Contrast — maximum legibility, light. */
:root[data-theme="contrast"] {
  --ink: #000000; --ink-soft: #333333; --line: #000000;
  --card: #ffffff; --card-solid: #ffffff;
  --red: #a40000; --red-dark: #7a0000; --green: #005c2e; --amber: #6a4a00;
  --bg: #ffffff; --backdrop-wash: rgba(255, 255, 255, 0.80); color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  /* Belt and braces against a sideways scroll on a narrow phone. */
  overflow-x: hidden;
}
/* Only a page that actually renders the sticky add bar reserves room for it (plus the iOS
   home indicator). Tying this to :has means the reservation can't drift out of sync with
   the markup the way a flat 96px on every page did. */
body:has(.addbar) { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  /* An oak woodland, drawn — see ../../build-backdrop.mjs. One SVG at every size: it is
     smaller than the JPEG pair it replaced and needs no resolution breakpoint.
     A per-theme wash sits OVER it (first background layer), so the dark themes darken the
     scene instead of swapping the image. */
  background:
    linear-gradient(var(--backdrop-wash), var(--backdrop-wash)),
    url("forest.svg") center / cover no-repeat,
    var(--bg);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px 0; /* the sticky .appbar above owns the safe-area top inset now */
}

/* ---------- top app bar (shared across pages, filled by common.js) ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.appbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.appbar-brand svg { width: 26px; height: 26px; flex: none; }
/* "Oak Forest Trust" is long enough to fight the account button on a 320px phone, so the
   name truncates rather than wrapping the bar onto two lines. */
.appbar-brand .brand-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-right {
  position: relative; /* anchors the dropdown */
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.appbar-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Collapse the name only on the narrowest phones — a long name truncates with an ellipsis
   above that (max-width + text-overflow), and the menu carries it in full either way. */
@media (max-width: 380px) { .appbar-name { display: none; } }
.hamburger {
  width: 42px;
  height: 42px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-solid);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.hamburger span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }
.hamburger[aria-expanded="true"] { border-color: var(--red); }
.appbar-signin { min-height: 38px; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  /* The aerial behind is blurred already; this keeps body text crisp regardless. */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 3px rgba(35, 32, 29, 0.09);
}

/* ---------- header ---------- */
.head { padding-bottom: 12px; }

.head-top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}

h1 {
  margin: 0;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
}

.sub {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.count {
  flex: none;
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.25;
  color: var(--ink-soft);
}
.count b {
  display: block;
  font-size: 1.05rem;
  color: var(--red);
  letter-spacing: -0.01em;
}
.count.is-urgent b { color: #b3210f; }

.bar {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  /* An unfilled track tinted to the surface so it works across themes, not a fixed grey. */
  background: color-mix(in srgb, var(--ink) 14%, transparent);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f8b62, var(--green));
  transition: width 0.35s ease;
}
.progress-text {
  margin: 7px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- section switcher ---------- */
.seg {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 12px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.seg-btn {
  flex: 1 1 0;
  min-height: var(--tap);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg-btn.is-on {
  background: var(--red);
  color: #fff;
}
.seg-n {
  font-weight: 500;
  opacity: 0.75;
  font-size: 0.85em;
}

.panel[hidden] { display: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
h2 { margin: 0; font-size: 1rem; letter-spacing: 0.01em; }

.filter select {
  font: inherit;
  font-size: 0.9rem;
  min-height: 38px;
  max-width: 46vw;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

.hint { margin: 0 0 8px; font-size: 0.85rem; color: var(--ink-soft); }
.empty { margin: 6px 2px; font-size: 0.9rem; color: var(--ink-soft); font-style: italic; }

/* ---------- rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.list > .row:first-child { border-top: 0; }

.check {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  /* Big invisible target; the visible box inside is smaller. */
  -webkit-tap-highlight-color: transparent;
}
.check i {
  display: block;
  width: 25px;
  height: 25px;
  border: 2px solid #b6ada1;
  border-radius: 7px;
  background: #fff;
  position: relative;
}
.check[aria-pressed="true"] i {
  background: var(--green);
  border-color: var(--green);
}
.check[aria-pressed="true"] i::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 6px; height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(43deg);
}

/* Drag handle. Leads the row; a full-height 38px column so it's an easy thumb target.
   touch-action:none is load-bearing — without it a touch-drag scrolls the page instead. */
.grip {
  flex: none;
  align-self: stretch;
  min-height: var(--tap);
  width: 38px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #bcb3a7;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
}
.grip:active { cursor: grabbing; background: transparent; }
/* Three bars, drawn in CSS so there's no icon font or SVG to depend on. */
.grip i {
  display: block;
  width: 15px;
  height: 12px;
  background: repeating-linear-gradient(currentColor 0 2px, transparent 2px 5px);
  border-radius: 1px;
}
.grip:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: -3px;
  border-radius: 9px;
  color: var(--ink-soft);
}

/* The lifted row while it's being dragged. */
.row.drag-src {
  background: #fffdf7;
  border-radius: 11px;
  box-shadow: 0 7px 20px rgba(35, 32, 29, 0.20);
  position: relative;
  z-index: 5;
}
/* Kill text selection and the row's own drag cursor for the duration. */
body.reordering { -webkit-user-select: none; user-select: none; }
body.reordering .grip { cursor: grabbing; }

.reorder-hint { margin: 0 2px 8px; }

.body {
  flex: 1 1 auto;
  min-width: 0;              /* lets long words wrap instead of pushing the row wide */
  padding: 9px 0 7px;
}
.txt {
  display: block;
  overflow-wrap: anywhere;
}
.row.is-done .txt { color: var(--ink-soft); text-decoration: line-through; }

/* Assignee chip on a task (and the supply note). Theme-relative — a soft tint of the accent
   so it reads as "who" without the old warm-tan clashing with the green theme. */
.who {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--red) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 24%, transparent);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--red-dark);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.stamp-done {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.more {
  flex: none;
  width: var(--tap);
  min-height: var(--tap);
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 9px;
}
.more:active { background: #e9e3d9; }

/* Notes are the owner's standing constraints, not work — no checkbox, own colour. */
.row.is-note {
  align-items: flex-start;
  background: #fdf6e3;
  border: 1px solid #ecdfba;
  border-radius: 11px;
  margin: 8px 0;
  padding: 4px 4px 4px 10px;
}
.row.is-note .body { font-size: 0.92rem; color: #5c4a1f; }
.row.is-note .note-tag {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 2px;
}

/* ---------- inline editor ---------- */
.editor {
  padding: 4px 0 12px;
  border-top: 1px dashed var(--line);
}
.editor textarea, .editor input {
  width: 100%;
  font: inherit;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  margin-top: 8px;
}
.editor textarea { min-height: 76px; resize: vertical; }
.editor label {
  display: block;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.editor-btns {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.editor-btns button { flex: 1 1 auto; min-width: 92px; }

button, .btn {
  font: inherit;
  font-weight: 600;
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
}
button:active { background: var(--red-dark); }
button.ghost {
  background: #ece6dd;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.danger { background: #7a1f18; }

.linkish {
  /* Rarely used, but still a finger target — 10px of vertical padding is what gets this
     from an 19px line of text to a 39px hit area without making it look like a button. */
  display: inline-block;
  min-height: 0;
  padding: 10px 2px;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
}
.linkish:active { background: none; }

/* ---------- completed drawer ---------- */
.done-box summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 30px;
  display: flex;
  align-items: center;
}
.done-box[open] summary { margin-bottom: 6px; }

/* ---------- add bar ---------- */
.addbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--card);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.addform {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 6px;
}
.addform input {
  font: inherit;
  min-width: 0;                /* the flex-item shrink fix; without it the row overflows */
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
#addtext { flex: 1 1 auto; }
#addwho  { flex: 0 1 96px; }
.addform button { flex: none; padding: 0 14px; }

/* ---------- pin sheet + toast ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(30, 26, 22, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.sheet[hidden] { display: none; }
.sheet-box {
  width: 100%;
  max-width: 420px;
  background: var(--card-solid);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: env(safe-area-inset-bottom);
}
.sheet-box h3 { margin: 0 0 6px; font-size: 1.05rem; }
.sheet-msg { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.sheet-msg.is-err { color: #b3210f; font-weight: 600; }
#pin {
  width: 100%;
  font: inherit;
  font-size: 1.2rem;
  letter-spacing: 0.16em;
  text-align: center;
  min-height: 52px;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.sheet-btns { display: flex; gap: 8px; margin-top: 12px; }
.sheet-btns button { flex: 1 1 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #23201d;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.toast[hidden] { display: none; }

/* ---------- footer ---------- */
.foot {
  margin: 4px 2px 20px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}
.foot p { margin: 4px 0; }

.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- wide screens: show both panels side by side ---------- */
@media (min-width: 900px) {
  .wrap { max-width: 1080px; padding-top: 20px; }
  .seg { display: none; }
  .panels {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 14px;
    align-items: start;
  }
  /* The switcher is gone at this width, so neither panel may stay hidden. */
  .panel, .panel[hidden] { display: block; }
  .addform { max-width: 1080px; }
  /* The switcher hides "who" when the Supplies panel is active. Above this width both
     panels are on screen and the add bar always posts a task, so un-hide it — otherwise
     someone who switched panels and then rotated to landscape loses the field. */
  #addwho, #addwho[hidden] { display: block; flex: 0 1 160px; }
  h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}

/* ===========================================================================
   v2 — accounts: shared header/account menu, auth pages, settings/users/audit,
   theme picker. Everything below reuses the theme tokens above, so it follows
   every theme automatically. Phone-first; wider screens get more room, not a
   different layout.
   =========================================================================== */

/* ---------- account menu (injected into #acctslot on every page) ---------- */
.acct-slot { position: relative; flex: none; }
.acct-btn {
  min-height: 40px; padding: 0 12px; border-radius: 999px;
  background: var(--card-solid); color: var(--ink);
  border: 1px solid var(--line); font: inherit; font-weight: 600; font-size: 0.9rem;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; max-width: 60vw;
}
.acct-btn .who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn .avatar {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--red); color: #fff; display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700;
}
.acct-btn.signed-out { color: #fff; background: var(--red); border-color: transparent; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 210px; padding: 6px;
  background: var(--card-solid); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
}
.acct-menu[hidden] { display: none; }
.acct-menu a, .acct-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 9px;
  background: none; color: var(--ink); font: inherit; font-weight: 500;
  text-align: left; text-decoration: none; cursor: pointer;
}
.acct-menu a:active, .acct-menu button:active { background: color-mix(in srgb, var(--ink) 8%, transparent); }
/* Menu header — a plain block, not the .who chip. Name over a muted handle, thin divider. */
.acct-who { padding: 6px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.acct-who b { display: block; font-size: 0.98rem; letter-spacing: -0.01em; }
.acct-who span { font-size: 0.8rem; color: var(--ink-soft); }
.acct-menu .danger-item { color: var(--red); }

/* ---------- generic page shell (settings / users / audit) ---------- */
/* Match the checklist container (.wrap) at every width: 640 on phones/tablets, widening to
   1080 on desktop just like the task page does. */
.page {
  max-width: 640px; margin: 0 auto;
  padding: 14px 12px calc(40px + env(safe-area-inset-bottom)); /* .appbar owns the top inset */
}
@media (min-width: 900px) { .page { max-width: 1080px; } }
.page > h1 { margin: 4px 2px 14px; font-size: 1.35rem; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.page-head .back {
  flex: none; min-height: 40px; min-width: 40px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card-solid);
  color: var(--ink); text-decoration: none; font-size: 1.1rem;
}
.page-head h1 { font-size: 1.3rem; margin: 0; flex: 1 1 auto; }
.card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.card .note { margin: 0 0 12px; font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- standalone form fields ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.inp {
  width: 100%; font: inherit; min-height: var(--tap); padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card-solid); color: var(--ink);
}
select.inp { -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 34px; }
.btn-block { width: 100%; justify-content: center; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions .btn, .row-actions button { flex: 1 1 auto; min-width: 110px; justify-content: center; }
.msg { margin: 8px 0 0; font-size: 0.88rem; }
.msg.err { color: var(--red); font-weight: 600; }
.msg.ok { color: var(--green); font-weight: 600; }

/* ---------- auth (login / setup) ---------- */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 20px; padding: 26px 22px;
  box-shadow: 0 12px 40px rgba(20, 16, 10, 0.28);
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 18px; }
.brand .mark { width: 66px; height: 66px; margin-bottom: 12px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25)); }
.brand h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.01em; }
.brand p { margin: 3px 0 0; font-size: 0.86rem; color: var(--ink-soft); }
.auth-card .field:last-of-type { margin-bottom: 16px; }
.auth-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--ink-soft); font-size: 0.8rem; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.passkey-btn {
  width: 100%; min-height: var(--tap); justify-content: center; gap: 9px;
  background: var(--card-solid); color: var(--ink); border: 1px solid var(--line); font-weight: 600;
}
.passkey-btn svg { width: 18px; height: 18px; }

/* ---------- tables that fold to cards on a phone ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); padding: 6px 8px; }
.tbl td { padding: 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.pill.admin { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.pill.user  { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink-soft); }
.pill.off   { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink-soft); }
.pill.me    { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }

/* user roster → card list under 640px */
.user-row .u-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-row .u-actions button { min-height: 38px; padding: 0 10px; font-size: 0.85rem; }
@media (max-width: 640px) {
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }
  .tbl thead { display: none; }
  .tbl tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--card-solid); }
  .tbl td { border: 0; padding: 3px 0; }
  .tbl td[data-l]::before { content: attr(data-l); display: inline-block; min-width: 78px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
}

/* ---------- audit list ---------- */
.audit-item { display: flex; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); }
.audit-item:first-child { border-top: 0; }
.audit-when { flex: none; width: 92px; font-size: 0.76rem; color: var(--ink-soft); }
.audit-body { flex: 1 1 auto; min-width: 0; }
.audit-actor { font-weight: 600; }
.audit-actor.pin { color: var(--amber); }
.audit-actor.anon { color: var(--ink-soft); font-style: italic; }
.audit-act { color: var(--ink-soft); }
.audit-target { overflow-wrap: anywhere; }

/* ---------- theme picker ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .theme-grid { grid-template-columns: repeat(3, 1fr); } }
.theme-opt {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer;
  background: var(--card-solid); text-align: left; font: inherit; color: var(--ink); position: relative;
}
.theme-opt[aria-pressed="true"] { border-color: var(--red); }
.theme-opt .sw { display: flex; gap: 4px; margin-bottom: 8px; }
.theme-opt .sw i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.15); }
.theme-opt .nm { font-weight: 600; font-size: 0.9rem; }
.theme-opt .tick { position: absolute; top: 8px; right: 8px; color: var(--red); font-weight: 800; opacity: 0; }
.theme-opt[aria-pressed="true"] .tick { opacity: 1; }

/* ---------- recovery codes ---------- */
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 10px 0; }
.codes code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem;
  padding: 8px; text-align: center; background: var(--card-solid); border: 1px solid var(--line); border-radius: 8px;
}
.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; margin: 10px 0; }
.qr-box svg { width: 200px; height: 200px; }
.secret-str { font-family: ui-monospace, monospace; font-size: 0.9rem; word-break: break-all; background: var(--card-solid); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* ---------- toggle switch (authMode, disable) ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 22%, transparent); transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--red); outline-offset: 2px; }

/* mode banner on the checklist while staged/locked */
.mode-banner { font-size: 0.82rem; color: var(--ink-soft); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }

/* ===========================================================================
   v3 — the home page (index.html). Reuses .card and the theme tokens, so it
   follows every theme and needs no colours of its own.
   =========================================================================== */

.hero { text-align: center; padding: 30px 20px 26px; }
.hero .mark { width: 76px; height: 76px; margin-bottom: 14px; filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.22)); }
.hero h1 { font-size: 1.9rem; margin: 0; }
.hero .tagline {
  margin: 8px auto 0;
  max-width: 46ch;
  font-size: 1rem;
  color: var(--ink-soft);
}
/* A short rule under the heading, in the accent — the one piece of ornament on the page. */
.hero .rule {
  width: 62px; height: 3px; border-radius: 2px;
  margin: 16px auto 0;
  background: var(--red);
  opacity: 0.75;
}
@media (min-width: 700px) {
  .hero { padding: 46px 28px 40px; }
  .hero h1 { font-size: 2.4rem; }
  .hero .mark { width: 92px; height: 92px; }
  .hero .tagline { font-size: 1.08rem; }
}

/* Card grid: one column on a phone, three across from tablet up. auto-fit rather than a
   fixed count so a fourth card can be added later without touching this rule. */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .home-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
}
.home-grid .card { margin-bottom: 0; }
.home-grid h2 { margin-bottom: 6px; }
.home-grid p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }

/* No text-shadow here, unlike .foot on the old checklist: that shadow was hard-coded white,
   which is backwards under the five dark themes. The tokens alone carry the contrast. */
.home-foot {
  margin: 18px 2px 6px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink);
  opacity: 0.7;
}
.home-foot p { margin: 3px 0; }
