:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1b1f26;
  --muted: #5b6270;
  --line: #d9d4c7;
  --state: #e3ded2;
  --state-stroke: #ffffff;
  --found: #1f7a4d;
  --found-ink: #ffffff;
  --accent: #f2b705;
  --warn: #b3261e;
  --focus: #1a5fd0;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181f;
    --surface: #1d232c;
    --ink: #eef1f5;
    --muted: #a3acb9;
    --line: #2f3742;
    --state: #36404d;
    --state-stroke: #14181f;
    --found: #3cb878;
    --found-ink: #0d1a12;
    --accent: #f2c230;
    --warn: #ff8a80;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181f; --surface: #1d232c; --ink: #eef1f5; --muted: #a3acb9; --line: #2f3742;
  --state: #36404d; --state-stroke: #14181f; --found: #3cb878; --found-ink: #0d1a12;
  --accent: #f2c230; --warn: #ff8a80; --focus: #8ab4ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 16px; z-index: 10; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: .01em; white-space: nowrap; }
.plate-mark {
  display: inline-grid; place-items: center; width: 44px; height: 28px; flex: none;
  border: 2px solid var(--ink); border-radius: 6px; font-weight: 800; font-size: .85rem;
  background: var(--accent); color: #1b1f26;
}
.top-links a { font-size: .95rem; color: var(--muted); padding: 10px 4px; display: inline-block; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.trip-bar { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; }
.trip-select { flex: 1; min-width: 0; }
.trip-select select {
  width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}

.btn {
  min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--found); border-color: var(--found); color: var(--found-ink); }
.btn.warn { color: var(--warn); }
.btn.ghost { background: transparent; }
.btn:active { transform: translateY(1px); }

.progress {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 8px 0 10px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
}
.count { grid-row: span 2; font-variant-numeric: tabular-nums; line-height: 1; }
.count strong { font-size: 2.6rem; font-weight: 800; }
.count span { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.bar { height: 12px; border-radius: 99px; background: var(--state); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--found); border-radius: inherit; transition: width .3s ease; }
.last { margin: 6px 0 0; font-size: .92rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.board { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .board { grid-template-columns: 1.35fr 1fr; align-items: start; }
  .map-wrap { position: sticky; top: 96px; }
}

.map { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 8px; aspect-ratio: 975 / 610; }
.map-loading { margin: 0; padding: 24px; color: var(--muted); }
.map svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.map .st { fill: var(--state); stroke: var(--state-stroke); stroke-width: 1; cursor: pointer; transition: fill .2s; }
.map .st.on { fill: var(--found); }
.map .st.dc { stroke-width: 1.5; }
.map .st.flash { animation: flash .6s ease; }
@keyframes flash { 50% { fill: var(--accent); } }
.map .labels text { font: 700 14px system-ui, sans-serif; fill: var(--muted); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.map .labels text.on { fill: var(--found-ink); }
.map .labels text.sm { text-anchor: start; pointer-events: auto; cursor: pointer; font-size: 15px; }
.map .labels text.sm.on { fill: var(--found); }
.map .labels .lead { stroke: var(--muted); stroke-width: .6; opacity: .6; }
@media (hover: hover) { .map .st:hover { stroke: var(--ink); stroke-width: 1.5; } }
.map-actions { display: flex; gap: 8px; margin-top: 10px; }
.map-actions .btn { flex: 1; }

.tabs { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.tabs button {
  flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: .95rem; cursor: pointer; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

.checklist h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 6px; display: flex; justify-content: space-between; }
.checklist h3:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; width: 100%;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.chip .ab {
  flex: none; width: 40px; height: 28px; border-radius: 6px; display: grid; place-items: center;
  border: 2px solid var(--line); font-weight: 800; font-size: .85rem; letter-spacing: .03em;
}
.chip .nm { font-size: .98rem; line-height: 1.2; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--found); border-color: var(--found); color: var(--found-ink); }
.chip[aria-pressed="true"] .ab { border-color: currentColor; }
.empty { color: var(--muted); padding: 16px 4px; }

.intro { margin: 32px 0 8px; max-width: 70ch; }
.intro h2 { font-size: 1.3rem; margin-bottom: 8px; }
.intro p { color: var(--muted); }

.foot { max-width: 1180px; margin: 24px auto 0; padding: 16px 16px 96px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 6px 6px 6px 16px; border-radius: 14px;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 20;
}
.toast[hidden] { display: none; }
.toast-btn { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }

.install-hint {
  margin-top: 10px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: .95rem;
}
.install-hint[hidden] { display: none; }
.install-hint p { margin: 0 0 10px; }
.install-hint .row { display: flex; gap: 8px; justify-content: flex-end; }

dialog {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.sheet { padding: 20px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font-size: 1.25rem; }
.sheet p { margin: 0; }
.sheet img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.field input { min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 1.05rem; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .wide { grid-column: 1 / -1; }
.hint { color: var(--muted); font-size: .9rem; min-height: 1em; }
.close { justify-self: end; }

/* Article page */
.article { max-width: 72ch; margin: 0 auto; padding: 8px 16px 32px; }
.article h1 { font-size: 1.9rem; line-height: 1.2; margin: 8px 0 12px; }
.article h2 { font-size: 1.3rem; margin-top: 32px; }
.article h3 { font-size: 1.05rem; margin: 20px 0 4px; }
.article p, .article li { color: var(--ink); }
.article .lede { font-size: 1.1rem; color: var(--muted); }
.article .cta { margin: 20px 0; }
.article details { border-top: 1px solid var(--line); padding: 12px 0; }
.article summary { font-weight: 700; cursor: pointer; min-height: 32px; }

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