:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --faint: #64748b;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --go: #15803d;
  --go-soft: #dcfce7;
  --caution: #b45309;
  --caution-soft: #fef3c7;
  --no: #b91c1c;
  --no-soft: #fee2e2;
  --info: #64748b;
  --radius: 8px;
  --shadow: 0 8px 30px rgb(15 23 42 / 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --line: #334155;
    --text: #f1f5f9;
    --muted: #cbd5e1;
    --faint: #94a3b8;
    --accent: #2dd4bf;
    --accent-soft: #134e4a;
    --go: #4ade80;
    --go-soft: #14532d;
    --caution: #fbbf24;
    --caution-soft: #422006;
    --no: #f87171;
    --no-soft: #450a0a;
    --info: #94a3b8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
#map { position: fixed; inset: 0; }

/* Panel: left column on wide screens, bottom sheet on phones. */
.panel {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 2;
}
.grabber { display: none; }

.panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.region { color: var(--faint); font-size: 14px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface); padding: 4px; border-radius: var(--radius); }
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 6px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgb(15 23 42 / 0.12); }
.tabs .count { font-weight: 500; color: var(--faint); margin-left: 5px; font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
}
/* Today / Sat / Sun: which day's conditions the map and list show (weekend planner). */
.days { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.days:empty { display: none; }
.days button { font: inherit; font-size: 13px; padding: 4px 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.days button + button { border-left: 1px solid var(--line); }
.days button[aria-checked="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.day-note { font-size: 12px; color: var(--faint); margin: 4px 0 0; }
.day-note .warn { color: var(--caution, #b45309); font-weight: 600; }
.nearby { margin: 14px 0 4px; }
.nearby h3 { font-size: 14px; margin: 0 0 6px; }
.nearby button { display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-top: 1px solid var(--line); padding: 8px 0; cursor: pointer; color: var(--text); }
.nearby .item-sub { font-size: 12px; }
.nearby .mi { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.chip input { margin: 0; accent-color: var(--accent); }
#search {
  flex: 1 1 100%;
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.view { flex: 1; overflow-y: auto; }
.list-note { margin: 10px 16px 4px; font-size: 13px; color: var(--faint); }
.list { list-style: none; margin: 0; padding: 4px 8px 12px; }
.list li button {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.list li button:hover, .list li button:focus-visible { background: var(--surface); outline: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.dot.go { background: var(--go); }
.dot.caution { background: var(--caution); }
.dot.no { background: var(--no); }
.dot.info { background: var(--info); }
.item-name { font-weight: 600; }
.item-sub { font-size: 13px; color: var(--faint); }
.item-why { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
}

.back { margin: 10px 12px 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 4px; }
#detail { padding: 6px 16px 16px; }
.photo { margin: 6px 0 8px; }
.photo img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface, #f1f5f9); }
.photo figcaption { font-size: 11px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo figcaption a { color: var(--faint, #64748b); text-decoration: none; }
#detail h2 { margin: 6px 0 2px; font-size: 20px; line-height: 1.25; }
#detail .sub { color: var(--faint); font-size: 14px; margin: 0 0 12px; }
.verdict { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-weight: 700; font-size: 17px; margin-bottom: 14px; }
.verdict small { display: block; font-weight: 500; font-size: 13px; opacity: 0.85; }
.verdict.go { background: var(--go-soft); color: var(--go); }
.verdict.caution { background: var(--caution-soft); color: var(--caution); }
.verdict.no { background: var(--no-soft); color: var(--no); }
.checks { list-style: none; padding: 0; margin: 0 0 16px; }
.checks li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.check-label { font-weight: 600; font-size: 14px; }
.check-detail { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-line; }
.check-detail.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.check-src { font-size: 12px; color: var(--faint); margin-top: 3px; }
.check-src a { color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a {
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: var(--radius);
}
.links a.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
/* Report a problem: a quiet button under the links that opens a short form in place. */
.report { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
.report-open { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 13px; color: var(--faint); text-decoration: underline; cursor: pointer; }
.report h3 { font-size: 15px; margin: 4px 0 2px; }
.report-intro { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.report fieldset { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.report legend { font-size: 12px; font-weight: 600; color: var(--faint); padding: 0; margin-bottom: 2px; }
.report label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 14px; cursor: pointer; overflow-wrap: anywhere; }
.report label input { flex: none; margin: 3px 0 0; accent-color: var(--accent); }
.report label .dot { flex: none; margin-top: 5px; }
.report textarea { display: block; width: 100%; font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); resize: vertical; }
.report button[type="submit"] { margin-top: 8px; font: inherit; font-size: 14px; font-weight: 600; padding: 7px 16px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: var(--bg); cursor: pointer; }
.report button[type="submit"]:disabled { opacity: 0.45; cursor: default; }
.report-msg { font-size: 13px; color: var(--no); margin: 8px 0 0; }
.report-msg:empty { display: none; }
.report-done { font-size: 14px; color: var(--muted); margin: 4px 0 0; }

.panel-foot { border-top: 1px solid var(--line); padding: 8px 16px; font-size: 12px; color: var(--faint); }
.panel-foot details summary { cursor: pointer; }
.panel-foot ul { margin: 6px 0 0; padding-left: 16px; }
.src-bad { color: var(--no); }

.maplibregl-popup-content { background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); }
.maplibregl-popup-tip { display: none; }

.legend {
  position: fixed;
  right: 12px;
  bottom: 28px;
  z-index: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  gap: 10px;
  box-shadow: var(--shadow);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.road-key { width: 16px; height: 0; border-top: 3px dashed #b91c1c; }

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 46vh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    transition: height 0.2s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.expanded { height: 88vh; }
  .tabs .count { display: none; }
  .grabber { display: block; border: 0; background: none; padding: 8px 0 0; cursor: pointer; }
  .grabber span { display: block; margin: 0 auto; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .panel-head { padding-top: 6px; }
  .brand { margin-bottom: 8px; }
  .legend { top: 12px; bottom: auto; right: 12px; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 46vh; }
  .report textarea { font-size: 16px; } /* smaller text makes iOS Safari zoom in on focus */
}

[hidden] { display: none !important; }
.disclaimer { margin: 6px 0 0; }
