:root {
  --bg: #ffffff; --fg: #1c2330; --muted: #5d6878; --line: #e2e6ec; --soft: #f3f5f8;
  --accent: #0b6e6e; --accent-fg: #ffffff; --a: #0b6e6e; --b: #c2410c;
  --shadow: 0 2px 14px rgba(20, 30, 50, .18);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
}
body.dark {
  --bg: #1d222b; --fg: #e8ecf2; --muted: #9aa5b5; --line: #323a47; --soft: #272e39;
  --accent: #4cc2c2; --accent-fg: #0d1116; --a: #4cc2c2; --b: #fb923c;
  --shadow: 0 2px 14px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--fg); }
#map { position: fixed; inset: 0; }

#panel {
  position: fixed; top: 12px; left: 12px; width: 380px; max-height: calc(100% - 24px);
  display: flex; flex-direction: column; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 10px 14px 4px; }
.brand .logo { width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); }
.brand .tag { margin-left: auto; font-size: 12px; color: var(--muted); }
section { padding: 8px 12px 4px; min-height: 0; display: flex; flex-direction: column; }
#dir-view { overflow: hidden; }
.field { display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 9px; padding: 0 6px 0 10px; }
.field:focus-within { border-color: var(--accent); }
input[type=search] { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; padding: 10px 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.icon-btn { border: 0; background: none; border-radius: 8px; padding: 6px 8px; color: var(--accent); line-height: 1; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--line); }

.suggest { list-style: none; margin: 6px 0 0; padding: 0; overflow-y: auto; max-height: 46vh; border-top: 1px solid var(--line); }
.suggest li { padding: 8px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggest li[aria-selected=true], .suggest li:hover { background: var(--soft); }
.suggest .n { font-weight: 600; }
.suggest .s { font-size: 12.5px; color: var(--muted); }

.card { margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.card h2 { margin: 0 0 2px; font-size: 16px; }
.card p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--soft); border-radius: 8px; padding: 6px 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.modes { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.modes [role=radio] { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.modes [role=radio][aria-checked=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.modes #close-directions { margin-left: auto; color: var(--muted); }
.stops { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.stops .field { grid-column: 1; }
.stops #swap { grid-column: 2; grid-row: 1 / span 2; font-size: 18px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.a { background: var(--a); } .dot.b { background: var(--b); }

#routes { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.route { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 8px 10px; }
.route[aria-pressed=true] { border-color: var(--accent); background: var(--soft); }
.route b { font-size: 16px; } .route span { color: var(--muted); font-size: 13px; margin-left: 6px; }
.msg { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.msg.err { color: var(--b); }
.steps { margin: 8px 0 0; padding: 0 0 0 0; list-style: none; overflow-y: auto; counter-reset: s; border-top: 1px solid var(--line); }
.steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr auto; gap: 6px; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.steps li::before { content: counter(s); color: var(--muted); font-size: 12px; text-align: right; padding-top: 2px; }
.steps li:hover { background: var(--soft); }
.steps .d { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
footer { padding: 8px 14px 10px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

.ctx { position: fixed; z-index: 9; background: var(--bg); border-radius: 9px; box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; min-width: 190px; }
.ctx button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; }
.ctx button:hover, .ctx button:focus-visible { background: var(--soft); }
.layers { position: fixed; top: 12px; right: 12px; z-index: 4; margin: 0; padding: 8px 12px 10px; border: 0; border-radius: 10px; background: var(--bg); box-shadow: var(--shadow); font-size: 13.5px; display: flex; flex-direction: column; gap: 5px; }
.layers legend { float: left; width: 100%; padding: 0; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.layers label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.layers input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.layers .map-mode { display: flex; gap: 14px; padding-bottom: 4px; margin-bottom: 1px; border-bottom: 1px solid var(--line, rgba(127, 127, 127, .25)); }
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .45); cursor: grab; }
.pin.a { background: var(--a); } .pin.b { background: var(--b); } .pin.p { background: #7c3aed; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 640px) {
  #panel { top: auto; bottom: 0; left: 0; width: 100%; max-height: 62%; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .suggest { max-height: 30vh; }
  .layers { top: 8px; right: 8px; }
  footer { display: none; }
}
