/* ---------- tokens ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #00123c;      /* Ayres navy (from the logo) */
  --on-accent: #ffffff;
  --brand-navy: #00123c;
  --brand-red: #d20002;   /* brake-disc red (from the logo) */

  /* event-type colors: solid + tint */
  /* 9 Nov: blue = Super Tour, Majors (incl. dual-sanctioned) and Runoffs; red = the other races; gray = tests */
  --runoffs: #1d4ed8;    --runoffs-tint: #e3ecfd;
  --supertour: #1d4ed8;  --supertour-tint: #e3ecfd;
  --majors: #1d4ed8;     --majors-tint: #e3ecfd;
  --bigregional: #dc2626; --bigregional-tint: #fde8e8;
  --regional: #dc2626;   --regional-tint: #fde8e8;
  --test: #64748b;       --test-tint: #eef1f5;
  --on-solid: #ffffff;

  --warn-bg: #fffbeb; --warn-fg: #78350f; --warn-line: #f59e0b;
  /* Traffic light (9 Nov): amber = Planned (proposed, may change), green = Confirmed (we're going) */
  --planned: #f59e0b; --planned-tint: #fef3c7; --on-planned: #3b2500;
  --confirmed: #16a34a; --confirmed-tint: #dcfce7; --on-confirmed: #ffffff;
  --needed: #d20002;  /* "You're needed" box (logo red) */
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #181b21; --text: #e8eaed; --muted: #9aa0a6; --line: #2a2e36;
    --accent: #e8eaed; --on-accent: #0f1115;
    --runoffs: #60a5fa;    --runoffs-tint: #172a3d;
    --supertour: #60a5fa;  --supertour-tint: #172a3d;
    --majors: #60a5fa;     --majors-tint: #172a3d;
    --bigregional: #f87171; --bigregional-tint: #3a1d1f;
    --regional: #f87171;   --regional-tint: #3a1d1f;
    --test: #94a3b8;       --test-tint: #23272f;
    --on-solid: #0f1115;
    --warn-bg: #2a2110; --warn-fg: #fcd34d; --warn-line: #b45309;
    --planned: #fbbf24; --planned-tint: #3a2e10; --on-planned: #2a1a00;
    --confirmed: #22c55e; --confirmed-tint: #133222; --on-confirmed: #04240d;
    --needed: #ff5a5a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b21; --text: #e8eaed; --muted: #9aa0a6; --line: #2a2e36;
  --accent: #e8eaed; --on-accent: #0f1115;
  --runoffs: #60a5fa;    --runoffs-tint: #172a3d;
  --supertour: #60a5fa;  --supertour-tint: #172a3d;
  --majors: #60a5fa;     --majors-tint: #172a3d;
  --bigregional: #f87171; --bigregional-tint: #3a1d1f;
  --regional: #f87171;   --regional-tint: #3a1d1f;
  --test: #94a3b8;       --test-tint: #23272f;
  --on-solid: #0f1115;
  --warn-bg: #2a2110; --warn-fg: #fcd34d; --warn-line: #b45309;
  --planned: #fbbf24; --planned-tint: #3a2e10; --on-planned: #2a1a00;
  --confirmed: #22c55e; --confirmed-tint: #133222; --on-confirmed: #04240d;
  --needed: #ff5a5a;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
