:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1b1d21;
  --muted: #5d6470;
  --line: #dcd7cc;
  --accent: #0a6cff;
  --danger: #d7263d;
  --warn: #f18f01;
  --ok: #2a9d8f;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #22262e;
    --text: #e9eaee;
    --muted: #9aa1ad;
    --line: #2e333c;
    --accent: #5aa0ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1a1d23; --surface-2: #22262e; --text: #e9eaee;
  --muted: #9aa1ad; --line: #2e333c; --accent: #5aa0ff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 20px; font-weight: 650; }
a { color: var(--accent); }

.hero {
  padding: 40px 0 28px;
  background:
    radial-gradient(1200px 300px at 80% -50%, rgba(10,108,255,.18), transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--bg));
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 6px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; }
.hero h1 { font-size: clamp(28px, 4.5vw, 44px); font-weight: 700; letter-spacing: -.02em; }
.lede { max-width: 760px; color: var(--muted); margin: 10px 0 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 2px 0 0; font: 600 20px/1.2 var(--mono); }
.stats dd small { font: 500 12px Inter, sans-serif; color: var(--muted); margin-left: 4px; }

.tabs { display: flex; gap: 6px; padding-top: 16px; padding-bottom: 4px; position: sticky; top: 0; z-index: 1000; background: var(--bg); overflow-x: auto; }
.tab {
  padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--text);
  border: 1px solid var(--line); background: var(--surface); white-space: nowrap; font-weight: 500;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.panel { display: none; padding: 16px 0 32px; }
.panel.active { display: block; }

.map { height: 560px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.map-card, .profile-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-card { padding: 6px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 8px 4px; color: var(--muted); font-size: 13px; }
.map-tools input { accent-color: var(--accent); }

.profile-card { margin-top: 14px; padding: 14px 16px 8px; }
.profile-head { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.hint { color: var(--muted); font-size: 13px; }
.profile { height: 190px; position: relative; margin-top: 6px; }
.profile.small { height: 140px; margin-top: 10px; }
.profile svg { width: 100%; height: 100%; display: block; overflow: visible; }
.profile .axis text { fill: var(--muted); font: 11px var(--mono); }
.profile .axis line { stroke: var(--line); }
.profile .area { fill: var(--accent); opacity: .12; }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.profile .band { fill: var(--danger); opacity: .13; cursor: pointer; }
.profile .band:hover, .profile .band.on { opacity: .28; }
.profile .band-label { fill: var(--danger); font: 600 11px var(--mono); }
.profile .cursor { stroke: var(--text); stroke-width: 1; opacity: .5; }
.profile .tip { fill: var(--text); font: 600 11px var(--mono); }

.legs { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.legs li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; border-left-width: 5px; }
.legs li:hover { box-shadow: var(--shadow); }
.legs .t { font-weight: 600; }
.legs .m { color: var(--muted); font-size: 13px; font-family: var(--mono); }

.danger-intro { margin-bottom: 14px; }
.danger-intro p { color: var(--muted); max-width: 820px; margin: 6px 0 0; }
.danger-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.seg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seg-list li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start;
}
.seg-list li.on { border-color: var(--danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 25%, transparent); }
.seg-list .rk { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font: 700 14px var(--mono); color: #fff; background: var(--danger); }
.seg-list .nm { font-weight: 600; }
.seg-list .sb { color: var(--muted); font-size: 12.5px; }
.meter { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--warn), var(--danger)); }
.seg-detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow); }
.seg-detail .map { height: 430px; }
.seg-info { padding: 10px 12px 12px; }
.seg-info h3 { font-size: 19px; }
.seg-info .road { color: var(--muted); margin-top: 2px; font-size: 13.5px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 12px 0; }
.kv div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.kv span { display: block; color: var(--muted); font-size: 11.5px; }
.kv b { font: 600 16px var(--mono); }
.seg-info ul { padding-left: 18px; margin: 8px 0; }
.seg-info li { margin: 3px 0; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-right: 6px; }

.method { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.method summary { cursor: pointer; font-weight: 600; }
.method table { border-collapse: collapse; margin: 10px 0; font-size: 13.5px; }
.method td, .method th { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.method p, .method li { color: var(--muted); max-width: 860px; }

.poi-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 14px; margin-top: 12px; align-items: start; }
.poi-grid .map { height: 680px; position: sticky; top: 64px; border: 1px solid var(--line); }
.poi-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.poi-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.poi-list li.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.poi-list .hd { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.poi-list .nm { font-weight: 650; }
.poi-list .km { font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; }
.poi-list p { margin: 6px 0 0; font-size: 14px; }
.poi-list .facts { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.pin {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font: 700 12px var(--mono); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.pin.stop { background: #1b1d21; }
.pin.sight { background: var(--accent); }
.pin.pass { background: #7b2cbf; }
.hp-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--danger); }
.leaflet-popup-content { font: 13.5px/1.45 Inter, sans-serif; }
.leaflet-popup-content b { font-weight: 650; }
.leaflet-container { font-family: Inter, sans-serif; }
.mstars { color: #c8102e; letter-spacing: 1px; font-size: 13px; white-space: nowrap; }
.mstars .off { color: var(--line); }
.michelin { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.michelin .mh { font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.michelin .mi { margin: 4px 0; }
.michelin .ml { color: var(--muted); font-size: 12px; }
.michelin q { display: block; margin-top: 2px; font-style: italic; color: var(--muted); }
.michelin a { font-weight: 600; text-decoration: none; }
.michelin a:hover { text-decoration: underline; }
.foot { color: var(--muted); font-size: 12.5px; padding-bottom: 40px; }

@media (max-width: 900px) {
  .danger-grid, .poi-grid { grid-template-columns: 1fr; }
  .map { height: 420px; }
  .poi-grid .map { position: static; height: 380px; }
  .seg-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .seg-list li { min-width: 250px; }
}
