/* BumperQuest — modern, neutral admin & public styles.
 *
 * Layered on top of Pico CSS. Design tokens at the top; everything else is
 * either an override of Pico defaults to make them neutral, or our own
 * components (sidebar, cards, badges, etc.).
 */

/* ============================================================ Design tokens */
:root {
  color-scheme: light;

  /* Surfaces */
  --bg:            #fafaf9;
  --surface:       #ffffff;
  --surface-soft:  #f5f5f4;
  --surface-sunk:  #fafaf9;

  /* Borders */
  --border:        #e7e5e4;
  --border-strong: #d6d3d1;
  --border-focus:  #a78bfa;

  /* Text */
  --text:          #1c1917;
  --text-muted:    #57534e;
  --text-subtle:   #78716c;
  --text-on-accent:#ffffff;

  /* Accent (single brand colour, used sparingly) */
  --accent:        #6d28d9;
  --accent-hover:  #5b21b6;
  --accent-soft:   #f5f3ff;
  --accent-border: #ddd6fe;

  /* Status colours */
  --success:       #16a34a;
  --success-soft:  #dcfce7;
  --success-border:#86efac;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;
  --danger-border: #fca5a5;
  --warning:       #d97706;
  --warning-soft:  #fef3c7;
  --warning-border:#fcd34d;

  /* Radii */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  /* Shadows — used very sparingly */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .06);

  /* Layout */
  --sidebar-w: 248px;
  --content-max: 1240px;

  /* Pico overrides */
  --pico-background-color: var(--bg);
  --pico-color: var(--text);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-muted-color: var(--text-muted);
  --pico-muted-border-color: var(--border);
  --pico-form-element-spacing-vertical: .55rem;
  --pico-form-element-spacing-horizontal: .8rem;
  --pico-primary: var(--accent);
  --pico-primary-background: var(--accent);
  --pico-primary-border: var(--accent);
  --pico-primary-hover: var(--accent-hover);
  --pico-primary-hover-background: var(--accent-hover);
  --pico-primary-hover-border: var(--accent-hover);
  --pico-primary-focus: rgba(124, 58, 237, .25);
  --pico-primary-inverse: #ffffff;
}

html[data-theme="dark"] { color-scheme: light; }

/* ============================================================ Base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { margin: 0; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.25;
}
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .35rem; }
hgroup p { color: var(--text-muted); margin-top: .25rem; }

p, li, td, th, label, input, button, select, textarea, summary, a {
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
nav a, .sidebar a { text-decoration: none; }

small, em, .muted, .public-quest__meta, .home-quest-info__city,
.team-roster strong, .quest-status-bar small, .leaderboard-card small,
.register-message, .faq-list p {
  color: var(--text-muted);
}

code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: .88em;
}
code {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ============================================================ Pico-component overrides */

/* Containers / surfaces */
article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: none;
  padding: 1rem 1.15rem;
  margin: 0 0 1rem;
}
article > header {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 0 .65rem;
  margin: -.25rem 0 .85rem;
  font-weight: 600;
  letter-spacing: -.005em;
}
article > footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: .65rem 0 0;
  margin: .85rem 0 -.25rem;
}

/* Tables */
table, table[role="grid"] {
  background: var(--surface);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
thead th {
  background: var(--surface-soft);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .72rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: .55rem .8rem;
  text-align: left;
}
tbody td {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .65rem .8rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-soft); }

/* Forms */
input:not([type="checkbox"]):not([type="radio"]),
textarea, select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: .95rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus, select:focus {
  outline: 0;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--pico-primary-focus);
}
input::placeholder, textarea::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}
label {
  display: block;
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: .9rem;
}
label > input, label > textarea, label > select {
  margin-top: .25rem;
}

/* Checkboxes / radios stay native, just colour them */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
}

/* Buttons */
button, [role="button"], input[type="submit"], input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem .9rem;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
}
button:hover, [role="button"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-on-accent);
  text-decoration: none;
}
button:focus, [role="button"]:focus {
  outline: 0;
  box-shadow: 0 0 0 3px var(--pico-primary-focus);
}
button:disabled, [role="button"][aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}

