*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:          #2d6a4f;
  --green-lt:       #40916c;
  --green-acc:      #52b788;
  --sand:           #d4a853;
  --bg:             #0f1a14;
  --bg-2:           #1a2820;
  --bg-3:           #243323;
  --border:         #2d3f30;
  --text:           #e8f0e9;
  --text-dim:       #7a9c7e;
  --red:            #e07070;
  --amber:          #e0b070;
  --radius:         8px;
  --topbar-h:       62px;
  /* Platform colours */
  --foreup:         #3b82f6;
  --kenna:          #4ecdc4;
  --quick18:        #a855f7;
  --golfnow:        #f59e0b;
  --troon:          #d4a853;
  /* Discount-network colours */
  --arcis:          #6ee7b7;
  --phoenix:        #93c5fd;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 7px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.topbar-left  { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.logo         { font-size: 26px; line-height: 1; }

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--green-acc);
  letter-spacing: 0.01em;
}
.search-summary {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Top nav tabs ───────────────────────────────────────── */
.top-nav { display: flex; gap: 6px; }
.nav-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  transition: all 0.15s;
}
.nav-btn:hover { border-color: var(--green-acc); color: var(--text); }
.nav-btn.active {
  background: var(--green);
  border-color: var(--green-acc);
  color: white;
}
/* Donate — opens the Ko-fi panel overlay. */
.donate-btn {
  background: var(--green);
  border: 1px solid var(--green-acc);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  transition: all 0.15s;
}
.donate-btn:hover { background: var(--green-lt); }

/* ── Help (header ? button + dialog) ────────────────────── */
.help-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
}
.help-btn:hover { border-color: var(--green-acc); color: var(--green-acc); }

.help-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.help-dialog {
  position: relative;
  width: 560px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.help-title { font-size: 17px; margin-bottom: 10px; }
.help-body  { overflow-y: auto; font-size: 13px; line-height: 1.55; }
.help-body details {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.help-body details:last-child { border-bottom: none; }
.help-body summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--green-acc);
  list-style: none;
  display: flex; align-items: center; gap: 7px;
}
.help-body summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.15s;
}
.help-body details[open] summary::before { transform: rotate(90deg); }
.help-body p { margin: 7px 0 3px; color: var(--text); }
.help-body strong { color: var(--text); }

@media (max-width: 720px) {
  .help-dialog {
    width: 100vw; max-width: none;
    height: 100dvh; max-height: none;
    border-radius: 0; border: none;
  }
}

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
}

/* ── Combined dual filter row (Players + Holes) ─────────── */
.dual-filter-row {
  display: flex;
  gap: 20px;
}
.dual-filter-col {
  flex: 0 0 auto;
}
.dual-filter-col .toggle-group { flex-wrap: nowrap; }
.dual-filter-col .toggle {
  flex: none;
  width: 28px;
  padding: 5px 0;
  text-align: center;
}

/* ── Toggle / pill buttons ──────────────────────────────── */
.toggle-group { display: flex; gap: 4px; flex-wrap: nowrap; }
.toggle {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  transition: all 0.12s;
  white-space: nowrap;
}
.toggle:hover  { border-color: var(--green-acc); color: var(--text); }
.toggle.active { background: var(--green); border-color: var(--green-acc); color: white; }

/* ── Tee time range ─────────────────────────────────────── */
.time-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.time-select {
  flex: 1;
  min-width: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 6px 6px;
  cursor: pointer;
}
.time-select:focus { border-color: var(--green-acc); }
.time-range-sep {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Date input ─────────────────────────────────────────── */
#input-date {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  color-scheme: dark;
  cursor: pointer;
}

/* ── Location ───────────────────────────────────────────── */
.location-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-gps-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.location-gps-btn:hover  { border-color: var(--green-acc); color: var(--green-acc); }
.location-gps-btn:active { background: var(--bg-2); }

.hub-select {
  flex: 1;
  min-width: 0;
  width: auto;
  background: var(--bg-3);
  border: 1px solid var(--green-acc);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
}

#location-status {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  min-height: 14px;
}

/* ── Radius slider ──────────────────────────────────────── */
.filter-slider {
  width: 100%;
  accent-color: var(--green-acc);
  margin-top: 6px;
  cursor: pointer;
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}
.value-label { font-size: 12px; color: var(--green-acc); font-weight: 600; }

/* ── Course list (collapsible) ──────────────────────────── */
details#course-details > summary {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 4px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details#course-details > summary::before {
  content: "▶";
  font-size: 9px;
  transition: transform 0.15s;
}
details[open]#course-details > summary::before { transform: rotate(90deg); }

