/* Wafflesmith -- the redesign's one stylesheet (webapp.py's templates).
   Borrowed from Waffle Tracker's design system (its static/style.css), with
   the colours from the Flip screen sketch the host approved. Every
   component reads only the tokens below, so dark mode and a group's accent
   colour (.accent-<name> on <html>, webapp.py's accent_for) come for free.
   Not used by App.py -- Streamlit serves this folder but nothing there
   links this file. */

:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --card-bg: #fff;
  --border: #dcdfdb;
  --text: #1a1d1b;
  --muted: #5f6661;
  --input-bg: #fff;
  --hover: rgba(0, 0, 0, 0.04);
  --code-bg: #f0f2f0;
  --switch-off: #c9cec9;
  /* The only accent colours any component may use -- a group's preset
     (.accent-* below) swaps these three and everything follows. The
     default is the sketch's blue. */
  --accent: #1f4e79;
  --accent-soft: #e4edf6;
  --accent-contrast: #fff;
  --danger: #b3261e;
  --danger-soft: #fbeae8;
  /* Red text on the page background (--danger itself is a fill colour). */
  --danger-text: #b3261e;
  /* Result chips: jackpot hit / not hit / added to settlement. */
  --good: #1e7a46;
  --good-soft: #e3f3e9;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  /* Spacing, shape and size scale shared by every component below. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 1px 3px rgba(16, 24, 20, 0.07);
  --shadow-lg: 0 10px 30px rgba(16, 24, 20, 0.18);
  /* Minimum tap target (Apple HIG / WCAG 2.5.5), and a tappable list row. */
  --tap: 44px;
  --row: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141716;
    --card-bg: #1d211f;
    --border: #2e3431;
    --text: #e8ebe9;
    --muted: #9aa39e;
    --input-bg: #171a19;
    --hover: rgba(255, 255, 255, 0.06);
    --code-bg: #171a19;
    --switch-off: #3d4440;
    --accent: #6ea8dc;
    --accent-soft: #1d2c3b;
    --accent-contrast: #0c1620;
    --danger-soft: #3a1f1c;
    --danger-text: #ff8a80;
    --good: #5cc98a;
    --good-soft: #17301f;
    --warn: #e5b85c;
    --warn-soft: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.4;
  /* Clear of the fixed bottom bar (step 3), so the last card never sits
     under it. */
  padding-bottom: calc(var(--tabbar-h, 0px) + var(--space-5) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
main { padding: var(--space-3) var(--space-4); max-width: 640px; margin: 0 auto; }
[hidden] { display: none !important; }

/* --- Base elements ------------------------------------------------------
   One link style, one focus ring, and form controls that are 44px tall
   with a 16px+ font -- below 16px iOS zooms the page in on focus (the
   same problem App.py patches into Streamlit's page). */
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font-family: inherit; color: inherit; }
/* :where() keeps this at zero specificity, so a component's own input
   style (the stepper's plain number) wins without fighting it. */
:where(input:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=range], [type=color]),
select,
textarea) {
  font-family: inherit;
  font-size: max(16px, 1rem);
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=checkbox], input[type=radio] {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

/* --- Buttons: .btn plus primary / secondary / ghost / danger ------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 10px var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, filter 0.15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.secondary { border-color: var(--border); }
.btn.secondary:hover { background: var(--hover); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.danger-outline { border-color: var(--danger); background: none; color: var(--danger-text); }
.btn.block { display: flex; width: 100%; }
/* The one action a screen is for (Fetch & Calculate, Copy). */
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: var(--radius); }
/* Compact text, same 44px tap height. */
.btn.small { padding: 6px var(--space-3); font-size: 0.85rem; }
.btn:active:not(:disabled) { filter: brightness(0.95); }
/* Square icon-only button (×, ⋯): a full 44px target around a small glyph. */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: 1.15rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-icon:hover { background: var(--hover); }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn-row > .btn, .btn-row > form { flex: 1 1 0; margin: 0; }
.btn-row > form > .btn { width: 100%; }
/* A short secondary action beside the main one takes only its own width. */
.btn-row > .btn.shrink { flex: 0 0 auto; }

