/* ============================================================
   EnPassant — global stylesheet
   Aesthetic: dark, refined, broadcast-quality. Forest greens,
   sharp lime accents. Editorial typography. Crisp motion.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,700;12..96,800&family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,600;9..144,800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ============================================================
   Task #9: theming. All themes override the same variable surface
   defined in :root. The "Forest" defaults below ARE the original
   palette — :root and [data-theme="forest"] produce identical
   output. Other themes (royal, crimson, ivory) sit further down
   the file as scoped overrides. The rgba(...) literals throughout
   the stylesheet have been rewritten as rgba(var(--accent-rgb),α)
   etc. so they re-tint when the variables change.
   ============================================================ */

:root {
  /* Palette — moss + lichen + pine + lime spark (Forest, default) */
  --bg-0: #07100c;        /* deepest */
  --bg-1: #0d1a14;
  --bg-2: #122620;
  --bg-3: #1a352c;
  --line: #224135;
  --line-2: #2e5447;

  --ink: #e8f2ec;
  --ink-mute: #9fb4a7;
  --ink-faint: #6a7e72;

  --moss: #4a8f6b;
  --pine: #2d6649;
  --lime: #b8ff5c;        /* signal / accent */
  --lime-dim: #7fb336;
  --gold: #d4b572;
  --rose: #d96a6a;        /* dispute / error */

  /* RGB triples for the colors that appear inside rgba(...) calls.
     Kept in sync with the hex values above. Themes override these
     alongside the hex variants. */
  --accent-rgb: 184, 255, 92;   /* matches --lime */
  --moss-rgb: 74, 143, 107;     /* matches --moss */
  --pine-rgb: 45, 102, 73;      /* matches --pine */
  --rose-rgb: 217, 106, 106;    /* matches --rose */
  --gold-rgb: 212, 181, 114;    /* matches --gold */
  --bg-0-rgb: 7, 16, 12;        /* matches --bg-0; used in round-hero overlay */
  --bg-1-rgb: 13, 26, 20;       /* matches --bg-1; used by join-form input */

  /* The body grain. Light themes flip this from white-on-dark to
     dark-on-light so the grid texture stays visible either way. */
  --grain-rgb: 255, 255, 255;
  --grain-alpha: 0.012;

  /* The btn-primary's text color sat at var(--bg-0) inline before
     theming. On light themes that produced white-on-lime, which is
     unreadable. Pulled out so each theme can pick the right contrast. */
  --btn-primary-ink: var(--bg-0);

  --grad-board: linear-gradient(135deg, #0e1a14 0%, #122620 50%, #0d1a14 100%);

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 0 1px rgba(var(--accent-rgb),0.25), 0 8px 32px rgba(var(--accent-rgb),0.12);

  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-body: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--ink);
  min-height: 100vh;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(var(--moss-rgb),0.10), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(var(--pine-rgb),0.10), transparent 50%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-deeper, #050a07) 100%);
  background-attachment: fixed;
}

/* Subtle board-grain texture. The color and alpha both flow from theme
   variables so the grid stays visible on light themes (dark-on-light)
   without becoming a heavy pattern. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(var(--grain-rgb), var(--grain-alpha)) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(90deg, rgba(var(--grain-rgb), var(--grain-alpha)) 0 1px, transparent 1px 80px);
  pointer-events: none;
  z-index: 0;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.25rem; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lime-dim);
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-mute); }
.faint { color: var(--ink-faint); }
.accent { color: var(--lime); }

/* Layout primitives */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2.5rem);
  max-width: 1280px;
  margin: 0 auto;
}

.row { display: flex; gap: 1rem; align-items: center; }
.col { display: flex; flex-direction: column; gap: 1rem; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-1);
}

.card-elevated {
  border-color: var(--line-2);
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb),0.04) 0%, transparent 30%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.btn:hover {
  background: var(--pine);
  border-color: var(--moss);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--lime);
  color: var(--btn-primary-ink);
  border-color: var(--lime);
  font-weight: 700;
}
.btn-primary:hover {
  background: var(--lime-hover, #cdff7e);
  border-color: var(--lime-hover, #cdff7e);
  box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.3);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
}
.btn-ghost:hover {
  background: var(--bg-2);
}

.btn-danger {
  background: transparent;
  border-color: rgba(var(--rose-rgb), 0.4);
  color: var(--rose);
}
.btn-danger:hover {
  background: rgba(var(--rose-rgb), 0.1);
  border-color: var(--rose);
}

.btn-lg {
  padding: 1rem 1.8rem;
  font-size: 1rem;
}

/* Form inputs */
input[type=text], input[type=number], select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--ink);
  width: 100%;
  transition: all 0.2s;
}
input[type=text]:focus, input[type=number]:focus, select:focus {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgba(var(--moss-rgb), 0.15);
}