a { color: inherit; }
main, footer, .top > * { max-width: 720px; margin-left: auto; margin-right: auto; }
main { padding: 8px 16px 24px; }
footer { padding: 8px 16px 32px; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.wide-only { display: none; }

/* ---------- header ---------- */
/* Brand header: Ayres navy bar, logo on a white badge, red underline on the active tab (same in light and dark). */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--brand-navy); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: block; height: 40px; width: auto; background: #fff; border-radius: 10px; padding: 3px 7px; }
h1 { font-size: 20px; margin: 0; line-height: 1.2; color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }
.pill-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.count { background: var(--accent); color: var(--on-accent); border-radius: 999px; font-size: 12px; padding: 0 7px; line-height: 20px; }
.top .count { background: var(--brand-red); color: #fff; }
.tabs { display: flex; gap: 4px; margin-top: 6px; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 4px; min-height: 44px; cursor: pointer;
  color: rgba(255, 255, 255, .68); border-bottom: 3px solid transparent; font-weight: 600;
}
.tabs button.active { color: #fff; border-bottom-color: var(--brand-red); }

/* ---------- key (legend) ---------- */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); margin: 8px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }
.sw { width: 20px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.race { background: linear-gradient(90deg, var(--supertour) 0 50%, var(--regional) 50%); }
.sw.tc { background: var(--c); }
.sw.test { background: var(--test); }
.sw.found { background: var(--surface); box-shadow: inset 3px 0 0 var(--muted), inset 0 0 0 1px var(--line); }
.sw.planned { background: var(--planned-tint); box-shadow: inset 0 0 0 2px var(--planned); }
.sw.confirmed { background: var(--confirmed-tint); box-shadow: inset 0 0 0 2px var(--confirmed); }
.legend .link-btn { padding: 0; font-size: 13px; }

/* ---------- type color hooks ---------- */
.t-runoffs { --c: var(--runoffs); --ct: var(--runoffs-tint); }
.t-supertour { --c: var(--supertour); --ct: var(--supertour-tint); }
.t-majors { --c: var(--majors); --ct: var(--majors-tint); }
.t-bigregional { --c: var(--bigregional); --ct: var(--bigregional-tint); }
.t-regional { --c: var(--regional); --ct: var(--regional-tint); }
.t-test { --c: var(--test); --ct: var(--test-tint); }

.group-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }

/* ---------- event card ---------- */
.ev {
  display: flex; align-items: stretch; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  border: 0; border-radius: var(--radius); padding: 10px 12px; margin: 0 0 8px; min-height: 56px;
  background: var(--ct);
}
/* Traffic light (9 Nov). Not planned: white card, thin type-color edge. Planned: amber card + PLANNED tag.
   Confirmed: green card + CONFIRMED tag. The type color stays on the left edge. */
