/* Future MRT Map - styles */
:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-panel: #11161d;
  --land: #1b2430;
  --water: #0b1017;
  --fg: #e6edf3;
  --fg-dim: #9aa7b4;
  --fg-faint: #6b7886;
  --line: #2a3440;
  --accent: #4dd4c4;
  --warn: #f0a04b;
  --danger: #ef6461;
  --ok: #7bc96f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-soft: #ffffff;
  --bg-panel: #ffffff;
  --land: #e7ecf2;
  --water: #dde6ef;
  --fg: #16202b;
  --fg-dim: #4a5966;
  --fg-faint: #78868f;
  --line: #d7dee6;
  --accent: #0f766e;
  --shadow: 0 10px 30px rgba(20, 30, 45, .12);
}

/* Follow the operating system unless the reader has picked a theme. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7fa;
    --bg-soft: #ffffff;
    --bg-panel: #ffffff;
    --land: #e7ecf2;
      --water: #dde6ef;
      --fg: #16202b;
    --fg-dim: #4a5966;
    --fg-faint: #78868f;
    --line: #d7dee6;
    --accent: #0f766e;
      --shadow: 0 10px 30px rgba(20, 30, 45, .12);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }

header.top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  flex: none;
  z-index: 5;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand span { font-size: 11.5px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .spacer { flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.ghost-btn {
  background: transparent; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 11px; font-size: 12.5px; color: var(--fg-dim);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--fg); }

.search-wrap { position: relative; }
#search {
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; width: 230px;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; width: 340px; max-height: 60vh;
  overflow: auto; background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); display: none; z-index: 40;
}
.results.open { display: block; }
.results button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 9px 12px; font-size: 13px;
}
.results button:hover, .results button.cursor { background: var(--land); }
.results .r-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--fg-faint); }

main.body { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------- map ---------- */
.map-wrap { flex: 1; position: relative; min-width: 0; background: var(--water); }
svg#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
svg#map.dragging { cursor: grabbing; }

.layer-land { opacity: .85; transition: opacity .12s linear; }
.extent {
  fill: none; stroke: var(--land); stroke-width: 78; stroke-linecap: round; stroke-linejoin: round;
}

.route { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.route.existing { stroke-width: 3.5; opacity: .5; }
.route.committed { stroke-width: 5; opacity: .95; }
.route.study { stroke-width: 5; opacity: .95; stroke-dasharray: 13 9; }
.route.model { stroke-width: 5; opacity: .9; stroke-dasharray: 3 9; }
.route.halo { stroke: var(--bg); stroke-width: 9; opacity: .55; pointer-events: none; }
.route.existing { pointer-events: none; }

.node { cursor: pointer; }
.node circle.hit { fill: transparent; stroke: none; }
.node circle.dot { stroke-width: 2; }
.node.existing circle.dot { fill: var(--bg); stroke-opacity: .55; r: 3.4; }
.node.committed circle.dot { fill: var(--bg); r: 5.4; }
.node.study circle.dot { fill: var(--bg); r: 6; }
.node.model circle.dot { fill: var(--bg); r: 6; stroke-dasharray: 3 2.5; }
.node.is-dgi circle.dot { r: 6.4; }
.node:hover circle.dot, .node:focus-visible circle.dot { stroke-width: 3.5; }
.node:focus, .bubble:focus { outline: none; }
.node:focus-visible circle.focus-ring, .node.selected circle.focus-ring {
  fill: none; stroke: var(--accent); stroke-width: 2; opacity: .9;
}
.node circle.focus-ring { fill: none; stroke: none; }
.bubble:focus-visible circle { stroke-width: 3.5; fill-opacity: .3; }

.node text.label {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  fill: var(--fg); paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px;
  stroke-linejoin: round;
}
.node.existing text.label { font-weight: 500; font-size: 11.5px; fill: var(--fg-dim); }
.node.hide-label text.label { display: none; }

.bubble { cursor: pointer; }
.bubble circle { fill: var(--warn); fill-opacity: .13; stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.bubble.covered circle { fill: var(--ok); stroke: var(--ok); fill-opacity: .08; }
.bubble:hover circle, .bubble.selected circle { fill-opacity: .26; }
.bubble text { font-size: 11.5px; fill: var(--warn); font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.bubble.covered text { fill: var(--ok); }

/* ---------- map chrome ---------- */
.map-ctl {
  position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px;
}
.map-ctl button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-panel); color: var(--fg-dim); font-size: 16px; line-height: 1;
  box-shadow: var(--shadow);
}
.map-ctl button:hover { color: var(--fg); border-color: var(--accent); }

.legend {
  position: absolute; left: 12px; top: 12px; width: 232px;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px; font-size: 12px;
}
.legend h2 { margin: 0 0 8px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--fg-faint); }
.legend .layer { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.legend .layer input { accent-color: var(--accent); margin: 0; }
.legend .swatch { width: 26px; height: 0; border-top-width: 3px; border-top-style: solid; flex: none; }
.legend .swatch.dash { border-top-style: dashed; }
.legend .swatch.dot { border-top-style: dotted; border-top-width: 4px; }
.legend .swatch.circle { width: 12px; height: 12px; border: 2px dashed var(--warn); border-radius: 50%; }
.legend .note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--fg-faint); font-size: 11px; line-height: 1.45; }
.legend.collapsed .legend-body { display: none; }
.legend-toggle { background: none; border: 0; color: var(--fg-faint); font-size: 11px; padding: 0; float: right; }