label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: block;
  margin-bottom: 0.4rem;
}

/* Radio / segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 2px;
}
.segmented input { display: none; }
.segmented label {
  margin: 0;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-mute);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.segmented input:checked + label {
  background: var(--lime);
  color: var(--btn-primary-ink);
  font-weight: 700;
}
.segmented label:hover:not(:has(input:checked)) {
  color: var(--ink);
}

/* Badges */
.badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--ink-mute);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-pending { color: var(--gold); border-color: rgba(var(--gold-rgb),0.3); }
.badge-reported { color: var(--lime); border-color: rgba(var(--accent-rgb),0.3); }
.badge-confirmed { color: var(--moss); border-color: rgba(var(--moss-rgb),0.3); }
.badge-disputed { color: var(--rose); border-color: rgba(var(--rose-rgb),0.3); }
.badge-bye { color: var(--ink-faint); }

/* Tournament code display */
.tcode {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--lime);
  text-shadow: 0 0 24px rgba(var(--accent-rgb), 0.3);
}

/* ============================================================
   EN PASSANT LOADING ANIMATION
   A white pawn captures a black pawn diagonally, then the
   captured pawn falls. Loop. This is our signature.
   ============================================================ */

.en-passant-loader {
  position: relative;
  width: 200px;
  height: 100px;
  margin: 1rem auto;
}

.ep-board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.ep-square {
  position: relative;
  background: var(--bg-2);
}
.ep-square.dark { background: var(--bg-1); }

.ep-pawn {
  position: absolute;
  font-size: 2.6rem;
  line-height: 1;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.ep-pawn.white {
  color: var(--ink);
  left: 12.5%;
  animation: ep-white-move 3.6s var(--ease-out) infinite;
}
.ep-pawn.black {
  color: var(--ink-faint);
  left: 37.5%;
  top: 25%;
  animation: ep-black-fade 3.6s var(--ease-out) infinite;
}

@keyframes ep-white-move {
  0%   { left: 12.5%; top: 75%; opacity: 1; }
  20%  { left: 12.5%; top: 75%; opacity: 1; }
  /* Diagonal capture: jumps to the square BEHIND the black pawn */
  45%  { left: 37.5%; top: 25%; opacity: 1; transform: translate(-50%, -50%) rotate(-8deg); }
  55%  { left: 37.5%; top: 25%; opacity: 1; transform: translate(-50%, -50%) rotate(0deg); }
  85%  { left: 37.5%; top: 25%; opacity: 1; }
  90%  { left: 12.5%; top: 75%; opacity: 0; transform: translate(-50%, -50%); }
  100% { left: 12.5%; top: 75%; opacity: 1; }
}
@keyframes ep-black-fade {
  0%, 35%   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  /* Black gets captured ON the white-pawn move */
  45%       { opacity: 0; transform: translate(-50%, calc(-50% + 30px)) scale(0.6) rotate(20deg); }
  85%       { opacity: 0; transform: translate(-50%, calc(-50% + 30px)) scale(0.6) rotate(20deg); }
  100%      { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ep-loader-label {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 0.8rem;
  animation: ep-pulse 1.6s ease-in-out infinite;
}
@keyframes ep-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Toasts */
.toast-stack {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--lime);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.92rem;
  min-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.3s var(--ease-spring);
  pointer-events: auto;
}
.toast.error { border-left-color: var(--rose); }
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Logo / wordmark */
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
}
.brand .accent { color: var(--lime); font-style: normal; }
.brand-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--lime);
  border-radius: 50%;
  margin: 0 0.1rem 0.15rem;
  box-shadow: 0 0 8px var(--lime);
}

/* Hide visually but keep accessible */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Responsive */
@media (max-width: 640px) {
  .page { padding: 1rem; }
  h1 { font-size: 2.4rem; }
}

/* ============================================================
   Join-first front page
   Append to main.css
   ============================================================ */

/* The whole page becomes a vertical layout that fills the viewport
   so the join input sits in the middle of the screen on first load. */
.page-join {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 3vw, 2rem);
}

/* --- Header ----------------------------------------------------- */
.join-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 2;
}
.brand-logo {
  height: 28px;
  width: auto;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.header-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  text-decoration: none;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}
.header-link:hover {
  color: var(--ink);
  background: var(--bg-2);
}
.header-link .accent {
  margin-left: 0.3rem;
}

/* --- Main: vertical-centered hero with the join form ------------ */
.join-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 4vh 0;
}

/* Background image, behind the hero. Subtle, never competes with text. */
.join-bg {
  position: absolute;
  inset: -10% -5%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.join-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
  filter: blur(2px) saturate(0.8);
}

.join-hero {
  position: relative;
  z-index: 1;
  max-width: 640px;
  width: 100%;
  text-align: center;
}
.join-hero .eyebrow {
  margin-bottom: 1.2rem;
  /* Tiny pulsing dot to signal "live" */
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.join-hero .eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: ep-pulse 1.6s ease-in-out infinite;
}

