:root {
  --paper: #f3f6f3; --surface: #fff; --ink: #1d3128; --muted: #53665b;
  --green: #164b39; --route: #237644; --line: #dbe4dd; --wash: #edf4ef;
  --error: #9e3a25; --error-wash: #fff3ec; --focus: #0879d1; --reference: #e7b84c;
  --direction-forest: #9b4b11; --direction-samhwan: #245f9b;
  --space: 8px; --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  color: var(--ink); background: var(--paper); font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 760px; margin: 48px auto; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
::selection { background: #c4e8cc; color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
a { color: var(--green); text-underline-offset: 4px; }
button { font: inherit; cursor: pointer; color: inherit; min-height: 44px; }
button:disabled { cursor: wait; opacity: .55; }
button, a { -webkit-tap-highlight-color: #c4e8cc; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.masthead { padding: 32px 36px 28px; background: var(--green); color: white; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
h1 { margin: 0; font-size: 34px; font-weight: 750; letter-spacing: -.035em; line-height: 1.25; text-wrap: balance; }
.heading svg { width: 34px; height: 34px; }
.masthead p { margin: 12px 0 0; color: #dceee3; line-height: 1.6; font-size: 16px; }
.masthead strong { color: white; font-weight: 650; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 36px; border-bottom: 1px solid var(--line); }
.mode { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; }
.mode::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.mode.live::before { background: var(--route); }
.toolbar p { color: var(--muted); font-size: 12px; margin: 7px 0 0; font-variant-numeric: tabular-nums; }
.notice { margin: 0; background: var(--error-wash); color: var(--error); padding: 14px 36px; font-size: 14px; line-height: 1.6; }
.stop { padding: 28px 36px; }
.stop + .stop { border-top: 1px solid var(--line); }
.stop-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stop h2 { font-size: 22px; letter-spacing: -.025em; font-weight: 700; line-height: 1.4; margin: 0; }
.ars { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.landmark { font-size: 13px; color: var(--muted); margin: 6px 0 20px; line-height: 1.5; }
.bus { display: grid; grid-template-columns: 132px 1fr; align-items: start; gap: 20px; }
.route-name { color: var(--route); font-size: 23px; font-weight: 750; letter-spacing: -.03em; margin: 0; line-height: 1.4; }
.destination { margin: 5px 0 0; font-size: 14px; font-weight: 650; }
.arrivals { border-left: 1px solid var(--line); padding-left: 20px; min-width: 0; }
.arrival-label { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.arrival-main { margin: 0; font-size: 27px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.4; overflow-wrap: anywhere; }
.arrival-main.unavailable { color: var(--muted); font-size: 23px; }
.arrival-second { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.arrival-error { color: var(--error); font-size: 13px; margin: 8px 0 0; line-height: 1.6; }
.stop-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; font-size: 12px; color: var(--muted); }
.stop-bottom a { min-height: 36px; display: flex; align-items: center; font-size: 12px; }
.stop-map-button { border: 0; padding: 0; background: transparent; color: var(--green); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.stop-map-button:hover { color: var(--route); }
.map-section { padding: 24px 36px 0; border-bottom: 1px solid var(--line); }
.map-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.map-heading h2 { font-size: 17px; margin: 0; letter-spacing: -.02em; }
#map-reset { border: 0; background: var(--wash); color: var(--green); font-size: 12px; padding: 8px 12px; border-radius: 8px; }
#map-reset { -webkit-tap-highlight-color: transparent; }
#map-reset:hover, #map-reset:active { background: var(--surface); }
.stop-map .leaflet-marker-icon { -webkit-tap-highlight-color: transparent; }
.stop-map { height: 360px; border-radius: var(--radius); background: var(--paper); isolation: isolate; }
.stop-map.leaflet-container { font-family: inherit; }
.map-caption { margin: 12px 0 20px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.map-status { color: var(--error); font-size: 13px; line-height: 1.6; margin: 12px 0 0; }
.stop-map .map-stop-pin { display: grid; place-items: center; background: var(--green); color: var(--surface); border-radius: 50%; box-shadow: 0 3px 10px #1d312830; }
.map-pin-number { font-family: inherit; font-size: 16px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.map-travel-arrow { position: absolute; width: 24px; height: 24px; left: calc(50% + var(--arrow-x) - 12px); top: calc(50% + var(--arrow-y) - 12px); transform: rotate(var(--arrow-angle)); stroke: var(--green); stroke-width: 3; pointer-events: none; }
.map-arrow-casing { stroke: var(--surface); stroke-width: 6; }
.reference-star { fill: var(--reference); stroke: var(--green); stroke-width: 1.6; }
.map-reference-pin { display: grid; place-items: center; }
.map-reference-pin svg { width: 32px; height: 32px; }
.map-stop-pin:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.stop-label.leaflet-tooltip { font-family: inherit; border: 0; border-radius: 8px; padding: 9px 12px; box-shadow: 0 2px 8px #1d312822; color: var(--ink); white-space: normal; width: max-content; max-width: 150px; text-align: center; }
.map-stop-name { display: block; font-size: 13px; line-height: 1.4; }
.map-stop-direction { display: block; color: var(--green); font-size: 12px; font-weight: 750; line-height: 1.5; margin-bottom: 4px; }
.map-stop-arrival { display: block; color: var(--muted); margin-top: 3px; font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.stop-popup { font-family: inherit; color: var(--ink); }
.stop-popup .leaflet-popup-content p { margin: 8px 0; }
.map-popup-title { font-size: 17px; }
.map-popup-route, .map-popup-second { font-size: 12px; color: var(--muted); line-height: 1.6; }
.map-popup-direction { font-size: 14px; font-weight: 700; line-height: 1.5; }
.direction-forest { color: var(--direction-forest); }
.direction-samhwan { color: var(--direction-samhwan); }
.route-guide { margin: 0; padding: 12px 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.7; }
.route-guide span { font-weight: 700; }
.map-popup-arrival { font-size: 20px; font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums; }
.map-detail-button { border: 0; background: var(--wash); color: var(--green); padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.map-detail-button:hover { background: var(--line); }
.stop-map .leaflet-control-attribution { font-size: 10px; background: var(--surface); color: var(--ink); }
.stop-map .leaflet-control-attribution a { color: var(--green); }
.stop-map .leaflet-control-zoom a { color: var(--green); }
.connection { margin: 0 36px 24px; padding: 20px; border-radius: 10px; background: var(--wash); }
.connection h2 { font-size: 15px; margin: 0 0 8px; }
.connection p { font-size: 13px; color: var(--muted); line-height: 1.7; margin: 0; }
.text-button { border: 0; padding: 10px 0 0; font-size: 13px; font-weight: 700; color: var(--green); background: transparent; text-align: left; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.leave-demo { margin: 0 36px 22px; padding-top: 0; }
footer { padding: 22px 36px 28px; border-top: 1px solid var(--line); }
footer p { margin: 0 0 12px; font-size: 12px; color: var(--muted); line-height: 1.8; }
footer a { font-size: 11px; color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 600px) {
  main { margin: 0; border-radius: 0; min-height: 100svh; }
  .masthead { padding: 28px 24px 24px; }
  h1 { font-size: 30px; }
  .toolbar { padding: 18px 24px; }
  .stop { padding: 24px; }
  .map-section { padding: 20px 16px 0; }
  .stop-map { height: 340px; }
  .map-heading, .map-caption, .map-status { margin-left: 8px; margin-right: 8px; }
  .stop h2 { font-size: 20px; }
  .bus { grid-template-columns: 115px 1fr; gap: 16px; }
  .arrivals { padding-left: 16px; }
  .route-name { font-size: 22px; }
  .arrival-main { font-size: 24px; }
  .connection { margin: 0 24px 24px; }
  .notice { padding: 12px 24px; }
  .leave-demo { margin-left: 24px; }
  footer { padding: 20px 24px 28px; }
}
@media (max-width: 350px) {
  .bus { grid-template-columns: 98px 1fr; gap: 12px; }
  .route-name { font-size: 20px; }
  .arrivals { padding-left: 12px; }
  .arrival-main { font-size: 21px; }
}
@media (prefers-reduced-motion: no-preference) {
    @keyframes turn { to { transform: rotate(360deg); } }
}

/* The map owns the viewport; the compact panel floats above it. */
body { overflow: hidden; }
main { max-width: none; margin: 0; border-radius: 0; min-height: 100svh; }
.map-section { position: fixed; inset: 0; padding: 0; border: 0; }
.stop-map { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; }
.sidebar { position: absolute; top: 16px; left: 16px; z-index: 900; width: 360px; max-height: calc(100svh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 6px 28px #1d31282b; scrollbar-width: thin; scrollbar-color: var(--muted) var(--wash); }
.sidebar .masthead { padding: 14px 18px; }
.sidebar h1 { font-size: 20px; }
.sidebar .heading svg { width: 20px; height: 20px; }
.heading-direction { font-size: 12px; font-weight: 650; white-space: nowrap; }
.sidebar .heading { gap: 12px; }
.sidebar .toolbar { padding: 14px 24px; }
.stop-details summary { min-height: 48px; padding: 14px 24px; font-size: 13px; font-weight: 700; color: var(--green); cursor: pointer; }
.stop-details summary:hover { background: var(--wash); }
.stop-details[open] summary { border-bottom: 1px solid var(--line); }
.sidebar .stop { padding: 20px 24px; }
.sidebar .stop h2 { font-size: 19px; }
.sidebar .landmark { margin-bottom: 16px; }
.sidebar .bus { grid-template-columns: 105px 1fr; gap: 14px; }
.sidebar .arrivals { padding-left: 14px; }
.sidebar .route-name { font-size: 21px; }
.sidebar .arrival-main { font-size: 22px; }
.sidebar .arrival-main.unavailable { font-size: 21px; }
.sidebar .stop-bottom { margin-top: 12px; }
.sidebar .connection { margin: 0 24px 20px; padding: 16px; }
.sidebar .leave-demo { margin-left: 24px; }
.sidebar footer { padding: 16px 24px 20px; }
.sidebar .notice { padding: 12px 24px; }
.map-heading { position: absolute; right: 16px; top: 16px; z-index: 800; margin: 0; }
.map-heading h2 { display: none; }
#map-reset { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; background: var(--surface); box-shadow: 0 3px 14px #1d31282b; }
#map-reset svg { width: 24px; height: 24px; }
.map-caption { position: absolute; left: 440px; bottom: 12px; z-index: 800; margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--surface); }
.stop-map .leaflet-bottom.leaflet-left { left: 392px; }
.map-status { position: absolute; right: 16px; bottom: 100px; z-index: 800; max-width: 300px; margin: 0; padding: 12px 16px; border-radius: 8px; background: var(--surface); }
@media (max-width: 600px) {
  .sidebar { top: 12px; left: 12px; width: calc(100% - 24px); max-height: 58svh; }
  .sidebar .masthead { padding: 12px 18px; }
  .sidebar .toolbar { padding: 10px 18px; }
  .stop-details summary { padding: 12px 18px; min-height: 44px; }
  .route-guide { padding: 12px 18px; }
  .map-heading { top: auto; right: 12px; bottom: 40px; }
  .stop-map .leaflet-bottom.leaflet-left { left: 0; }
  .map-caption { display: none; }
  .map-status { left: 12px; right: 12px; bottom: 100px; max-width: none; }
}
@media (min-width: 601px) and (max-width: 900px) {
  .map-caption { display: none; }
}

/* 가독성: 작은 글씨를 키우고 보조 글자색을 진하게, 시간·정거장 수·현재 위치를 분리 */
:root { --muted: #3f5247; }
.arrival-main { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.last-bus { font-size: 13px; font-weight: 750; letter-spacing: 0; color: #fff; background: var(--error); border-radius: 6px; padding: 2px 8px; line-height: 1.5; }
.arrival-away { margin: 2px 0 0; font-size: 16px; font-weight: 700; color: var(--route); }
.arrival-where { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.arrival-label, .ars, .landmark, .stop-bottom, .stop-map-button, .route-guide, .toolbar p { font-size: 13px; }
.arrival-second { font-size: 14px; }
.destination { font-size: 15px; }
.stop-label.leaflet-tooltip { max-width: 170px; }
.map-stop-name { font-size: 14px; font-weight: 700; }
.map-stop-direction { font-size: 13px; }
.map-stop-arrival { font-size: 13px; font-weight: 650; color: var(--ink); }
.map-popup-route, .map-popup-second { font-size: 13px; }
.map-detail-button { font-size: 13px; padding: 10px 14px; }

.refresh-label { font-size: 14px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-stop-route { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.map-stop-arrival { display: block; font-size: 18px; font-weight: 750; margin-top: 4px; }
.map-stop-away { display: block; font-size: 13px; font-weight: 650; color: var(--route); margin-top: 2px; }
.map-popup-away { font-size: 14px; font-weight: 650; color: var(--route); margin-top: -4px; }

/* 제목·실시간 상태는 고정하고 아래 안내만 스크롤 */
.sidebar-top { position: sticky; top: 0; z-index: 3; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.naver-link { color: var(--green); font-size: 13px; font-weight: 650; text-decoration: underline; text-underline-offset: 4px; white-space: nowrap; }
.stop-links { display: flex; gap: 14px; align-items: center; }

/* 지도 아래 한 줄: 확대/축소 · 안내 문구(가운데) · 기준 위치 버튼. 세로 중심을 맞춘다. */
:root { --bar-bottom: 28px; }
.stop-map .leaflet-bottom.leaflet-left .leaflet-control { margin-bottom: var(--bar-bottom); }
.map-heading { top: auto; right: 12px; bottom: calc(var(--bar-bottom) + 12px); }
.map-caption { display: flex; align-items: center; justify-content: center; text-align: center; box-sizing: border-box;
  left: 56px; right: 68px; bottom: calc(var(--bar-bottom) + 12px); min-height: 44px; font-size: 13px; line-height: 1.4; color: var(--ink); }
@media (min-width: 601px) {
  .map-heading { right: 16px; }
  .map-caption { left: 450px; right: 76px; }
}
@media (min-width: 601px) and (max-width: 760px) { .map-caption { display: none; } }
.toolbar { flex-wrap: wrap; row-gap: 6px; }
.toolbar p { white-space: nowrap; }

/* 안내 문구는 글자만 감싸는 반투명 어두운 칩으로 보여 지도를 가리지 않는다. */
.map-caption { background: none; box-shadow: none; padding: 0; pointer-events: none; }
.map-caption span { background: rgba(20, 30, 25, .66); color: #fff; padding: 6px 12px; border-radius: 8px; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }

/* 카드 가독성: 첫차·막차·배차는 항목별 줄, 하단 링크는 다음 정류장 아래 한 줄 */
.service-hours { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 10px 0 0; font-size: 14px; font-weight: 650; line-height: 1.6; color: var(--ink); }
.service-hours span { white-space: nowrap; }
.service-hours small { flex-basis: 100%; font-size: 12px; font-weight: 500; color: var(--muted); }
.sidebar .stop-bottom { flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 16px; font-size: 13px; }
.sidebar .stop-links { gap: 20px; }
.sidebar .stop-map-button, .sidebar .naver-link { display: inline-flex; align-items: center; min-height: 36px; font-size: 14px; white-space: nowrap; }
.sidebar .landmark { margin-bottom: 18px; }

/* 방향선 끝의 큰 화살촉(방면 색, 흰 테두리) */
.route-head { width: 34px; height: 34px; transform: rotate(var(--head-angle)); }
.route-head svg { width: 34px; height: 34px; fill: var(--head-color); stroke: #fff; stroke-width: 2.2; stroke-linejoin: round; paint-order: stroke; filter: drop-shadow(0 1px 3px #0003); }