.course-list-controls {
  margin: 8px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bulk-btns { display: flex; gap: 4px; }
.bulk-btns .toggle { flex: 1; font-size: 11px; padding: 4px 6px; }

.course-search-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.course-search-input:focus  { border-color: var(--green-acc); }
.course-search-input::placeholder { color: var(--text-dim); }

.course-filters {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}
.filter-check {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 3px 0;
}
.filter-check input { accent-color: var(--green-acc); flex-shrink: 0; }
.filter-check-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  gap: 4px;
}
.filter-check-name { font-size: 12px; flex: 1; color: var(--text); }
.filter-check-dist { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
/* "opens Aug 2" — this course doesn't sell as far out as the picked date.
   Amber like the other not-a-failure states, never red: nothing is broken. */
.filter-check-window {
  font-size: 10px;
  color: var(--amber);
  white-space: nowrap;
  margin-left: 6px;
}

/* ── Search button ──────────────────────────────────────── */
.search-btn {
  width: 100%;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  transition: background 0.15s;
  margin-bottom: 8px;
}
.search-btn:hover:not(:disabled) { background: var(--green-lt); }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Errors ─────────────────────────────────────────────── */
.errors { border-top: 1px solid var(--border); padding-top: 10px; }
.error-msg { font-size: 11px; color: var(--red); margin-top: 5px; line-height: 1.4; }

/* ── Main content area ──────────────────────────────────────
   overflow-x stays visible: every page has a position:sticky top bar,
   and a scroll container would capture it. Wide content (the results
   table) scrolls inside #results-area instead. */
.results-main {
  flex: 1;
  /* Flex items default to min-width:auto, which lets a single wide child
     (e.g. the Player tab group) push main past the viewport and scroll the
     whole app sideways on a phone. Pinning it to 0 keeps main within the
     viewport; wide children handle their own overflow (#results-area scrolls,
     the tab groups wrap). */
  min-width: 0;
  padding: 20px 24px;
  overflow-x: visible;
  min-height: calc(100vh - var(--topbar-h));
}
#results-area { overflow-x: auto; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Legend ─────────────────────────────────────────────── */
.results-legend {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Results topbar: rating scope toggle (Community / Mine) ── */
.results-topbar {
  display: flex;
  align-items: center;
  /* WRAP, don't overflow: .results-main is overflow-x: visible, so an
     unwrapped row (4 sort pills + "⭐ Ratings:" + Community/Mine) pushes the
     whole app sideways on a phone instead of scrolling inside itself. */
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.results-topbar:empty { display: none; }
.rating-scope-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ── Month-aware rating + price deal flag ──────────────────── */
.rating-n { color: var(--text-dim); font-weight: 400; }
.deal-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: 1px;
  cursor: help;
  white-space: nowrap;
}
.deal-badge.good {
  color: var(--green-acc);
  border: 1px solid var(--green-acc);
  background: rgba(82, 183, 136, 0.12);
}
.deal-badge.bad {
  color: var(--red);
  border: 1px solid var(--red);
  background: rgba(224, 112, 112, 0.12);
}

/* ── Live search progress ──────────────────────────────────── */
.search-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--bg-3);
  border-radius: 8px;
  font-size: 12px;
}
.search-progress-eta {
  width: 100%;   /* forces its own row in the flex-wrap container above */
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.progress-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.progress-chip.running { color: var(--text-dim); }
.progress-chip.done     { border-color: var(--green-acc); color: var(--green-acc); }
.progress-chip.error    { border-color: var(--red); color: var(--red); }
.progress-chip.warn     { border-color: var(--amber); color: var(--amber); }
.progress-chip .spinner { margin-right: 5px; width: 10px; height: 10px; }

/* ── Diagnostics banner ────────────────────────────────────── */
.diagnostics-banner {
  margin-bottom: 10px;
  border: 1px solid var(--red);
  border-radius: 8px;
  overflow: hidden;
}
.diagnostics-banner summary {
  cursor: pointer;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--red);
  font-weight: 600;
  list-style: none;
}
.diagnostics-banner summary::-webkit-details-marker { display: none; }
.diag-detail {
  padding: 4px 14px 10px;
  border-top: 1px solid var(--border);
}
.diag-line {
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 0;
}
.diag-line.diag-error { color: var(--red); }
.diag-line.diag-warn  { color: var(--amber); }

/* Warnings only (e.g. a course that doesn't sell that far out) — amber, so a
   real platform failure still reads as the only red thing on screen. */
.diagnostics-banner.warn-only         { border-color: var(--amber); }
.diagnostics-banner.warn-only summary { color: var(--amber); }

/* ── Next availability banner ──────────────────────────────── */
/* Sits at the top of the results column (never missed on long result
   tables): one line per course that had no times on the searched date,
   filling in live as later dates are probed. */