/* --- Field: label, control, one-line hint ------------------------------- */
.field { display: block; margin: 0 0 var(--space-4); }
.field-label { display: block; margin-bottom: var(--space-1); font-size: 0.875rem; font-weight: 500; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { display: block; width: 100%; }
.field-hint { display: block; margin-top: var(--space-1); font-size: 0.78rem; color: var(--muted); }
/* A control with a button beside it (the link box + Paste). */
.field-row { display: flex; gap: var(--space-2); }
.field-row > input, .field-row > select { flex: 1; min-width: 0; }
.field-row > .btn { flex-shrink: 0; }

/* --- Card: the surface everything sits on ------------------------------- */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.card-pad { padding: var(--space-4); }
/* A whole card that is one button (the Flip game card). */
button.card, a.card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 72px;
  padding: 14px var(--space-4);
  font: inherit;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
button.card:active, a.card:active { background: var(--accent-soft); }

/* --- Page and section titles -------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-4);
}
.page-header h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; min-width: 0; }
.page-header-actions { display: flex; gap: var(--space-2); flex-shrink: 0; margin-left: auto; }
/* A sub-page's header: a ‹ back button, then the title. */
.page-header-back { justify-content: flex-start; }
.page-header-back .btn-icon { margin-left: calc(-1 * var(--space-2)); font-size: 1.6rem; }
/* The small grey heading above a card or list ("JACKPOT", "THIS GAME"). */
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-5) var(--space-1) var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label:first-child { margin-top: var(--space-2); }
.section-label .btn { text-transform: none; letter-spacing: 0; }
.list-note { margin: calc(-1 * var(--space-2)) var(--space-1) var(--space-4); font-size: 0.8rem; color: var(--muted); }

/* --- List: iOS-style grouped list of 56px tappable rows ------------------
   A link row gets a "›" automatically; a <button> row doesn't. */
.list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list > * + * { border-top: 1px solid var(--border); }
.list form { margin: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--row);
  padding: var(--space-2) var(--space-4);
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.list-row:hover { background: var(--hover); }
.list-row:active { background: var(--accent-soft); }
a.list-row::after { content: "›"; margin-left: auto; padding-left: var(--space-2); color: var(--muted); font-size: 1.4rem; line-height: 1; }
.list-row-icon { width: 24px; flex-shrink: 0; text-align: center; color: var(--muted); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.list-row-hint { display: block; font-size: 0.8rem; color: var(--muted); }
/* A figure on the right of a row (a fund's balance, a player's net). */
.list-row-value { flex-shrink: 0; max-width: 55%; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.list-row-static { cursor: default; }
.list-row-static:hover, .list-row-static:active { background: none; }
.list-row.danger, .list-row.danger .list-row-icon { color: var(--danger-text); }
/* The selected row in a picker sheet. */
.list-row[aria-current="true"] .list-row-title { color: var(--accent); font-weight: 600; }
.list-row[aria-current="true"]::after { content: "✓"; margin-left: auto; padding-left: var(--space-2); color: var(--accent); font-weight: 700; font-size: 1rem; }
.pos { color: var(--good); }
.neg { color: var(--danger-text); }

/* --- Switch row: label left, iOS switch right, the whole row tappable ----
   Still a real <input type="checkbox"> underneath, so form posts are
   unchanged. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--row);
  padding: var(--space-2) 0;
  cursor: pointer;
}
.list .switch-row { padding: var(--space-2) var(--space-4); }
/* A list item holding a label over a control (the House Fund amount under
   its switch). */
.list-block { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.switch-row-text { flex: 1; min-width: 0; }
.switch-row-hint { display: block; font-size: 0.8rem; color: var(--muted); }
.switch-row input[type=checkbox], input[type=checkbox].switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background-color 0.2s;
  cursor: pointer;
}
.switch-row input[type=checkbox]::before, input[type=checkbox].switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}
.switch-row input[type=checkbox]:checked, input[type=checkbox].switch:checked { background: var(--accent); }
.switch-row input[type=checkbox]:checked::before, input[type=checkbox].switch:checked::before { transform: translateX(20px); }
.switch-row input[type=checkbox]:disabled { opacity: 0.5; cursor: default; }

/* --- Segmented buttons ---------------------------------------------------
   Either <button aria-pressed> (client-side views, e.g. Facebook / Sheet
   row / Pairings) or <label><input type=radio><span> (a form field --
   still a real radio, so the post doesn't change). */
.seg {
  display: flex;
  width: 100%;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--hover);
  border: 1px solid var(--border);
}
.seg > button, .seg > a, .seg > label > span {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--tap);
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.seg > label { flex: 1; display: flex; position: relative; margin: 0; }
.seg > label > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg > button[aria-pressed="true"], .seg > a.active, .seg > label > input:checked + span {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  box-shadow: var(--shadow);
}
/* A short choice beside a field (Oz / $ / g next to an amount). */
.seg.seg-inline { width: auto; flex: 0 0 auto; }
.seg > button:focus-visible, .seg > label > input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* --- Chips ---------------------------------------------------------------
   .chip: a small status label (results: "No jackpot hit", "Pool now
   59 oz"). .choice-chips: pick one or several (fund chips, "who pays
   instead" name chips) -- real radios/checkboxes underneath. */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--danger-soft); color: var(--danger-text); }
.choice-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-4); padding: 0; border: 0; }
.choice-chips label { position: relative; display: flex; }
.choice-chips input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice-chips span {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  font-size: 0.9rem;
  font-weight: 500;
}
.choice-chips input:checked + span { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.choice-chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-chips input:disabled + span { opacity: 0.5; }

/* Two big side-by-side choices (Adds to fund / Takes from fund) -- real
   radios underneath, like .choice-chips. */
.choice-buttons { display: flex; gap: var(--space-2); margin: 0 0 var(--space-4); }
.choice-buttons label { position: relative; flex: 1; display: flex; }
.choice-buttons input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice-buttons span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-weight: 600;
  text-align: center;
}
.choice-buttons input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.choice-buttons input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Admin › Pricing: each tier opens in place. */
.tier-summary { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; list-style: none; cursor: pointer; }
.tier-summary::-webkit-details-marker { display: none; }
details[open] > .tier-summary .text-muted { visibility: hidden; }

