/* BGI — Modernist design system (spec 020).
 *
 * Tokens come from the Modernist design system (Claude Design export). The
 * dark set is derived from it: ink ground, ramps mirrored so the same step
 * keeps its role (100–300 tinted fills, 700–900 text on fills).
 *
 * Documented exceptions to the system:
 *   - .play-fab is round (the only rounded element; one-handed thumb target).
 *   - Box covers are shown in colour (recognition on the shelf beats purity).
 *
 * BGI adjustments (docs/design/DESIGN-ALIGNMENT.md):
 *   - Three text sizes: --text-title 25, --text-body 15, --text-meta 12. Hierarchy
 *     inside a level comes from weight (400 / 600 / 800) and colour. Form fields
 *     are 16px (--text-input) everywhere so iOS never zooms in. Decorative only:
 *     cover initials, the BGI wordmark, big numbers on the statistics page.
 *   - Rules are 2px, at section edges and between equal grid cells. Inside a
 *     section, spacing separates rows. Control outlines (inputs, chips,
 *     segmented controls) keep their 1px edge.
 */

@font-face { font-family: "Archivo"; font-style: normal; font-weight: 400; font-display: optional; src: url(fonts/archivo-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-style: normal; font-weight: 600; font-display: optional; src: url(fonts/archivo-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-style: normal; font-weight: 800; font-display: optional; src: url(fonts/archivo-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Archivo"; font-style: normal; font-weight: 400; font-display: optional; src: url(fonts/archivo-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Archivo"; font-style: normal; font-weight: 600; font-display: optional; src: url(fonts/archivo-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Archivo"; font-style: normal; font-weight: 800; font-display: optional; src: url(fonts/archivo-latin-ext-800-normal.woff2) format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;
  --color-bg: #f3f2f2;
  --color-surface: #eae9e9;
  --color-text: #201e1d;
  --color-accent: #ec3013;
  --color-divider: color-mix(in srgb, #201e1d 40%, transparent);
  --color-on-accent: #f3f2f2;
  --color-scan-bg: #201e1d;
  --color-scan-fg: #f3f2f2;
  --color-scan-accent: #ff9783; /* red text on the always-dark scan screen */
  --color-scan-surface: #262423;
  --color-scan-line: #605d5d;
  --color-success: #1f7a3a;   /* "fits / ok", the one status colour besides the accent */
  --color-scrim: #2d2b2b;     /* behind sheets and dialogs */
  --color-splash: #dd2b0f;    /* startup screen, both themes; accent-600 so its small white text passes AA */

  --color-neutral-100: #f8f4f4;
  --color-neutral-200: #eae7e7;
  --color-neutral-300: #d7d3d3;
  --color-neutral-400: #bab6b6;
  --color-neutral-500: #9b9797;
  --color-neutral-600: #7d7979;
  --color-neutral-700: #605d5d;
  --color-neutral-800: #444141;
  --color-neutral-900: #2d2b2b;

  --color-accent-100: #fff2ef;
  --color-accent-200: #ffe0d9;
  --color-accent-300: #ffc4b8;
  --color-accent-400: #ff9783;
  --color-accent-500: #ff563c;
  --color-accent-600: #dd2b0f;
  --color-accent-700: #ae1800;
  --color-accent-800: #7c1405;
  --color-accent-900: #4d170e;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: "Archivo", system-ui, sans-serif;

  --text-title: 25px;
  --text-body: 15px;
  --text-meta: 12px;
  --text-input: 16px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-md: 0px;

  --shadow-sm: 0 1px 2px color-mix(in srgb, #2d2b2b 14%, transparent);
  --shadow-md: 0 3px 10px color-mix(in srgb, #2d2b2b 16%, transparent);
  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);

  --tabbar-h: 60px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #1b1918;
  --color-surface: #262423;
  --color-text: #f3f2f2;
  --color-accent: #ff563c;
  --color-divider: color-mix(in srgb, #f3f2f2 35%, transparent);
  --color-on-accent: #1b1918;
  --color-scan-bg: #0f0e0d;
  --color-scan-fg: #f3f2f2;
  --color-scan-accent: #ff9783; /* red text on the always-dark scan screen */
  --color-scan-surface: #262423;
  --color-scan-line: #605d5d;
  --color-success: #6fd08c;
  --color-scrim: #000;

  --color-neutral-100: #2d2b2b;
  --color-neutral-200: #363433;
  --color-neutral-300: #444141;
  --color-neutral-400: #605d5d;
  --color-neutral-500: #7d7979;
  --color-neutral-600: #9b9797;
  --color-neutral-700: #bab6b6;
  --color-neutral-800: #d7d3d3;
  --color-neutral-900: #f8f4f4;

  --color-accent-100: #4d170e;
  --color-accent-200: #7c1405;
  --color-accent-300: #ae1800;
  --color-accent-400: #dd2b0f;
  --color-accent-500: #ff563c;
  --color-accent-600: #ff9783;
  --color-accent-700: #ff9783;
  --color-accent-800: #ffe0d9;
  --color-accent-900: #fff2ef;

  --shadow-sm: 0 0 0 1px color-mix(in srgb, #f3f2f2 10%, transparent);
  --shadow-md: 0 0 0 1px color-mix(in srgb, #f3f2f2 12%, transparent), 0 4px 14px rgba(0, 0, 0, .5);
  --shadow-lg: 0 0 0 1px color-mix(in srgb, #f3f2f2 12%, transparent), 0 12px 32px rgba(0, 0, 0, .6);
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
/* Reserve icon boxes before the page modules replace their spans with SVG. */
[data-icon] { display: inline-block; width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
[data-icon][data-size="28"] { width: 28px; height: 28px; }
[data-icon][data-size="22"] { width: 22px; height: 22px; }
[data-icon][data-size="20"] { width: 20px; height: 20px; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: var(--text-body); line-height: 1.55; font-weight: 400;
}
h1, h2, h3, h4 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0;
}
h1, h2 { font-size: var(--text-title); }
h3, h4 { font-size: var(--text-body); }
button, input, select, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--color-accent-700); text-underline-offset: 3px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
[hidden], .hidden { display: none !important; }
.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;
}
.nosb { scrollbar-width: none; }
.nosb::-webkit-scrollbar { display: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-neutral-700); }
.kicker {
  font-size: var(--text-meta); letter-spacing: .1em; text-transform: uppercase;
  color: var(--color-accent-700);
}
.eyebrow {
  font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase;
  color: var(--color-neutral-700);
}
.rule { height: 2px; background: var(--color-divider); flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── App shell ──────────────────────────────────────────────────────────── */

body.app { min-height: 100vh; min-height: 100dvh; }
.app-main {
  max-width: 720px; margin: 0 auto;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-4));
}
.screen-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3);
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) 0;
}
.screen-head h1 { font-size: var(--text-title); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--color-bg); border-top: 2px solid var(--color-divider);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar a {
  height: var(--tabbar-h); display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 4px; padding: 0 14px; text-decoration: none;
  color: var(--color-text); font-size: var(--text-meta); font-weight: 600; white-space: nowrap;
}
.tabbar a:hover { background: color-mix(in srgb, var(--color-text) 5%, transparent); }
.tabbar a[aria-current="page"] { color: var(--color-accent-700); box-shadow: inset 0 3px 0 var(--color-accent); }
.tabbar svg { width: 22px; height: 22px; }
body.scan-screen .tabbar { background: var(--color-bg); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px;
  min-height: 44px; padding: 0 14px; cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: var(--text-body); line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent; border-radius: 0;
}
.btn svg { display: block; flex: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-600); }
.btn-primary:active:not(:disabled) { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active:not(:disabled) { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent-700); padding-inline: 6px; }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-danger { border-color: var(--color-accent); color: var(--color-accent-700); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-icon { width: 44px; height: 44px; padding: 0; justify-content: center; }
.btn-block { width: 100%; }
.btn-spread { justify-content: space-between; }
.btn-lg { min-height: 48px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .label { font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.input {
  width: 100%; min-height: 44px; padding: 6px 10px; font: inherit; font-size: var(--text-input);
  color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: 0;
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: var(--text-body); }
.check input { accent-color: var(--color-accent); width: 20px; height: 20px; margin: 0; }

.search { position: relative; padding: var(--space-3) var(--space-4) 0; }
.search svg { position: absolute; left: 28px; top: 25px; opacity: .55; pointer-events: none; }
.search .input { padding-left: 38px; }

/* Option grid: filters, location picker */
.seg-grid { display: flex; flex-wrap: wrap; border: 1px solid var(--color-divider); }
.seg-grid button {
  flex: 1 0 auto; min-width: 52px; height: 44px; padding: 0 10px; border: 0;
  background: transparent; color: var(--color-text); font-size: var(--text-body); cursor: pointer; text-align: left;
}
.seg-grid button:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.seg-grid button[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); }
/* Switching a view, mode or preference shows ink; picking a value (filters, form options) shows the accent */
.seg-grid.seg-ink button[aria-pressed="true"], .seg-grid.seg-ink button[aria-selected="true"] { background: var(--color-text); color: var(--color-bg); }

/* ── Tags ───────────────────────────────────────────────────────────────── */

.tag { display: inline-flex; align-items: center; font-size: var(--text-meta); letter-spacing: .02em; padding: 2px 6px; white-space: nowrap; column-gap: .3em; }
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-lg {
  font-size: var(--text-body); font-weight: 600; padding: 7px 12px; border: 1px solid var(--color-text);
  color: var(--color-text); background: transparent; line-height: 1.2;
}
button.tag-lg { cursor: pointer; font-family: inherit; }
.tag-lg.more { border-color: var(--color-accent); background: var(--color-accent); color: var(--color-on-accent); }

/* ── Collection toolbar ─────────────────────────────────────────────────── */

.chips { display: flex; gap: 8px; padding: var(--space-3) var(--space-4); overflow-x: auto; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border: 1px solid var(--color-divider); background: transparent; color: var(--color-text);
  font-size: var(--text-meta); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.chip-filters { background: var(--color-text); border-color: var(--color-text); color: var(--color-bg); font-weight: 600; }

.listbar { display: flex; justify-content: space-between; align-items: center; padding: 8px var(--space-4); font-size: var(--text-meta); }
.listbar-left { display: flex; align-items: center; gap: 12px; }
.viewswitch { display: flex; border: 1px solid var(--color-divider); }
.viewswitch button {
  width: 44px; height: 36px; border: 0; background: transparent; color: var(--color-text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.viewswitch button[aria-pressed="true"] { background: var(--color-text); color: var(--color-bg); }
.sortbtn {
  display: flex; align-items: center; gap: 6px; background: none; border: 0; min-height: 44px; padding: 0;
  font-size: var(--text-meta); font-weight: 600; color: var(--color-text); cursor: pointer;
}

/* ── Covers ─────────────────────────────────────────────────────────────── */

.cover {
  position: relative; overflow: hidden; background: var(--color-surface);
  display: flex; align-items: flex-end; justify-content: flex-start;
}
/* Whole cover, never cropped, aligned bottom-left on the surface colour (replaces the blurred backdrop of #102) */
.cover img { position: relative; width: 100%; height: 100%; object-fit: contain; object-position: left bottom; }
.cover-ph {
  background: repeating-linear-gradient(135deg, var(--color-neutral-300) 0 6px, var(--color-neutral-200) 6px 12px);
  padding: 6px; font-weight: 800; line-height: 1;
}
.cover .corner { position: absolute; z-index: 1; right: 8px; bottom: 8px; }

/* ── Welcome tour (spec 079) ────────────────────────────────────────────── */

.tour { max-width: 520px; }
.tour-step { font-size: var(--text-meta); color: var(--color-neutral-700); }
.tour h2 { margin: 0; }
.tour p { margin: 0; }
.tour-list, .tour-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tour-list li { display: flex; flex-direction: column; gap: 2px; }
.tour-list li span { font-size: var(--text-meta); color: var(--color-neutral-700); }
.tour-links .btn { width: 100%; justify-content: flex-start; }
.tour-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Owned · Wishlist · Sold & traded (spec 010) ────────────────────────── */

.coll-tabs { margin: 8px 16px; }
.coll-tabs button { flex: 1 1 0; white-space: nowrap; }
.coll-tabs .num { margin-left: 4px; font-weight: 400; opacity: .8; }
.collection-main[data-tab="wishlist"] .owned-only,
.collection-main[data-tab="archived"] .owned-only { display: none !important; }
.wish-panel { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 24px; }
.wish-intro { margin: 0; font-size: var(--text-meta); }
.wish-list { list-style: none; margin: 0; padding: 0; }
.wish { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--color-divider); }
.wish-cover { flex: 0 0 48px; width: 48px; height: 64px; }
.wish-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wish-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.wish-meta { font-size: 12px; color: var(--color-neutral-700); }
.wish-owner { font-size: 12px; color: var(--color-accent-700); }
[data-theme="dark"] .wish-owner { color: var(--color-accent-400); }
.wish-add { align-self: flex-start; }

/* ── Collection views ───────────────────────────────────────────────────── */

.row-compact {
  width: 100%; display: flex; gap: 10px; align-items: center; min-height: 44px; padding: 0 var(--space-4);
  background: none; border: 0;
  text-align: left; cursor: pointer; color: var(--color-text);
}
.row-compact:hover { background: var(--color-surface); }
.row-compact .dot { width: 6px; height: 6px; flex: none; }
.row-compact .dot.on { background: var(--color-accent); }
.row-compact .title { flex: 1; min-width: 0; font-weight: 600; font-size: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-compact .short { font-size: var(--text-meta); color: var(--color-neutral-700); white-space: nowrap; }
.row-compact .loc { width: 64px; flex: none; font-size: var(--text-meta); color: var(--color-neutral-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }

.cards { display: flex; flex-direction: column; gap: 8px; padding: 8px var(--space-4) var(--space-4); }
.card-game {
  width: 100%; display: flex; gap: 12px; align-items: stretch; padding: 0;
  background: var(--color-surface); border: 0; text-align: left; cursor: pointer; color: var(--color-text);
}
.card-game:hover { background: var(--color-neutral-300); }
.card-game .cover { width: 96px; height: 96px; flex: none; align-self: flex-start; }
.card-game .cover-ph { font-size: 25px; }
.card-game .body { flex: 1; min-width: 0; padding: 10px 12px 10px 0; display: flex; flex-direction: column; gap: 3px; line-height: 1.35; }
.card-game .title { font-weight: 800; font-size: var(--text-body); line-height: 1.2; }
.card-game .pt { font-size: var(--text-meta); color: var(--color-neutral-700); }
.card-game .stats { display: flex; gap: 14px; align-items: center; font-size: var(--text-meta); flex-wrap: wrap; }
.card-game .tagline { font-size: var(--text-meta); color: var(--color-neutral-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-game .foot { display: flex; gap: 6px; margin-top: auto; align-items: center; flex-wrap: wrap; }
.rating { display: inline-flex; align-items: center; gap: 5px; }
.rating svg { fill: var(--color-accent); }
.weight { display: inline-flex; align-items: center; gap: 6px; }
.weight .bars { display: flex; gap: 2px; }
.weight .bars span { width: 6px; height: 10px; background: var(--color-neutral-300); }
.weight .bars span.on { background: var(--color-text); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile-game {
  display: flex; flex-direction: column; gap: 6px; padding: 12px; min-width: 0;
  background: none; border: 0;
  text-align: left; cursor: pointer; color: var(--color-text);
}
.tile-game:hover { background: var(--color-surface); }
.tile-game .cover { aspect-ratio: 1; width: 100%; }
.tile-game .cover-ph { font-size: 25px; padding: 8px; }
.tile-game .title { font-weight: 800; font-size: var(--text-body); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-game .meta { font-size: var(--text-meta); color: var(--color-neutral-700); }

/* Virtual list (spec 032): every row has a fixed height, so where a row sits is arithmetic and
   only the rows near the screen exist. Text is clamped so a row never grows. */
.vl-layer.cards { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0; }
.vl .row-compact, .vl .card-game, .vl .tile-game { contain: layout paint style; }
.vl-layer { will-change: transform; }
.vl .row-compact { height: 52px; min-height: 0; box-sizing: border-box; }
/* Taller than its 96px cover (as designed), so title, players, rating, tags and location all fit */
.vl .card-game { height: 120px; width: auto; margin: 4px var(--space-4); box-sizing: border-box; overflow: hidden; }
.vl .card-game .body > * { flex: none; }
.vl .card-game .body { overflow: hidden; }
.vl .card-game .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vl .card-game .stats, .vl .card-game .foot { flex-wrap: nowrap; overflow: hidden; }
.vl .tile-game { height: var(--tile-h, auto); box-sizing: border-box; overflow: hidden; }
.vl .gtable tbody tr { height: 44px; }
@media (min-width: 768px) {
  .vl .card-game { margin: 4px 8px; }
  .vl-layer.cards { padding: 0 8px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
}

/* Touch screens keep :hover after a tap; don't leave rows tinted */
@media (hover: none) {
  .card-game:hover { background: var(--color-surface); }
  .row-compact:hover, .tile-game:hover { background: none; }
}

.empty { padding: 32px var(--space-4); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.empty h2 { font-size: var(--text-body); }
/* "Powered by BGG" attribution: always links to BGG (docs/integrations/BGG_ATTRIBUTION.md).
   The artwork is dark navy + orange, so in dark mode it sits on a white plate
   instead of being recoloured. */
.bgg-logo-link { display: inline-block; line-height: 0; }
.bgg-logo { height: auto; display: block; }
.list-attribution { padding: 20px 16px 24px; }
[data-theme="dark"] .bgg-logo { background: #fff; padding: 6px 10px; }

/* ── Detail overlay ─────────────────────────────────────────────────────── */

.detail {
  position: fixed; inset: 0; z-index: 20; background: var(--color-bg); overflow-y: auto;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
.detail-inner { max-width: 720px; margin: 0 auto; }
.detail-actions { display: flex; gap: 2px; }
.detail-bar {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: calc(4px + env(safe-area-inset-top)) 8px 4px; background: var(--color-bg); border-bottom: 2px solid var(--color-divider);
}
/* Full-width banner of fixed height: whole cover, bottom-left on the surface colour */
.detail-cover { height: 200px; }
.detail-cover.cover-ph { height: 200px; font-size: 72px; padding: 12px 16px; line-height: .8; justify-content: space-between; }
.detail-head { padding: 16px 16px 12px; }
.detail-head h2 { font-size: var(--text-title); margin-bottom: 4px; }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); }
.stat-strip > div { padding: 10px 8px 10px 12px; min-width: 0; }
.stat-strip > div:first-child { padding-left: 16px; }
.stat-strip > div + div { border-left: 2px solid var(--color-divider); }
.stat-strip .label { height: 16px; display: flex; align-items: center; color: var(--color-neutral-700); }
.stat-strip .label.star { color: var(--color-accent); }
.stat-strip .value { font-weight: 800; font-size: var(--text-body); white-space: nowrap; letter-spacing: -.01em; }

.play-row { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.play-row.right { flex-direction: row-reverse; }
.play-col { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.play-fab {
  /* DS exception: the only round element (see file header) */
  width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--color-accent); color: var(--color-on-accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  touch-action: pan-y; box-shadow: var(--shadow-md); transition: transform .2s;
  font-family: var(--font-heading); font-weight: 800; font-size: var(--text-meta); user-select: none; -webkit-user-select: none;
}
.play-fab:hover { background: var(--color-accent-600); }
.play-fab:active { background: var(--color-accent-700); }
.play-fab.dragging { transition: none; }
/* The play count opens the play history */
.play-count {
  font-size: var(--text-meta); font-weight: 800; white-space: nowrap; min-height: 32px; padding: 0 6px;
  background: transparent; border: 0; color: var(--color-accent-700); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; font-family: inherit;
}
.play-hint { font-size: var(--text-meta); color: var(--color-neutral-600); white-space: nowrap; text-align: center; line-height: 1.4; }
.tags-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.tags-col .head { font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

.kv { font-size: var(--text-body); border-top: 2px solid var(--color-divider); }
.kv > div, .kv > .kv-link { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.kv .k { color: var(--color-neutral-700); flex: none; }
.kv .v { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv > .kv-link {
  width: 100%; align-items: center; border: 0; background: none; color: var(--color-text);
  font: inherit; text-align: left; cursor: pointer;
}
.kv > .kv-link:hover { background: var(--color-surface); }
.kv .kv-link .v { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.kv .v.act { color: var(--color-accent-700); font-weight: 600; }

/* Location under the stats: pin, name, fit, Move (only when set) */
.loc-line {
  width: 100%; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 16px;
  border: 0; background: none; color: var(--color-text); font: inherit; text-align: left; cursor: pointer;
}
.loc-line:hover { background: var(--color-surface); }
.loc-line svg { flex: none; color: var(--color-neutral-700); }
.loc-line .name { font-weight: 600; white-space: nowrap; }
.loc-line .fit { min-width: 0; font-size: var(--text-meta); color: var(--color-neutral-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-line .move { margin-left: auto; font-weight: 600; color: var(--color-accent-700); }
/* Lent out: who has it, since when, Returned */
.lent-banner { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px; background: var(--color-accent-100); }
.lent-banner .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lent-banner strong { font-weight: 800; }
.lent-banner .sub { font-size: var(--text-meta); color: var(--color-neutral-700); }
.lent-banner .sub.overdue { color: var(--color-accent-700); font-weight: 600; }

.label-block { display: flex; gap: 14px; padding: 14px 16px; border-top: 2px solid var(--color-divider); align-items: center; }
.label-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.label-info .state { font-weight: 800; }
.label-info .btn { align-self: flex-start; margin-left: -6px; }
.qr-box { width: 84px; height: 84px; flex: none; background: #fff; padding: 6px; }
.qr-box canvas, .qr-box img { width: 72px !important; height: 72px !important; image-rendering: pixelated; }
.uid { font-size: var(--text-meta); color: var(--color-neutral-700); word-break: break-all; font-family: ui-monospace, Menlo, monospace; }

.more-block { border-top: 2px solid var(--color-divider); }
.more-block summary { list-style: none; cursor: pointer; padding: 12px 16px; min-height: 44px; font-weight: 600; font-size: var(--text-body); display: flex; justify-content: space-between; }
.more-block summary::-webkit-details-marker { display: none; }
.more-block[open] summary .chev { transform: rotate(180deg); }
.more-block .content { padding: 0 16px 16px; font-size: var(--text-body); display: flex; flex-direction: column; gap: 12px; }
.more-block .content .desc { color: var(--color-neutral-800); }

/* ── Play log and history sheets (spec 008) ─────────────────────────────── */

textarea.input { min-height: 64px; resize: vertical; line-height: 1.4; }
.field-error { font-size: var(--text-meta); color: var(--color-accent-700); font-weight: 600; }
.field-error:empty { display: none; }

.picked { display: flex; flex-direction: column; }
.picked > .muted { padding: 10px 0; }
.pchip { display: flex; align-items: center; gap: 4px; min-height: 44px; }
.pchip-name { flex: 1; min-width: 0; font-size: var(--text-body); overflow-wrap: anywhere; }
.pchip button {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 0; color: var(--color-neutral-600);
}
.pchip button:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); color: var(--color-text); }
.pchip-win[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); }
.pchip-win[aria-pressed="true"]:hover { background: var(--color-accent-600); color: var(--color-on-accent); }
.pchip.won .pchip-name { font-weight: 800; }

.recent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chips .chip { height: 44px; }

.player-search { display: flex; flex-direction: column; }
.suggest { display: flex; flex-direction: column; }
.suggest:not(:empty) { border: 1px solid var(--color-divider); border-top: 0; }
.suggest button {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; text-align: left; cursor: pointer;
  background: var(--color-bg); border: 0; color: var(--color-text); font: inherit; font-size: var(--text-body);
}
.suggest button:hover, .suggest button:focus-visible { background: var(--color-surface); }
.suggest button[data-new] { color: var(--color-accent-700); font-weight: 600; }

.stepper-row { display: flex; align-items: center; gap: 12px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--color-divider); }
.stepper output { min-width: 40px; text-align: center; font-weight: 800; font-size: var(--text-title); }

.ps-details { border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); margin: 0 -16px; }
.detail-row { display: grid; grid-template-columns: 1fr 88px auto auto; align-items: center; gap: 8px; }
.detail-name { min-width: 0; overflow-wrap: anywhere; }
.detail-row .score { min-height: 40px; }
.check.small { font-size: var(--text-meta); gap: 6px; min-height: 40px; }
.check.small input { width: 18px; height: 18px; }

.play-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--color-divider); }
.play-item { padding: 12px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.play-item-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: var(--text-body); }
.play-item-head .muted { font-size: var(--text-meta); }
.play-people { font-size: var(--text-body); line-height: 1.5; }
.play-people .pl.won { font-weight: 800; }
.play-people .pl svg { display: inline-block; vertical-align: -2px; margin-right: 3px; color: var(--color-accent); }
.play-notes { font-size: var(--text-body); color: var(--color-neutral-800); white-space: pre-line; overflow-wrap: anywhere; }
.play-actions { display: flex; gap: 4px; margin-left: -6px; }

/* ── Sheets (native <dialog>) ───────────────────────────────────────────── */

dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 720px; max-height: 88dvh;
  padding: 0; border: 0; border-top: 2px solid var(--color-text); background: var(--color-bg); color: var(--color-text);
  display: none; flex-direction: column;
}
dialog.sheet[open] { display: flex; }
dialog.sheet::backdrop { background: color-mix(in srgb, var(--color-scrim) 50%, transparent); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; border-bottom: 2px solid var(--color-divider); flex: none; }
.sheet-head h2 { font-size: var(--text-body); }
.sheet-body { padding: 16px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sheet-actions { display: flex; gap: 8px; }
/* A list of actions in a sheet (game page: More) */
.action-list { display: flex; flex-direction: column; padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); }
.action-list .action {
  display: flex; flex-direction: column; gap: 2px; min-height: 56px; padding: 10px 16px; border: 0; background: none;
  color: var(--color-text); font: inherit; text-align: left; cursor: pointer;
}
.action-list .action:hover { background: var(--color-surface); }
.action-list .action .t { font-weight: 600; }
.action-list .action .s { font-size: var(--text-meta); color: var(--color-neutral-700); }
.action-list .action.danger .t { color: var(--color-accent-700); }
.sheet-actions .btn { flex: 1; }
.sheet-actions .btn-primary { flex: 2; }

/* ── Measure sheet: box and shelf sizes from photos (spec 026) ───────────── */

.kv .box-btn { min-height: 0; padding: 0 4px; margin: -4px -4px -4px 0; font-weight: 800; text-align: right; }
.kv .box-btn small { font-weight: 400; }
.ms-hint { font-size: var(--text-body); }
.loc-pick { display: flex; flex-direction: column; margin: -16px -16px 0; }
.loc-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 10px 16px; border: 0; background: none; color: var(--color-text); font: inherit; text-align: left; cursor: pointer; }
.loc-opt:hover { background: var(--color-surface); }
.loc-opt[aria-pressed="true"] { box-shadow: inset 4px 0 0 var(--color-accent); font-weight: 800; }
.loc-opt-name { font-size: var(--text-body); }
.loc-opt-note { font-size: var(--text-meta); font-weight: 400; color: var(--color-neutral-700); }
.loc-fit.ok { color: var(--color-success); font-weight: 600; }
.loc-fit.no { color: var(--color-accent-700); font-weight: 600; }
[data-theme="dark"] .loc-fit.no { color: var(--color-accent-400); }
.ms-ref-field { gap: 4px; }
.ms-print, .loc-tools .btn { align-self: flex-start; margin-left: -6px; }
.loc-tools { padding: 4px 16px 0; display: flex; flex-direction: column; align-items: flex-start; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.about-row { border-top: 2px solid var(--color-divider); }
.about-row .v { display: inline-flex; align-items: center; gap: 4px; }
.place-hint { font-size: var(--text-body); }
.place-list { display: flex; flex-direction: column; margin: 0 -16px; }
.place-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.place-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.place-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-to::before { content: "→ "; }
.place-room, .place-none { font-size: var(--text-meta); color: var(--color-neutral-700); }
.mc-hint { font-size: var(--text-body); }
.mc-row { display: flex; gap: 8px; align-items: flex-end; }
.mc-row > .field, .mc-row > .input { flex: 1; min-width: 0; }
.mc-msg { font-size: var(--text-body); min-height: 1.4em; }
.ms-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-shot { position: relative; justify-content: center; gap: 6px; min-height: 52px; text-align: center; cursor: pointer; }
.ms-shot:focus-within { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.ms-photo { display: flex; flex-direction: column; gap: 8px; }
.ms-stage { position: relative; background: var(--color-surface); }
.ms-stage canvas { display: block; width: 100%; height: auto; }
.ms-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.ms-stage .ms-ref { fill: color-mix(in srgb, var(--color-accent-400) 18%, transparent); stroke: var(--color-accent-400); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-dasharray: 6 4; }
.ms-stage .ms-face { fill: color-mix(in srgb, var(--color-accent) 12%, transparent); stroke: var(--color-accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.ms-stage .ms-handle { fill: transparent; cursor: grab; }
.ms-stage .ms-dot { fill: #fff; stroke: var(--color-accent); stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.ms-stage .ms-tapdot { fill: var(--color-accent-400); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.ms-msg { font-size: var(--text-body); min-height: 1.4em; }
.ms-photo-actions { display: flex; justify-content: flex-start; margin-left: -6px; }
.ms-fields { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ms-fields legend { margin-bottom: 6px; }
.ms-num { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-meta); position: relative; }
.ms-num .input { width: 100%; padding-right: 32px; }
.ms-unit { position: absolute; right: 10px; bottom: 12px; font-size: var(--text-meta); color: var(--color-neutral-700); pointer-events: none; }
.ms-source { font-size: var(--text-meta); min-height: 1em; margin-top: -10px; }
.ms-keep { display: flex; gap: 8px; align-items: center; font-size: var(--text-body); }
.ms-error { color: var(--color-accent-700); font-size: var(--text-body); }
.ms-error:empty, .ms-source:empty { display: none; }
[data-theme="dark"] .ms-error { color: var(--color-accent-400); }

.add-scan { min-height: 72px; font-size: var(--text-body); justify-content: space-between; padding: 0 16px; }
.add-scan small { display: block; font-size: var(--text-meta); font-weight: 400; opacity: .9; }
.result-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.result-row .grow { flex: 1; min-width: 0; }
.result-row .t { font-weight: 600; font-size: var(--text-body); }
.result-row .s { font-size: var(--text-meta); color: var(--color-neutral-700); }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 12px; right: 12px; z-index: 50; max-width: 696px; margin: 0 auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--color-text); color: var(--color-bg); padding: 8px 8px 8px 14px; min-height: 44px;
  font-size: var(--text-body); box-shadow: var(--shadow-md); border-left: 4px solid var(--color-accent);
}
.toast.error { border-left-color: var(--color-accent-500); }
.toast button {
  background: none; border: 0; color: var(--color-accent-400); font-weight: 800; font-size: var(--text-body);
  min-height: 36px; padding: 0 8px; cursor: pointer;
}

/* ── Scan ───────────────────────────────────────────────────────────────── */

body.scan-screen { background: var(--color-scan-bg); color: var(--color-scan-fg); }
body.scan-screen .kicker { color: var(--color-scan-accent); }
.viewfinder { margin: 0 16px; position: relative; min-height: 300px; background: var(--color-scan-surface); overflow: hidden; }
.viewfinder #reader { width: 100%; border: 0 !important; }
.viewfinder #reader video { display: block; width: 100% !important; height: 300px !important; object-fit: cover; }
.viewfinder #reader img[alt="Info icon"], .viewfinder #reader__dashboard_section_csr span { display: none !important; }
.viewfinder .reticle { position: absolute; inset: 40px 36px; border: 2px solid var(--color-neutral-600); pointer-events: none; }
.viewfinder.read .reticle { border-color: var(--color-accent); }
.viewfinder .laser { position: absolute; left: 36px; right: 36px; top: 50%; height: 2px; background: var(--color-accent); opacity: .5; pointer-events: none; }
.viewfinder.read .laser { opacity: 0; }
.viewfinder .vf-hint { position: absolute; left: 12px; bottom: 10px; font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-500); pointer-events: none; }
.viewfinder .vf-idle { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.scan-tools { display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px 16px 0; border: 1px solid var(--color-scan-line); }
.scan-tools button { height: 44px; border: 0; background: transparent; color: var(--color-scan-fg); font-size: var(--text-meta); cursor: pointer; text-align: left; padding: 0 12px; }
.scan-tools button + button { border-left: 1px solid var(--color-scan-line); }
.scan-tools button:hover { background: rgba(255, 255, 255, .06); }
.scan-manual { display: flex; margin: 8px 16px 0; }
.scan-manual .input { background: transparent; color: var(--color-scan-fg); border-color: var(--color-scan-line); }
.scan-manual .btn { border: 1px solid var(--color-scan-line); color: var(--color-scan-fg); }
.scan-status { margin: 12px 16px 0; font-size: var(--text-body); min-height: 20px; }

/* Sort back (spec 024): scan a location, then the games put there */
.sort-back { margin: 8px 16px 0; }
.scan-add { margin: 16px 16px 0; display: flex; flex-direction: column; gap: 8px; }
/* Buttons and the search field on the always-dark scan screen */
.scan-add .btn:not(.btn-primary) { color: var(--color-scan-fg); border: 1px solid var(--color-scan-line); background: transparent; }
.scan-add .btn:not(.btn-primary):hover { background: rgb(255 255 255 / .06); }
.scan-add .input { background: transparent; color: var(--color-scan-fg); border-color: var(--color-scan-line); }
.scan-add-hint { margin: 0; font-size: var(--text-meta); color: var(--color-neutral-500); }
.scan-add-search { display: flex; gap: 8px; }
.scan-add-search .input { flex: 1; min-width: 0; }
.scan-add .result-row .s { color: inherit; opacity: .7; }
.scan-add .muted { font-size: var(--text-meta); }
.scan-add .bgg-logo-link { align-self: flex-start; }
.scan-add .bgg-logo { background: #fff; padding: 6px 10px; } /* the scan screen is dark in both themes */
.sort-back .sb-toggle { width: 100%; min-height: 44px; border: 1px solid var(--color-scan-line); color: var(--color-scan-fg); background: transparent; }
.sb-banner { display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--color-scan-accent); padding: 10px 12px; color: var(--color-scan-fg); }
.sb-where { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sb-label { font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-400); }
.sb-target { font-size: var(--text-body); font-weight: 800; overflow-wrap: anywhere; }
.sb-count { font-size: var(--text-meta); color: var(--color-neutral-400); }
.sb-actions { display: flex; gap: 8px; }
.sb-actions .btn { flex: 1; min-height: 44px; }
.sb-actions .btn:not(.btn-primary) { border: 1px solid var(--color-scan-line); color: var(--color-scan-fg); background: transparent; }
.result-card.sb-card.ok { border-left: 4px solid var(--color-scan-accent); }
.result-card.sb-card.warn .rc-title { color: var(--color-accent-700); }
.sb-summary, .sb-games { list-style: none; margin: 0; padding: 0 14px 12px; display: grid; gap: 6px; font-size: var(--text-body); }
.sb-summary .num { font-weight: 800; }
.sb-games a { color: inherit; }
.sb-picker-list { gap: 8px; }
.sb-picker-list .btn[aria-pressed="true"] { border-color: var(--color-accent); }

.result-card { margin: 16px; background: var(--color-bg); color: var(--color-text); display: flex; flex-direction: column; }
[data-theme="dark"] .result-card { background: var(--color-surface); }
.result-card .rc-head { padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.result-card .rc-head .cover { width: 56px; height: 56px; flex: none; }
.result-card .rc-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result-card .rc-kicker { font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; color: var(--color-accent-700); }
.result-card .rc-title { font-weight: 800; font-size: var(--text-body); line-height: 1.15; overflow-wrap: anywhere; }
.result-card .rc-sub { font-size: var(--text-meta); color: var(--color-neutral-700); overflow-wrap: anywhere; }
.result-card .rc-note { padding: 0 14px 12px; font-size: var(--text-meta); color: var(--color-accent-700); }
.result-card .cand {
  display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; min-height: 52px; border: 0;
  background: transparent; text-align: left; font-size: var(--text-body); cursor: pointer; color: var(--color-text);
}
.result-card .cand:hover { background: var(--color-accent-100); }
.result-card .cand img { width: 36px; height: 36px; object-fit: contain; object-position: left bottom; background: var(--color-surface); flex: none; }
.result-card .cand small { display: block; color: var(--color-neutral-700); font-size: var(--text-meta); }
.result-card .rc-actions { display: grid; grid-template-columns: 1fr 1.4fr; border-top: 2px solid var(--color-divider); }
.result-card .rc-actions .btn { min-height: 48px; border: 0; }
.result-card .rc-actions .btn-secondary { border-right: 2px solid var(--color-divider); }
.result-card .rc-more { display: flex; flex-direction: column; border-top: 2px solid var(--color-divider); }
.result-card .rc-more .btn { border: 0; min-height: 44px; }
.result-card .assign { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.result-card .assign-list { max-height: 240px; overflow-y: auto; }
.result-card .assign-list button { display: block; width: 100%; min-height: 44px; text-align: left; border: 0; background: none; color: var(--color-text); cursor: pointer; font-size: var(--text-body); }

/* ── Labels ─────────────────────────────────────────────────────────────── */

.format-body { overflow-y: auto; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.format-body .more-block { margin-top: 12px; }
.format-done { padding: 16px 16px 0; }
.format-body .sheet-format-row { flex-wrap: wrap; row-gap: 6px; }
.format-body .sheet-format-row > label { flex: 1 0 100%; }
.format-body .sheet-format-row > .btn-ghost:first-child { margin-left: -6px; }
.sheet-format-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.sheet-format-row select { flex: 1; min-width: 0; }
.cat-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; overflow-wrap: anywhere; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-row img { width: 72px; height: 72px; object-fit: contain; background: #fff; border: 1px solid var(--color-divider); }
.label-preview { padding: 12px 16px 0; }
.label-preview canvas { display: block; max-width: 100%; background: #fff; box-shadow: var(--shadow-md); }
.label-preview .muted { font-size: var(--text-meta); margin-top: 6px; }
.sheet-preview-row { display: flex; gap: 16px; padding: 12px 16px 14px; }
.sheet-preview {
  width: 150px; flex: none; aspect-ratio: 210 / 297; background: #fff; box-shadow: var(--shadow-md); padding: 7px;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(6, 1fr); gap: 3px;
}
/* A miniature of the paper: fixed paper colours in both themes, blocks without text */
.sheet-preview button { border: 1px dashed #bab6b6; background: transparent; padding: 0; cursor: pointer; min-width: 0; }
.sheet-preview button.used { border-style: solid; background: #d7d3d3; }
.sheet-preview button.fill { border: 1px solid #ec3013; background: #fff2ef; }
.sheet-preview button[aria-current="true"] { box-shadow: inset 0 0 0 2px #ec3013; }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--color-divider); height: 44px; }
.stepper button { width: 44px; border: 0; background: none; font-size: var(--text-body); cursor: pointer; color: var(--color-text); }
.stepper output { flex: 1; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--text-title); }
.label-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; }
/* Games | Locations (spec 024) */
.label-mode { margin: 12px 16px; }
.label-mode button { text-align: center; }
.label-row {
  width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px 16px; min-height: 52px;
  background: none; border: 0; text-align: left; cursor: pointer; color: var(--color-text);
}
.vl .label-row { height: 60px; min-height: 0; box-sizing: border-box; contain: layout paint style; }
.label-row .cb {
  width: 20px; height: 20px; flex: none; border: 2px solid var(--color-divider); color: var(--color-on-accent);
  display: flex; align-items: center; justify-content: center;
}
.label-row .cb svg { visibility: hidden; }
.label-row[aria-checked="true"] .cb { border-color: var(--color-accent); background: var(--color-accent); }
.label-row[aria-checked="true"] .cb svg { visibility: visible; }
.label-row .grow { flex: 1; min-width: 0; }
.label-row .t { display: block; font-weight: 600; font-size: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-row .s { display: block; font-size: var(--text-meta); color: var(--color-neutral-700); }
.label-row .pos { font-size: var(--text-meta); font-weight: 600; color: var(--color-accent-700); }
.label-footer {
  position: fixed; left: 0; right: 0; z-index: 25; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: var(--color-bg); border-top: 2px solid var(--color-divider);
}
.label-footer-inner { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 12px; align-items: center; }
.label-footer .sum { flex: 1; font-size: var(--text-meta); line-height: 1.3; }
body.has-label-footer .app-main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 90px); }

/* ── Profile ────────────────────────────────────────────────────────────── */

.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); margin-top: 16px; }
.stat3 > div { padding: 14px 16px; }
.stat3 > div + div { border-left: 2px solid var(--color-divider); }
.stat3 .n { font-weight: 800; font-size: var(--text-title); }
.stat3 .l { font-size: var(--text-meta); color: var(--color-neutral-700); }
.section { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.section + .section { border-top: 2px solid var(--color-divider); }
.section h2 { font-size: var(--text-body); }
/* A heading styled as an eyebrow keeps the eyebrow look (not the heading weight) */
h2.eyebrow, h3.eyebrow, .section h2.eyebrow { font-family: var(--font-body); font-size: var(--text-meta); font-weight: 400; line-height: 1.55; }
.rows { }
.rows > * {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 0 16px; border: 0;
  background: none; color: var(--color-text); font-size: var(--text-body); text-align: left; text-decoration: none; cursor: pointer;
}
.rows > a:hover, .rows > button:hover { background: var(--color-surface); }
.rows .v { color: var(--color-neutral-700); font-size: var(--text-meta); white-space: nowrap; }
.rows > .loc-row { justify-content: flex-start; gap: 4px; padding: 0 4px 0 16px; cursor: default; }
.rows > .muted { cursor: default; font-size: var(--text-meta); }
.loc-row .name { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 6px 0; }
.loc-row .loc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-row .loc-size { align-self: flex-start; max-width: 100%; border: 0; background: none; padding: 2px 0; margin: 0; font: inherit; font-size: var(--text-meta); color: var(--color-accent-700); text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-row .loc-size:hover { text-decoration: underline; }
[data-theme="dark"] .loc-row .loc-size { color: var(--color-accent-400); }
.loc-fill { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--text-meta); color: var(--color-neutral-700); }
.loc-fill .bar { width: 72px; height: 6px; background: var(--color-neutral-300); display: inline-block; }
.loc-fill .bar > span { display: block; height: 100%; background: var(--color-text); }
.loc-fill.over .bar > span { background: var(--color-accent); }
.loc-misfits { font-size: var(--text-meta); }
.loc-misfits summary { cursor: pointer; color: var(--color-accent-700); }
[data-theme="dark"] .loc-misfits summary { color: var(--color-accent-400); }
.loc-misfits ul { margin: 4px 0 0; padding-left: 18px; }
.loc-row .cnt { margin-right: 4px; white-space: nowrap; }
.loc-row .cnt { font-size: var(--text-meta); color: var(--color-neutral-700); }
.loc-add { display: flex; gap: 8px; padding: 12px 16px; }

/* ── Footer (shared footer.html on migrated pages) ─────────────────────── */

.app-main .footer { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 16px; font-size: var(--text-meta); color: var(--color-neutral-700); border-top: 2px solid var(--color-divider); }
.app-main .footer img { width: 150px; }
.app-main .footer img { height: auto; }
[data-theme="dark"] .app-main .footer img { background: #fff; padding: 2px 6px; }
.app-main .footer a { color: var(--color-neutral-700); }

/* ── Small fixes ────────────────────────────────────────────────────────── */
.scan-tools button:disabled { color: var(--color-neutral-600); cursor: not-allowed; }
[data-theme="dark"] .scan-tools button:disabled { color: var(--color-neutral-400); }
.scan-manual .btn { white-space: nowrap; }
/* Profile and About show the large logo themselves; the footer keeps only the text */
.app-main .footer.no-logo .bgg-logo-link { display: none; }

/* ── Auth (login) ───────────────────────────────────────────────────────── */

body.auth { min-height: 100vh; min-height: 100dvh; }
.auth .app-main { max-width: 440px; padding-bottom: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.auth-brand {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3);
  padding: calc(var(--space-6) + env(safe-area-inset-top)) var(--space-4) var(--space-4);
  border-bottom: 2px solid var(--color-divider);
}
.auth-mark { font-family: var(--font-heading); font-weight: 800; font-size: 64px; line-height: .85; letter-spacing: -0.04em; }
.auth-mark span { color: var(--color-accent); }
.auth-brand .eyebrow { text-align: right; max-width: 9em; }
.auth-body { padding: var(--space-6) var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }
.auth-body h1 { font-size: var(--text-title); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-alt { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); border-top: 2px solid var(--color-divider); font-size: var(--text-body); }
.auth .app-main > #footer-container { margin-top: auto; }

/* Inline status notice (form feedback) */
.notice { padding: 10px 14px; font-size: var(--text-body); background: var(--color-surface); border-left: 4px solid var(--color-neutral-500); }
.notice.success { border-left-color: var(--color-text); }
.notice.error { border-left-color: var(--color-accent); background: var(--color-accent-100); color: var(--color-accent-900); }
.notice.loading { border-left-color: var(--color-neutral-500); }

/* ══ Tablet and desktop ("BGI Wide", spec 022) ═════════════════════════════
   Breakpoints: phone < 768px (above), tablet 768–1279px, desktop ≥ 1280px.
   Everything below only adds to the phone layout. */

.rail-brand { display: none; }

@media (min-width: 768px) {
  /* The tab bar becomes a side menu; nothing is offset by a bottom bar any more */
  :root { --tabbar-h: 0px; --rail-w: 72px; }
  body.app { padding-left: var(--rail-w); }
  .tabbar {
    top: 0; bottom: 0; right: auto; width: var(--rail-w);
    border-top: 0; border-right: 2px solid var(--color-divider); padding-bottom: 0;
  }
  .tabbar-inner { max-width: none; height: 100%; display: flex; flex-direction: column; }
  .rail-brand {
    display: flex; align-items: center; justify-content: center; height: 64px; flex: none;
    font-family: var(--font-heading); font-weight: 800; font-size: 18px; letter-spacing: -.02em;
    border-bottom: 2px solid var(--color-divider);
  }
  .tabbar a { height: 64px; align-items: center; padding: 0; position: relative; }
  .tabbar a .tab-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tabbar a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--color-accent); }
  .app-main { padding-bottom: var(--space-8); }
  .toast { left: calc(var(--rail-w) + 12px); bottom: 16px; }
  .label-footer { left: var(--rail-w); }
}

@media (min-width: 1280px) {
  :root { --rail-w: 208px; }
  .rail-brand { justify-content: flex-start; padding: 0 20px; font-size: 22px; }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 20px; font-size: var(--text-body); height: 52px; }
  .tabbar a .tab-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

/* ── Collection on tablet and desktop (spec 022) ─────────────────────────── */

.facets, .wedge, .viewswitch .wide-only, .play-bar, .detail-backdrop { display: none; }
body.detail-open { overflow: hidden; }

/* The open game, visible next to the docked detail */
#games-list [aria-current="true"] { box-shadow: inset 4px 0 0 var(--color-accent); }

@media (min-width: 768px) {
  .collection-main { max-width: none; margin: 0; }
  .viewswitch .wide-only { display: flex; }
  .wedge { display: flex; position: relative; flex: 1; max-width: 340px; margin-left: auto; align-self: center; }
  .wedge svg { position: absolute; left: 12px; top: 13px; opacity: .55; pointer-events: none; }
  .wedge .input { padding-left: 38px; }
  .screen-head { align-items: center; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }

  /* Table view */
  .table-wrap { overflow-x: auto; }
  .gtable { width: 100%; border-collapse: collapse; font-size: var(--text-body); }
  .gtable th {
    height: 40px; padding: 0 8px; text-align: left; white-space: nowrap; vertical-align: middle;
    font-size: var(--text-meta); font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--color-neutral-700); border-bottom: 2px solid var(--color-divider);
  }
  .gtable th[aria-sort="ascending"], .gtable th[aria-sort="descending"] { color: var(--color-text); }
  .th-sort {
    display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0; cursor: pointer;
    background: none; border: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit;
  }
  .gtable th[aria-sort="ascending"] .th-sort svg { transform: rotate(180deg); }
  .gtable td { height: 44px; padding: 0 8px; white-space: nowrap; }
  .gtable .c-num { text-align: right; }
  .gtable th.c-num .th-sort { flex-direction: row-reverse; }
  .gtable td.c-title { font-weight: 600; white-space: normal; min-width: 160px; }
  .gtable .c-tick { width: 44px; padding: 0 0 0 16px; }
  .gtable .c-tick input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); cursor: pointer; }
  .gtable .c-loc { max-width: 160px; overflow: hidden; text-overflow: ellipsis; color: var(--color-neutral-800); }
  .gtable tbody tr { cursor: pointer; }
  .gtable tbody tr:hover { background: var(--color-surface); }
  .gtable tbody tr:focus-visible { outline-offset: -2px; }

  .bulk-bar {
    position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; background: var(--color-text); color: var(--color-bg);
  }
  .bulk-bar strong { flex: 1; font-size: var(--text-body); }
  .bulk-bar .btn-secondary { border-color: color-mix(in srgb, var(--color-bg) 50%, transparent); color: var(--color-bg); }
}

/* Tablet: the detail slides over the list; Play is a bar along the bottom */
@media (min-width: 768px) and (max-width: 1279.98px) {
  .detail {
    left: auto; width: min(560px, 80vw); padding-bottom: 0;
    border-left: 2px solid var(--color-text); box-shadow: var(--shadow-lg);
  }
  .detail-backdrop:not(.hidden) {
    display: block; position: fixed; inset: 0; z-index: 19;
    background: color-mix(in srgb, var(--color-scrim) 45%, transparent);
  }
  .play-row .play-col { display: none; }
  .play-bar {
    display: flex; align-items: center; gap: 8px; position: sticky; bottom: 0; z-index: 2;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--color-bg);
    border-top: 2px solid var(--color-divider); order: 99;
  }
  .play-bar #play-bar-log { flex: 1; justify-content: center; }
  .detail-inner { display: flex; flex-direction: column; min-height: calc(100% - 52px); }
}

/* Desktop: filter column, detail docked on the right */
@media (min-width: 1280px) {
  .collection-main {
    display: grid; grid-template-columns: 248px minmax(0, 1fr); align-items: start;
  }
  .collection-main > * { grid-column: 2; min-width: 0; }
  .collection-main > .facets {
    display: block; grid-column: 1; grid-row: 1 / span 20; position: sticky; top: 0;
    min-height: 100vh; max-height: 100vh; overflow-y: auto; padding: 16px 16px 32px; border-right: 2px solid var(--color-divider);
  }
  .collection-main #chips { display: none; }
  body.detail-open { overflow: visible; }
  body.detail-open .collection-main { padding-right: 440px; }
  /* Less room next to the docked detail: drop the two least-used columns */
  body.detail-open .gtable .c-loc { display: none; }
  .detail { left: auto; width: 440px; z-index: 10; padding-bottom: 32px; border-left: 2px solid var(--color-divider); }

  .facets-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
  .facets-head h2 { font-size: var(--text-body); }
  .facet-group { display: flex; flex-direction: column; margin-top: 16px; }
  .facet-group .eyebrow { margin-bottom: 4px; }
  .facet {
    display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px;
    border: 0; background: none; color: var(--color-text); cursor: pointer; font: inherit; font-size: var(--text-body); text-align: left;
  }
  .facet:hover { background: var(--color-surface); }
  .facet .facet-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .facet .n { font-size: var(--text-meta); color: var(--color-neutral-700); }
  .facet[data-empty] { color: var(--color-neutral-600); }
  .facet[aria-pressed="true"] { background: var(--color-accent); color: var(--color-on-accent); }
  .facet[aria-pressed="true"] .n { color: var(--color-on-accent); }
}

/* ── Labels on a desktop: sheet on the left, checklist on the right (spec 022) ── */
@media (min-width: 1280px) {
  .labels-main {
    max-width: 1120px; display: grid; column-gap: 24px; align-items: start;
    grid-template-columns: 380px minmax(0, 1fr);
    grid-template-areas: "head head" "sheet mode" "sheet tools" "sheet list" "sheet empty";
  }
  .labels-main > .screen-head { grid-area: head; }
  .labels-main > .label-mode { grid-area: mode; margin: 0 0 12px; }
  .labels-main > .sheet-preview-row { grid-area: sheet; position: sticky; top: 16px; }
  .labels-main > .rule { display: none; }
  .labels-main > .label-toolbar { grid-area: tools; border-bottom: 2px solid var(--color-divider); }
  .labels-main > #label-list { grid-area: list; }
  .labels-main > #empty-state { grid-area: empty; }
  .label-footer-inner { max-width: 1120px; }
}

/* ── Utility pages: about, admin, import, create/edit (#92) ─────────────── */

.page-intro { padding: 4px var(--space-4) 0; font-size: var(--text-body); color: var(--color-neutral-700); margin: 0; }
.data-table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-body); }
.data-table th {
  text-align: left; font-size: var(--text-meta); font-weight: 400; letter-spacing: .08em; text-transform: uppercase;
  color: var(--color-neutral-700); padding: 8px 10px 8px 0; border-bottom: 2px solid var(--color-divider);
}
.data-table td { text-align: left; vertical-align: top; padding: 10px 10px 10px 0; }
.data-table td small { display: block; margin-top: 2px; color: var(--color-neutral-700); font-size: var(--text-meta); }
/* Developer section (spec 032): a p95 over the budget is marked with the accent; never colour alone, the Budget column has the number */
.dev-over td:nth-child(4) { color: var(--color-accent); font-weight: 800; }
.data-table .mono, .mono { font-family: ui-monospace, Menlo, monospace; font-size: var(--text-meta); }
.service { padding: 12px 0; }
.service h3 { font-size: var(--text-body); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.install-h3 { font-size: var(--text-body); margin-top: 8px; }
.install-steps { margin: 0; padding-left: 22px; font-size: var(--text-body); display: flex; flex-direction: column; gap: 4px; }
.service ul { margin: 6px 0 0; padding-left: 18px; font-size: var(--text-meta); color: var(--color-neutral-700); overflow-wrap: anywhere; }
.tag-ok { background: var(--color-neutral-100); color: var(--color-text); border-left: 3px solid var(--color-text); }
.tag-bad { background: var(--color-accent-100); color: var(--color-accent-800); border-left: 3px solid var(--color-accent); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field .hint { font-size: var(--text-meta); color: var(--color-neutral-700); }
.progress { height: 6px; background: var(--color-neutral-300); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width .2s; }
.log {
  max-height: 260px; overflow-y: auto; font-family: ui-monospace, Menlo, monospace; font-size: var(--text-meta);
  background: var(--color-surface); padding: 8px 10px; border-left: 2px solid var(--color-divider); white-space: pre-wrap;
}
fieldset.group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
fieldset.group > legend { padding: 0; margin-bottom: 4px; font-family: var(--font-heading); font-weight: 800; font-size: var(--text-body); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
textarea.input { min-height: 96px; resize: vertical; }
.notice.warning { border-left-color: var(--color-accent-400); }
.notice p { margin: 0 0 4px; }
.notice p:last-child { margin-bottom: 0; }

/* Missing-metadata dialog built in bgg-api.js (shown during BGG imports) */
.md-backdrop {
  position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: color-mix(in srgb, var(--color-scrim) 60%, transparent);
}
.md-dialog {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--color-bg); color: var(--color-text); border-top: 2px solid var(--color-text);
  box-shadow: var(--shadow-lg); padding: 20px 16px;
}
.md-title { font-size: var(--text-title); margin-bottom: 8px; }
.md-body { margin: 0 0 12px; font-size: var(--text-body); line-height: 1.6; }
.md-question { margin: 0 0 12px; font-weight: 600; font-size: var(--text-body); }
.md-actions, .md-form { display: flex; flex-direction: column; gap: 8px; }
.md-form .field { font-size: var(--text-body); }
.md-note { margin: 0; font-size: var(--text-meta); color: var(--color-neutral-700); }
.md-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.md-form-actions .btn-primary { flex: 1; }

/* Create / edit game (create-game.html) */
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.input-row .btn { white-space: nowrap; }
.field .required { color: var(--color-accent-700); }
/* One row of equal options (edit game: condition, language dependence) */
.seg-grid.seg-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); }
.seg-grid.seg-row button { min-width: 44px; padding: 0 8px; white-space: nowrap; }
@media (max-width: 360px) { .seg-grid.seg-row button { padding: 0 4px; } }
.bgg-search-results { border-top: 2px solid var(--color-divider); max-height: 320px; overflow-y: auto; }
.bgg-result-item { padding: 10px 0; min-height: 44px; cursor: pointer; }
.bgg-result-item:hover { background: var(--color-surface); }
.bgg-result-title { font-weight: 600; font-size: var(--text-body); }
.bgg-result-meta { display: flex; gap: 12px; font-size: var(--text-meta); color: var(--color-neutral-700); }
.image-crop-area { background: var(--color-surface); padding: 8px; }
#crop_canvas { display: block; max-width: 100%; height: auto; }
.crop-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
@media (min-width: 560px) { .crop-controls { grid-template-columns: repeat(4, 1fr); } }
.image-previews { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; align-items: end; }
.preview-label { font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-700); margin-bottom: 4px; }
.preview-item img { width: 100%; height: auto; background: var(--color-surface); }
.edit-bar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(4px + env(safe-area-inset-top)) 8px 4px; background: var(--color-bg); border-bottom: 2px solid var(--color-divider);
}
.edit-bar h1 { font-size: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar .btn-primary { justify-self: end; min-height: 40px; }
.edit-bar #edit-cancel { justify-self: start; }
.edit-bar + .page-intro { padding-top: 12px; }

/* BGG collection sync review (spec 021, profile.html via bgg-sync-ui.js) */
.sync-actions { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 2px solid var(--color-divider); flex: none; }
.sync-group { display: flex; flex-direction: column; }
.sync-group h3 { font-size: var(--text-body); margin-bottom: 2px; }
.sync-group > p { margin: 0 0 6px; font-size: var(--text-meta); }
.sync-row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0;
  cursor: pointer;
}
.sync-row input { accent-color: var(--color-accent); width: 20px; height: 20px; margin: 0; flex: none; }
.sync-row .grow { flex: 1; min-width: 0; }
.sync-row .t { display: block; font-weight: 600; font-size: var(--text-body); overflow-wrap: anywhere; }
.sync-row .s { display: block; font-size: var(--text-meta); color: var(--color-neutral-700); }
.sync-remove-label { font-size: var(--text-meta); color: var(--color-accent-700); font-weight: 600; }
.sync-row input:not(:checked) ~ .sync-remove-label { color: var(--color-neutral-600); font-weight: 400; }

/* ── Five tabs on a narrow phone (spec 030) ─────────────────────────────── */

@media (max-width: 420px) {
  .tabbar a { padding: 0 8px; }
  .tabbar a .tab-label { display: flex; flex-direction: column; line-height: 1.1; }
  .tabbar a [data-labels-badge] { font-size: var(--text-meta); }
}

/* ── Statistics (spec 030) ──────────────────────────────────────────────── */

/* Categorical series in fixed order (validated with the dataviz palette
   checker against --color-bg and --color-surface); other = neutral */
:root {
  --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
  --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #4a3aa7; --chart-8: #e34948;
  --chart-other: var(--color-neutral-500);
  --chart-single: var(--color-accent-600);
}
[data-theme="dark"] {
  --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
  --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
  --chart-single: var(--color-accent);
}

/* A strip of three, as designed: 2px rule on top, 2px between cells, a rule above each next row */
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(min-content, 1fr)); border-top: 2px solid var(--color-divider); margin-top: 16px; }
.stat-tiles > div { padding: 12px 8px 12px 16px; min-width: 0; }
.stat-tiles > div:not(:nth-child(3n + 1)) { border-left: 2px solid var(--color-divider); }
.stat-tiles > div:nth-child(n + 4) { border-top: 2px solid var(--color-divider); }
.stat-tiles .n { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: var(--text-title); line-height: 1.1; }
.stat-tiles .l { font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.figures { display: flex; gap: 8px 24px; flex-wrap: wrap; }
.figures .n { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: var(--text-title); line-height: 1.1; }
.figures .l { font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.stats-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; align-items: center; }
.stats-filters select, .stats-filters input { min-height: 44px; }
.stats-head-note { padding: 0 16px; font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 70%, transparent); }

.stats-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.chart-card { padding: 16px; border-top: 2px solid var(--color-divider); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart-card h2, .chart-card h3 { font-size: var(--text-body); }
.chart-card .takeaway { font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 75%, transparent); }
.chart-card .chart-body { min-height: 40px; }
.chart-card .note { font-size: var(--text-meta); color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.chart-card .card-tools { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chart-card .card-tools .btn { min-height: 44px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chart-table { border-collapse: collapse; width: 100%; font-size: var(--text-meta); }
.chart-table th, .chart-table td { text-align: left; padding: 4px 8px 4px 0; }
.chart-table td { font-variant-numeric: tabular-nums; }
.stats-section-title { padding: 16px 16px 4px; border-top: 2px solid var(--color-divider); }
.stats-section-title h2 { font-size: var(--text-meta); font-weight: 400; letter-spacing: .1em; text-transform: uppercase; color: var(--color-accent-700); }

.hero-h { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 48px; line-height: 1; }
.h-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

svg.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
svg.chart .grid { stroke: var(--color-divider); stroke-width: 1; opacity: .45; }
svg.chart .baseline { stroke: var(--color-divider); stroke-width: 1; }
svg.chart .axis-text { fill: color-mix(in srgb, var(--color-text) 70%, transparent); font-size: var(--text-meta); font-family: var(--font-body); }
svg.chart .value-text { fill: var(--color-text); font-size: var(--text-meta); font-weight: 600; font-family: var(--font-body); }
svg.chart .hero-text { fill: var(--color-text); font-size: var(--text-title); font-weight: 800; font-family: var(--font-heading); }
svg.chart .mark { fill: var(--chart-single); }
svg.chart .track { fill: color-mix(in srgb, var(--color-text) 12%, transparent); }
svg.chart .line { fill: none; stroke: var(--chart-single); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--chart-single); opacity: .1; }
svg.chart .dot { fill: var(--chart-single); stroke: var(--color-bg); stroke-width: 2; }
svg.chart .slice { fill: none; stroke-width: 22; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit[data-i] { cursor: pointer; }
svg.chart .hit:focus-visible { outline: 2px solid var(--color-text); outline-offset: -2px; }
svg.chart .hit[data-i]:hover { fill: color-mix(in srgb, var(--color-text) 6%, transparent); }
svg.chart .c-1 { stroke: var(--chart-1); fill: var(--chart-1); } svg.chart .c-2 { stroke: var(--chart-2); fill: var(--chart-2); }
svg.chart .c-3 { stroke: var(--chart-3); fill: var(--chart-3); } svg.chart .c-4 { stroke: var(--chart-4); fill: var(--chart-4); }
svg.chart .c-5 { stroke: var(--chart-5); fill: var(--chart-5); } svg.chart .c-6 { stroke: var(--chart-6); fill: var(--chart-6); }
svg.chart .c-7 { stroke: var(--chart-7); fill: var(--chart-7); } svg.chart .c-8 { stroke: var(--chart-8); fill: var(--chart-8); }
svg.chart .c-other { stroke: var(--chart-other); fill: var(--chart-other); }
svg.chart .slice.c-1, svg.chart .slice.c-2, svg.chart .slice.c-3, svg.chart .slice.c-4, svg.chart .slice.c-5,
svg.chart .slice.c-6, svg.chart .slice.c-7, svg.chart .slice.c-8, svg.chart .slice.c-other { fill: none; }
svg.chart .swatch { stroke: none; }

/* First-load splash (startup screen): <html class="booting"> is set inline in each page's head, which
   paints the red ground at once; theme.js adds the content (.boot-splash) and clears it (bgiBootDone).
   Red in both themes. Decorative sizes: the 120px wordmark and the 20px tagline. */
html.booting::before { content: ''; position: fixed; inset: 0; z-index: 9998; background: var(--color-splash); }
.boot-splash {
  position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(56px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
  background: var(--color-splash); color: #fff; cursor: pointer; font-family: var(--font-heading);
}
.boot-splash .bs-eyebrow { border-top: 2px solid #fff; padding-top: 12px; font-size: var(--text-meta); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.boot-splash .bs-middle { display: flex; flex-direction: column; gap: 24px; }
.boot-splash .bs-mark { font-weight: 800; font-size: 120px; line-height: .85; letter-spacing: -.04em; }
.boot-splash .bs-tagline { font-size: 20px; font-weight: 600; line-height: 1.25; max-width: 16em; text-wrap: pretty; }
.boot-splash .bs-foot { display: flex; flex-direction: column; gap: 10px; }
.boot-splash .bs-strip { position: relative; height: 2px; overflow: hidden; background: rgb(255 255 255 / .35); }
.boot-splash .bs-strip::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: #fff;
  animation: boot-strip 1.4s cubic-bezier(.6, 0, .4, 1) infinite;
}
.boot-splash .bs-msg { font-size: var(--text-meta); }
@keyframes boot-strip { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
html.boot-leaving::before, html.boot-leaving .boot-splash { opacity: 0; transition: opacity .2s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid color-mix(in srgb, var(--color-text) 15%, transparent); border-top-color: var(--color-accent); border-radius: 50%; animation: spin .8s linear infinite; }
.list-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px 16px; }

.skeleton-card { height: 180px; margin: 16px; background: linear-gradient(90deg, color-mix(in srgb, var(--color-text) 6%, transparent), color-mix(in srgb, var(--color-text) 12%, transparent), color-mix(in srgb, var(--color-text) 6%, transparent)); background-size: 200% 100%; animation: skeleton 1.4s linear infinite; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-card { animation: none; } }

.games-sheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.games-sheet-list li a { display: flex; gap: 12px; align-items: center; padding: 8px 0; text-decoration: none; color: var(--color-text); min-height: 52px; }
.games-sheet-list img, .games-sheet-list .thumb-fallback { width: 40px; height: 40px; object-fit: cover; flex: none; background: var(--color-surface); }
.games-sheet-list .v { margin-left: auto; font-variant-numeric: tabular-nums; font-size: var(--text-meta); }
.explain p { margin: 0 0 8px; }
.explain ul { margin: 0 0 12px; padding-left: 20px; }

@media (min-width: 768px) {
  .stat-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stat-tiles > div:nth-child(n) { border-top: 0; border-left: 2px solid var(--color-divider); }
  .stat-tiles > div:first-child { border-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid .chart-card { border-left: 2px solid var(--color-divider); }
  .stats-grid .chart-card:nth-child(odd) { border-left: 0; }
  .stats-grid .chart-card.wide { grid-column: 1 / -1; border-left: 0; }
}
@media (min-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid .chart-card:nth-child(odd) { border-left: 2px solid var(--color-divider); }
  .stats-grid .chart-card:nth-child(3n + 1) { border-left: 0; }
}

/* Wide screens: the statistics use the room (the other pages cap their column) */
@media (min-width: 1280px) {
  .stats-main { max-width: 1280px; }
}

/* ── Friends and lending (spec 031, friends.html, lend-sheet.js) ───────── */

.friends-main .screen-head { gap: 12px; margin-bottom: 12px; }
.friends-note { margin: 0 16px 8px; padding: 8px 12px; font-size: var(--text-meta); background: var(--color-surface); border-left: 4px solid var(--color-accent); }
.friends-search { position: relative; padding: 0 16px 12px; }
.friends-search .input { padding-left: 40px; }
.friends-search > svg { position: absolute; left: 28px; top: 13px; color: var(--color-neutral-700); pointer-events: none; }
.friends-main > .section[aria-labelledby="friends-h"] { border-top: 2px solid var(--color-divider); }
.friends-none, .friends-empty { padding: 12px 16px; color: var(--color-neutral-700); font-size: var(--text-body); }
.friends-empty p { margin: 0; }
.rows > .friend-row { justify-content: flex-start; min-height: 60px; }
.friend-row .name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.friend-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-meta { font-size: var(--text-meta); color: var(--color-neutral-700); }
.friend-error { color: var(--color-accent-700); font-weight: 600; }
[data-theme="dark"] .friend-error { color: var(--color-accent-400); }
.owner-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 52px; padding: 8px 16px; }
.owner-title { font-weight: 600; flex: 1 1 100%; overflow-wrap: anywhere; }
.owner-row .tag { flex: none; }
.owner-names { flex: 1 1 100%; font-size: var(--text-meta); color: var(--color-neutral-700); }
.friends-add { display: flex; flex-direction: column; gap: 12px; }
.friends-inline { display: flex; gap: 8px; }
.friends-inline .input { flex: 1; min-width: 0; }
.friends-collection { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.loan-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; }
.loan-row .name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.merge-row { padding: 6px 0; font-size: var(--text-body); }
.lend-game { font-weight: 800; font-size: var(--text-body); overflow-wrap: anywhere; }
.lend-warning { padding: 10px 12px; background: var(--color-accent-100); color: var(--color-accent-800); border-left: 4px solid var(--color-accent); font-size: var(--text-body); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
[data-theme="dark"] .lend-warning { background: var(--color-accent-900); color: var(--color-accent-200); }
.lend-warning .btn { margin-top: 6px; }
/* Linking accounts and sharing (spec 031, phase B) */
.friends-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.friends-main #offline-note.hidden { display: none !important; }
.friends-main .loading-window { height: auto; max-height: 360px; }
.friends-main .loading-status:has(> span:empty) { display: none; }
.friends-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }
.friend-code-name { font-weight: 800; font-size: var(--text-body); text-align: center; overflow-wrap: anywhere; }
.friend-code-qr { display: flex; justify-content: center; padding: 12px; margin: 0 auto; background: #fff; width: fit-content; }
.friend-code-qr img, .friend-code-qr canvas { max-width: 100%; height: auto; }
.friend-code-note { text-align: center; font-size: var(--text-meta); color: var(--color-neutral-700); }
.friend-new .btn { flex: none; }
.share-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; }
.share-row .name { font-weight: 600; }
.share-opt { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: var(--text-body); }
.share-opt input[type="checkbox"] { width: 22px; height: 22px; flex: none; }
/* Game nights and the bring list (spec 031, phase C, nights.html) */
.nights-main .night-back { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; font-weight: 600; text-decoration: none; color: inherit; }
.night-head { padding: 0 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.night-head h2 { margin: 0; overflow-wrap: anywhere; }
.night-note { font-size: var(--text-body); white-space: pre-wrap; overflow-wrap: anywhere; }
.night-tools { display: flex; gap: 8px; margin-top: 8px; }
.night-people-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.person-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; }
.person-name { flex: 1 1 100%; font-weight: 600; overflow-wrap: anywhere; }
.person-answer { flex: 1 1 200px; }
.person-row > .btn-ghost { margin-left: auto; }
.person-extra { display: flex; align-items: center; gap: 6px; font-size: var(--text-meta); }
.person-extra .input { width: 4.5em; min-height: 44px; }
.night-add { display: flex; gap: 8px; margin-top: 8px; }
.night-add .input { flex: 1; min-width: 0; }
.night-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.night-tabs { margin: 8px 16px; }
.night-filters { padding: 0 0 8px; }
.night-filters .chip { min-height: 44px; }
.night-row .tag { flex: none; }
.bring-card { margin: 0 16px 16px; }
.bring-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 12px; background: var(--color-surface); }
.bring-head h3 { margin: 0; font-size: var(--text-body); }
.bring-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 52px; }
.bring-row .name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bring-row .input { width: auto; max-width: 45%; min-height: 44px; }
#bring-warnings { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.night-past { padding: 0 16px 16px; }
.tonight-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 16px 12px; padding: 12px 14px; border-left: 4px solid var(--color-accent); background: var(--color-surface); text-decoration: none; color: inherit; }
.tonight-link strong { overflow-wrap: anywhere; }
.tag-lent { background: var(--color-accent-100); color: var(--color-accent-800); }
[data-theme="dark"] .tag-lent { background: var(--color-accent-900); color: var(--color-accent-200); }

/* ── Form fields: 16px minimum ──────────────────────────────────────────────
   iOS Safari zooms into a focused field whose font is under 16px and does not
   always zoom back out. Every text control is 16px (--text-input) on every
   device, so the fields look the same everywhere; never fix the zoom with
   maximum-scale / user-scalable=no (blocks pinch zoom). */
.input, select, textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]) {
  font-size: var(--text-input);
}

/* ── Settings, with Profile as a page inside it (spec 033) ──────────────────
   Design: "BGI Mobile" settings / profile screens and "BGI Settings Wide".
   Groups: 25px heading + one help line, 2px rule between groups, nothing between
   settings. Each setting: 15px label + 12px help, then the control (phone); label
   left and control right from 768px. */

.field-help { font-size: var(--text-meta); line-height: 1.4; color: var(--color-neutral-700); margin: 0; text-wrap: pretty; }

.settings-head .screen-head { padding-bottom: 12px; }
.profile-link {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; margin-bottom: 12px;
  background: var(--color-surface); color: var(--color-text); text-decoration: none;
}
.profile-link:hover { background: var(--color-neutral-200); }
[data-theme="dark"] .profile-link:hover { background: color-mix(in srgb, var(--color-text) 10%, var(--color-surface)); }
.profile-link svg { flex: none; }
.profile-link .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-link .n { min-height: 1lh; font-size: var(--text-body); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-link .s { font-size: var(--text-meta); color: var(--color-neutral-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* In-page index: wrapping chips on a phone and tablet, a sticky side list on a desktop */
.settings-index { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 20px; }
.settings-index-title { display: none; }
.settings-index a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--color-divider);
  color: var(--color-text); text-decoration: none; font-size: var(--text-meta); white-space: nowrap;
}
.settings-index a:hover { background: var(--color-surface); }

/* Phone: the group in view once the chips have scrolled away */
.settings-stuck {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: 52px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: env(safe-area-inset-top) 8px 0 16px;
  background: var(--color-bg); border-bottom: 2px solid var(--color-divider);
}
.settings-stuck .t { min-width: 0; display: flex; flex-direction: column; }
.settings-stuck .k { font-size: var(--text-meta); color: var(--color-neutral-700); }
.settings-stuck .n { font-size: var(--text-body); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.settings-group {
  scroll-margin-top: 56px; border-top: 2px solid var(--color-divider);
  padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 20px;
}
.settings-group .group-head { display: flex; flex-direction: column; gap: 4px; }
.settings-group .group-head h2 { margin: 0; font-size: var(--text-title); }
.setting { display: flex; flex-direction: column; gap: 8px; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-text .label { font-size: var(--text-body); font-weight: 600; color: var(--color-text); }
.setting .seg-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.setting-check { flex-direction: row; align-items: flex-start; gap: 10px; cursor: pointer; }
.setting-check input { accent-color: var(--color-accent); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.setting-block { display: flex; flex-direction: column; gap: 8px; }
.setting-box { background: var(--color-surface); padding: 16px; }
.setting-box:empty { display: none; }
.setting-install:has(#install-pwa-btn[style*="none"]) { display: none; }
.setting .btn { align-self: flex-start; }
.net-status { display: flex; align-items: center; gap: 8px; min-height: 24px; font-size: var(--text-body); font-weight: 600; }
.net-status::before { content: ""; width: 8px; height: 8px; flex: none; background: var(--color-neutral-500); }
.net-status[data-net="online"] { color: var(--color-success); }
.net-status[data-net="online"]::before, .net-status[data-net="waiting"]::before { background: currentColor; }
.net-status[data-net="offline"] { color: var(--color-accent-700); }
.net-status[data-net="offline"]::before { background: currentColor; }
[data-theme="dark"] .net-status[data-net="offline"] { color: var(--color-accent-400); }

/* Storage: rows reach the screen edge; ⋯ opens Rename / Set size / Delete under the row */
.settings-group #loc-list { margin: -8px -16px 0; }
.settings-group .loc-add { padding: 0; }
.settings-group .loc-tools { padding: 0; margin-top: -8px; }
.rows > .loc-row:has(+ .loc-actions), .rows > .loc-actions { background: var(--color-surface); }
.rows > .loc-actions { flex-wrap: wrap; justify-content: flex-start; gap: 8px; min-height: 0; padding: 2px 16px 16px; cursor: default; }

/* Profile, a page inside Settings: back to Settings, then the person and the account */
.page-back {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; padding: calc(4px + env(safe-area-inset-top)) 8px 4px;
  background: var(--color-bg); border-bottom: 2px solid var(--color-divider);
}
.page-back a { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px; color: var(--color-text); text-decoration: none; font-weight: 800; font-size: var(--text-body); }
.page-back a:hover { background: var(--color-surface); }
.profile-head { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.profile-who { display: flex; flex-direction: column; gap: 2px; }
.profile-who h1 { min-height: 1lh; margin: 0; overflow-wrap: anywhere; }
.profile-email { min-height: 1lh; font-size: var(--text-body); color: var(--color-neutral-700); overflow-wrap: anywhere; }
.profile-head .stat3 { margin: 0 -16px; border-bottom: 0; }
.profile-main .section h2 { font-size: var(--text-body); font-weight: 800; margin: 0; }
.profile-main .section { gap: 12px; }
.profile-main .tool-row { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-main .about-row { border-top: 2px solid var(--color-divider); }
.profile-cols > .section:first-child, .profile-main > .danger-zone { border-top: 2px solid var(--color-divider); }
.profile-main .profile-password { margin: 0 -16px; border-top: 0; }
.app-main > .bgg-credit { padding: 16px; }
.profile-main .bgg-credit { padding: 20px 16px 24px; }
.profile-main .bgg-credit img { margin-left: -8px; }
.danger-zone h2 { color: var(--color-accent-700); }
[data-theme="dark"] .danger-zone h2 { color: var(--color-accent-400); }
.danger-zone .btn, .profile-session .btn { align-self: flex-start; }

@media (min-width: 768px) {
  /* Settings: Profile beside the title; the chips stay under it while scrolling */
  .settings-main { max-width: 1040px; }
  .settings-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 32px; padding: 28px 32px 0; }
  .settings-head .screen-head { padding: 0; }
  .profile-link { min-width: 280px; min-height: 56px; padding: 10px 16px; margin: 0; }
  .settings-index { position: sticky; top: 0; z-index: 3; background: var(--color-bg); padding: 16px 32px; }
  .settings-index a[aria-current] { background: var(--color-text); border-color: var(--color-text); color: var(--color-bg); }
  .settings-group { scroll-margin-top: 76px; padding: 24px 0 36px; margin: 0 32px; gap: 24px; }
  .setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 8px 32px; align-items: start; }
  .setting-text { padding-top: 2px; }
  .setting-check { display: flex; }
  .settings-group #loc-list { margin: -8px 0 0; }
  .rows > .loc-row { padding-left: 12px; }
  .settings-group .loc-add { max-width: 520px; }
  .setting-box { padding: 20px; }
  .settings-stuck { display: none; }

  /* Profile: stats beside the name; Labels and Session left of Account */
  .profile-main { max-width: 1040px; }
  .page-back { position: static; border: 0; padding: 16px 24px 0; }
  .profile-head { padding: 12px 32px 24px; }
  .profile-head .stat3 { margin: 0; border-top: 0; }
  .profile-head .stat3 > div { padding: 4px 16px; }
  .profile-head .stat3 > div:first-child { border-left: 2px solid var(--color-divider); }
  .profile-main > .section, .profile-cols, .profile-main > .about-row, .profile-main > .bgg-credit { margin-left: 32px; margin-right: 32px; }
  .profile-main .section { padding: 24px 0; }
  .profile-main .about-row > a { padding: 0 12px; margin: 0 -12px; }
}

@media (min-width: 1280px) {
  /* Settings: a sticky "On this page" list left of the groups */
  .settings-main {
    display: grid; grid-template-columns: 220px minmax(0, 780px); column-gap: 32px; align-items: start; max-width: 1100px;
  }
  .settings-main > * { grid-column: 1 / -1; min-width: 0; }
  .settings-head { padding: 40px 0 0 16px; }
  .settings-main > .settings-index {
    grid-column: 1; grid-row: 2 / span 3; position: sticky; top: 0; flex-direction: column; flex-wrap: nowrap;
    gap: 0; padding: 24px 0 0;
  }
  .settings-main > .settings-groups { grid-column: 2; grid-row: 2; padding-top: 24px; }
  .settings-index-title { display: block; font-size: var(--text-meta); letter-spacing: .08em; text-transform: uppercase; color: var(--color-neutral-700); padding: 0 0 8px 16px; }
  .settings-index a { min-height: 40px; padding: 0 16px; border: 0; font-size: var(--text-body); }
  .settings-index a[aria-current] { background: none; color: var(--color-text); font-weight: 800; box-shadow: inset 3px 0 0 var(--color-accent); }
  .settings-group { scroll-margin-top: 8px; margin: 0; }

  .profile-head { flex-direction: row; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 12px 48px 24px; }
  .profile-head .stat3 { grid-template-columns: repeat(3, minmax(96px, 1fr)); }
  .page-back { padding: 16px 40px 0; }
  .profile-main > .section, .profile-cols, .profile-main > .about-row, .profile-main > .bgg-credit { margin-left: 48px; margin-right: 48px; }
  .profile-cols {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start;
    grid-template-areas: "labels account" "session account"; border-top: 2px solid var(--color-divider);
  }
  .profile-cols > .section:first-child { border-top: 0; }
  .profile-labels { grid-area: labels; padding-right: 32px !important; }
  .profile-session { grid-area: session; padding-right: 32px !important; }
  /* Danger zone: the warning text on the left, the button on the right (design I7) */
  .profile-main .danger-zone { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 32px; align-items: center; }
  .danger-zone h2 { grid-column: 1 / -1; }
  .danger-zone .field-help { grid-column: 1; }
  .danger-zone .btn { grid-column: 2; grid-row: 2; align-self: center; }
  .profile-account { grid-area: account; align-self: stretch; border-top: 0 !important; border-left: 2px solid var(--color-divider); padding-left: 32px !important; }
  .profile-main .profile-password { margin: 0 -12px; }
  .profile-main .profile-password summary { padding: 12px; }
}

/* Data loading keeps the shell and nearby controls steady (spec 075). */
.loading-region { position: relative; min-width: 0; }
.loading-status { min-height: 2.8rem; padding: 8px 16px; display: flex; align-items: center; gap: 8px; color: var(--color-neutral-700); font-size: var(--text-meta); }
.loading-status:empty { visibility: hidden; }
.loading-window { height: clamp(160px, 26vh, 280px); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.loading-window .friends-empty { min-height: 120px; display: grid; align-content: center; }
.loading-window .friends-empty.hidden { display: none; }
.loading-skeleton { height: 120px; margin: 0 16px; background: repeating-linear-gradient(to bottom, var(--color-divider) 0 12px, transparent 12px 60px); opacity: .45; }
.loading-skeleton[hidden] { display: none; }
.settings-main .seg-grid:empty { min-height: 44px; }
#bgg-sync { min-height: 212px; }
#bgg-writeback { min-height: 248px; }
#share-section { min-height: 240px; }
#share-list { height: 160px; overflow: auto; scrollbar-gutter: stable; }
.sharing-empty { min-height: 140px; display: grid; align-content: center; gap: 8px; }
.sharing-empty p { margin: 0; }
.sharing-empty a { justify-self: start; }
#loc-list { height: 160px; overflow: auto; scrollbar-gutter: stable; }
.profile-who h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.profile-who { min-width: 0; }
.profile-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-head .num { font-variant-numeric: tabular-nums; min-width: 3ch; }
.profile-labels > #labels-missing, .profile-labels > #labels-done { min-height: 2.5rem; }
#labels-kicker { min-height: 1lh; }
.loading-note { min-height: 2.8rem; }
.loading-note.hidden { display: block !important; visibility: hidden; }
.labels-main > #labels-loading { grid-area: list; min-height: 180px; }
.profile-totals .loading-status { min-height: 1.5rem; padding: 0 16px; }
/* Diagnostics always has three services; results replace the same short viewport. */
#services-list { height: 240px; overflow: auto; scrollbar-gutter: stable; }
.page-intro:has(#user-email) { min-height: 3lh; }
.stats-filters[hidden] { display: flex !important; visibility: hidden; }
.stat-tiles[hidden] { display: grid !important; visibility: hidden; }
#user-email { display: inline-block; width: 24ch; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.stats-filters { min-height: 96px; }
.stat-tiles { min-height: 144px; }
.stat-tiles[hidden] { min-height: 144px; }
#stats-root { min-height: max(400px, calc(100svh - 220px)); }
#stats-root:has(> .empty) { min-height: 260px; }
@media (min-width: 768px) { .stat-tiles, .stat-tiles[hidden] { min-height: 76px; } }

/* Friend planning controls reserve the same responsive rows before translation. */
@media (max-width: 767px) {
  .friends-main .screen-head { min-height: 80px; align-items: flex-end; }
  .nights-main .screen-head { min-height: 112px; align-items: flex-end; }
  .friends-main .screen-head > div, .nights-main .screen-head > div { min-width: 0; }
  .friends-actions {
    flex-wrap: nowrap; overflow-x: auto;
    /* Local covers hide each edge shadow once that end is reached. */
    background:
      linear-gradient(to right, var(--color-bg) 60%, transparent) left / 32px 100% local,
      linear-gradient(to left, var(--color-bg) 60%, transparent) right / 32px 100% local,
      linear-gradient(to right, color-mix(in srgb, var(--color-text) 25%, transparent), transparent) left / 16px 100% scroll,
      linear-gradient(to left, color-mix(in srgb, var(--color-text) 25%, transparent), transparent) right / 16px 100% scroll;
    background-repeat: no-repeat;
  }
  .friends-actions .btn { flex: none; min-height: 44px; white-space: nowrap; }
  .friends-main .loading-note, .nights-main .loading-note { min-height: 4lh; }
  .friends-main .footer > span, .nights-main .footer > span { min-height: 4lh; }
}
