/* ------------------------------------------------------------------ 색 (라이트 기본) */
:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --panel: #ffffff;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, .96);
  --ink: #1b2333;
  --ink-2: #4a5468;
  --ink-3: #8a93a6;
  --line: #e3e7ef;
  --line-2: #f1f3f7;
  --dash: #c5cde0;
  --hover-line: #b8c4e6;
  --accent: #2f5bea;
  --accent-bg: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eeff;
  --accent-ring: rgba(47, 91, 234, .25);
  --warn: #c2410c;
  --ok: #15803d;
  --star: #f59f00;
  --danger-soft: #ffeeee;
  --danger: #cc0000;
  --meet-top: #fff9eb;
  --meet-line: #f6dfa6;
  --kicker: #b26b00;
  --banner-bg: #fff8e6;
  --banner-line: #f6dfa6;
  --banner-ink: #7a4b00;
  --code-bg: #eef1f7;
  --bus-bg: #eef7ee;
  --map-bg: #e9edf3;
  --pin-line: #ffffff;
  --lm-pin-line: #536079;
  --tip-bg: rgba(27, 35, 51, .92);
  --overlay: rgba(15, 23, 42, .45);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 14px rgba(20, 30, 60, .06);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .25);
}

/* ------------------------------------------------------------------ 다크 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141c;
  --panel: #151b25;
  --surface: #1b2330;
  --glass: rgba(21, 27, 37, .95);
  --ink: #e6e9ef;
  --ink-2: #b4bccb;
  --ink-3: #7d879a;
  --line: #2a3342;
  --line-2: #222b38;
  --dash: #3a4558;
  --hover-line: #44527a;
  --accent: #7c9bff;
  --accent-bg: #4a6cf0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(124, 155, 255, .16);
  --accent-ring: rgba(124, 155, 255, .35);
  --warn: #ff9466;
  --ok: #4ade80;
  --star: #f59f00;
  --danger-soft: rgba(255, 90, 90, .15);
  --danger: #ff7b7b;
  --meet-top: rgba(245, 159, 0, .13);
  --meet-line: rgba(245, 159, 0, .35);
  --kicker: #fbbf24;
  --banner-bg: #2a2313;
  --banner-line: #5c4a1c;
  --banner-ink: #f3d38a;
  --code-bg: #243042;
  --bus-bg: rgba(74, 222, 128, .13);
  --map-bg: #1a1f27;
  --pin-line: #f2f4f8;
  --lm-pin-line: #8f9ab0;
  --tip-bg: rgba(5, 8, 14, .92);
  --overlay: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select { font: inherit; color: var(--ink); background: var(--surface); }
a { color: var(--accent); }

.topbar {
  height: 52px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.logo { color: var(--accent); font-size: 20px; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; color: var(--ink-2); }
.ghost:hover { background: var(--bg); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.seg.theme { padding: 2px; }
.seg.theme button { padding: 3px 9px; font-size: 12.5px; flex: none; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr 390px; }
.panel { background: var(--panel); overflow-y: auto; padding: 16px; }
.panel.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.panel.right { border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head.sub { margin: 18px 0 8px; }
.panel-head h2 { font-size: 15px; margin: 0; }
.pill { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.pill.muted { background: var(--bg); color: var(--ink-3); font-weight: 400; }
.hint { margin: 0; color: var(--ink-3); font-size: 12.5px; }
.hint b { color: var(--ink-2); font-weight: 600; }

.people { display: flex; flex-direction: column; gap: 10px; }
.person { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--surface); transition: border-color .15s; }
.person:focus-within { border-color: var(--accent); }
.person .row { display: flex; gap: 6px; align-items: center; }
.person .row + .row { margin-top: 7px; }
.badge {
  width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px;
  display: grid; place-items: center; flex: none;
}
.person .label { border: none; font-weight: 600; flex: 1; min-width: 0; padding: 2px 4px; border-radius: 6px; background: transparent; }
.person .label:hover, .person .label:focus { background: var(--bg); outline: none; }
.person .del { border: none; background: none; color: var(--ink-3); font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.person .del:hover { background: var(--danger-soft); color: var(--danger); }
.person .addr {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none;
}
.person .addr:focus { border-color: var(--accent); }
.person .find { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; white-space: nowrap; }
.person .find:hover { background: var(--accent-soft); color: var(--accent); }
.person .status { font-size: 12px; color: var(--ink-3); margin-top: 6px; min-height: 0; word-break: keep-all; }
.person .status.ok { color: var(--ok); }
.person .status.err { color: var(--warn); }
.person select { width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 5px; font-size: 12px; }

.add { border: 1.5px dashed var(--dash); background: none; border-radius: var(--radius); padding: 9px; color: var(--ink-2); font-weight: 600; }
.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.options { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.opt-title { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-top: 4px; }
.opt-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
.seg { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; border: none; background: none; border-radius: 7px; padding: 6px 4px; color: var(--ink-2); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.check { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.check[hidden] { display: none; }

.primary {
  background: var(--accent-bg); color: var(--accent-ink); border: none; border-radius: var(--radius);
  padding: 13px; font-weight: 700; font-size: 15px; box-shadow: 0 4px 12px rgba(47, 91, 234, .3);
}
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .6; cursor: wait; }
.primary.small { padding: 8px 18px; font-size: 14px; box-shadow: none; }
.msg { font-size: 12.5px; color: var(--warn); min-height: 18px; }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: 11px; padding: 0 6px; }

/* ------------------------------------------------------------------ 지도 */
.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }
.progress {
  position: absolute; z-index: 1000; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--glass); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 18px; display: flex; gap: 12px; align-items: center; max-width: 80%;
}
.progress[hidden] { display: none; }
.progress .sub { font-size: 12px; color: var(--ink-3); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend {
  position: absolute; z-index: 1000; left: 12px; bottom: 24px; background: var(--glass);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; font-size: 12.5px; max-width: 320px;
}
.legend[hidden] { display: none; }
.legend .t { font-weight: 700; margin-bottom: 4px; }
.legend .li { display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 18px; height: 4px; border-radius: 2px; flex: none; }
.legend .foot { color: var(--ink-3); margin-top: 5px; font-size: 11.5px; }
.map-banner {
  position: absolute; z-index: 1000; right: 12px; bottom: 28px; max-width: 420px; background: var(--banner-bg); border: 1px solid var(--banner-line);
  border-radius: var(--radius); padding: 8px 12px; font-size: 12.5px; color: var(--banner-ink); box-shadow: var(--shadow);
}
.map-banner[hidden] { display: none; }
.map-banner button { margin-left: 6px; border: 1px solid var(--banner-line); background: var(--surface); color: var(--ink); border-radius: 6px; padding: 2px 8px; font-size: 12px; }

/* 지도 마커: 좌표 = 요소의 왼쪽 위 → 아래쪽 꼭지점/가운데로 옮김 */
.anc { position: absolute; left: 0; top: 0; }
.anc-bottom { transform: translate(-50%, calc(-100% - 5px)); }
.anc-center { transform: translate(-50%, -50%); }
.kk-ov { position: relative; width: 0; height: 0; cursor: pointer; }
.kk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 3px solid #333; box-sizing: content-box; }
.kk-tip { background: var(--tip-bg); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c);
  border: 2.5px solid var(--pin-line); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 13px; }