/* A stacked list of plan choices (My Account's seat tiers): real radios
   underneath, one full-width row each, name and seats on the left, price
   on the right. */
.plan-options { display: flex; flex-direction: column; gap: var(--space-2); margin: 0 0 var(--space-4); }
.plan-options label { position: relative; display: flex; }
.plan-options input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.plan-options .plan-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
}
.plan-option-main { flex: 1; min-width: 0; }
.plan-option-name { display: block; font-weight: 600; }
.plan-option-hint { display: block; font-size: 0.8rem; color: var(--muted); }
.plan-option-price { flex-shrink: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-options input:checked + .plan-option { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.plan-options input:focus-visible + .plan-option { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-options input:disabled + .plan-option { opacity: 0.5; }

/* --- Stepper: − number + -------------------------------------------------
   The number is a real <input type=number> styled as plain text, so
   tapping it types a new value (big changes) with no extra step, and the
   form posts it as-is. app.js wires the − / + buttons. */
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.stepper { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-1); min-width: 0; }
.stepper-label { display: block; font-size: 0.75rem; color: var(--muted); text-align: center; }
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.stepper-row button {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.stepper-row button:active { filter: brightness(0.92); }
.stepper-row button:disabled { opacity: 0.4; cursor: default; }
.stepper-row input[type=number] {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px dotted var(--border);
  border-radius: 0;
  background: none;
  min-height: var(--tap);
  color: var(--text);
  font-family: inherit;
  /* app.js's fitStepper shrinks this for a long value instead of cutting
     it off. */
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
}
.stepper-row input[type=number]::-webkit-inner-spin-button,
.stepper-row input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-row input[type=number]:focus { border: 2px solid var(--accent); border-radius: 8px; box-shadow: none; background: var(--input-bg); }

/* A big figure (the jackpot pool). */
.big-figure { font-size: 2rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big-figure small { font-size: 0.95rem; font-weight: 600; color: var(--muted); }

/* Copyable output (Facebook post, sheet row). */
.output {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  max-height: 300px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Game post templates: numbered steps, and each blank in its own box
   with a Copy button beside it. */
.steps { margin: 0; padding-left: 1.25rem; }
.steps li + li { margin-top: var(--space-2); }
.blank-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.blank-row-plain { padding: 0; }
.blank-code {
  display: inline-block;
  margin-bottom: var(--space-1);
  padding: 2px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  user-select: all;
}
.blank-row .btn { flex-shrink: 0; }

/* --- Sheets ----------------------------------------------------------------
   Every <dialog> is a bottom sheet on phones (slides up, rounded top,
   grabber, scrolls inside, clear of the home indicator) and a centred
   panel on wider screens. app.js locks the page behind it and closes it on
   a backdrop tap; Escape closes it natively. */
dialog {
  width: 100%;
  max-width: none;
  max-height: 90vh;
  max-height: 90dvh;
  margin: auto 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  border: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--card-bg);
}
dialog::before {
  content: "";
  display: block;
  width: 36px;
  height: 5px;
  margin: 8px auto 0;
  border-radius: 3px;
  background: var(--border);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog[open] { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-fade { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@media (min-width: 640px) {
  dialog {
    width: min(92vw, 480px);
    max-height: 85vh;
    margin: auto;
    padding-bottom: 0;
    border-radius: var(--radius-lg);
  }
  dialog::before { display: none; }
  dialog[open] { animation-name: sheet-fade; animation-duration: 0.15s; }
}
.sheet-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
  background: var(--card-bg);
}
.sheet-header h2 { margin: 0; font-size: 1.1rem; }
.sheet-body { padding: var(--space-2) var(--space-4) var(--space-4); }
.sheet-body > .list { box-shadow: none; }
/* A group heading inside a picker sheet ("Silver flips", "Jackpots"). */
.sheet-body .section-label { margin-top: var(--space-4); }
.sheet-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--border);
}
.sheet-actions > .btn { flex: 1; }
.confirm-message { margin: 4px 0 16px; font-size: 1rem; line-height: 1.45; }

/* --- Toasts ----------------------------------------------------------------
   Flash messages (base.html) and app.js's showToast(): confirmations fade,
   errors stay until their × is tapped. */
.toasts {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(calc(100% - 24px), 480px);
  transform: translateX(-50%);
  pointer-events: none;
}
.has-topbar .toasts { top: calc(60px + env(safe-area-inset-top)); }
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 4px 4px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-error { border-left-color: var(--danger); background: var(--danger-soft); }
.toast-text { flex: 1; min-width: 0; padding: 8px 0; overflow-wrap: anywhere; }
.toast.hiding { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* --- Top bar (base.html) ---------------------------------------------------
   The group's name with a letter badge in its colour; a super-admin's
   opens the group switch. Who's logged in on the right. */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--space-3) 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: var(--tap);
  padding: 0 var(--space-2) 0 var(--space-1);
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.topbar-switch:hover { background: var(--hover); }
.topbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.85rem;
  font-weight: 700;
}
.topbar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-caret { color: var(--muted); font-size: 0.85rem; }
.topbar-who { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; color: var(--muted); }

/* --- Bottom bar (base.html, web_nav.tabbar) --------------------------------
   Equal slots, the centre one the raised dice that opens Run game. Pads
   itself clear of the iPhone home indicator; body keeps the room. */
.has-tabbar { --tabbar-h: 62px; }
nav.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  min-height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
}
.tabbar-item, .tabbar-run {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: var(--tabbar-h);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  text-decoration: none;
}
.tabbar-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar-item.active { color: var(--accent); font-weight: 700; }
.tabbar-item.active svg { stroke-width: 2.2; }
.tabbar-run { justify-content: flex-end; padding-bottom: 6px; }
.tabbar-run-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-top: -22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: 4px solid var(--card-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: transform 0.1s;
}
.tabbar-run-circle svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar-run-circle svg .pip { fill: currentColor; stroke: none; }
.tabbar-run-label { color: var(--accent); font-weight: 700; }
.tabbar-run:active .tabbar-run-circle { transform: scale(0.94); }
.text-center { text-align: center; }

/* Logged-out screens (templates/_auth_layout.html). */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: calc(var(--space-5) + env(safe-area-inset-top)) 0 var(--space-6); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); font-size: 1.15rem; font-weight: 700; }
.auth-brand img { border-radius: 14px; box-shadow: var(--shadow); }
.auth-title { margin: 0 0 var(--space-4); font-size: 1.5rem; }
.page-header .auth-title { margin: 0; }
.tap-link { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 var(--space-2); }

/* A one-line notice at the top of a page (the trial countdown). */
.banner {
  margin-bottom: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.9rem;
}

/* The trial countdown + "contact us" line: smaller and quieter than a notice. */
.banner-quiet { padding: var(--space-2) var(--space-3); font-size: 0.8rem; line-height: 1.4; overflow-wrap: anywhere; }

.banner-action { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); }