/* Secondary / outline / ghost buttons */
.secondary, button.secondary, [role="button"].secondary,
.outline, button.outline, [role="button"].outline,
button[type="button"].secondary {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
.secondary:hover, .outline:hover {
  background: var(--surface-soft) !important;
  border-color: var(--border-strong) !important;
  color: var(--text) !important;
}
.secondary.outline, button.secondary.outline {
  background: transparent !important;
}

/* Details / summary */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .55rem .85rem;
  margin: 0 0 .8rem;
}
details[open] { background: var(--surface); }
details > summary {
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  color: var(--text);
}
details > summary::-webkit-details-marker { display: none; }
/* `<summary role="button" class="secondary outline">` should look like a ghost
   button. Pico applies its own `[role=button]` defaults; we only soften the
   shape so it sits inside our cards consistently. */
details > summary[role="button"] {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .75rem;
  margin: 0;
  border-radius: var(--r-md);
  font-size: .88rem;
  font-weight: 500;
}

/* ============================================================ Layout (admin sidebar) */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.1rem .7rem;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .15rem .55rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .9rem;
}
.sidebar__brand a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.015em;
  font-size: 1.02rem;
}
.sidebar__brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  box-shadow: 0 2px 4px rgba(124, 58, 237, .25);
  flex-shrink: 0;
}

.sidebar__section {
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-subtle);
  font-weight: 600;
  padding: .85rem .65rem .3rem;
}
.sidebar__section:first-of-type { padding-top: .25rem; }

.sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .48rem .65rem;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: .91rem;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
  position: relative;
}
.sidebar__nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}
.sidebar__nav a:hover .ico { color: var(--text); }
.sidebar__nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar__nav a.is-active::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sidebar__nav a.is-active .ico { color: var(--accent); }

.sidebar__nav .ico {
  width: 18px;
  height: 18px;
  color: var(--text-subtle);
  flex-shrink: 0;
  transition: color .12s ease;
}
.sidebar__nav .badge,
.sidebar__nav .badge-slot {
  margin-left: auto;
  font-size: .68rem;
  padding: 1px 7px;
}
.sidebar__nav .badge-slot { display: inline-flex; }

.sidebar__footer {
  margin-top: auto;
  padding-top: .9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .55rem;
}
.sidebar__user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .82rem;
  color: var(--accent);
  flex-shrink: 0;
}
.sidebar__user-info { min-width: 0; flex: 1; }
.sidebar__user-name {
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-role {
  color: var(--text-subtle);
  font-size: .73rem;
  line-height: 1.2;
  margin-top: 1px;
}
.sidebar__user-actions {
  display: flex;
  gap: .35rem;
  align-items: center;
}
.sidebar__user-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar__user-action:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}
.sidebar__user-action .ico { width: 16px; height: 16px; }

.sidebar__logout-form {
  margin: 0;
  flex: 1;
}
.sidebar__logout-form button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--surface) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  font-size: .85rem;
  font-weight: 500;
  padding: .4rem .65rem;
}
.sidebar__logout-form button:hover {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: var(--danger-border) !important;
}
.sidebar__logout-form button .ico { width: 15px; height: 15px; }

.app-main {
  padding: 1.8rem clamp(1.1rem, 3vw, 2.6rem);
  max-width: var(--content-max);
  width: 100%;
  flex: 1;
}

/* Topbar (mobile only) — brand left, toggle RIGHT. */
.app-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--text);
}
.app-topbar__brand strong {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  font-size: 1rem;
}
.app-topbar__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
}
.app-topbar__toggle:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Mobile: drawer-style sidebar. */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-105%);
    transition: transform .2s cubic-bezier(.4, 0, .2, 1);
    z-index: 60;
    box-shadow: var(--shadow-md);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .app-main {
    padding: 1.2rem 1rem;
  }
}

/* Page header (used by every admin page). */
.page-head {
  margin: 0 0 1.6rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin: 0; font-size: 1.55rem; }
.page-head p { color: var(--text-muted); margin: .25rem 0 0; max-width: 60ch; font-size: .95rem; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Quick-link cards (dashboard). */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .65rem;
}
.quick-link {
  display: block;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.quick-link:hover {
  border-color: var(--accent-border);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.quick-link strong {
  display: block;
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .15rem;
}
.quick-link small { color: var(--text-muted); font-size: .82rem; }

/* ============================================================ Section card */
/* Default `<article>` is the section card. Override with .section-card-flat
   to drop the accent strip if you need a plain card. */
article {
  position: relative;
  overflow: hidden;
}
article::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), #a855f7);
  opacity: .55;
  transition: opacity .15s ease;
}
article:hover::before { opacity: 1; }
article.section-card-accent::before { opacity: 1; }
article.section-card-flat::before { display: none; }

