:root {
  --bg: #fff8ef;
  --card: #ffffff;
  --ink: #2b2118;
  --sub: #7a6a5c;
  --line: #eadfd2;
  --accent: #e8590c;
  --d1: #e8590c;
  --d2: #0c8599;
  --d3: #6741d9;
  --day: var(--d1);
  --walk: #6b7280;
  --metro: #e03131;
  --train: #1c4fd6;
  --shadow: 0 2px 10px rgba(60, 40, 20, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --card: #26201c;
    --ink: #f3ebe2;
    --sub: #b3a496;
    --line: #3a312b;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line); z-index: 5;
}
.title h1 { font-size: 17px; margin: 0; letter-spacing: -.02em; }
.title p { margin: 0; font-size: 12px; color: var(--sub); }
.tabs { display: flex; gap: 6px; flex: 1 1 320px; max-width: 460px; }
.tabs button {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 6px; font-size: 13px; font-weight: 600; white-space: nowrap; min-height: 38px; flex: 1 1 0; line-height: 1.2;
}
.tabs button small { display: block; font-weight: 400; font-size: 10.5px; color: var(--sub); }
.tabs button[aria-selected="true"] { background: var(--tab, var(--ink)); border-color: transparent; color: #fff; }
.tabs button[aria-selected="true"] small { color: rgba(255, 255, 255, .85); }

.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mapwrap { position: relative; height: 40dvh; flex: none; border-bottom: 1px solid var(--line); }
#map { position: absolute; inset: 0; background: #e8e4dc; }
.mapbtns { position: absolute; right: 10px; top: 10px; z-index: 500; display: flex; flex-direction: column; gap: 6px; }
.mapbtns button {
  background: #fff; color: #2b2118; border: 0; border-radius: 10px; padding: 7px 10px;
  font-size: 12px; font-weight: 600; box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
.legend {
  position: absolute; left: 10px; bottom: 22px; z-index: 500; display: flex; gap: 10px;
  background: rgba(255, 255, 255, .92); color: #2b2118; padding: 4px 9px; border-radius: 8px; font-size: 11px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.legend span { display: flex; align-items: center; gap: 4px; }
.ln { display: inline-block; width: 18px; height: 0; border-top: 3px solid; }
.ln.walk { border-color: var(--walk); border-top-style: dotted; }
.ln.metro { border-color: var(--metro); }
.ln.train { border-color: var(--train); }

.panel { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px calc(16px + env(safe-area-inset-bottom)); }

.now {
  position: sticky; top: 0; z-index: 4; margin: 0 -12px 10px; padding: 10px 14px 8px;
  background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.nowhead { display: flex; align-items: center; gap: 8px; }
.badge { background: var(--day); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
#liveBtn { margin-left: auto; border: 1px solid var(--line); background: transparent; border-radius: 999px; font-size: 12px; padding: 3px 10px; }
.nowmain { font-size: 15px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.nowmain small { font-weight: 400; color: var(--sub); }
.nownext { font-size: 13px; color: var(--sub); margin-top: 2px; }
.nownext b { color: var(--ink); font-weight: 600; }
.slider { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--sub); }
.slider span { white-space: nowrap; }
.slider input { flex: 1; accent-color: var(--day); height: 28px; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  position: relative; display: grid; grid-template-columns: 46px 1fr; gap: 8px;
  padding: 0 0 12px; scroll-margin-top: calc(var(--nowh, 150px) + 10px);
}
.item::before { content: ""; position: absolute; left: 67px; top: 30px; bottom: -2px; width: 2px; background: var(--line); }
.item:last-child::before { display: none; }
.time { text-align: right; font-variant-numeric: tabular-nums; padding-top: 4px; }
.time b { display: block; font-size: 13px; }
.time span { font-size: 11px; color: var(--sub); }
.card {
  position: relative; margin-left: 28px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer;
}
.dot {
  position: absolute; left: -27px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--day); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.item.move .dot { background: var(--card); color: var(--sub); border-color: var(--line); }
.item.move .card { background: transparent; box-shadow: none; border-style: dashed; }
.item.past { opacity: .5; }
.item.cur .card { border-color: var(--day); box-shadow: 0 0 0 2px var(--day), var(--shadow); }
.item.sel .card { border-color: var(--day); }
.chip { display: inline-block; font-size: 11px; font-weight: 700; color: var(--day); margin-bottom: 1px; }
.card h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; line-height: 1.35; }
.card p { margin: 3px 0 0; font-size: 13px; }
.tip { color: var(--sub); }
.tip::before { content: "💡 "; }
.how { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--day) 9%, transparent); font-size: 13px; }
.how strong { display: block; font-size: 12px; color: var(--day); margin-bottom: 2px; }
.how ol { margin: 0; padding-left: 18px; }
.how li { margin: 1px 0; }
.warn { margin-top: 6px; font-size: 12.5px; color: #c2410c; font-weight: 600; }
.acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.acts a {
  text-decoration: none; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; min-height: 30px;
  border: 1px solid var(--line); color: var(--ink); background: var(--bg);
}
.acts a.pri { background: var(--day); border-color: transparent; color: #fff; }

.info h2 { font-size: 15px; margin: 16px 0 6px; }
.info .box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px; box-shadow: var(--shadow); }
.info dl { margin: 0; }
.info .row { padding: 8px 0; border-bottom: 1px solid var(--line); cursor: default; }
.info .row:last-child { border-bottom: 0; }
.info .row[data-place] { cursor: pointer; }
.info dt { font-size: 12px; color: var(--sub); }
.info dd { margin: 0; font-size: 13.5px; }
.info dd b { font-weight: 600; }
.info dd small { display: block; color: var(--sub); font-size: 12px; }

.foot { font-size: 11px; color: var(--sub); padding: 12px 4px 0; }
.sync { display: block; margin-bottom: 4px; font-weight: 600; color: #2f9e44; }
.sync::before { content: "● "; }
.sync.off { color: #c2410c; }
.info .note { font-size: 12px; color: var(--sub); margin: 6px 4px 0; }

/* Leaflet markers */
.pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c, #e8590c); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  display: grid; place-items: center;
}
.pin b { transform: rotate(45deg); color: #fff; font: 700 11px/1 -apple-system, "Malgun Gothic", sans-serif; }
.pin.sel { outline: 3px solid rgba(0, 0, 0, .25); outline-offset: 1px; }
.pin.extra { background: #868e96; width: 20px; height: 20px; }
.me { position: relative; width: 22px; height: 22px; }
.me i { position: absolute; inset: 3px; border-radius: 50%; background: #111; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .5); }
.me::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; background: rgba(17, 17, 17, .22); animation: pulse 1.8s ease-out infinite; }
.gps i { background: #1971c2; }
.gps::before { background: rgba(25, 113, 194, .25); }
@keyframes pulse { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .me::before { animation: none; } }
.leaflet-popup-content { margin: 10px 12px; font: 13px/1.45 -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.leaflet-popup-content b { font-size: 14px; }
.leaflet-popup-content ul { margin: 4px 0 0; padding-left: 16px; }
.leaflet-popup-content a { font-weight: 600; }

@media (min-width: 900px) {
  .layout { flex-direction: row-reverse; }
  .mapwrap { height: auto; flex: 1; border-bottom: 0; border-left: 1px solid var(--line); }
  .panel { flex: none; width: 440px; padding: 0 16px 20px; }
  .now { margin: 0 -16px 12px; padding: 12px 18px 10px; }
  .top { padding: 10px 20px; }
  .title h1 { font-size: 19px; }
}