/* Home (templates/home.html). */
.page-header-stack { flex-direction: column; align-items: flex-start; gap: 0; }
.page-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.live-dot { flex-shrink: 0; width: 10px; height: 10px; margin: 0 4px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.quick {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-1);
  min-width: 0;
  min-height: 76px;
  padding: 10px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}
.quick:active { background: var(--accent-soft); }
.quick b { font-size: 0.88rem; line-height: 1.2; overflow-wrap: anywhere; }
.quick span { font-size: 0.72rem; color: var(--muted); }
.big-value { font-size: 1.1rem; font-weight: 750; }
.section-label .btn.small { margin: -12px calc(-1 * var(--space-2)) -12px 0; padding: 0 var(--space-2); }

/* Game screens (templates/poker.html, ...). */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.field-grid .field { margin-bottom: var(--space-2); min-width: 0; }
.inline-toast { margin-bottom: var(--space-3); animation: none; }
.inline-toast .toast-text { white-space: pre-line; }
.steppers-one { grid-template-columns: minmax(0, 220px); }
.high-hand { margin-top: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--code-bg); font-size: 0.92rem; overflow-wrap: anywhere; }
.high-hand-label { display: block; margin-bottom: 2px; font-size: 0.75rem; color: var(--muted); }
textarea { width: 100%; }
.disclosure { margin: var(--space-4) 0; }
.disclosure > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "›"; display: inline-block; width: 1em; transition: transform 0.15s; }
.disclosure[open] > summary::before { transform: rotate(90deg); }
.plain-list { margin: 0; padding-left: 1.1em; }
.plain-list li { margin: 4px 0; }
.results { scroll-margin-top: 60px; }
.mb-0 { margin-bottom: 0; }
.mt-0 { margin-top: 0; }