article > header {
  display: flex;
  align-items: center;
  gap: .65rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: .65rem 1rem .65rem 1rem;
  margin: -1rem -1.15rem .9rem -1.15rem;
  font-weight: 600;
  letter-spacing: -.005em;
}
article > header > strong { font-weight: 600; flex: 1; }
article > header .header-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
article > header .header-icon .ico { width: 15px; height: 15px; }
article > header .count-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
}
article > header small {
  color: var(--text-subtle);
  font-weight: 500;
  font-size: .78rem;
}
article > header .header-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* ============================================================ Stat chip strip */
.stat-strip {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}
.stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .4rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: .82rem;
  color: var(--text-muted);
}
.stat-chip strong {
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-chip.is-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.stat-chip.is-accent strong { color: var(--accent); }
.stat-chip.is-warn {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}
.stat-chip.is-warn strong { color: var(--warning); }
.stat-chip.is-success {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}
.stat-chip.is-success strong { color: var(--success); }

/* ============================================================ Table card */
/* Wrap a table with .table-card for a card-framed list. */
.table-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  margin: 0 0 1rem;
}
.table-card > table { margin: 0; }
.table-card thead th {
  background: var(--surface-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table-card tbody tr:hover td { background: var(--accent-soft); }
.table-card tbody tr:last-child td { border-bottom: 0; }
.table-card__head {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  font-weight: 600;
}
.table-card__head .count-pill { margin-right: auto; }
.table-card__foot {
  padding: .65rem .85rem;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

/* ============================================================ Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}
.empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  margin-bottom: .65rem;
}
.empty-state__icon .ico { width: 22px; height: 22px; }
.empty-state__title {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  margin: .2rem 0 .15rem;
}
.empty-state__hint { font-size: .9rem; max-width: 36ch; margin: 0 auto; }

/* ============================================================ Disclosure */
details > summary[role="button"] + form,
details > summary + form,
details > summary + table,
details > summary + .table-card,
details > summary + div {
  margin-top: .75rem;
}
details {
  transition: background .12s ease;
}
details[open] { background: var(--surface); }
details > summary {
  position: relative;
  padding-right: 1.6rem;
}
details > summary::after {
  content: "";
  position: absolute;
  right: .35rem;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-subtle);
  border-bottom: 2px solid var(--text-subtle);
  transform: translateY(-65%) rotate(45deg);
  transition: transform .15s ease;
  pointer-events: none;
}
details[open] > summary::after {
  transform: translateY(-30%) rotate(-135deg);
}

/* ============================================================ Code chip / copyable */
.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .6rem .25rem .7rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .8rem;
  color: var(--text);
  cursor: text;
  user-select: all;
}
.copy-chip__btn {
  padding: 0 .25rem;
  margin-left: .15rem;
  background: transparent !important;
  border: 0 !important;
  color: var(--text-muted) !important;
  font-size: .85rem;
  line-height: 1;
}
.copy-chip__btn:hover { color: var(--accent) !important; }

.invite-row {
  display: flex;
  gap: .4rem;
  align-items: stretch;
}
.invite-row input {
  flex: 1;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .78rem;
  background: var(--surface-soft) !important;
}
.invite-row button {
  flex-shrink: 0;
  margin: 0;
  padding: .4rem .6rem;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
}
.invite-row button:hover {
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}

/* ============================================================ Status dot pills */
.dot-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.dot-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.dot-pill.is-active   { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.dot-pill.is-pending  { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.dot-pill.is-stopped  { background: var(--surface-soft); color: var(--text-muted); border-color: var(--border); }
.dot-pill.is-danger   { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

/* ============================================================ Form sections */
.form-section + .form-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.form-section__title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  font-weight: 600;
  margin: 0 0 .6rem;
}

/* ============================================================ Split row helpers */
.split {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}
.split--end { justify-content: flex-end; }
.split--between { justify-content: space-between; }
.spacer { flex: 1; }

/* ============================================================ Components */

/* Banners (success / error / info). */
.error-banner, .success-banner, .info-banner {
  padding: .6rem .9rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  font-size: .92rem;
}
.error-banner   { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.success-banner { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.info-banner    { background: var(--accent-soft);  color: var(--accent);  border-color: var(--accent-border); }

/* Stat cards (dashboard). */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat-grid article {
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  padding: .9rem 1rem;
  box-shadow: var(--shadow-sm);
}
.stat-grid article header {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--text-subtle) !important;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .7rem;
  font-weight: 600;
}
.big-number {
  display: block;
  font-size: 1.9rem;
  line-height: 1.1;
  margin: .35rem 0 .15rem;
  color: var(--text) !important;
  font-weight: 600;
  letter-spacing: -.02em;
}
.stat-grid article small,
.stat-grid article * {
  color: var(--text-muted) !important;
}

/* Badges (status pills). */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
  vertical-align: middle;
}
.badge-draft     { background: var(--surface-soft); color: var(--text-muted);  border-color: var(--border); }
.badge-published { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-archived  { background: var(--surface-soft); color: var(--text-subtle); border-color: var(--border); }

/* Always-visible inline team roster chips (replaces the old hover tooltip). */
.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .4rem;
  max-width: 22rem;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: .73rem;
  font-weight: 500;
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.member-chip.is-captain {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}
.member-chip__icon {
  font-size: .82rem;
  line-height: 1;
  color: #f59e0b;
}

/* Legacy hover tooltip — kept as a no-op since templates may still reference. */
.team-name { position: relative; display: inline-block; }
.team-name.has-roster {
  border-bottom: 1px dashed var(--border-strong);
  cursor: help;
}
.team-roster {
  position: absolute;
  left: 0;
  top: calc(100% + .25rem);
  z-index: 20;
  min-width: 14rem;
  max-width: 22rem;
  padding: .55rem .75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: .85rem;
  line-height: 1.4;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
  pointer-events: none;
}
.team-name:hover .team-roster,
.team-name:focus-within .team-roster {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0s;
}
.team-roster strong {
  display: block;
  margin-bottom: .35rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-subtle);
}
.team-roster ul { margin: 0; padding-left: 1rem; }
.team-roster li { margin: .1rem 0; }

/* Login. */
.login-container {
  max-width: 24rem;
  margin: 8vh auto;
}

/* ============================================================ Public site */

/* Public top nav (templates/public/_layout.html). */
.public-nav {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .85rem clamp(1rem, 3vw, 2rem);
  margin-bottom: 1.25rem;
}
.public-nav ul:first-of-type strong a {
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
  font-weight: 700;
}
.public-menu-links a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  min-height: 2.1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.public-menu-links {
  display: flex;
  width: min(20rem, 92vw);
  flex-direction: column;
  align-items: flex-start;
  gap: .15rem;
  position: fixed;
  top: .85rem;
  left: .85rem;
  z-index: 2200;
  margin: 0;
  padding: .45rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px) scale(.98);
  visibility: hidden;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
}
.public-menu-links.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.public-menu-links li { width: 100%; list-style: none; }
.public-menu-links a {
  display: block;
  width: 100%;
  border-radius: var(--r-sm);
  padding: .45rem .6rem;
  text-decoration: none;
  color: var(--text);
}
.public-menu-links a:hover { background: var(--surface-soft); }

.menu-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(15, 23, 42, .35);
  backdrop-filter: blur(2px) saturate(110%);
  opacity: 1;
  transition: opacity .14s ease;
}
.menu-screen-overlay[hidden] { opacity: 0; pointer-events: none; }
body.menu-open main, body.menu-open footer, body.menu-open .quest-status-bar {
  pointer-events: none;
}

/* Public quest hero / cards. */
.quest-status-bar {
  margin-top: -.4rem;
  margin-bottom: 1rem;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: .92rem;
}
.public-quest { margin-bottom: 2rem; }
.home-quest-info {
  margin: 0 0 1.5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.home-quest-info__title {
  margin: 0 0 .35rem;
  font-size: 1.4rem;
  font-weight: 600;
}
.home-quest-info__city { margin: 0 0 .5rem; color: var(--text-muted); }
.home-quest-info__stats { margin: .65rem 0 .85rem; }
.home-quest-info__stats p { margin: .25rem 0; }
.home-quest-info__actions { margin-top: 1rem; }
.home-quest-info__note {
  display: block;
  margin-top: .85rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.home-cta__actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.home-quest-about ul { margin: .5rem 0 0; }

.home-map-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem;
  background: var(--surface);
}
.home-google-map-frame {
  position: relative;
  width: 100%;
  max-width: 52rem;
  margin: .7rem auto 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 10;
  box-shadow: var(--shadow-sm);
}
.home-google-map-frame iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.home-map-actions { margin: 1rem 0 0; text-align: center; }

.home-footer-links { font-size: .92rem; }
.home-steps { margin: .25rem 0 0; }
.home-leaderboard__header {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .75rem;
}
.home-details { margin-bottom: 2rem; }
.home-details > summary { cursor: pointer; font-weight: 500; }

.public-quest__meta { margin: 0; color: var(--text-muted); font-size: .9rem; }
.public-quest__stats { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.public-teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: .75rem;
}
.public-team {
  margin: 0;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.public-team__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .35rem;
}
.public-team__roster { margin: 0; padding-left: 1.1rem; font-size: .9rem; line-height: 1.4; }

/* Public leaderboard. */
.leaderboard-card { margin-bottom: 2rem; }
.leaderboard-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: .6rem;
}
.leaderboard-table td, .leaderboard-table th { white-space: nowrap; }
.leaderboard-table__ago { white-space: normal; max-width: 10rem; line-height: 1.25; }
.leaderboard-row--gold td:first-child {
  background: color-mix(in srgb, #facc15 22%, transparent);
}
.leaderboard-row--silver td:first-child {
  background: color-mix(in srgb, #94a3b8 18%, transparent);
}
.leaderboard-row--bronze td:first-child {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
}

/* Public team detail. */
.team-card { margin-bottom: 2rem; }
.team-card__header {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; flex-wrap: wrap;
}
.team-stats { margin: 1rem 0 1.2rem; }
.team-stats article { text-align: center; }
.team-locations { margin: 0; padding-left: 1.2rem; }
.team-progress__nav { margin: 0 0 .75rem; font-size: .95rem; }
.team-progress__subtitle { margin: .25rem 0 0; }
.team-progress__privacy { margin: 0 0 1rem; font-size: .92rem; }
.team-progress__h2 { font-size: 1.05rem; margin: 1.1rem 0 .5rem; }
.team-progress__hint { margin: 0 0 .5rem; font-size: .88rem; }
.team-progress__meta { margin-top: 1rem; }
.team-progress__list { margin: 0; padding-left: 1.2rem; }
.team-chart-wrap { margin: .25rem 0 .5rem; }
svg.team-chart {
  display: block; width: 100%; max-width: 40rem; height: auto;
  color: var(--text-muted);
}
.team-history-table {
  width: 100%; border-collapse: collapse; font-size: .92rem;
}
.team-history-table th, .team-history-table td {
  padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--border);
}
.team-history-table th { font-weight: 600; background: var(--surface-soft); }

/* Public locations gallery. */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: .9rem;
  margin-bottom: 2rem;
}
.location-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
}
.location-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.location-card__image {
  width: 100%; height: 10rem; object-fit: cover;
  border-radius: var(--r-sm); margin-bottom: .55rem;
}
.location-card__meta { display: flex; gap: .4rem; flex-wrap: wrap; }

