/* Shiloh GIS styles. No web fonts, no CDN (SDD section 14). Colors are tokens with light and dark values. */
:root {
  --union: #2b5d9b;
  --confed: #6b7280;
  --bg: #f4f1ea;
  --surface: #fbfaf6;
  --surface-2: #ece8dd;
  --text: #1f2430;
  --text-muted: #5b6270;
  --border: #cfc9b8;
  --accent: #24364f;
  --accent-text: #ffffff;
  --focus: #1a6fd1;
  --ok: #1f7a46;
  --warn: #a35a00;
  --info: #3a5a8a;
  --danger: #b3261e;
  --topbar-h: 48px;
  --tabbar-h: 56px;
  --timeline-h: 78px;
  --rail-w: 76px;
  --panel-w: 400px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --surface: #1c2028; --surface-2: #262b35; --text: #e8e6df; --text-muted: #a3a9b6;
    --border: #3a4150; --accent: #8fb2e6; --accent-text: #101319; --focus: #6aa8ff;
    --ok: #5dd08c; --warn: #f0b060; --info: #8fb2e6; --danger: #ff8a80; --union: #6fa3e4; --confed: #a0a7b4;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--sans); font-size: 16px; line-height: 1.45; color: var(--text); background: var(--bg); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-text); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { top: 8px; }

/* ---- layout: phone first ---- */
.app {
  position: fixed; inset: 0; display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--timeline-h) calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  grid-template-columns: 1fr;
  grid-template-areas: "top" "stage" "time" "tabs";
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 12px; padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); background: var(--accent); color: var(--accent-text); z-index: 20; }
@media (prefers-color-scheme: dark) { .topbar { background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); } }
.brand { font-size: 1.05rem; margin: 0; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.topbar .btn { white-space: nowrap; }
.spacer { flex: 1; }
.stage { grid-area: stage; position: relative; min-height: 0; }
.map { position: absolute; inset: 0; }
.map-message { position: absolute; left: 12px; right: 12px; top: 12px; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; max-width: 420px; }

.rail { display: none; }
.tabbar { grid-area: tabs; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; font-size: .72rem; color: var(--text-muted); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--union); font-weight: 600; }

/* Phone: panel is a bottom sheet over the map */
.panel { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--timeline-h) + env(safe-area-inset-bottom)); top: 14vh; z-index: 30; background: var(--surface);
  border-top-left-radius: 14px; border-top-right-radius: 14px; border: 1px solid var(--border); border-bottom: 0; display: flex; flex-direction: column; box-shadow: 0 -6px 24px rgba(0,0,0,.18); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel-body { overflow: auto; padding: 14px; flex: 1; -webkit-overflow-scrolling: touch; }

.banners { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--timeline-h) + env(safe-area-inset-bottom) + 8px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
.banner { pointer-events: auto; background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; max-width: 520px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.banner .btn { background: var(--accent-text); color: var(--accent); border-color: transparent; }

.overlay { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; width: 100%; max-width: 400px; }
.card h2 { margin-top: 0; }

/* Narrow phones: keep the top bar on one line; the user name stays available to screen readers */
@media (max-width: 599px) {
  .brand { font-size: .95rem; }
  #user-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar { gap: 8px; }
}

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; background: transparent; color: inherit; border-color: currentColor; }
.btn-quiet { border-color: transparent; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-icon { min-width: 44px; padding: 0; background: transparent; color: var(--text); border-color: transparent; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 600; margin-bottom: 4px; }
.field input { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.error { color: var(--danger); margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--text-muted); }
.badge { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.18); border: 1px solid currentColor; white-space: nowrap; }
.badge[data-tone="ok"] { color: #9be3b4; } .badge[data-tone="warn"] { color: #ffd08a; } .badge[data-tone="info"] { color: #c5d6f2; }
@media (prefers-color-scheme: dark) { .badge[data-tone="ok"] { color: var(--ok); } .badge[data-tone="warn"] { color: var(--warn); } .badge[data-tone="info"] { color: var(--info); } }

.section { margin-bottom: 22px; }
.section h3 { margin: 0 0 8px; font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; }
.choice input { width: 20px; height: 20px; }
progress { width: 100%; height: 14px; }
table.counts { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.counts td { padding: 3px 0; border-bottom: 1px solid var(--border); } table.counts td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.reading { font-family: var(--serif); }
.noscript { padding: 20px; }

/* MapLibre controls: keep touch targets comfortable */
.maplibregl-ctrl-group button { width: 40px; height: 40px; }

/* ---- tablet: panels overlay the map beside the rail ---- */
@media (min-width: 600px) {
  :root { --timeline-h: 144px; }
  .app { grid-template-columns: var(--rail-w) 1fr; grid-template-rows: calc(var(--topbar-h) + env(safe-area-inset-top)) 1fr var(--timeline-h); grid-template-areas: "top top" "rail stage" "rail time"; }
  .tabbar { display: none; }
  .rail { grid-area: rail; grid-row: 2 / span 2; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; z-index: 20; }
  .rail a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px; min-height: 56px; font-size: .7rem; color: var(--text-muted); text-decoration: none; }
  .rail a[aria-current="page"] { color: var(--union); background: var(--surface-2); font-weight: 600; }
  .panel { position: absolute; left: var(--rail-w); top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: var(--timeline-h); right: auto; width: min(var(--panel-w), calc(100vw - var(--rail-w) - 24px));
    border-radius: 0; border: 0; border-right: 1px solid var(--border); box-shadow: 4px 0 18px rgba(0,0,0,.15); }
  .banners { bottom: calc(var(--timeline-h) + 16px); left: var(--rail-w); }
}
/* ---- desktop: list panel sits beside the map instead of covering it ---- */
@media (min-width: 1024px) {
  .app { grid-template-columns: var(--rail-w) auto 1fr; grid-template-areas: "top top top" "rail panel stage" "rail time time"; }
  .panel { position: static; grid-area: panel; width: 380px; box-shadow: none; }
  .panel[hidden] { display: none !important; }
  .banners { left: 0; bottom: calc(var(--timeline-h) + 16px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
