:root {
  --bg: #fef7ff;
  --surface: #ffffff;
  --surface-2: #f3edf7;
  --text: #1d1b20;
  --muted: #5f5a66;
  --line: #cac4d0;
  --primary: #6750a4;
  --primary-soft: #e8def8;
  --error: #b3261e;
  --express: #d32f2f;
  --express-soft: #fdf0f0;
  --st-enter: #ef6c00;
  --st-arrive: #2e7d32;
  --st-depart: #1565c0;
  --st-prev: #757575;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141218;
    --surface: #1d1b20;
    --surface-2: #2b2930;
    --text: #e6e0e9;
    --muted: #b0a9b8;
    --line: #49454f;
    --primary: #d0bcff;
    --primary-soft: #4a4458;
    --error: #f2b8b5;
    --express: #ff6b6b;
    --express-soft: #3a1f1f;
    --st-enter: #ffab40;
    --st-arrive: #81c784;
    --st-depart: #64b5f6;
    --st-prev: #9e9e9e;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
main { max-width: 760px; margin: 0 auto; padding: 0 12px 24px; }
[hidden] { display: none !important; }

/* ── 상단 ── */
.site-header {
  background: #1c1b1f;
  color: #fff;
  padding: 10px 16px 0;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 19px; display: block; max-width: 760px; margin: 0 auto 8px; }
.tabs { display: flex; gap: 4px; max-width: 760px; margin: 0 auto; }
.tab {
  flex: 1; text-align: center; padding: 10px 0; color: #cfc9d6; text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: #ffb300; }

/* ── 공통 ── */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 0 14px; height: 44px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: default; }
.meta { color: var(--muted); font-size: 13px; margin: 8px 2px; }
.error { color: var(--error); font-size: 14px; margin: 8px 2px; white-space: pre-line; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-label { font-size: 13px; font-weight: 700; color: var(--primary); align-self: center; flex-shrink: 0; }
.chip {
  flex-shrink: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 5px 11px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--primary-soft); border-color: var(--primary-soft); font-weight: 700; }
.chip .x { margin-left: 6px; color: var(--muted); }
.tag { display: inline-block; color: #fff; font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 5px; vertical-align: 1px; font-weight: 600; }
.tag.express { background: var(--express); }
.tag.special { background: #6a1b9a; }
.tag.itx { background: #00838f; }
.tag.local { background: #78909c; }
.tag.last { background: #424242; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; white-space: pre-line; }

/* ── 역 도착 ── */
.search { display: flex; gap: 6px; margin-top: 14px; }
.search input {
  flex: 1; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
  font: inherit; font-size: 16px; background: var(--surface); color: var(--text);
}
.card { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; margin: 10px 0; }
.card h2 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; }
.dir { font-size: 14px; font-weight: 700; margin: 10px 0 2px; }
.dir + .dir, .train + .dir { border-top: 1px solid var(--line); padding-top: 10px; }
.train { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; }
.train .dest { font-weight: 700; }
.train .cur { font-size: 12.5px; color: var(--muted); }
.train .eta { font-weight: 800; white-space: nowrap; }
.train .eta.now { color: var(--express); }

/* ── 노선 운행 ── */
.line-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; }
@media (min-width: 560px) { .line-grid { grid-template-columns: repeat(7, 1fr); } }
.line-btn {
  border: 0; border-radius: 7px; height: 40px; font: inherit; font-size: 14px; cursor: pointer; padding: 0 2px;
}
.line-btn.on { outline: 3px solid var(--text); outline-offset: -3px; font-weight: 800; }
.board { border-radius: 12px; overflow: clip; background: var(--surface); }
.board-head {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 84px 1fr 1fr;
  font-weight: 800; text-align: center; padding: 6px 0; align-items: center; line-height: 1.25;
}
.board-head small { display: block; font-size: 12px; font-weight: 700; opacity: .95; }
.board-head .head-ex small { display: inline-block; background: var(--express); color: #fff; border-radius: 4px; padding: 0 5px; margin-top: 2px; }
.row { display: grid; grid-template-columns: 84px 1fr 1fr; align-items: center; min-height: 52px; border-bottom: 1px solid var(--line); padding: 3px 0; }
.row .stn {
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1.25;
  text-align: center; padding: 6px 2px; cursor: pointer; border: 0; background: none; color: inherit;
  word-break: normal; overflow-wrap: anywhere;   /* 긴 역 이름은 두 줄로 */
  min-width: 0;
}
.row .stn:hover { text-decoration: underline; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 3px; }
.cell .none { color: var(--line); }
.tcard {
  width: 100%; max-width: 190px; border: 1.5px solid; border-radius: 8px; background: var(--surface);
  text-align: center; padding: 3px 4px; font-size: 12px; line-height: 1.35;
}
.tcard.ex { border-width: 2.5px; border-color: var(--express) !important; background: var(--express-soft); }
.tcard.ex.itx { border-color: #00838f !important; background: #00838f14; }
.tcard.ex.special { border-color: #6a1b9a !important; background: #6a1b9a14; }
.tcard .no { font-weight: 800; }
.tcard.tap { cursor: pointer; }
.tcard.tap:hover { filter: brightness(0.97); }
.fm { font-size: 11.5px; font-weight: 800; color: var(--primary); }
.fm.inline { margin-left: 8px; }
.fm-dialog { border: 0; border-radius: 16px; padding: 18px 18px 12px; width: min(92vw, 360px); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px #0005; }
.fm-dialog::backdrop { background: #0006; }
.fm-dialog h3 { margin: 0 0 6px; font-size: 17px; }
.fm-dialog label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; margin-top: 10px; }
.fm-dialog input { height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 18px; background: var(--bg); color: var(--text); }
.fm-now { margin: 0; color: var(--muted); font-size: 13.5px; }
.fm-msg { min-height: 1.2em; margin: 6px 0 0; color: var(--error); font-size: 13px; }
.fm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.fm-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.tcard.small { font-size: 11px; padding: 2px 2px; border-radius: 6px; }
.tcard.small .d { font-size: 11.5px; word-break: keep-all; }
.tcard.small .s { word-break: keep-all; }
.tcard .d { font-size: 13px; font-weight: 700; }
.tcard .s { font-weight: 800; }
.st-0 { color: var(--st-enter); } .st-1 { color: var(--st-arrive); } .st-2 { color: var(--st-depart); } .st-3, .st-x { color: var(--st-prev); }
.section { text-align: center; font-weight: 700; font-size: 13.5px; padding: 6px 0; }

/* ── 노선도 (도식형) ── */
.map-wrap { border-radius: 12px; background: var(--surface); border: 1px solid var(--line); padding: 6px 0; }
#mapSvg { display: block; width: 100%; user-select: none; -webkit-user-select: none; }
.s-stn, .s-train { cursor: pointer; }
.s-label { font-size: 11.5px; font-weight: 700; fill: var(--text); text-anchor: middle; }
.s-label.end { font-size: 12.5px; font-weight: 800; }
.s-sec { font-size: 13px; font-weight: 800; fill: var(--text); text-anchor: middle; }
.s-note { font-size: 11.5px; font-weight: 700; fill: var(--muted); text-anchor: end; }
.s-arrow { font-size: 10.5px; font-weight: 900; text-anchor: middle; pointer-events: none; }
.map-legend { font-size: 12.5px; color: var(--muted); margin: 0 2px 8px; }
.lg-ex { color: #d32f2f; font-weight: 800; }
.map-info { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 48px;
  position: sticky; top: 0; z-index: 3; box-shadow: 0 2px 8px #0002; }
.map-info .info-title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.map-info .muted { color: var(--muted); font-size: 13.5px; }
.btn.small { height: 36px; font-size: 14px; align-self: flex-start; margin-top: 4px; }

/* ── 하단 ── */
.site-footer { max-width: 760px; margin: 0 auto; padding: 16px 16px 32px; color: var(--muted); font-size: 12px; }
.site-footer p { margin: 4px 0; }