.join-headline {
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  margin-bottom: 2.5rem;
  line-height: 1.02;
}
.join-headline em {
  font-style: italic;
}

/* --- The join form: the page's single focal point --------------- */
.join-form {
  display: flex;
  gap: 0.6rem;
  max-width: 520px;
  margin: 0 auto 1.5rem;
}
.join-form input[type=text] {
  flex: 1;
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 600;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 1rem 1.2rem;
  text-transform: uppercase;
  background: rgba(var(--bg-1-rgb), 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-2);
}
.join-form input[type=text]::placeholder {
  color: var(--ink-faint);
  letter-spacing: 0.25em;
  font-weight: 400;
}
.join-form input[type=text]:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}
.join-form .btn-primary {
  padding: 1rem 1.6rem;
  font-size: 1.05rem;
  white-space: nowrap;
}

/* "Or scan the QR" hint, deliberately small */
.join-or {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.join-or-icon {
  width: 22px;
  height: 22px;
  opacity: 0.7;
}

/* --- Footer ----------------------------------------------------- */
.join-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2vh;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  position: relative;
  z-index: 2;
}
.footer-link {
  color: var(--ink-mute);
  text-decoration: none;
}
.footer-link:hover {
  color: var(--lime);
}

/* --- Mobile tightening ------------------------------------------ */
@media (max-width: 560px) {
  .join-form {
    flex-direction: column;
  }
  .join-form input[type=text] {
    font-size: 1.5rem;
  }
  .join-form .btn-primary {
    text-align: center;
  }
  .join-headline {
    margin-bottom: 1.8rem;
  }
  .join-or {
    justify-content: flex-start;
  }
  .header-link {
    font-size: 0.72rem;
  }
  /* Tighten the "Hosting?" link on small screens so it doesn't crowd the logo */
  .header-link .accent {
    display: block;
    margin-left: 0;
  }
}

/* ============================================================
   Segmented control variant: allow wrapping when it doesn't fit
   in a narrow column (e.g. host dashboard's 320px-wide column
   trying to hold four options).
   ============================================================ */