.ev.s-found { background: var(--surface); box-shadow: inset 4px 0 0 var(--c), inset 0 0 0 1px var(--line); }
.ev.s-planned { background: var(--planned-tint); box-shadow: inset 5px 0 0 var(--c), inset 0 0 0 2px var(--planned); }
.ev.s-confirmed { background: var(--confirmed-tint); box-shadow: inset 5px 0 0 var(--c), inset 0 0 0 2px var(--confirmed); }
.ev-date { flex: 0 0 44px; text-align: center; display: flex; flex-direction: column; justify-content: center; line-height: 1.1; }
.ev-date b { font-size: 20px; }
.ev-date small { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.ev-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.ev-name { font-weight: 650; overflow-wrap: anywhere; }
.ev-meta { font-size: 13px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.badge { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.badge.strong { border-color: var(--c); color: var(--c); font-weight: 600; }
.badge.warn { border-color: #b91c1c; color: #b91c1c; font-weight: 600; }
.ev-status-word { flex: 0 0 auto; align-self: center; font-size: 11px; font-weight: 800; text-transform: uppercase; background: var(--planned); color: var(--on-planned); border-radius: 999px; padding: 3px 9px; letter-spacing: .04em; white-space: nowrap; }
.ev-status-word.confirmed { background: var(--confirmed); color: var(--on-confirmed); }
.cards { display: block; }

/* ---------- month grid ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.month-nav h2 { font-size: 18px; margin: 0; }
.month-nav button { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.grid .wd { font-size: 11px; color: var(--muted); text-align: center; padding: 4px 0; }
.cell {
  min-height: 62px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 3px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; text-align: left; min-width: 0;
}
.cell.out { opacity: .35; }
.cell.has-planned { border-color: var(--planned); box-shadow: inset 0 0 0 1px var(--planned); background: var(--planned-tint); }
.cell.has-confirmed { border-color: var(--confirmed); box-shadow: inset 0 0 0 1px var(--confirmed); background: var(--confirmed-tint); }
.cell.has-confirmed .num::after { content: " \2713"; color: var(--confirmed); font-weight: 800; }
.cell.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.cell.today .num { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 5px; }
.cell .num { font-size: 12px; font-weight: 600; align-self: flex-start; }
.bar { display: block; height: 7px; border-radius: 3px; background: var(--ct); min-width: 0; font-style: normal; }
.bar span { display: none; }
/* Phone bars: Not planned = thin, full type color (was a faded tint: too faint for Test/Super Tour, 9 Nov),
   Planned = thick with fluorescent green ring (and the day box gets a green outline), Confirmed = thick solid. */
.bar.s-found { height: 5px; background: var(--c); }
.bar.s-planned { height: 10px; background: var(--c); }
.bar.s-confirmed { height: 10px; background: var(--c); }
.more { font-size: 10px; color: var(--muted); line-height: 1; }
.day-list { margin-top: 14px; }
.side-h { font-size: 16px; margin: 0 0 8px; }

/* ---------- weekends ---------- */
.wk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.wk-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 650; margin-bottom: 6px; }
.wk-h small { color: var(--muted); font-weight: 400; }
.wk .ev { margin-bottom: 6px; }
.wk-empty { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; font-size: 14px; background: none; border-style: dashed; }
.wk-empty small { color: var(--muted); }

/* ---------- plan totals ---------- */
.totals { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.totals th, .totals td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); }
.totals th:first-child, .totals td:first-child { text-align: left; }
.totals thead th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.totals tfoot td { font-weight: 700; border-bottom: 0; }
.totals .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat small { color: var(--muted); font-size: 12px; }

/* ---------- sheet (dialog) ---------- */
dialog#sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 720px; max-height: 88vh;
  border-radius: 18px 18px 0 0; background: var(--surface); color: var(--text);
  /* Phones: fit the visible screen and sit above the keyboard (app.js sets --vvh/--kb). */
  max-height: calc(var(--vvh, 100dvh) * .9); margin-bottom: var(--kb, 0px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
dialog#sheet::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-inner { padding: 14px 16px calc(env(safe-area-inset-bottom) + 20px); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--surface); padding-bottom: 6px; z-index: 1; }
.sheet-head h2 { margin: 4px 0 0; font-size: 19px; }
.close { border: 0; background: var(--bg); border-radius: 999px; min-width: 40px; min-height: 40px; cursor: pointer; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; margin: 10px 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 650; border: 0; margin: 12px 0 6px;
}
.btn.disabled { background: var(--bg); color: var(--muted); border: 1px dashed var(--line); }
.info { white-space: pre-line; font-size: 14px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.days { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.days li { padding: 4px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.plan-box { background: var(--bg); border-radius: 14px; padding: 10px; margin: 6px 0 4px; }
.plan-box .lbl { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px 2px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 650; }
.seg button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg button.on.planned { background: var(--planned); color: var(--on-planned); border-color: var(--planned); }
.seg button.on.confirmed { background: var(--confirmed); color: var(--on-confirmed); border-color: var(--confirmed); }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.warnbox { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 12px; min-height: 38px; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.link-btn { background: none; border: 0; text-decoration: underline; cursor: pointer; color: var(--muted); padding: 8px 0; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-top: 12px; }
.toggle input { width: 20px; height: 20px; }
.key-full { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; }
.key-full span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- wide screens (PC) ---------- */
@media (min-width: 960px) {
  main, footer, .top > * { max-width: 1240px; }
  main { padding: 12px 24px 32px; }
  .top { padding: 14px 24px 0; }
  .logo { height: 52px; }
  h1 { font-size: 24px; }
  .wide-only { display: inline-flex; }
  .tabs { justify-content: flex-start; gap: 8px; }
  .tabs button { flex: 0 0 auto; padding: 10px 18px; }

  /* month: big calendar + side panel */
  .month-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
  .month-side { position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
  .month-side .day-list { margin-top: 0; }
  .grid { gap: 4px; }
  .cell { min-height: 112px; padding: 5px; gap: 3px; }
  .bar, .bar.s-found, .bar.s-planned, .bar.s-confirmed { height: auto; padding: 2px 5px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 1.3; opacity: 1; }
  .bar.s-found { background: var(--surface); color: var(--muted); font-weight: 500; box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 1px var(--line); }
  .bar.s-planned { background: var(--planned-tint); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 2px var(--planned); }
  .bar.s-confirmed { background: var(--confirmed-tint); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 2px var(--confirmed); }
  .bar span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .more { font-size: 11px; }

  /* lists: two columns of cards */
  .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .wk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: start; }
  .plan-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(0, 1.6fr); gap: 24px; align-items: start; }

  dialog#sheet { margin: auto; border-radius: 18px; max-width: 560px; }
}

/* ---------- Phase 2: sign-in, account, team plan ---------- */
[hidden] { display: none !important; }
.avatar {
  border-radius: 999px; border: 2px solid rgba(255, 255, 255, .6);
  background: var(--brand-red); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.signin {
  max-width: 400px; margin: 32px auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.signin h2 { margin: 0; font-size: 22px; }
.signin label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.signin input {
  font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 48px;
}
.signin input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.signin .btn { margin: 4px 0 0; cursor: pointer; }
.signin .btn:disabled { opacity: .6; cursor: default; }
.error { color: #b91c1c; font-size: 14px; margin: 6px 0 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { color: #fca5a5; } }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.seg button.on:disabled { opacity: 1; }
.badge.going { border-color: var(--line); color: var(--text); font-weight: 600; }
.going-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; }
.person { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; margin: 2px 4px 2px 0; font-size: 13px; }
.going-btn.on { background: var(--confirmed); color: var(--on-confirmed); border-color: var(--confirmed); font-weight: 700; }
.about-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 4px 0 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .about-logo { background: #f4f5f7; border-radius: 10px; padding: 6px 10px; } }

/* ---------- Round 3: header icon buttons, day popup, Info page ---------- */
.hdr-btn {
  position: relative; min-width: 38px; height: 38px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .45); background: transparent; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600;
}
.hdr-btn svg { width: 19px; height: 19px; }
.hdr-btn .lbl { display: none; }
.hdr-btn .count { position: absolute; top: -5px; right: -5px; }
.avatar { width: 38px; height: 38px; }
.actions { gap: 6px; }
@media (max-width: 959px) {
  .logo { height: 36px; padding: 3px 6px; }
  h1 { font-size: 18px; }
  .brand { gap: 8px; }
}
@media (min-width: 960px) {
  .hdr-btn { padding: 0 14px; height: 40px; }
  .hdr-btn .lbl { display: inline; }
  .avatar { width: 40px; height: 40px; }
  .actions { gap: 8px; }
}
.link-btn.back { display: block; padding: 0 0 8px; font-weight: 600; color: var(--accent); text-decoration: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link-btn.back { color: var(--text); } }
.days li.expected span:last-child { font-style: italic; color: var(--muted); }
.info-page h3 { font-size: 15px; margin: 18px 0 6px; color: var(--accent); }
.info-page h3:first-child { margin-top: 4px; }
.info-page p { margin: 6px 0; font-size: 15px; }
.info-page ul { margin: 6px 0; padding-left: 18px; font-size: 14px; }
.info-page ul.plain { list-style: none; padding-left: 0; }
.info-page ul.plain li, .info-page .srclist li { margin: 5px 0; }
.info-page .sw { vertical-align: -1px; margin-right: 2px; }
.info-page .tracklist { font-size: 14px; color: var(--muted); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .info-page h3 { color: var(--text); } }

/* ---------- Crew needed ---------- */
.grid { position: relative; }
.need-box {
  position: relative; z-index: 2; pointer-events: none; margin: -3px;
  border: 4px solid var(--needed); border-radius: 12px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--needed) 22%, transparent);
}
.need-box span {
  /* label sits INSIDE the box's top-right corner (empty space beside the date), so stacked boxes never overlap */
  position: absolute; top: 3px; right: 4px; white-space: nowrap; max-width: calc(100% - 30px); overflow: hidden; text-overflow: ellipsis;
  background: var(--needed); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; line-height: 16px;
}
@media (max-width: 959px) { .need-box span { top: auto; bottom: 3px; right: 3px; } } /* phone: bottom corner, clear of the date */
@media (min-width: 960px) { .need-box span { font-size: 11px; top: 4px; right: 6px; line-height: 18px; } }
.badge.needed { background: var(--needed); border-color: var(--needed); color: #fff; font-weight: 700; }
.badge.crew { border-color: var(--needed); color: var(--needed); font-weight: 600; }
.needbox {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 10px;
  border: 3px solid var(--needed); border-radius: 14px; padding: 10px 12px;
  background: color-mix(in srgb, var(--needed) 8%, var(--surface));
}
.needbox b { color: var(--needed); text-transform: uppercase; letter-spacing: .03em; }
.needbox small { color: var(--muted); width: 100%; }
.crew-box { background: var(--bg); border-radius: 14px; padding: 10px; margin: 10px 0 4px; border: 1px dashed var(--needed); }
.crew-box .lbl { font-size: 13px; font-weight: 700; color: var(--needed); margin: 0 0 6px 2px; }
.crew-box .lbl .note { font-weight: 400; color: var(--muted); }
.crew-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px 2px; border-top: 1px solid var(--line); }
.crew-row:first-of-type { border-top: 0; }
.crew-name { font-weight: 650; }
.crew-days { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.crew-days select { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 40px; }
.crew-actions { display: flex; align-items: center; gap: 12px; }
.crew-actions .pill-btn { min-height: 38px; font-weight: 650; }
.crew-row.on .crew-actions .pill-btn { border-color: var(--needed); color: var(--needed); }
.need-line > b { display: block; color: var(--needed); font-size: 13px; margin: 4px 0 4px 2px; }
.crew-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.crew-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.crew-list .link-btn { padding: 0; text-align: left; }

/* About separate from Info */
.hdr-btn.wide-only { display: none; }
@media (min-width: 960px) { .hdr-btn.wide-only { display: inline-flex; } }
.btn.secondary { background: var(--bg); color: var(--accent); border: 1px solid var(--line); cursor: pointer; }
.foot-links { display: flex; gap: 18px; }
.about-page .about-logo { width: 260px; margin: 4px auto 12px; }
.about-page h3 { font-size: 18px; }

/* ---------- Data-change notices ---------- */
.update-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; width: 100%; text-align: left; cursor: pointer;
  margin: 8px 0 4px; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line);
}
.update-banner span { flex: 1; min-width: 0; }
.update-banner u { font-weight: 700; }
.upd-warn { color: #b91c1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .upd-warn { color: #fca5a5; } }
.upd { border-top: 1px solid var(--line); padding: 6px 0; }
.upd h3 { font-size: 14px; margin: 6px 0; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.upd.new h3 { color: var(--text); }
.upd-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.upd-list > li { padding: 6px 0; }
.upd-list li span { color: var(--muted); font-size: 13px; }
.upd-list li.upd-dates { color: #b91c1c; font-weight: 600; }
.upd-list li.upd-dates span { color: #b91c1c; font-weight: 500; }
.upd-list ul { list-style: none; padding: 4px 0 0 12px; margin: 0; }
.upd-list ul li { padding: 3px 0; }
.upd-list details summary { cursor: pointer; }
.ev-link { padding: 0; text-align: left; font-weight: 600; color: inherit; }

.needwarn { width: 100%; color: #b91c1c; font-weight: 600; font-size: 13px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .needwarn { color: #fca5a5; } }

/* ---------- Not available + private tests (9 Nov) ---------- */
:root { --out: #6b7280; --out-bg: #eef0f3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --out: #a1a7b0; --out-bg: #23272f; } }
:root[data-theme="dark"] { --out: #a1a7b0; --out-bg: #23272f; }
.out-tag {
  margin-top: auto; align-self: stretch; font-size: 9px; font-weight: 700; line-height: 14px; color: var(--out);
  background: var(--out-bg); border-radius: 4px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 960px) { .out-tag { font-size: 11px; line-height: 18px; padding: 0 5px; } }
/* Days I'm out: soft gray stripes behind the day */
.cell.me-out { background: repeating-linear-gradient(135deg, var(--surface) 0 6px, var(--out-bg) 6px 12px); }
.badge.out { border-color: var(--out); color: var(--out); font-weight: 600; }
.outbox { border: 1px solid var(--line); background: var(--out-bg); border-radius: 12px; padding: 10px 12px; margin: 10px 0 4px; font-size: 14px; }
.outbox b { color: var(--out); }
.outbox ul { list-style: none; margin: 6px 0 0; padding: 0; }
.outbox li { padding: 2px 0; }
.day-tools { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; font-size: 14px; }
.day-out b { color: var(--out); }
.day-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.day-actions .pill-btn { font-weight: 650; }
.out-btn.on { background: var(--out); border-color: var(--out); color: var(--surface); }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.plan-actions .pill-btn { font-weight: 650; }
.wk-out { font-size: 13px; color: var(--out); font-weight: 600; margin: -2px 0 6px; }
.wk-empty .wk-out { margin: 2px 0 0; font-size: 12px; }
.pvt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 4px; }
.pvt-actions .pill-btn { font-weight: 650; }
.link-btn.danger { color: #b91c1c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link-btn.danger { color: #fca5a5; } }
.kv dd.pre { white-space: pre-line; }
.btn.secondary + .btn { margin-top: 0; }
/* forms in the sheet */
.form { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
.field .note { font-weight: 400; margin: 0; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; font-weight: 400; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 46px; width: 100%; min-width: 0;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .btn { cursor: pointer; margin: 4px 0 0; }
/* The Save button stays in reach at the bottom of a long form. */
.form > .btn[type="submit"] { position: sticky; bottom: 8px; z-index: 1; box-shadow: 0 0 0 8px var(--surface); }
.form .btn:disabled { opacity: .6; cursor: default; }
.seg-opt { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; }
.seg-opt input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg-opt input[value="planned"]:checked + span { background: var(--planned); color: var(--on-planned); border-color: var(--planned); }
.seg-opt input[value="confirmed"]:checked + span { background: var(--confirmed); color: var(--on-confirmed); border-color: var(--confirmed); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#outWho { margin-bottom: 4px; }
.out-list { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.out-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.out-note { font-weight: 400; font-style: italic; color: var(--muted); }
/* "Private" checkbox in the Add event form, lined up with the Type select next to it */
.check-field { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 14px; font-weight: 600; cursor: pointer; }
.check-field input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.check-field span { display: flex; flex-direction: column; line-height: 1.2; }
.check-field .note { font-weight: 400; font-size: 12px; margin: 0; }

/* Key: three color groups + the three plan states (9 Nov) */
.key-groups { display: grid; gap: 8px; font-size: 14px; }
.key-groups > div { display: flex; align-items: flex-start; gap: 10px; }
.key-groups .sw { flex: 0 0 auto; margin-top: 3px; }
.key-groups b { margin-right: 4px; }
.info-page .t-supertour .sw, .info-page .t-regional .sw, .info-page .t-test .sw { vertical-align: -1px; }
