:root {
  --bg: #f7f6f3; --fg: #1d1d1f; --muted: #6b6b70; --card: #fff; --line: #dedcd6;
  /* Brand: navy #0B1E48 (primary), orange #FF6A00 (accent), white. White on orange is only 2.9:1,
     so buttons are navy (light) or orange with navy text (dark); orange is for highlights. */
  --primary: #0B1E48; --primary-fg: #fff; --chart: #0B1E48;
  --accent: #FF6A00; --accent-fg: #fff; --claim: #7b3fe4; --own: #1f6feb; --danger: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #070f24; --fg: #eef1f7; --muted: #a3acc4; --card: #0f1a3a; --line: #24315a;
    --primary: #FF6A00; --primary-fg: #0B1E48; --chart: #FF6A00; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
a { color: inherit; }
.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; }
.brand img { width: 32px; height: 32px; }
.main-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; align-items: center; }
.main-nav a { text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.main-nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.nav-toggle, .nav-toggle-label { display: none; }
.visitor-nav { display: flex; gap: 1rem; align-items: center; }
.visitor-nav > a:not(.button) { text-decoration: none; }
a.button { display: inline-block; text-decoration: none; padding: .4rem .9rem; border-radius: 6px; border: 1px solid var(--line); }
a.button.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
@media (max-width: 640px) {
  .nav-toggle-label { display: block; cursor: pointer; padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 6px; }
  .main-nav { display: none; flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: .1rem; }
  .nav-toggle:checked ~ .main-nav { display: flex; }
}
.page { max-width: 960px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin: 1rem 0; }
.narrow { max-width: 480px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; }
button { font: inherit; padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
button.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
button.danger { color: var(--danger); }
button.small { padding: .2rem .5rem; font-size: .85rem; }
button.link { border: 0; background: none; padding: 0; text-decoration: underline; }
input, select { font: inherit; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); max-width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 1rem 0; }
fieldset ul { list-style: none; padding: 0; }
.messages { list-style: none; margin: 0; padding: 0; }
.messages li { padding: .6rem 1rem; background: #e8f3ea; color: #1d4a27; }
.messages li.msg-error { background: #fde8e6; color: #7a1d14; }
.notice { background: #fff6d6; color: #4a3b00; border: 1px solid #f0d97a; border-radius: 10px; padding: .6rem 1rem; margin: 1rem 0; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); }
.badge.claimed { border-color: var(--claim); color: var(--claim); }
.badge.recorded { border-color: var(--own); color: var(--own); }
.badge.error { border-color: var(--danger); color: var(--danger); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
@media (max-width: 640px) { table.list { display: block; overflow-x: auto; } }
.filters-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-grid .card { margin: 0; }
.big { font-size: 2rem; font-weight: 700; margin: .2rem 0; }
.mini-map { height: 320px; border-radius: 10px; border: 1px solid var(--line); }
.zones { padding-left: 1.2rem; }

/* Map page: map fills the viewport under the top bar. */
body.map-page { height: 100dvh; display: flex; flex-direction: column; }
.map-shell { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-controls { position: absolute; top: .75rem; left: .75rem; margin: 0; padding: .6rem .8rem; max-width: min(320px, calc(100% - 4.5rem)); z-index: 2; }
.map-controls label { display: block; margin: .2rem 0; }
.scope-switch { display: flex; gap: .8rem; }
.scope-switch label { display: inline; }
.legend { margin: .3rem 0 0; font-size: .85rem; }
.route-panel { position: absolute; z-index: 3; top: .75rem; right: 3.5rem; width: 340px; max-height: calc(100% - 1.5rem); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.15); }
.panel-body { padding: 1rem; position: relative; }
.panel-body h2 { margin: 0 1.5rem .3rem 0; font-size: 1.15rem; }
.panel-body .close { position: absolute; top: .4rem; right: .4rem; border: 0; font-size: 1.4rem; line-height: 1; }
.stats { display: grid; grid-template-columns: auto auto; gap: .25rem 1rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; }
.choices { list-style: none; padding: 0; }
.choices button { width: 100%; text-align: left; margin: .2rem 0; }
@media (max-width: 640px) {
  .route-panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 55%; border-radius: 14px 14px 0 0; }
}
/* segno SVGs carry a viewBox (omitsize) so they scale instead of being cropped; the quiet zone is built in. */
.qr svg { width: min(280px, 100%); height: auto; aspect-ratio: 1; display: block; background: #fff; border-radius: 8px; }
code.secret { word-break: break-all; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { margin: .35rem 0; }
.roster { columns: 2 180px; padding-left: 1.1rem; }
.backblast { white-space: normal; font-size: .9rem; }

/* Join honeypot: off-screen for people, still in the form for bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Home */
.hero h1 { margin: .5rem 0 .2rem; font-size: 2rem; }
.lede { font-size: 1.1rem; max-width: 60ch; margin: 0 0 1rem; }
.home-map { height: min(60vh, 480px); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.map-summary { position: absolute; left: .6rem; bottom: .4rem; margin: 0; z-index: 2; background: var(--card); padding: .1rem .5rem; border-radius: 6px; }

/* Sub-navigation tabs (Profile, Events) */
.tabs-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin: .5rem 0 1rem;
  border-bottom: 1px solid var(--line); }
.tabs { display: flex; flex-wrap: wrap; gap: 0 1.2rem; }
.tabs a { text-decoration: none; padding: .45rem 0; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.tabs-row form { margin-bottom: .3rem; }
input.wide { width: 100%; }

/* Workout cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.card-grid .card { margin: 0; }
.event-card { display: block; text-decoration: none; }
.event-card:hover { border-color: var(--accent); }
.event-card-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; margin-bottom: .2rem; }
.pager { display: flex; gap: 1rem; justify-content: center; }

/* Home cards: 30-day bar chart (single series, accent colour validated light + dark). */
.home-stats { grid-template-columns: 2fr 1fr; }
.home-stats .chart-card { grid-row: span 3; }
@media (max-width: 640px) { .home-stats { grid-template-columns: 1fr; } .home-stats .chart-card { grid-row: auto; } }
.unit { font-size: 1rem; font-weight: 400; color: var(--muted); }
.bar-chart { margin: .4rem 0 .2rem; }
.bar-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar-chart .baseline { stroke: var(--line); stroke-width: 1; }
.bar-chart .bar path { fill: var(--chart); }
.bar-chart .bar .hit { fill: transparent; }
.bar-chart .bar:hover path { fill: var(--fg); }
.bar-chart .bar:hover .hit { fill: var(--line); fill-opacity: .35; }
.chart-axis { display: flex; justify-content: space-between; margin-top: .2rem; }
.chart-max { text-align: right; }
ul.codes { columns: 2 140px; padding-left: 1.2rem; }
.passkey-error { color: var(--danger); }

/* Admin: default map view picker */
.view-picker { height: 280px; border-radius: 8px; overflow: hidden; margin: 8px 0; }

/* Club events */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.event-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; align-items: start; }
.event-layout .card { margin: 0; }
@media (max-width: 700px) { .event-layout { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: .5rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ul.plain, ul.roster { list-style: none; padding: 0; margin: .3rem 0; }
ul.plain li { padding: .15rem 0; }
ul.roster { columns: 2 14rem; }
textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
.form-card { max-width: 640px; }
.form-card input:not([type="checkbox"]):not([type="radio"]), .form-card select, .form-card textarea { width: 100%; }
.form-table { width: 100%; }
.form-table td, .form-table th { padding: .3rem .4rem; }
.form-table .num { width: 6.5rem; }
.form-table td.num:last-child, .form-table th.num:last-child { width: 4rem; text-align: center; }
p.links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
input.size { width: 4.5rem; }

/* Footer */
.site-footer { max-width: 960px; margin: 2rem auto 0; padding: 1rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; font-size: .85rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.site-footer a { color: var(--muted); }
.choices-inline ul { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; margin: .3rem 0; }
.narrow-prose { max-width: 720px; }
.danger-link { color: var(--danger); margin-left: 1rem; }
.welcome { border-color: var(--accent); }