.meet-pin {
  width: 44px; height: 44px; border-radius: 50%; background: var(--star); border: 3px solid var(--pin-line);
  box-shadow: 0 0 0 6px rgba(245, 159, 0, .28), 0 3px 10px rgba(0, 0, 0, .35);
  display: grid; place-items: center; font-size: 22px; color: #fff;
}
.lm-pin {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--lm-pin-line);
  display: grid; place-items: center; font-size: 15px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.lm-pin.sel { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.leaflet-popup-content { font: 13px/1.5 "Malgun Gothic", system-ui, sans-serif; }
.ml-tip .maplibregl-popup-content { background: var(--tip-bg); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.ml-tip .maplibregl-popup-tip { display: none; }

/* 다크: OpenStreetMap(Leaflet) 배경 타일은 색을 반전해 어둡게 (경로·마커는 그대로) */
:root[data-theme="dark"] #map.prov-osm .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.88) saturate(.75); }
:root[data-theme="dark"] .leaflet-container { background: var(--map-bg); }
:root[data-theme="dark"] .leaflet-bar a,
:root[data-theme="dark"] .leaflet-control-layers,
:root[data-theme="dark"] .leaflet-control-attribution,
:root[data-theme="dark"] .leaflet-control-scale-line { background: var(--panel) !important; color: var(--ink-2) !important; border-color: var(--line) !important; }
:root[data-theme="dark"] .leaflet-control-layers-toggle { filter: invert(1); }
:root[data-theme="dark"] .leaflet-tooltip { background: var(--panel); color: var(--ink); border-color: var(--line); }
/* 다크: 카카오맵은 공식 다크 지도가 없어 일반 지도 타일만 반전 (위성 지도는 제외) */
:root[data-theme="dark"] #map.prov-kakao:not(.kk-sky) img { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.88) saturate(.75); }
/* 다크: 내장 지도(MapLibre)는 다크 전용 지도 스타일로 바뀌고, 조작 버튼만 맞춤 */
:root[data-theme="dark"] .maplibregl-ctrl-group { background: var(--panel); }
:root[data-theme="dark"] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme="dark"] .maplibregl-ctrl-icon { filter: invert(1); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib { background: rgba(21, 27, 37, .8); color: var(--ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-scale { background: rgba(21, 27, 37, .8); color: var(--ink-2); border-color: var(--ink-3); }

/* ------------------------------------------------------------------ 오른쪽 결과 */
.empty { text-align: center; color: var(--ink-2); padding: 30px 8px; }
.empty-icon { font-size: 44px; }
.empty h3 { margin: 8px 0 4px; font-size: 16px; }
.empty p { margin: 0 0 16px; font-size: 13px; color: var(--ink-3); }
.how { text-align: left; font-size: 12.5px; color: var(--ink-2); background: var(--bg); border-radius: var(--radius); padding: 12px 14px 12px 30px; margin: 0; }
.how li + li { margin-top: 6px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.card.meet { background: linear-gradient(180deg, var(--meet-top), var(--surface) 70%); border-color: var(--meet-line); }
.meet .kicker { font-size: 12px; font-weight: 700; color: var(--kicker); display: flex; align-items: center; gap: 6px; }
.meet h3 { margin: 4px 0 2px; font-size: 17px; }
.meet .addr { color: var(--ink-2); font-size: 13px; }
.meet .coord { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 12px 0 10px; }
.stat { background: var(--glass); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.stat .k { font-size: 11px; color: var(--ink-3); }
.stat .v { font-weight: 700; font-size: 15px; }
table.who { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.who th { text-align: left; color: var(--ink-3); font-weight: 500; font-size: 11.5px; padding: 3px 4px; border-bottom: 1px solid var(--line); }
table.who th.r { text-align: right; }
table.who td { padding: 5px 4px; border-bottom: 1px solid var(--line-2); }
table.who td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.who .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
table.who tr.itin td { padding: 0 4px 8px 19px; border-bottom: 1px solid var(--line); }
.st { display: inline-block; font-size: 11.5px; border-radius: 6px; padding: 1px 6px; margin: 2px 0; background: var(--bg); color: var(--ink-2); }
.st.rail { background: var(--surface); border: 1.5px solid var(--lc); }
.st.bus { background: var(--bus-bg); }
.arr { color: var(--ink-3); margin: 0 3px; }
.back { margin-top: 10px; width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px; color: var(--ink-2); }
.back:hover { background: var(--bg); }
.algo { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }

.landmarks { display: flex; flex-direction: column; gap: 8px; }
.lm { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; background: var(--surface); transition: .12s; }
.lm:hover { border-color: var(--hover-line); box-shadow: var(--shadow); }
.lm.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.lm .top { display: flex; gap: 8px; align-items: flex-start; }
.lm .ic { font-size: 20px; line-height: 1.2; }
.lm .nm { font-weight: 700; }
.lm .cat { font-size: 11.5px; color: var(--ink-3); }
.lm .best { font-size: 11px; background: var(--accent-bg); color: #fff; border-radius: 999px; padding: 1px 8px; margin-left: 6px; font-weight: 600; vertical-align: 1px; }
.lm .ad { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.lm .ad.loading { color: var(--ink-3); }
.lm .meta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.lm .meta a { color: var(--accent); text-decoration: none; }
.lm .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.lm .chip { font-size: 11px; border-radius: 6px; padding: 1px 6px; background: var(--bg); color: var(--ink-2); display: flex; align-items: center; gap: 4px; }
.lm .chip i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.lm .copy { float: right; border: none; background: none; color: var(--ink-3); font-size: 11.5px; padding: 0 0 0 6px; }
.lm .copy:hover { color: var(--accent); }
.note { font-size: 11.5px; color: var(--ink-3); margin-top: 12px; line-height: 1.5; }

/* ------------------------------------------------------------------ 설정 창 */
.modal { position: fixed; inset: 0; z-index: 5000; background: var(--overlay); display: grid; place-items: center; }
.modal[hidden] { display: none; }
.dlg { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 8px; }
.dlg h3 { margin: 0; font-size: 18px; }
.dlg h4 { margin: 10px 0 0; font-size: 14px; }
.dlg .desc { margin: 0 0 4px; color: var(--ink-2); font-size: 13px; }
.dlg label { font-weight: 600; font-size: 13px; margin-top: 4px; }
.dlg label small { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.dlg label.check { font-weight: 400; }
.dlg input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: Consolas, monospace; outline: none; width: 100%; }
.dlg input[type=checkbox] { width: auto; }
.dlg input:focus { border-color: var(--accent); }
.dlg .guide { margin: 6px 0 0; padding: 10px 12px 10px 30px; background: var(--bg); border-radius: 10px; font-size: 12.5px; color: var(--ink-2); }
.dlg .guide li + li { margin-top: 5px; }
.dlg code { background: var(--code-bg); border-radius: 5px; padding: 1px 5px; font-size: 12px; }
.dlg .note { font-size: 11.5px; color: var(--ink-3); margin-top: 0; }
.dlg details { font-size: 12.5px; color: var(--ink-2); }
.dlg details small { display: block; color: var(--ink-3); margin-top: 4px; }
.dlg .btns { display: flex; gap: 8px; margin-top: 6px; }
.dlg-msg { font-size: 12.5px; color: var(--warn); min-height: 18px; }
.dlg-msg.ok { color: var(--ok); }
.offbox { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.off-status { font-size: 12.5px; color: var(--ink-2); }
.off-status small { color: var(--ink-3); word-break: break-all; }
.off-msg { font-size: 12px; color: var(--ink-3); min-height: 16px; }
.offbox progress { width: 100%; height: 8px; accent-color: var(--accent-bg); }
.offbox .btns { margin-top: 0; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 300px 1fr 330px; }
}