/* ---------- panel ---------- */
aside.panel {
  width: 430px; flex: none; background: var(--bg-panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.panel-head .titles { min-width: 0; flex: 1; }
.panel-head h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.panel-head .sub { font-size: 12px; color: var(--fg-dim); margin-top: 3px; }
.panel-body { overflow: auto; padding: 14px 16px 40px; flex: 1; }
.panel-body h3 {
  margin: 20px 0 8px; font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: var(--fg-faint);
}
.panel-body h3:first-child { margin-top: 0; }
.panel-body p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; color: var(--fg); }
.panel-body p.dim { color: var(--fg-dim); font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--fg-dim); line-height: 1.5; max-width: 100%;
}
.chip.strong { border-color: currentColor; }
.chip.sited { color: var(--ok); }
.chip.indicative { color: var(--warn); }
.chip.model { color: var(--danger); }
.chip.open { color: var(--fg-faint); }

.callout {
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  background: var(--bg-soft); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px;
  font-size: 12.5px; line-height: 1.55; color: var(--fg-dim);
}
.callout.model { border-left-color: var(--danger); }
.callout strong { color: var(--fg); }

.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--bg-soft); }
.card .card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card .big { font-size: 24px; font-weight: 700; font-family: var(--mono); }
.card .card-label { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .7px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
table.mini th, table.mini td { text-align: right; padding: 4px 5px; border-bottom: 1px solid var(--line); }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini th { color: var(--fg-faint); font-weight: 600; font-size: 10.5px; text-transform: uppercase; }
table.mini td.num { font-family: var(--mono); }

.prob { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.prob .bar { flex: 1; height: 6px; border-radius: 4px; background: var(--land); overflow: hidden; }
.prob .bar i { display: block; height: 100%; background: var(--accent); }
.prob .pct { font-family: var(--mono); font-size: 13px; font-weight: 700; width: 42px; text-align: right; }

.item { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; background: var(--bg-soft); }
.item > summary {
  list-style: none; cursor: pointer; padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
  display: flex; gap: 9px; align-items: flex-start;
}
.item > summary::-webkit-details-marker { display: none; }
.item > summary:hover { background: var(--land); }
.item .tag {
  font-family: var(--mono); font-size: 11px; color: var(--accent); flex: none; padding-top: 1px;
}
.item .body { padding: 0 12px 12px 12px; font-size: 12.5px; line-height: 1.55; color: var(--fg-dim); }
.item .body .srcline { margin-top: 8px; font-size: 11.5px; }

.src { display: flex; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.src:last-child { border-bottom: 0; }
.grade {
  font-family: var(--mono); font-size: 10px; font-weight: 700; width: 18px; height: 18px; flex: none;
  display: grid; place-items: center; border-radius: 5px; color: var(--bg);
}
.grade.A { background: var(--ok); } .grade.B { background: var(--accent); }
.grade.C { background: var(--warn); } .grade.D { background: var(--danger); }
.src .meta { color: var(--fg-faint); font-size: 11.5px; }

.list-btn {
  display: block; width: 100%; text-align: left; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 7px; font-size: 13px;
}
.list-btn:hover { border-color: var(--accent); }
.list-btn .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.list-btn .name { font-weight: 600; }
.list-btn .meta { font-size: 11.5px; color: var(--fg-dim); margin-top: 2px; line-height: 1.4; }
.list-btn .score { font-family: var(--mono); font-size: 13px; color: var(--warn); font-weight: 700; }
.list-btn .score.covered { color: var(--ok); }

.back-btn { background: none; border: 0; color: var(--fg-dim); font-size: 12px; padding: 0 0 8px; }
.back-btn:hover { color: var(--accent); }
.close-btn { background: none; border: 0; color: var(--fg-faint); font-size: 20px; line-height: 1; padding: 0 2px; }
.close-btn:hover { color: var(--fg); }


dialog.about {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-panel);
  color: var(--fg); max-width: 640px; padding: 0; box-shadow: var(--shadow);
}
dialog.about::backdrop { background: rgba(0, 0, 0, .55); }
dialog.about .dlg-body { padding: 18px 22px 22px; font-size: 13.5px; line-height: 1.6; }
dialog.about h2 { margin: 0 0 4px; font-size: 18px; }
dialog.about ul { padding-left: 18px; }
dialog.about li { margin-bottom: 6px; }

.tooltip {
  position: absolute; pointer-events: none; background: var(--bg-panel); color: var(--fg);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; font-size: 12px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .1s; white-space: nowrap; z-index: 20;
}
.tooltip.show { opacity: 1; }
.tooltip .t-sub { color: var(--fg-faint); font-size: 11px; }

.brand .short { display: none; }

@media (max-width: 1100px) {
  aside.panel { width: 370px; }
  #search { width: 170px; }
}

@media (max-width: 900px) {
  main.body { flex-direction: column; }
  .map-wrap { height: 52%; flex: none; }
  aside.panel {
    width: 100%; height: 48%; flex: 1; border-left: 0; border-top: 1px solid var(--line);
  }
  header.top { padding: 8px 10px; gap: 8px; }
  .top .spacer { display: none; }
  .brand { flex: 1 1 auto; overflow: hidden; }
  .brand h1 { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
  .brand span { display: none; }
  .brand .full { display: none; }
  .brand .short { display: inline; }
  .top-actions { flex: none; gap: 6px; }
  #search { width: 116px; padding: 7px 8px; font-size: 12.5px; }
  .results { width: min(80vw, 320px); right: 0; left: auto; }
  .ghost-btn { padding: 6px 9px; font-size: 11.5px; }
  .legend { width: 176px; font-size: 11.5px; padding: 8px 10px; }
  .legend .note { font-size: 10.5px; }
  .map-ctl { left: auto; right: 10px; bottom: 10px; }
  .panel-head h2 { font-size: 15.5px; }
}

@media (max-width: 420px) {
  #about-btn .long { display: none; }
}
