:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #14213d;
  --text: #1f2a3d;
  --muted: #5d6676;
  --line: #ddd8cc;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3da;
  --marker: #2b4c7e;
  --ok: #1f7a4d;
  --ok-soft: #dff3e8;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1420;
    --surface: #152033;
    --surface-2: #1b2940;
    --ink: #eef2f8;
    --text: #d9e0eb;
    --muted: #93a0b5;
    --line: #26354f;
    --accent: #ff7a50;
    --accent-ink: #1a0e08;
    --accent-soft: #3a2119;
    --marker: #6f9be0;
    --ok: #5dd39e;
    --ok-soft: #133426;
    --danger: #ff8a7a;
    --danger-soft: #3b1a17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3 { color: var(--ink); line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
img { max-width: 100%; height: auto; display: block; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .85rem; white-space: pre; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: var(--accent); margin: 0 0 .6rem; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
.note { font-size: .85rem; color: var(--muted); }

/* Header & footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.25rem; color: var(--ink); letter-spacing: -.01em; }
.brand b { color: var(--accent); }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.site-header nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-header nav a[aria-current] { color: var(--ink); background: var(--surface-2); }
.site-footer { margin-top: 64px; border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .88rem; }
.site-footer p { margin: .3em 0; }
.site-footer a { color: var(--muted); }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.button:hover { color: var(--accent-ink); filter: brightness(1.06); }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button.ghost:hover { border-color: var(--ink); color: var(--ink); }
.button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.link-button { background: none; border: 0; padding: 0; color: var(--danger); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; align-items: center; padding: 56px 0 24px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.hero .stats { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
.hero-art { width: 100%; max-width: 380px; height: auto; justify-self: center; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 0; font-size: 2rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats.compact { grid-template-columns: repeat(3, minmax(0, 220px)); }
.stats.compact dd { font-size: 1.5rem; }

/* Sections */
.section { margin-top: 40px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h1, .section-head h2 { margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 4vw, 40px); box-shadow: var(--shadow); margin-top: 32px; }
.narrow { max-width: 760px; margin-inline: auto; }
.empty, .empty-photo { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 20px; }
.empty-photo strong { color: var(--ink); }
.crumbs { margin-top: 24px; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* Filters & table */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { width: min(380px, 100%); }
.reset { font-size: .9rem; }
.sortbar { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.sortbar a { color: var(--muted); }
.sortbar a[aria-current] { color: var(--ink); font-weight: 700; text-decoration: none; }
textarea { resize: vertical; min-height: 140px; width: 100%; line-height: 1.5; }
input[type=text], input[type=search], input[type=password], input[type=month], input[type=file], input[type=email], textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.stations { width: 100%; border-collapse: collapse; font-size: .95rem; }
.stations th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; }
.stations td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stations tr:last-child td { border-bottom: 0; }
.stations tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.stations .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.freq { font-family: var(--mono); font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stations td a { text-decoration: none; font-weight: 600; }
.stations td a:hover { text-decoration: underline; }
.remark { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.has-photo { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* Location & program pages */
.site-head { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; margin-top: 16px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 20px 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.freq-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.freq-list span { font-family: var(--mono); font-size: .85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.mini-map { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; background: var(--surface-2); }
.mini-map.tall { height: 420px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.gallery.large { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.photo-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; display: flex; flex-direction: column; }
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); }
.photo-card > span, .photo-card figcaption { padding: 10px 12px; font-size: .9rem; color: var(--text); }
.photo-card figcaption small { display: block; color: var(--muted); margin-top: 2px; }
.photo-card figcaption form { margin-top: 6px; }

/* Forms */
.form { display: grid; gap: 6px; margin-top: 16px; }
.form label { font-weight: 600; margin-top: 10px; color: var(--ink); }
.form .button { justify-self: start; margin-top: 16px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .row > div { display: grid; gap: 6px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.check input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.alert { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.tips { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.tips h2 { font-size: 1.05rem; }
.tips ul, .prose ul { padding-left: 1.2em; }
.tips li, .prose li { margin: .3em 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.prose h2 { margin-top: 1.6em; }

/* Review (admin) */
.review-list { display: grid; gap: 16px; }
.review { display: grid; grid-template-columns: minmax(200px, 360px) 1fr; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.review img { border-radius: 10px; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.review .form { margin-top: 0; }
.review .actions .button { margin-top: 12px; }

/* Map page */
.map-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; margin-top: 24px; }
.map-panel h1 { font-size: 1.5rem; }
.map-panel .muted { font-size: .92rem; }
.map-filters { display: grid; gap: 6px; }
.map-filters label { font-weight: 600; font-size: .9rem; margin-top: 8px; color: var(--ink); }
.map-filters input[type=search], .map-filters select { width: 100%; }
.map-count { font-size: .9rem; color: var(--muted); }
.map-full { height: calc(100vh - 140px); min-height: 520px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.legend { list-style: none; padding: 0; margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--marker); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.dot.photo { background: var(--accent); }

/* Leaflet popup */
.leaflet-container { font: inherit; }
.popup strong { display: block; font-size: 1rem; margin-bottom: 6px; color: #14213d; }
.popup ul { list-style: none; margin: 0 0 8px; padding: 0; font-size: .85rem; max-height: 220px; overflow: auto; }
.popup li { padding: 2px 0; color: #1f2a3d; }
.popup .freq { color: #14213d; }
.popup .muted { color: #5d6676; }
.popup-link { font-weight: 600; color: #c2410c !important; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(.8) contrast(1.1) saturate(.8); }
}

/* Photo buttons in tables & call to action */
.photo-cell { white-space: nowrap; text-align: right; }
.stations td a.has-photo { text-decoration: none; }
.add-photo { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; white-space: nowrap; }
.stations td a.add-photo { font-weight: 700; }
.add-photo:hover { border-color: var(--accent); color: var(--accent); }
.freq a { color: inherit; }
.cta-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.cta-box strong { color: var(--ink); }
.cta-box p { margin: 4px 0 0; font-size: .92rem; color: var(--text); max-width: 48ch; }
.freq-list a { font-size: .85rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.freq-list a:hover { border-color: var(--accent); }

/* Admin */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-nav a { text-decoration: none; padding: 7px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.admin-nav a[aria-current] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.grid-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 16px; }
.grid-form > div { display: grid; gap: 6px; align-content: start; }
.grid-form input, .grid-form select { width: 100%; }
.grid-form small { font-size: .82rem; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.delete-form { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
h3.sub { margin-top: 28px; }
.form .actions .button { margin-top: 16px; }
.stats.compact { grid-template-columns: repeat(4, minmax(0, 200px)); }

/* Admin quick photo upload (mobile first) */
.quick-upload { max-width: 560px; margin-inline: auto; }
.quick-upload h1 { font-size: 1.6rem; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.step > div { display: grid; gap: 8px; min-width: 0; }
.step label { margin-top: 0; }
.step-no { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }
.quick-upload input, .quick-upload select { width: 100%; min-height: 48px; font-size: 16px; }
.button.wide { width: 100%; justify-self: stretch; }
.button.big { min-height: 56px; font-size: 1.1rem; margin-top: 20px; }
.button:disabled { opacity: .6; cursor: wait; }
.small { font-size: .85rem; margin: 0; }
.file-drop { display: grid !important; gap: 4px; place-items: center; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 700 !important; }
.file-drop:hover { border-color: var(--accent); }
.file-drop small { font-weight: 400; color: var(--muted); }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 900px) {
  .grid-form { grid-template-columns: 1fr 1fr; }
  .hero, .site-head, .map-layout { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-top: 32px; gap: 24px; }
  .hero-art { max-width: 240px; grid-row: 1; }
  .hero .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-full { height: 70vh; min-height: 420px; }
  .review { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  html, body { overflow-x: clip; }
  body { font-size: 15px; }
  .hide-sm { display: none; }

  /* Header: logo on top, menu as one swipeable row */
  .header-inner { padding: 8px 0 0; gap: 4px; min-height: 0; }
  .brand { font-size: 1.15rem; }
  .brand img { width: 28px; height: 28px; }
  .site-header nav { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 32px); margin: 0 -16px; padding: 4px 12px 8px; gap: 2px; scrollbar-width: none; }
  .site-header nav::-webkit-scrollbar { display: none; }
  .site-header nav a { padding: 6px 12px; font-size: .9rem; white-space: nowrap; flex: none; }

  /* Hero: compact, illustration small next to the eyebrow */
  .hero { padding: 20px 0 8px; gap: 16px; }
  .hero-art { max-width: 150px; margin-bottom: -8px; }
  .hero h1 { font-size: 1.85rem; }
  .hero .lead { font-size: 1rem; }
  .hero-actions { margin-top: 18px; gap: 8px; }
  .hero-actions .button { flex: 1 1 0; padding: 10px 12px; }
  .hero .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stats div { padding: 10px 6px; text-align: center; border-radius: 12px; }
  .stats dt { font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stats dd { font-size: 1.25rem; }
  .stats.compact { grid-template-columns: 1fr 1fr; }
  .stats.compact dd { font-size: 1.3rem; }

  /* Newest photos: swipeable strip */
  .section { margin-top: 28px; }
  .gallery:not(.large) { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; gap: 10px; margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .gallery:not(.large)::-webkit-scrollbar { display: none; }
  .gallery:not(.large) .photo-card { flex: 0 0 62%; scroll-snap-align: start; }
  .gallery.large { grid-template-columns: minmax(0, 1fr); }

  /* Search: full-width field, province + button side by side */
  .section-head { gap: 10px; }
  .filters { width: 100%; }
  .filters input[type=search] { flex: 1 1 100%; width: 100%; }
  .filters select { flex: 1 1 0; min-width: 0; }
  .filters .button { flex: none; }
  .sortbar { line-height: 1.9; }

  /* Station list as compact cards instead of a wide table */
  .station-list thead { display: none; }
  .station-list, .station-list tbody { display: block; }
  .station-list tr { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; grid-template-areas: "freq prog power" "freq loc photo"; gap: 2px 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .station-list tbody tr:last-child { border-bottom: 0; }
  table.station-list td { padding: 0; border: 0; min-width: 0; line-height: 1.35; }
  .station-list td:nth-child(1) { grid-area: freq; font-size: 1rem; }
  .station-list td:nth-child(2) { grid-area: prog; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .station-list td:nth-child(3) { grid-area: loc; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .station-list td:nth-child(3) a { font-weight: 500; color: var(--muted); }
  .station-list td:nth-child(5) { grid-area: power; font-size: .82rem; color: var(--muted); }
  .station-list td:nth-child(6) { grid-area: photo; }
  .station-list .tag { display: none; }

  .form .row { grid-template-columns: 1fr; }
  .stations td, .stations th { padding: 9px 10px; }
  .panel { margin-top: 20px; }
  .site-footer { margin-top: 40px; }
}
