:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #6b7180;
  --border: #dfe2e8;
  --accent: #c8102e;
  --accent-text: #ffffff;
  --ok: #157a3c;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --dim: #b9bec8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1b1e24;
    --text: #e9ebef;
    --muted: #9aa1ae;
    --border: #2e323b;
    --accent: #ff4d5e;
    --accent-text: #1b0004;
    --ok: #6bd391;
    --warn: #ffcf66;
    --warn-bg: #3a2e10;
    --dim: #4a505b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; border-radius: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 24px; margin: 4px 0 10px; }
h1 small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
h2 small { font-weight: 500; }
.muted { color: var(--muted); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent); color: var(--accent-text);
}
.brand { font-weight: 700; font-size: 18px; }
.logo { background: var(--accent-text); color: var(--accent); padding: 0 6px; margin-right: 4px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 17px; }
.top-right { display: flex; align-items: center; gap: 12px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-btn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: #fff; color: #c8102e; padding: 7px 13px; font-weight: 700; font-size: 14px;
  box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.18);
  transition: transform .12s, box-shadow .12s, background .12s;
}
.map-btn svg { width: 18px; height: 18px; }
.map-btn:hover { background: #fff3f4; box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 4px 14px rgba(0,0,0,.25); }
.map-btn:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.map-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
body.no-scroll { overflow: hidden; }

/* ---------- penampil peta ---------- */
.map-view { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #dfe2e8; }
.map-bar {
  display: flex; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.map-bar { gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; align-items: center; }
.map-close {
  flex: 0 0 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); transition: background .12s, color .12s;
}
.map-close:hover { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.map-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.map-tabs a {
  padding: 10px 14px; white-space: nowrap; font-weight: 600; font-size: 14px; color: var(--muted);
  border: 1px solid var(--border); background: var(--bg); transition: background .12s, color .12s, border-color .12s;
}
.map-tabs a:hover { color: var(--text); border-color: var(--muted); }
.map-tabs a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.map-scroller {
  position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none;
  display: flex; flex-direction: column;
}
.map-scroller:active { cursor: grabbing; }
.map-scroller img { display: block; max-width: none; margin: auto; background: #fff; flex: none; }
.map-status { margin: auto; color: #333; padding: 20px; }
.map-zoom {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 21;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
.map-zoom button {
  width: 48px; height: 46px; display: grid; place-items: center; border: 0; background: var(--surface);
  transition: background .12s, color .12s;
}
.map-zoom button:hover:not(:disabled) { background: var(--accent); color: var(--accent-text); }
.map-zoom button:active:not(:disabled) { filter: brightness(.9); }
.map-zoom button:disabled { color: var(--dim); cursor: default; }
.map-zoom .zoom-fit { border-top: 1px solid var(--border); }
.zoom-level {
  font-size: 11px; font-weight: 700; text-align: center; color: var(--muted); padding: 2px 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.map-credit {
  position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 21;
  background: rgba(255,255,255,.85); color: #555; font-size: 11px; padding: 3px 8px; pointer-events: none;
}
@media (max-width: 480px) {
  .clock { font-size: 15px; }
  .top-right { gap: 8px; }
  .map-btn { padding: 6px 9px; font-size: 13px; gap: 5px; }
}

main { max-width: 860px; margin: 0 auto; padding: 14px 16px 24px; min-height: 60vh; }

.box { background: var(--surface); border: 1px solid var(--border); padding: 14px; }
.box.error { color: var(--accent); }
.btn { border: 1px solid var(--border); background: var(--bg); padding: 6px 12px; margin-left: 8px; }

/* ---------- halaman awal ---------- */
.search {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); font-size: 16px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--border); padding: 10px 12px;
}
.tile b { font-weight: 600; line-height: 1.25; }
.tile small { color: var(--muted); font-size: 12px; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }

/* ---------- halaman stasiun (ringkas & minimalis) ---------- */
.station h1 { font-size: 18px; margin: 2px 0 8px; }
.station h1 small { display: inline; font-size: 12px; margin-left: 6px; }
.station h2 { font-size: 11px; margin: 12px 0 6px; }
.back { display: inline-block; color: var(--muted); padding: 2px 0; font-size: 13px; }
.back:hover { color: var(--accent); }

.chips { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips:empty { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--border); border-left: 3px solid var(--c);
  background: var(--surface); padding: 3px 9px; font-size: 12px;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.strip {
  display: flex; gap: 4px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px;
}
.strip > .box { flex: 1; }
.station .box { font-size: 12px; padding: 8px 10px; }
.station #diagram > .box { margin-top: 10px; }
.dep {
  flex: 0 0 118px; scroll-snap-align: start; text-align: left;
  display: flex; flex-direction: column; gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--c); padding: 5px 8px;
}
.dep-time { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dep-cd { font-size: 11px; font-weight: 600; color: var(--ok); }
.dep-dest { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-id { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep.past { background: var(--warn-bg); }
.dep.past .dep-cd { color: var(--warn); }
.dep.sel { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }

/* ---------- diagram rute (garis vertikal di tengah) ---------- */
.dg { margin-top: 10px; background: var(--surface); border: 1px solid var(--border); }
.dg-head { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.dg-head b { color: var(--text); font-weight: 600; }
.badge {
  display: inline-block; background: var(--c); color: #fff; font-weight: 700; font-size: 11px;
  padding: 0 5px; margin-right: 4px; text-shadow: 0 0 2px rgba(0,0,0,.4);
}
.line { list-style: none; margin: 0; padding: 14px 10px; }
.line li { position: relative; }
.line li > a, .line .more {
  display: grid; grid-template-columns: 1fr 20px 1fr; align-items: center; gap: 0 10px; min-height: 30px;
}
/* garis penghubung antar stasiun, tepat di tengah kolom titik */
.line li::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--c);
}
.line li:first-child::before { top: 50%; }
.line li:last-child::before { bottom: 50%; }
.line li.passed::before { background: var(--dim); }
.nm { text-align: right; font-size: 13px; line-height: 1.2; }
.tm { text-align: left; font-size: 13px; font-variant-numeric: tabular-nums; }
.dot {
  position: relative; z-index: 1; justify-self: center;
  width: 12px; height: 12px; border-radius: 50%; background: var(--c);
}
.stop.passed .dot { background: var(--dim); }
.stop.passed .nm, .stop.passed .tm { color: var(--muted); }
.stop.cur .nm, .stop.cur .tm { font-weight: 700; }
.stop.cur .dot { width: 16px; height: 16px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.stop > a:hover .nm { text-decoration: underline; }
.line .more button {
  grid-column: 1; justify-self: end; border: 1px dashed var(--border); background: var(--bg); padding: 2px 8px; font-size: 11px;
}
.line .more::before { background: repeating-linear-gradient(var(--dim) 0 4px, transparent 4px 8px); }

.note {
  margin: 10px 0 0; padding: 7px 10px; font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
}