/* Lotto's names check (templates/lotto.html). */
.spot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.spot-row { display: flex; align-items: center; gap: var(--space-2); }
.spot-row input { flex: 1; min-width: 0; }
.spot-num { flex-shrink: 0; width: 28px; text-align: center; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.spot-winner .spot-num { color: var(--good); }
.spot-winner input { border-color: var(--good); }
.spot-match { width: calc(100% - 36px); margin: var(--space-1) 0 0 36px; }
.empty-output { font-family: var(--font); color: var(--muted); }
.mt-2 { margin-top: var(--space-2); }

/* Flip (templates/flip.html). */
.game-card .game-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}
.pool-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.gate-card { border-color: var(--warn); background: var(--warn-soft); }
.settle-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.prose { line-height: 1.5; }
.prose p { margin: 0 0 var(--space-3); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
.prose ul { padding-left: 1.2em; }

/* Flip settlement (templates/flip_settlement.html, flip.html). */
.live-dot.stopped { background: var(--muted); box-shadow: 0 0 0 4px var(--hover); }
.names-check { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.names-check select { width: 100%; }
.player-block { margin-bottom: var(--space-3); }
.player-block-head { display: flex; align-items: center; justify-content: space-between; }
.list-details > summary { list-style: none; }
.list-details > summary::-webkit-details-marker { display: none; }
.list-details > summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.4rem; transition: transform 0.15s; }
.list-details[open] > summary::after { transform: rotate(90deg); }
.output.mx { margin: 0 var(--space-4) var(--space-3); }
.entry-row { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.entry-line { font-family: var(--mono); font-size: 0.85rem; overflow-wrap: anywhere; }
.pull-up { margin-top: calc(-1 * var(--space-2)); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-3 { margin-bottom: var(--space-3); }

/* Empty list: a short line and the button that fills it. */
.empty-state {
  padding: var(--space-5) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.empty-state p { margin: 0 0 var(--space-3); }

.text-muted { color: var(--muted); }
.text-sm { font-size: 0.875rem; }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  dialog[open], .toast { animation: none; }
  .toast, .switch-row input[type=checkbox], .switch-row input[type=checkbox]::before,
  input[type=checkbox].switch, input[type=checkbox].switch::before { transition: none; }
}

/* --- Group accent presets (webapp.py's ACCENTS / accent_for) ---------------
   On <html> they recolour a group's pages; on a badge or swatch just that
   element. Waffle Tracker's presets (each checked for 4.5:1 contrast,
   light and dark), with its default "blue" swapped for the sketch's blue,
   which is also the Wafflesmith default above. */
.accent-blue   { --accent: #1f4e79; --accent-soft: #e4edf6; --accent-contrast: #fff; }
.accent-indigo { --accent: #4338ca; --accent-soft: #e8e7fb; --accent-contrast: #fff; }
.accent-purple { --accent: #7e22ce; --accent-soft: #f1e5fb; --accent-contrast: #fff; }
.accent-pink   { --accent: #be185d; --accent-soft: #fbe4ee; --accent-contrast: #fff; }
.accent-orange { --accent: #b33c0b; --accent-soft: #fdece3; --accent-contrast: #fff; }
.accent-teal   { --accent: #0f766e; --accent-soft: #dcf2ef; --accent-contrast: #fff; }
.accent-brown  { --accent: #8a4b14; --accent-soft: #f6ebdf; --accent-contrast: #fff; }
.accent-slate  { --accent: #475569; --accent-soft: #e8ecf1; --accent-contrast: #fff; }
@media (prefers-color-scheme: dark) {
  .accent-blue   { --accent: #6ea8dc; --accent-soft: #1d2c3b; --accent-contrast: #0c1620; }
  .accent-indigo { --accent: #9b9cf6; --accent-soft: #24244d; --accent-contrast: #11112e; }
  .accent-purple { --accent: #c79af7; --accent-soft: #33204a; --accent-contrast: #1d0f2e; }
  .accent-pink   { --accent: #f48fbe; --accent-soft: #45192e; --accent-contrast: #2b0c1a; }
  .accent-orange { --accent: #fb9c63; --accent-soft: #45230f; --accent-contrast: #2b1405; }
  .accent-teal   { --accent: #3fd1bf; --accent-soft: #123a36; --accent-contrast: #05211e; }
  .accent-brown  { --accent: #e0a96d; --accent-soft: #3d2a17; --accent-contrast: #21150a; }
  .accent-slate  { --accent: #a3b3c7; --accent-soft: #283240; --accent-contrast: #121821; }
}

/* --- Changing pairings by hand (step 12) --------------------------------- */
/* Name chips that are links (choose who pays instead), styled like
   .choice-chips. */
.name-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-4); }
.name-chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.name-chip.selected { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.pairing-now { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.swap-changes { margin: 0 0 var(--space-3); padding-left: 1.2em; }
.swap-changes li + li { margin-top: var(--space-1); }
.swap-card .chip { margin-bottom: var(--space-2); }
.pairing-list { margin-bottom: var(--space-3); }
.pairing-list .chip { margin-left: var(--space-2); padding: 2px 8px; font-size: 0.72rem; }
.pairing-unit { margin: var(--space-3) 0 var(--space-1); font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* --- Funds (step 14) ------------------------------------------------------ */
.list-row-total .list-row-title { font-weight: 700; }
.list-row-total { background: var(--hover); }
/* The Oz / $ / g buttons beside an amount box. */
.field-row > .seg-units { flex: 0 0 auto; width: auto; }
.seg-units > label > span { min-width: 48px; padding: 0 var(--space-2); }
.section-label-row { display: flex; align-items: center; justify-content: space-between; }
.section-label-row .btn { margin-top: var(--space-3); }
input[type="file"] { max-width: 100%; font: inherit; font-size: 0.9rem; color: var(--muted); }
/* Manage Group's colour swatches: each label carries its .accent-<name>,
   so the dot shows that colour in light and dark. */
.swatches { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 0; padding: 0; border: 0; }
.swatches label { position: relative; display: flex; }
.swatches input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.swatches span { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card-bg); }
.swatches input:checked + span { box-shadow: 0 0 0 3px var(--card-bg), 0 0 0 5px var(--accent); }
.swatches input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 4px; }

/* --- Waffle post (raffle.html, payment_info.html) --------------------------
   Tap-first: chip links/buttons for quick picks, side-game cards, the
   first-visit steps, and the Copy post button pinned above the bottom bar
   while the results are on screen. */
.mb-2 { margin-bottom: var(--space-2); }
.field-row > .field { flex: 1; min-width: 0; }
a.chip-link, button.chip-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent-soft);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
button.chip-button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.check-row { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); }
.check-row input { width: 22px; height: 22px; }
.side-game-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.side-game-add { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.side-game-add > .btn { min-height: var(--tap); }
.setup-steps { margin: 0 0 var(--space-3); padding-left: 1.4em; }
.setup-steps li { margin-bottom: var(--space-3); }
.setup-steps .setup-step-title { display: block; font-weight: 600; min-height: 28px; }
.setup-steps li.done .setup-step-title { color: var(--muted); }
.copy-dock {
  position: sticky;
  bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom));
  z-index: 4;
  margin-top: var(--space-3);
  padding: var(--space-2) 0;
  background: var(--bg);
}
/* My payment info: one big tap row per app, its handle and fees under it. */
.app-toggle { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); cursor: pointer; }
.app-toggle input { width: 24px; height: 24px; margin: 0; flex-shrink: 0; }
.app-toggle-name { font-weight: 600; flex: 1; }
.app-toggle-tag { color: var(--muted); }
.app-card [data-show-if-checked] { margin-top: var(--space-2); }

/* Home: live spot (webapp._home_context), two tiles side by side. */
.section-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.spot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.spot-tile { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-1); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-bg); }
.spot-metal { flex-basis: 100%; font-size: 0.8rem; color: var(--muted); }
.spot-price { font-size: 1.3rem; }
.spot-unit, .spot-missing { font-size: 0.85rem; color: var(--muted); }
/* Waffle post: a waffle's pieces, one line each. */
.piece-row { align-items: flex-end; }
.piece-row .piece-cost { flex: 0 0 96px; }
.piece-row .piece-remove { flex: 0 0 auto; min-height: var(--tap); margin-bottom: var(--space-3); }
/* A waffle's cost card that opens to show its pieces. */
.disclosure-card > summary { cursor: pointer; list-style: none; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; gap: var(--space-1); }
.disclosure-card > summary::-webkit-details-marker { display: none; }
.disclosure-card > summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.disclosure-card[open] > summary::after { transform: rotate(90deg); }
.mt-1 { margin-top: var(--space-1); }
/* Side games, tight: name, price and remove on one line, steppers below. */
.card.side-game { padding: var(--space-2) var(--space-3) var(--space-3); margin-bottom: var(--space-2); }
.side-game .side-game-head { margin-bottom: var(--space-1); }
.side-game-head b { flex: 1; min-width: 0; }
.side-game-price { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.side-game-remove { flex-shrink: 0; }
.steppers-tight { gap: var(--space-1); }
.steppers-tight .stepper { padding: 2px; }
.side-game-fill { grid-template-columns: 1fr 1fr; margin-top: var(--space-2); }
/* Who owes me: the Part paid box with its Save button. */
.field-row .part-btn { align-self: flex-end; margin-bottom: var(--space-3); min-height: var(--tap); }

/* Reports (and any page with a row of small totals): three across, label
   over number. The tapped period chip shows as picked. */
.stack-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.stack-totals > div { display: flex; flex-direction: column; min-width: 0; }
.stack-totals b { font-size: 1.1rem; overflow-wrap: anywhere; }
a.chip-link.active { background: var(--accent); color: #fff; }
/* Two buttons side by side, half each (My entries' Won / Lost). */
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.btn-pair > .btn, .btn-pair > form > .btn { width: 100%; min-width: 0; }
.btn-pair > form { margin: 0; }