.next-avail-banner {
  margin-top: 16px;    /* breathing room below the results grid */
  margin-bottom: 10px;
  padding: 8px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green-acc);
  border-radius: 8px;
  font-size: 12px;
}
.next-avail-head {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.next-avail-row {
  padding: 3px 0;
  color: var(--text-dim);
}
.next-avail-row .spinner {
  width: 10px;
  height: 10px;
  margin-right: 6px;
}
.next-avail-row.found { color: var(--text); }
/* Books not open yet — a known date, not a failed lookup, so it reads as
   solidly as a "found" row; only the date colour says "not yet". */
.next-avail-row.not_open { color: var(--text); }
.next-avail-row.not_open .na-date { color: var(--amber); }
.na-est { color: var(--text-dim); font-style: italic; }
.na-course { font-weight: 600; color: var(--text); }
.na-date   { font-weight: 600; color: var(--green-acc); }
.na-show-btn {
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.na-show-btn:hover { border-color: var(--green-acc); color: var(--green-acc); }
.next-avail-table-wrap {
  margin: 6px 0 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}

/* ── Results table ──────────────────────────────────────── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table thead tr { border-bottom: 2px solid var(--border); }
.results-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
}
.results-table th[data-col]:hover { color: var(--text); }
.results-table th.sorted          { color: var(--green-acc); }
.results-table td {
  padding: 11px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.results-table tbody tr:hover { background: var(--bg-2); }

.col-time {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-acc);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.col-course     { font-weight: 600; max-width: 220px; }
.col-course-name-row { display: flex; align-items: center; gap: 8px; }
.col-course-rating   { font-size: 11px; color: var(--sand); white-space: nowrap; }
.col-course-pref     { font-size: 11px; color: var(--green-acc); white-space: nowrap; cursor: help; }
.col-course-sub  { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-weight: 400; }
.col-course-maint       { font-size: 11px; color: var(--sand); margin-top: 2px; }
.col-course-maint.active { color: var(--red); font-weight: 600; }
.col-dist, .col-spots { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.col-spots.low  { color: var(--red); font-weight: 700; }
.col-rate       { font-size: 12px; color: var(--text-dim); }
.col-price      { white-space: nowrap; }
/* The bold price is whichever one drives the sort (user call 2026-07-11):
   the headline when no entitled sub-rate beats it, else that sub-rate.
   .sort-driver bolds the headline; a winning sub-rate is already bold via
   .rate-eligible. */
.price-total    { font-size: 15px; font-weight: 400; color: var(--sand); display: block; }
.price-total.sort-driver { font-weight: 700; }
.price-detail   { font-size: 11px; color: var(--text-dim); display: block; margin-top: 1px; }

/* ── Platform badge ─────────────────────────────────────── */
.platform-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  text-decoration: none;
}
.platform-badge.foreup  { background: #1e3a5f; color: var(--foreup); }
.platform-badge.kenna   { background: #0d3030; color: var(--kenna); }
.platform-badge.quick18 { background: #2d1b4e; color: var(--quick18); }
.platform-badge.golfnow { background: #3d2600; color: var(--golfnow); }
.platform-badge.troon   { background: #3a2800; color: var(--troon); }
.platform-badge.arcis   { background: #0d3d2e; color: var(--arcis); }
.platform-badge.phoenix { background: #1e2f4d; color: var(--phoenix); }
a.platform-badge:hover { filter: brightness(1.2); }

/* ── Book button ────────────────────────────────────────── */
.book-btn {
  background: var(--green);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
  display: inline-block;
}
.book-btn:hover { background: var(--green-lt); }

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--green-acc);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Course Manager ─────────────────────────────────────── */
/* ── Course search bar (Courses page) ───────────────────── */
.cm-topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 95;                    /* above the bottom tab bar (90), below dialogs */
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -20px -24px 16px;       /* full-bleed across .results-main's padding */
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cm-search-main {
  flex: 1;
  max-width: 440px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
}
.cm-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.cm-topbar-actions { display: flex; gap: 6px; margin-left: auto; }

/* ── Course grid: compact tiles, details in the drawer ──── */
.cm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  align-items: start;
}
.cm-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.cm-card:hover { border-color: var(--green-acc); }
.cm-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 13px;
}
.cm-card-main   { min-width: 0; }
.cm-card-name   { font-weight: 700; font-size: 13px; }
.cm-card-sub    { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.cm-card-rating { font-size: 12px; color: var(--sand); font-weight: 600; white-space: nowrap; }

/* ── Course detail: full-page editor (opened over the grid, below the app
   top bar). Two-column on desktop, stacks on mobile. ─────────────────────── */
.cm-drawer-overlay {
  /* Sits below the app header (100) and every dialog (100+), but above the
     page's own sticky bars (95) and the mobile bottom nav (90) so it fully
     covers the course grid it opens over. */
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 96;
  background: var(--bg);
  display: flex;
}
.cm-drawer {
  width: 100%; max-width: none; height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.cm-drawer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.ce-back {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim); font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 12px; cursor: pointer;
}
.ce-back:hover { color: var(--green-acc); }
.cm-drawer-titles { display: flex; align-items: center; gap: 10px; }
.cm-drawer-title { font-size: 17px; font-weight: 700; }
.cm-drawer-sub   { font-size: 12px; color: var(--text-dim); flex-basis: 100%; }
.badge-admin {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--green-acc); background: rgba(82, 183, 136, .12);
  border: 1px solid rgba(82, 183, 136, .35); border-radius: 20px; padding: 3px 9px;
}
.cm-drawer-body  {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 24px;
}
.cm-drawer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.cm-dirty-note {
  font-size: 11px;
  color: var(--sand);
  visibility: hidden;
}
.cm-drawer-save-plain {
  margin-left: auto;
  padding: 8px 16px;
}
.cm-drawer-save-plain:disabled { opacity: 0.5; cursor: not-allowed; }
.cm-drawer-save {
  width: auto;
  margin: 0;
  padding: 9px 22px;
}
.cm-drawer-foot .cm-save-status { font-size: 12px; }

@media (max-width: 720px) {
  .cm-topbar { margin: -12px -12px 12px; padding: 10px 12px; }
  .cm-count  { display: none; }        /* room for the search box first */
  .cm-drawer-head { padding: 10px 14px; }
  .cm-drawer-body { padding: 14px 14px 22px; }
  .cm-drawer-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
}

/* ── Course editor: two-column accordion ──────────────────── */
.ce-edit { padding-top: 0; }
.ce-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  align-items: start; max-width: 1120px; margin: 0 auto;
}
.ce-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 900px) { .ce-cols { grid-template-columns: 1fr; } }

.ce-sec {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-2); overflow: hidden;
}
.ce-sec-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; user-select: none;
}
.ce-ico  { font-size: 14px; }
.ce-name { font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.ce-sec-meta {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim);
}
.ce-meta-warn { color: var(--amber); font-weight: 700; }
.ce-chev { color: var(--text-dim); font-size: 11px; transition: transform .15s ease; }
.ce-sec.collapsed .ce-sec-body { display: none; }
.ce-sec.collapsed .ce-chev { transform: rotate(-90deg); }
.ce-sec-body { padding: 2px 14px 14px; }
.ce-sec-body .cm-label:first-child { margin-top: 4px; }

.ce-lock {
  font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--sand); background: rgba(212, 168, 83, .12);
  border: 1px solid rgba(212, 168, 83, .32); border-radius: 20px; padding: 2px 8px;
}
.ce-hint { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.ce-hint code { color: var(--sand); background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.ce-empty { font-size: 12px; color: var(--text-dim); padding: 4px 0; }
.ce-price-now { color: var(--green-acc); font-weight: 700; }
.ce-maint-alert {
  font-size: 12px; font-weight: 600; color: var(--amber);
  background: rgba(224, 176, 112, .1); border: 1px solid rgba(224, 176, 112, .38);
  border-radius: 6px; padding: 8px 11px; margin-bottom: 10px;
}

.ce-kv {
  display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px;
  font-size: 13px; align-items: baseline;
}
.ce-kv .k { color: var(--text-dim); font-size: 12px; }
.ce-kv a  { color: var(--green-acc); text-decoration: none; }
.ce-kv a:hover { text-decoration: underline; }

/* Scorecard (read-only, from sub_courses) */
.ce-sub { margin-top: 14px; }
.ce-sub:first-child { margin-top: 2px; }
.ce-sub-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.ce-sub-title .nm { font-size: 13px; font-weight: 700; }
.ce-sub-title .holes { font-size: 11px; color: var(--text-dim); }
.ce-par-pill {
  font-size: 11px; color: var(--green-acc); font-weight: 700;
  background: rgba(82, 183, 136, .1); border: 1px solid rgba(82, 183, 136, .3);
  border-radius: 20px; padding: 2px 9px;
}
.ce-sc-wrap { overflow-x: auto; }
table.ce-scorecard { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.ce-scorecard th {
  text-align: right; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); font-weight: 700; padding: 5px 8px; border-bottom: 1px solid var(--border);
}
table.ce-scorecard th:first-child { text-align: left; }
table.ce-scorecard td { text-align: right; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid rgba(45, 63, 48, .5); }
table.ce-scorecard td:first-child { text-align: left; }
table.ce-scorecard tr:last-child td { border-bottom: none; }
.ce-tee-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.ce-tee-swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .25); flex: none; }
.ce-num-dim { color: var(--text-dim); }
/* Women's rating/slope columns — a subtle left rule + tint so the men's and
   women's course-rating groups read apart at a glance. */