#locationModal::backdrop { background: rgba(15, 23, 42, .45); }
.location-modal__card { min-width: min(40rem, 92vw); }
.location-modal__header {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
}
.location-modal__meta { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Quest route page. */
.quest-locations-note { margin-bottom: 1.25rem; }
.quest-route-section { margin-bottom: 2rem; }
.quest-route-map {
  width: 100%;
  min-height: 20rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-soft);
}
.quest-route-map--empty { min-height: 4rem; display: none; }
.quest-map-fallback { margin-top: .35rem; }
.quest-spots-grid {
  display: grid; grid-template-columns: 1fr; gap: 1.25rem;
  margin-bottom: 2rem;
}
@media (min-width: 768px) {
  .quest-spots-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.quest-spot-card {
  margin: 0;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  box-shadow: var(--shadow-sm);
}
.quest-spot-card__media {
  position: relative; background: var(--surface-soft);
}
.quest-spot-card__photo {
  display: block; width: 100%; height: 220px; object-fit: cover;
}
.quest-spot-card__photo--placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle); font-size: .92rem; height: 220px;
}
.quest-spot-card__body { padding: .95rem 1.05rem 1.1rem; flex: 1; }
.quest-spot-card__title {
  font-size: 1.08rem; margin: 0 0 .45rem; line-height: 1.3;
}
.quest-spot-card__badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7rem; height: 1.7rem; padding: 0 .35rem; margin-right: .35rem;
  border-radius: var(--r-pill); font-size: .8rem; font-weight: 700;
  color: #fff; vertical-align: middle;
  background: var(--accent);
}
.quest-spot-card__address { font-size: .88rem; color: var(--text-muted); margin: 0 0 .5rem; }
.quest-spot-card__story { margin: 0 0 .65rem; font-size: .94rem; line-height: 1.5; }
.quest-spot-card__actions { margin: 0; }