.segmented.segmented-wrap {
  flex-wrap: wrap;
  /* When wrapped, give each label room to breathe */
}
.segmented.segmented-wrap label {
  flex: 1 0 auto;
  text-align: center;
  /* Slightly tighter padding so 4 buttons stand a chance at fitting */
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

/* ============================================================
   Task #9: themes. Each theme overrides only the variables;
   every rule above reads from them, so a theme switch is a
   single attribute change on <html>. The picker UI lives at
   the very bottom of this section.

   Picking palettes:
     Royal   — deep navy + warm amber. The classic chess look.
     Crimson — near-black + signal red. Broadcast / drama mode.
     Ivory   — light surfaces + charcoal ink + bottle green.
               For daylight rooms and TV/projector setups that
               aren't dark.

   Forest (the original) is :root, so an unset attribute or
   data-theme="forest" produces identical output to before.
   ============================================================ */

:root[data-theme="forest"] {
  /* Explicit duplicate of :root, so the picker has a stable
     selector to highlight when "Forest" is the active theme. */
}

:root[data-theme="royal"] {
  --bg-0: #060914;
  --bg-1: #0c1426;
  --bg-2: #131e3a;
  --bg-3: #1d2c52;
  --line: #243562;
  --line-2: #314782;

  --ink: #e8edf7;
  --ink-mute: #a3afca;
  --ink-faint: #6c7894;

  --moss: #5a7bc0;        /* repurposed: "secondary accent" — the cool blue */
  --pine: #3e5aa0;
  --lime: #f0b955;        /* primary accent: warm amber */
  --lime-dim: #c08a2c;
  --gold: #f0b955;        /* on royal, gold IS the accent */
  --rose: #e07a7a;

  --accent-rgb: 240, 185, 85;
  --moss-rgb: 90, 123, 192;
  --pine-rgb: 62, 90, 160;
  --rose-rgb: 224, 122, 122;
  --gold-rgb: 240, 185, 85;
  --bg-0-rgb: 6, 9, 20;
  --bg-1-rgb: 12, 20, 38;

  --grain-rgb: 255, 255, 255;
  --grain-alpha: 0.012;

  --btn-primary-ink: #1a1308;
  --lime-hover: #f5cb78;
  --bg-deeper: #03060f;

  --grad-board: linear-gradient(135deg, #0c1426 0%, #131e3a 50%, #0c1426 100%);
}

:root[data-theme="crimson"] {
  --bg-0: #0a0606;
  --bg-1: #150c0c;
  --bg-2: #1f1414;
  --bg-3: #2e1d1d;
  --line: #3b2828;
  --line-2: #553535;

  --ink: #f2eaea;
  --ink-mute: #b8a8a8;
  --ink-faint: #7a6a6a;

  --moss: #b87878;        /* repurposed: muted rose for "confirmed" badge */
  --pine: #8a4848;
  --lime: #ef4d4d;        /* primary accent: signal red */
  --lime-dim: #c83838;
  --gold: #e0a44a;
  --rose: #ef4d4d;        /* on crimson, rose IS the accent — disputes use gold instead */

  --accent-rgb: 239, 77, 77;
  --moss-rgb: 184, 120, 120;
  --pine-rgb: 138, 72, 72;
  --rose-rgb: 239, 77, 77;
  --gold-rgb: 224, 164, 74;
  --bg-0-rgb: 10, 6, 6;
  --bg-1-rgb: 21, 12, 12;

  --grain-rgb: 255, 255, 255;
  --grain-alpha: 0.014;

  --btn-primary-ink: #1a0606;
  --lime-hover: #ff6868;
  --bg-deeper: #050202;

  --grad-board: linear-gradient(135deg, #150c0c 0%, #1f1414 50%, #150c0c 100%);
}

:root[data-theme="ivory"] {
  /* Light theme. All the dark-on-dark assumptions in the
     stylesheet route through variables, so this works by
     inverting bg / ink and picking accent colors that read
     well on a near-white surface. */
  --bg-0: #f5f1e8;        /* warm parchment */
  --bg-1: #ebe5d4;
  --bg-2: #e2dac3;
  --bg-3: #d4c9a8;
  --line: #c5b893;
  --line-2: #a89a72;

  --ink: #1a2118;        /* near-black with a green undertone */
  --ink-mute: #4a574a;
  --ink-faint: #7a857a;

  --moss: #4a8f6b;       /* keep the moss greens — they read well on cream */
  --pine: #2d6649;
  --lime: #2d6649;       /* primary accent: bottle green */
  --lime-dim: #5a8f6e;
  --gold: #a8842c;
  --rose: #b03838;

  --accent-rgb: 45, 102, 73;
  --moss-rgb: 74, 143, 107;
  --pine-rgb: 45, 102, 73;
  --rose-rgb: 176, 56, 56;
  --gold-rgb: 168, 132, 44;
  --bg-0-rgb: 245, 241, 232;
  --bg-1-rgb: 235, 229, 212;

  /* Light theme inverts the grain: dark gridlines on a cream
     surface, slightly heavier alpha because dark-on-light needs
     more contrast to be visible than light-on-dark. */
  --grain-rgb: 0, 0, 0;
  --grain-alpha: 0.025;

  /* On bottle-green buttons, white text reads. The dark var(--bg-0)
     fallback used by the other themes would render as cream-on-green
     here, which is too low-contrast. */
  --btn-primary-ink: #f5f1e8;
  --lime-hover: #1f4f37;
  --bg-deeper: #e8dec5;

  --grad-board: linear-gradient(135deg, #ebe5d4 0%, #e2dac3 50%, #ebe5d4 100%);
}

/* The :root[data-theme="ivory"] body backdrop still uses the moss/pine
   radial-gradient tints from the body rule above. Those work — the
   accent-rgb triples themselves now map to bottle-green RGB on this
   theme, so the gradients tint correctly. No special-case needed. */

/* ============================================================
   Theme picker — used on host.html, can be embedded anywhere.
   Renders four small color chips with a checked state.
   ============================================================ */

.theme-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.theme-picker label {
  /* Override the global uppercase-mono label styling for this control. */
  margin: 0;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-mute);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem 0.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.theme-picker input[type=radio] {
  /* Visually hidden but still focusable via keyboard. */
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.theme-picker label:hover { color: var(--ink); }
.theme-picker label:has(input:checked) {
  border-color: var(--lime);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--ink);
}
/* Fallback for browsers without :has() — JS adds .is-checked too. */
.theme-picker label.is-checked {
  border-color: var(--lime);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--ink);
}
.theme-picker .swatch {
  width: 36px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
/* Swatch previews: each one shows the bg + accent of its theme,
   so the host sees what they're picking without applying it first.
   Hardcoded colors here are intentional — they're a preview, not
   the live theme. */
.theme-picker .swatch.forest  { background: linear-gradient(135deg, #0d1a14 0% 60%, #b8ff5c 60% 100%); }
.theme-picker .swatch.royal   { background: linear-gradient(135deg, #0c1426 0% 60%, #f0b955 60% 100%); }
.theme-picker .swatch.crimson { background: linear-gradient(135deg, #150c0c 0% 60%, #ef4d4d 60% 100%); }
.theme-picker .swatch.ivory   { background: linear-gradient(135deg, #ebe5d4 0% 60%, #2d6649 60% 100%); }
.theme-picker .swatch-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}