table.ce-scorecard th.ce-w, table.ce-scorecard td.ce-w { border-left: 1px solid var(--border); }
table.ce-scorecard td.ce-w { color: var(--text-dim); }
table.ce-scorecard th.ce-w:first-of-type { border-left: 1px solid var(--border); }

/* Current-month row in the seasonal-pricing list */
.cm-price-row.ce-price-now-row .cm-price-month { color: var(--text); font-weight: 700; }
.cm-price-row.ce-price-now-row .cm-price-range { color: var(--green-acc); }

@media (prefers-reduced-motion: reduce) { .ce-chev { transition: none; } }
.cm-edit { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.cm-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); font-weight: 700; margin-top: 10px;
}
.cm-input, .cm-textarea {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 13px; padding: 7px 10px; font-family: inherit;
  width: 100%;
}
.cm-textarea { min-height: 56px; resize: vertical; }

.cm-windows       { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.cm-windows-empty { font-size: 11px; color: var(--text-dim); padding: 4px 0; }
.cm-window-row    { display: flex; align-items: center; gap: 6px; }
.cm-window-date   { width: auto; flex: 1; }
.cm-window-sep    { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.cm-window-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 4px 6px; flex-shrink: 0;
}
.cm-window-remove:hover { color: var(--red); }
.cm-add-window    { align-self: flex-start; margin-top: 2px; }

.cm-maint-badge         { font-size: 11px; color: var(--sand); margin-top: 3px; }
.cm-maint-badge.current { color: var(--red); font-weight: 600; }

.cm-rating-latest-line { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.cm-ratings-log        { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.cm-rating-entry       { background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.cm-rating-entry-head  { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cm-rating-entry-date  { font-size: 12px; font-weight: 600; color: var(--green-acc); flex: 1; }
.cm-rating-entry-avg   { font-size: 12px; color: var(--sand); }
.cm-rating-entry-cats  { font-size: 11px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px; }
.cm-rating-cat         { white-space: nowrap; }
.cm-rating-entry-note  { font-size: 11px; color: var(--text-dim); margin-top: 4px; font-style: italic; }
.cm-ratings-add        { background: var(--bg-3); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-top: 6px; }
.cm-ratings-add-row    { margin-bottom: 8px; }
.cm-ratings-grid       { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.cm-rating-add-row     { margin-top: 6px; }
.cm-rating-status      { font-size: 12px; color: var(--text-dim); }

.cm-ratings     { display: flex; flex-direction: column; gap: 6px; }
.cm-rating-row  { display: flex; align-items: center; justify-content: space-between; }
.cm-rating-label{ font-size: 12px; color: var(--text); }
.cm-stars       { display: flex; gap: 2px; cursor: pointer; }
.cm-star        { font-size: 16px; color: var(--border); transition: color 0.1s; }
.cm-star.filled { color: var(--sand); }

.cm-pricing       { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.cm-pricing-empty { font-size: 11px; color: var(--text-dim); padding: 6px 0; }
.cm-price-row     { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cm-price-month   { font-size: 11px; color: var(--text-dim); width: 64px; flex-shrink: 0; }
.cm-price-bar-track { flex: 1; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.cm-price-bar     { height: 100%; background: var(--green-acc); }
.cm-price-range   { font-size: 11px; color: var(--sand); width: 80px; text-align: right; flex-shrink: 0; }

/* Shared with the admin Debug page's per-course event drill-down. */
.cm-reliability-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
  font-size: 11px; color: var(--text-dim); border-bottom: 1px solid var(--border);
}
.cm-reliability-row.has-error   { color: var(--red); }
.cm-reliability-date            { width: 104px; flex-shrink: 0; }
.cm-reliability-system          { width: 70px; flex-shrink: 0; text-transform: capitalize; }
.cm-reliability-status          { width: 130px; flex-shrink: 0; }
.cm-reliability-detail          { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Debug page (admin) — search health exception report ─────────────────── */
.debug-summary {
  font-size: 14px; color: var(--text); padding: 12px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 12px;
}
.debug-row {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 8px;
}
.debug-row.broken   { border-left: 3px solid var(--red); }
.debug-row.degraded { border-left: 3px solid var(--sand); }
.debug-row-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.debug-course { font-weight: 600; color: var(--text); }
.debug-reason { font-size: 12px; color: var(--text-dim); }
.debug-row-stats {
  font-size: 11px; color: var(--text-dim); margin-top: 4px;
}
.debug-row-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.debug-test-result { font-size: 12px; color: var(--text-dim); }
.debug-events { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }

/* Debug page — search speed: per build, per platform, per day. */
.debug-section-title { font-size: 14px; font-weight: 700; margin: 16px 0 8px; color: var(--text); }
.debug-subtitle { font-size: 12px; color: var(--text-dim); margin: 12px 0 6px; }
.debug-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.debug-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.debug-table th, .debug-table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap;
}
.debug-table th { color: var(--text-dim); font-weight: 600; }
.debug-table th:first-child, .debug-table td:first-child { text-align: left; }
.debug-table tr.probe td { color: var(--text-dim); }

.cm-edit-actions  { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.cm-save-btn      { width: auto; padding: 8px 16px; margin-bottom: 0; }
.cm-save-status   { font-size: 12px; color: var(--text-dim); }

/* ── Player profile ─────────────────────────────────────── */
.pl-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  max-width: 720px;
}
.pl-heading { font-size: 15px; font-weight: 700; margin: 0; }
.pl-hint    { font-size: 12px; color: var(--text-dim); margin: 4px 0 12px; line-height: 1.5; }
.pl-field-row {
  display: flex; gap: 20px; flex-wrap: wrap;
}
.pl-field   { flex: 1; min-width: 200px; }
.pl-field .toggle-group { margin-top: 4px; }
.pl-field .cm-input     { margin-top: 4px; }
.pl-field .filter-slider { margin-top: 8px; }

.pl-membership-list { display: flex; flex-direction: column; gap: 8px; }
.pl-membership {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; cursor: pointer;
}
.pl-membership:hover { border-color: var(--green-acc); }
.pl-membership input { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--green-acc); cursor: pointer; }
.pl-membership-body { display: flex; flex-direction: column; }
.pl-membership-name { font-size: 14px; font-weight: 600; }
.pl-membership-sub  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.pl-hide-wrap {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.pl-hide-wrap input { width: 13px; height: 13px; margin-top: 0; accent-color: var(--text-dim); }
/* "How you play" rows carry no Hide control — those rate kinds are always
   shown. The slot still reserves its width so the three groups line up. */
.pl-hide-na { font-style: italic; opacity: .65; }

.pl-favorite-list { max-height: 320px; margin-top: 8px; }

/* Pricing-normalization display: exactly one rate per row gets the green
   highlight — the cheapest one the player's checked toggles entitle them to
   (it drives the price sort). Cart is assumed included in every displayed
   price; 🚶 marks the walking (no-cart) exceptions. A "conditional" headline
   is a course with no plain public rate (AZ Resident / Pre-paid-only) that
   the player doesn't currently qualify for. */
.price-detail.rate-eligible { color: var(--green-acc); font-weight: 700; }
.price-total.rate-eligible  { color: var(--green-acc); font-weight: 700; }
.price-total.rate-conditional {
  font-style: italic;
  border-bottom: 1px dashed var(--text-dim);
  cursor: help;
  width: fit-content;
}

/* ── Account (header) ─────────────────────────────────────── */
.account-area {
  display: flex; align-items: center; gap: 8px;
}
.account-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 6px 12px;
  border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.account-btn:hover { border-color: var(--green-acc); color: var(--green-acc); }
.account-email {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-admin-chip {
  background: var(--green); color: var(--text);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 10px; text-transform: uppercase;
}

/* ── Sign-in dialog ───────────────────────────────────────── */
.auth-overlay {
  /* Above every other overlay (drawer/picker/help are 100): sign-in can be
     summoned from INSIDE any of them, and at equal z-index DOM order let
     the drawer paint over the dialog. */
  position: fixed; inset: 0; z-index: 130;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.auth-dialog {
  position: relative;
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--bg-2, #16241b); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.auth-title { font-size: 18px; margin: 0 0 12px; }
.auth-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer;
}
.auth-close:hover { color: var(--text); }
.auth-note {
  background: var(--bg-3, #1c2e22); border: 1px solid var(--border);
  border-left: 3px solid var(--green-acc);
  border-radius: var(--radius); padding: 8px 10px;
  font-size: 12px; margin-bottom: 12px;
}
.auth-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.auth-tabs .toggle { flex: 1; }
.auth-dialog .cm-input { width: 100%; margin: 4px 0 10px; box-sizing: border-box; }
.auth-error { font-size: 12px; color: var(--red); min-height: 16px; margin-bottom: 6px; }
.auth-submit { width: 100%; }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim); font-size: 11px; margin: 12px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.auth-oauth-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 13px; padding: 9px 12px; border-radius: var(--radius); cursor: pointer;
}
.auth-oauth-btn:hover { border-color: var(--green-acc); }
.auth-oauth-btn + .auth-oauth-btn { margin-top: 8px; }
.auth-fineprint {
  font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-top: 14px;
}

/* ── Donate dialog (Ko-fi) ────────────────────────────────── */
.donate-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.donate-dialog {
  position: relative;
  /* Phone-ish width on every screen: Ko-fi's compact mobile layout fits the
     iframe without a scrollbar, its wider desktop layout doesn't. */
  width: 400px; max-width: calc(100vw - 32px);
  background: var(--bg-2, #16241b); border: 1px solid var(--border);
  border-radius: 12px; padding: 36px 12px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.donate-dialog iframe {
  display: block; width: 100%;
  /* Compact-layout panel is ~670px tall once a message adds the
     private-message row; more just shows gray filler. On short windows
     give the iframe every pixel the dialog chrome doesn't need. */
  height: min(700px, calc(100vh - 70px));
  border: none; border-radius: 8px;
  background: #f9f9f9;   /* Ko-fi panel is light-themed */
}

/* Read-only Course Manager card body (non-admin view) */
.cm-readonly { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cm-ro-row   { display: flex; gap: 8px; font-size: 13px; }
.cm-ro-label { color: var(--text-dim); min-width: 150px; }
.cm-ro-row a { color: var(--green-acc); word-break: break-all; }
.cm-ro-notes {
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
  border-left: 3px solid var(--border); padding-left: 10px; margin-top: 4px;
}
.cm-rating-entry-by { font-size: 11px; color: var(--text-dim); }

/* ── Back-to-top button ───────────────────────────────────
   The results table runs many screens long and the native scrollbar is
   fiddly, so a floating button rides the bottom-right corner once the
   page is scrolled. z-index stays under the dialogs (100). */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover { border-color: var(--green-acc); color: var(--green-acc); }

/* Anchored scrolls land under the fixed topbar without this. */
.results-table tbody tr, .cm-card { scroll-margin-top: calc(var(--topbar-h) + 10px); }

/* Between full desktop and the phone layout the header gets tight —
   drop the subtitle and compact the tabs before anything crushes. */
@media (max-width: 1000px) {
  .search-summary { display: none; }
  .topbar h1 { font-size: 15px; }
  .nav-btn { font-size: 12px; padding: 6px 9px; }
}

/* ── Bottom tab bar (mobile only — desktop uses the header tabs) ── */
.bottom-nav { display: none; }
@media (max-width: 720px) {
  .top-nav { display: none; }   /* nav lives in the bottom bar instead */

  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    display: flex;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 7px 0 6px;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--text-dim);
  }
  .bottom-nav .nav-btn.active {
    background: none;
    color: var(--green-acc);
    border-top: 2px solid var(--green-acc);
    margin-top: -1px;             /* the active border replaces the bar's */
  }
  .bn-icon  { font-size: 18px; line-height: 1; }
  .bn-label { font-size: 10px; font-weight: 600; }

  /* Content and floating widgets clear the bar (bottom sheets and the
     course picker deliberately cover it — z-index 120 vs 90). */
  .results-main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .back-to-top  { bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ── New-build banner ────────────────────────────────────────────────────────
   Floats just under the app header rather than in the results column: it is
   app-wide and rare, and every page has its own sticky bar at that spot to
   avoid pushing around. z-index clears the page bars (95) and the course
   editor (96) but stays under the header and dialogs (100). */
.update-banner {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 9px 10px 9px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--green-acc);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.update-banner .ub-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-banner .ub-reload {
  background: var(--green);
  border: 1px solid var(--green-acc);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 4px 14px;
  white-space: nowrap;
}
.update-banner .ub-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 13px; line-height: 1; padding: 2px 4px;
}
.update-banner .ub-close:hover { color: var(--text); }
@media (max-width: 720px) {
  .update-banner { left: 8px; right: 8px; transform: none; max-width: none; font-size: 12px; }
}

/* ── Course lists ────────────────────────────────────────────────────────────
   ⭐ split-button + list dropdown in the course picker, and the list
   manager (rows + editor + smart-rule builder) on the Player page. */
.fav-split { position: relative; display: flex; flex: 1; }
.fav-split #btn-fav { flex: 1; border-radius: var(--radius) 0 0 var(--radius); }
.fav-caret {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
  padding: 4px 7px;
  font-size: 11px;
}
.fav-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.fav-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.fav-menu-item:last-child { border-bottom: none; }
.fav-menu-item:hover { background: var(--bg-3); color: var(--green-acc); }
.fav-menu-count { font-size: 10px; color: var(--text-dim); }
.fav-menu-empty { padding: 9px 10px; font-size: 11px; color: var(--text-dim); }

/* Player page — saved list rows */
.pl-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pl-list-star { width: 14px; color: var(--sand); }
.pl-list-name { font-weight: 600; }
.pl-list-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.pl-list-badge.smart { border-color: var(--green-acc); color: var(--green-acc); }
.pl-list-count { flex: 1; text-align: right; font-size: 11px; color: var(--text-dim); }
.pl-list-btn { font-size: 11px; padding: 2px 8px; }
.pl-list-detail {
  padding: 2px 4px 8px 26px;
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.pl-list-lapsed { color: var(--text-dim); font-style: italic; opacity: 0.75; }
.pl-lists-empty { font-size: 12px; color: var(--text-dim); padding: 6px 0; }
#btn-new-list { margin-top: 10px; }

/* List editor */
#pl-list-editor {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.ple-default-row { margin: 8px 0; font-size: 12px; }
.ple-cond-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.ple-cond-field { max-width: 130px; }
.ple-cond-value { flex: 1; }
.ple-preview {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   Filter chip bar + course picker (Tee Times page)
   Filters live in a horizontal chip bar above the results; the
   ⛳ Courses chip opens a full-height picker overlay grouped by
   metro region. (No sidebar anywhere — .results-main handles
   the layout for every page.)
   ═══════════════════════════════════════════════════════════ */

.pl-topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 95;                    /* above the bottom tab bar, below dialogs */
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -20px -24px 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pl-save-chip { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* Debug page (admin) — same sticky-bar pattern, just a title + refresh. */
.dbg-topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -20px -24px 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.dbg-title {
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 720px) {
  .dbg-topbar { margin: -12px -12px 12px; padding: 10px 12px; }
}

@media (max-width: 720px) {
  .pl-topbar { margin: -12px -12px 12px; padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  /* The 4 settings tabs don't fit one phone-width row — let them wrap. */
  .pl-tabs { flex-wrap: wrap; }
  .pl-tabs .toggle { font-size: 11px; padding: 5px 8px; }
}

/* ── Chip bar ───────────────────────────────────────────── */
.filter-bar {
  position: sticky;
  top: var(--topbar-h);
  /* Sticky + z-index makes this a stacking context, so the chip popovers /
     bottom sheets inside it can never out-stack anything above THIS value —
     their own z-index only counts internally. Must beat the bottom tab bar
     (90) or the sheets render underneath it; stays below dialogs (100). */
  z-index: 95;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  /* full-bleed across .results-main's 20/24px padding */
  margin: -20px -24px 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.chip-wrap { position: relative; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--green-acc); }
.chip.open  { border-color: var(--green-acc); background: var(--bg-2); }
.chip-courses { border-color: var(--green-lt); }

/* Search stays a real button, pushed to the bar's right edge */
.filter-bar-search {
  width: auto;
  margin: 0 0 0 auto;
  padding: 8px 22px;
  border-radius: 999px;
}

/* ── Chip popovers ──────────────────────────────────────── */
.chip-pop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 80;
  min-width: 230px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.chip-pop.open { display: block; }
.chip-pop h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 700;
}
.chip-pop-wide { min-width: 290px; }

/* Mobile sort group — desktop sorts via the table header, so this only
   shows under 720px where the header row is hidden. */
.sort-group-wrap { display: none; }
@media (max-width: 720px) {
  .sort-group-wrap { display: inline-flex; }
  /* Same compact pills for the rating scope, so the whole topbar has a
     chance of fitting one line on a narrow phone. */
  .sort-group-wrap .toggle,
  .rating-scope-wrap .toggle { font-size: 11px; padding: 4px 9px; }
  .rating-scope-wrap { font-size: 11px; }
}

/* Date quick picks (Today / Tomorrow / Fri / Sat / Sun) */
.date-quick-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.date-quick-row .toggle { flex: 1; padding: 5px 6px; font-size: 11px; }

/* ── Collapsed bar summary (mobile, post-search) ────────── */
.filter-bar-summary {
  display: none;
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fbs-edit { color: var(--green-acc); font-weight: 700; margin-left: 6px; }

/* ── Course picker overlay ──────────────────────────────── */
.picker-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.picker-dialog {
  position: relative;
  width: 620px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.picker-title { font-size: 17px; margin-bottom: 2px; }
.picker-sub   { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }

/* The one and only scrollbar: two columns of course rows with the
   band headers spanning both. Overrides .course-filters' 260px cap. */
.picker-list {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
  max-height: none;
  overflow-y: auto;
  margin-top: 8px;
  padding-right: 4px;
}
.picker-done { margin: 14px 0 0; }

/* ── Distance-band headers ──────────────────────────────── */
.band-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.band-header:first-child { margin-top: 0; }
.band-count { color: var(--green-acc); }
.band-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 10px;
  padding: 1px 8px;
  cursor: pointer;
}
.band-btn:hover { border-color: var(--green-acc); color: var(--text); }
.band-btn[data-act="all"] { margin-left: auto; }

/* ── Mobile (≤720px): chips wrap, popovers become bottom
      sheets, the picker goes full-screen ────────────────── */
@media (max-width: 720px) {
  /* Nav is in the bottom bar, so the header only holds the title plus
     account / help / donate. The TITLE is what shrinks (ellipsis) when
     space runs out — the right-side buttons never truncate. */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar h1 {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-left { gap: 8px; flex-shrink: 1; min-width: 0; }
  .topbar-left > div { min-width: 0; }
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .donate-btn { font-size: 11px; padding: 5px 8px; white-space: nowrap; }
  .logo { font-size: 20px; }
  .search-summary { display: none; }
  /* Signed in, the full email + Sign out is wider than the phone header —
     drop the email (it's on the Player page; its hover tooltip doesn't
     exist on touch anyway) so Donate stays fully on screen. */
  .account-email { display: none; }

  /* Keep the bottom-nav clearance from the tab-bar block above — the
     `padding` shorthand would silently drop it and hide the last row
     behind the fixed bar. */
  .results-main { padding: 12px 12px calc(64px + env(safe-area-inset-bottom)); }
  .filter-bar {
    margin: -12px -12px 12px;
    padding: 10px 12px;
  }
  .chip { font-size: 12px; padding: 6px 11px; }
  .filter-bar-search {
    flex: 1 1 100%;
    margin-left: 0;
    border-radius: var(--radius);
  }

  .chip-pop {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    min-width: 0;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    z-index: 120;
  }

  .picker-dialog {
    width: 100vw; max-width: none;
    height: 100dvh; max-height: none;
    border-radius: 0; border: none;
  }
  .picker-list { grid-template-columns: 1fr; }

  /* ── Collapsed chip bar (after a search) ──────────────── */
  .filter-bar.collapsed > * { display: none; }
  .filter-bar.collapsed .filter-bar-summary { display: block; }

  /* ── Result cards ─────────────────────────────────────────
     The 7-column table re-lays out as cards: each <tr> becomes a
     small grid, the header row disappears (the sort toggle group in
     the results topbar takes over). Cell classes are stable, so this
     is presentation-only. Applies to the next-availability expansion
     tables too — same markup. */
  .results-table { display: block; }
  .results-table thead { display: none; }
  .results-table tbody { display: block; }
  /* Two rows: time + course (name over par/tax/fee) on the left with the
     price stack top-right; dist · spots · rate meta line on the bottom-left
     with Book bottom-right. */
  .results-table tr {
    display: grid;
    grid-template-columns: auto auto auto 1fr auto;
    grid-template-areas:
      "time   course course course price"
      "dist   spots  rate   rate   book";
    gap: 3px 6px;
    align-items: start;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 6px;
  }
  .results-table td {
    display: block;
    border: none !important;
    padding: 0 !important;
    background: none !important;
  }
  .col-time   { grid-area: time; font-weight: 700; font-size: 15px; padding-right: 4px !important; }
  .col-course { grid-area: course; }
  /* Dist · spots · rate read as one dim meta line */
  .col-dist, .col-spots, .col-rate {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    align-self: center;
  }
  .col-dist  { grid-area: dist; }
  .col-spots { grid-area: spots; }
  .col-rate  { grid-area: rate; white-space: normal; }
  .col-dist::after, .col-spots::after { content: " ·"; }
  .col-price {
    grid-area: price;
    justify-self: end;
    text-align: right;
    max-width: 46vw;   /* long rate-detail lines wrap instead of squeezing the course name */
  }
  /* The conditional headline is width:fit-content (for its dashed
     underline), and a shrunk block box ignores text-align — push it to
     the right edge like the other prices. */
  .col-price .price-total.rate-conditional { margin-left: auto; }
  .col-book  { grid-area: book; align-self: end; justify-self: end; }
}

/* ─── Players' Pick page ──────────────────────────────────────────────────────
   Same sticky page-topbar pattern as Player/Debug; below it either the
   two-card "duel" (Compare) or the derived Elo leaderboard (Rankings). */
.pk-topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -20px -24px 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pk-scope-wrap { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.pk-body { max-width: 860px; margin: 0 auto; }

/* Compare — the duel. Two course cards, tap the one you'd rather play. */
.pk-prompt { text-align: center; color: var(--text-dim); font-size: 14px; margin: 4px 0 18px; }
.pk-prompt strong { color: var(--text); }
.pk-duel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 14px;
}
.pk-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 22px 18px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
}
.pk-card:hover  { border-color: var(--green-acc); background: var(--bg-3); }
.pk-card:active { transform: scale(.98); }
.pk-card:focus-visible { outline: 2px solid var(--green-acc); outline-offset: 2px; }
.pk-card.picked { border-color: var(--green-acc); background: var(--green); }
.pk-card-name { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.25; }
.pk-card-meta { font-size: 12px; color: var(--text-dim); }
.pk-card-hint { margin-top: 4px; font-size: 11px; color: var(--text-dim); opacity: .8; }

/* The "vs" divider carries the too-close-to-call action. */
.pk-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: center;
}
.pk-vs-label { font-size: 15px; font-weight: 700; color: var(--text-dim); }

.pk-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.pk-tie, .pk-skip {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  padding: 7px 14px;
  cursor: pointer;
}
.pk-tie:hover, .pk-skip:hover { border-color: var(--green-acc); color: var(--text); }
.pk-count { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 14px; }

/* Sign-in / not-enough-courses gate. */
.pk-gate { text-align: center; color: var(--text-dim); padding: 40px 16px; }
.pk-gate p { margin: 0 0 14px; font-size: 14px; }
.pk-gate .toggle { font-size: 13px; padding: 8px 16px; }

/* Rankings — derived Elo leaderboard. */
.pk-rank-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.pk-rank-num  { font-size: 13px; font-weight: 700; color: var(--text-dim); text-align: center; }
.pk-rank-name { font-size: 14px; color: var(--text); }
.pk-rank-city { font-size: 11px; color: var(--text-dim); }
.pk-rank-score { font-size: 15px; font-weight: 700; color: var(--green-acc); white-space: nowrap; }
.pk-rank-pm    { font-size: 11px; font-weight: 400; color: var(--text-dim); }
.pk-rank-games { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

@media (max-width: 720px) {
  .pk-topbar { margin: -12px -12px 12px; padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  /* On a phone the two cards stack; the "vs" divider sits between them. */
  .pk-duel { grid-template-columns: 1fr; }
  .pk-vs { flex-direction: row; }
  .pk-card { min-height: 120px; padding: 16px; }
}