.quest-map-marker {
  background: var(--accent) !important;
  border: 2px solid #fff !important;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}
.quest-map-marker span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-size: .78rem; font-weight: 700; color: #fff;
}

/* Public registration. */
.register-disclaimer {
  max-width: 42rem;
  margin: -.4rem 0 1rem;
  padding: .65rem .85rem;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  font-size: .95rem;
  background: var(--surface-soft);
}
.register-card { max-width: 42rem; margin-bottom: 2rem; }
.register-result.register-result--success .register-success-title {
  font-size: 1.2rem; margin: 0 0 .35rem;
}
.register-pending, .register-approved {
  margin-top: .85rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.register-approved__lead { margin: 0 0 .5rem; }
.register-join-wrap { margin: .5rem 0 .75rem; }
.register-join-command {
  display: block; width: 100%; box-sizing: border-box;
  padding: .75rem .95rem; font-size: 1.1rem; line-height: 1.45;
  word-break: break-all;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-soft); color: var(--text);
}
.register-copy-row { margin: .35rem 0 .5rem; }
.register-approved__hint { margin: .35rem 0 0; }
.register-message { margin-top: .8rem; white-space: pre-wrap; }
.register-message--success { color: var(--success); }
.register-message--error   { color: var(--danger); }
.register-result {
  margin-top: .9rem;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.register-result__actions {
  display: flex; gap: .55rem; flex-wrap: wrap; margin: .45rem 0;
}

#submitRegister, #openBotButton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.4rem; padding: .55rem .95rem;
  border-radius: var(--r-md); font-weight: 600;
  background: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  color: #fff !important;
  text-decoration: none;
}
#submitRegister:hover, #openBotButton:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #fff !important;
}

.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-label { margin: 0; cursor: pointer; user-select: none; }
.checkbox-row input[type="checkbox"] {
  width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer;
  accent-color: var(--accent);
}

/* Public FAQ. */
.faq-list { margin-bottom: 2rem; }
.faq-list details {
  margin-bottom: .55rem; padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.faq-list summary { cursor: pointer; font-weight: 500; }

/* ============================================================ Admin tasks (legacy modal) */
.tasks-admin-table-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.tasks-table-wrap { overflow-x: auto; }
.tasks-admin-table { min-width: 64rem; }
.tasks-admin-td--clip, .tasks-admin-td--hints {
  max-width: 18rem; font-size: .88rem; line-height: 1.35; word-break: break-word;
}
.tasks-admin-td--hints small { display: inline-block; margin-left: .2rem; }
.quest-control-stats { margin: 1rem 0 1.25rem; }
.quest-broadcast-box { margin: 1rem 0 1.5rem; }
.results-table-wrap { overflow-x: auto; margin: .65rem 0 1.5rem; }
.results-pre {
  max-width: 22rem; white-space: pre-wrap; word-break: break-word;
  font-size: .87rem;
}
.tasks-admin-table th, .tasks-admin-table td { vertical-align: middle; }

#taskModal::backdrop { background: rgba(15, 23, 42, .45); }
.task-modal-card { min-width: min(56rem, 95vw); }
.task-modal-header {
  margin-bottom: .75rem;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-soft);
}
.task-modal-header strong { color: var(--text) !important; }
.task-modal-footer {
  display: flex; gap: .55rem; justify-content: flex-start; flex-wrap: wrap;
}
.task-toast {
  position: fixed; right: 1rem; top: 1rem; z-index: 2500;
  padding: .55rem .85rem;
  border-radius: var(--r-md);
  border: 1px solid var(--success-border);
  background: var(--success-soft);
  color: var(--success);
  box-shadow: var(--shadow-md);
}

.settings-table code, .settings-table pre {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.settings-upsert-card > header {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* Quest start button. */
.start-quest-btn {
  background: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  color: #fff !important;
}
.start-quest-btn:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}
.start-quest-btn.is-started {
  background: var(--success) !important;
  border-color: var(--success) !important;
}
.start-quest-btn.is-started:hover {
  background: #15803d !important;
  border-color: #15803d !important;
}
.start-quest-btn.is-started:disabled {
  background: var(--success) !important;
  border-color: var(--success) !important;
  opacity: .9;
}

/* Leaflet popups (light theme). */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-popup-content {
  margin: .65rem .85rem !important;
  color: var(--text) !important;
}
.leaflet-container a.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

@media (max-width: 768px) {
  .public-menu-links a { padding: .25rem 0; }
  .tasks-admin-table { min-width: 36rem; }
  .task-modal-card { min-width: min(36rem, 96vw); }
}
