:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #68746e;
  --line: #e1e7e3;
  --panel: rgba(255, 255, 255, 0.97);
  --green: #087a50;
  --green-soft: #e8f5ef;
  --blue: #2386f5;
  --shadow: 0 18px 55px rgba(22, 39, 31, 0.16);
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background: #e8eeea;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.map-app { position: relative; width: 100%; height: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(145deg, #e7eee9, #f2eee7); }
.map-canvas-overlay { position: absolute; z-index: 5; pointer-events: none; }
.stop-canvas-overlay { position: absolute; z-index: 5; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.route-arrow-canvas-overlay { position: absolute; z-index: 6; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.fallback-grid {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image: linear-gradient(rgba(255,255,255,.75) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.75) 1px, transparent 1px);
  background-size: 58px 58px;
  transform: rotate(-8deg) scale(1.2);
}

#fallbackRoutes, #fallbackMarkers { position: absolute; inset: 0; width: 100%; height: 100%; }
.fallback-label { position: absolute; color: rgba(22, 35, 29, .12); font-family: Georgia, serif; font-size: clamp(70px, 11vw, 170px); font-weight: 700; pointer-events: none; }
.seoul-label { top: 13%; left: 36%; }
.gyeonggi-label { bottom: 9%; right: 13%; }
.incheon-label { top: 43%; left: 6%; }

.sidebar {
  position: absolute;
  z-index: 30;
  top: 14px;
  bottom: 14px;
  left: 14px;
  width: 382px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(216, 224, 219, .92);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.mobile-sheet-handle { display: none; }
.app-header { display: flex; align-items: center; gap: 16px; padding: 20px 20px 15px; }
.eyebrow, .section-label { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; line-height: 1; letter-spacing: -.04em; }
h2, h3, p { margin-top: 0; }

.search-section { padding: 0 16px 14px; border-bottom: 1px solid var(--line); }
.search-form { height: 46px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 7px; padding: 4px 5px 4px 13px; border: 1px solid #ccd6d0; border-radius: 12px; background: white; box-shadow: 0 4px 15px rgba(29, 51, 40, .05); }
.search-form:focus-within { border-color: #5fae8e; box-shadow: 0 0 0 3px rgba(8, 122, 80, .1); }
.search-icon { color: #849089; font-size: 22px; transform: rotate(-20deg); }
.search-form input { min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 14px; }
.search-form input::placeholder { color: #98a19c; }
.search-form button { height: 36px; padding: 0 13px; border: 0; border-radius: 9px; color: white; background: var(--ink); font-size: 12px; font-weight: 750; cursor: pointer; }
.search-feedback { margin: 9px 3px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.search-results { max-height: 240px; display: grid; gap: 5px; margin-top: 10px; overflow-y: auto; }
.search-result-heading { padding: 5px 3px 1px; color: var(--green); font-size: 10px; font-weight: 850; }
.search-result { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; text-align: left; background: #fff; cursor: pointer; }
.search-result:hover, .search-result:focus-visible { border-color: #78b69d; background: #f7fbf9; outline: none; }
.search-result-name { min-width: 0; overflow: hidden; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.search-result-count { color: var(--green); font-size: 11px; font-weight: 800; }
.search-result-meta { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.search-empty { padding: 18px 12px; border: 1px dashed #cbd5cf; border-radius: 10px; color: var(--muted); text-align: center; font-size: 12px; }

.panel-content { min-height: 0; flex: 1; overflow-y: auto; }

.empty-state { min-height: 390px; display: flex; padding: 46px 34px; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-icon { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 16px; color: var(--green); background: var(--green-soft); font-size: 26px; }
.empty-state h2 { margin-bottom: 9px; font-size: 19px; }
.empty-state p { max-width: 285px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }

.detail { padding: 22px 18px 34px; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-title { min-width: 0; flex: 1; }
.detail-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.detail-heading h2 { margin-bottom: 5px; font-size: 23px; letter-spacing: -.04em; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: #66736c; background: white; font-size: 21px; line-height: 1; cursor: pointer; }
.icon-button:hover { background: #f1f5f3; }
.color-mode-control { margin: 0; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f3f6f4; }
.segmented-control button { padding: 6px 10px; border: 0; border-radius: 6px; color: #68746e; background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.segmented-control button.active { color: #075f3e; background: white; box-shadow: 0 2px 7px rgba(28, 49, 39, .12); }
.route-density-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 -5px; color: #53615b; font-size: 11px; font-weight: 750; }
.route-density-control .segmented-control { min-width: 118px; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 22px 0 11px; }
.section-header h3 { margin: 0; font-size: 15px; }
.section-description { max-width: 250px; margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.count { flex: none; color: var(--muted); font-size: 10px; }
.route-list { display: grid; gap: 8px; }

.route-card { width: 100%; display: grid; grid-template-columns: 5px 1fr auto; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; text-align: left; background: white; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.route-card:hover, .route-card.hovered, .route-card.selected { transform: translateY(-1px); border-color: #aab9b1; box-shadow: 0 8px 20px rgba(28, 49, 39, .08); }
.route-card.hovered { background: #f7fbf9; }
.route-card.selected { outline: 2px solid rgba(15, 122, 83, .18); }
.route-card.unavailable { cursor: default; opacity: .55; }
.route-card.unavailable:hover { transform: none; border-color: var(--line); box-shadow: none; }
.route-color { border-radius: 6px; }
.route-main { min-width: 0; display: grid; gap: 5px; }
.route-title-row { display: flex; align-items: center; gap: 8px; }
.route-name { font-size: 14px; }
.route-type { padding: 2px 6px; border-radius: 5px; color: var(--muted); background: #f0f3f1; font-size: 9px; }
.route-description { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.route-headway { width: fit-content; padding: 4px 7px; border-radius: 6px; color: #075f3e; background: #e8f5ef; font-size: 11px; font-weight: 850; line-height: 1.2; }
.route-headway.missing { color: #7a817d; background: #f0f3f1; font-weight: 700; }
.route-arrow { align-self: center; color: #9aa69f; font-size: 10px; }
.empty-list { padding: 18px; border: 1px dashed #cad4ce; border-radius: 12px; color: var(--muted); text-align: center; font-size: 12px; }
.transfer-detail { padding-bottom: 24px; }
.transfer-line-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.transfer-line-pill { padding: 5px 9px; border: 1px solid color-mix(in srgb, var(--line-color) 55%, white); border-left: 5px solid var(--line-color); border-radius: 7px; color: #34423b; background: white; font-size: 10px; font-weight: 850; }
.radius-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; color: #53615b; font-size: 11px; font-weight: 750; }
.radius-control .segmented-control { grid-template-columns: repeat(3, 1fr); }
.transfer-summary { display: grid; gap: 5px; padding: 12px 13px; border-radius: 11px; color: #53615b; background: #edf7f2; }
.transfer-summary strong { color: #075f3e; font-size: 13px; }
.transfer-summary span { font-size: 10px; line-height: 1.5; }
.transfer-stop-list { display: grid; gap: 8px; }
.transfer-stop-card { display: grid; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.transfer-stop-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.transfer-stop-heading > div { min-width: 0; display: grid; gap: 3px; }
.transfer-stop-heading strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.transfer-stop-heading div span { color: var(--muted); font-size: 10px; }
.walk-badge { flex: none; padding: 5px 7px; border-radius: 7px; color: #075f3e; background: var(--green-soft); font-size: 10px; font-weight: 850; }
.transfer-route-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.transfer-route-pills span { padding: 3px 6px; border-left: 3px solid var(--route-color); border-radius: 5px; color: #435149; background: #f1f4f2; font-size: 9px; font-weight: 800; }
.transfer-route-pills .more-routes { border-left: 0; color: var(--muted); }
.transfer-stop-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 9px; }

.map-guide, .legend { position: absolute; z-index: 20; display: flex; align-items: center; border: 1px solid rgba(216, 224, 219, .9); border-radius: 11px; color: #4f5d56; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(30, 50, 41, .12); backdrop-filter: blur(10px); font-size: 11px; font-weight: 750; }
.map-guide { top: 16px; right: 66px; gap: 7px; padding: 9px 12px; }
.naver-stop-symbol { width: 19px; height: 19px; display: grid; place-items: center; border: 2px solid #42a6fa; border-radius: 6px; color: #168af1; font-size: 10px; }
.legend { right: 16px; bottom: 18px; gap: 13px; padding: 9px 11px; }
.route-swatch { display: inline-block; width: 14px; height: 5px; margin-right: 4px; border-radius: 4px; background: linear-gradient(90deg, #2563eb 0 33%, #dc2626 33% 66%, #d97706 66%); vertical-align: 2px; }
.selected-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border: 2px solid white; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(8,122,80,.3); vertical-align: 0; }
.regular-stop-swatch, .route-stop-swatch { position: relative; display: inline-block; width: 11px; height: 11px; margin-right: 4px; border: 1.5px solid white; border-radius: 3px; vertical-align: -1px; }
.regular-stop-swatch::after, .route-stop-swatch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 4px; height: 3px; border: 1px solid white; border-radius: 1px; }
.regular-stop-swatch { background: #2196f3; box-shadow: 0 0 0 1px rgba(33,150,243,.35); }
.route-stop-swatch { background: #f97316; box-shadow: 0 0 0 1px rgba(249,115,22,.35); }

.fallback-marker { position: absolute; width: 16px; height: 16px; transform: translate(-50%, -50%); border: 2px solid white; border-radius: 50%; color: white; background: var(--blue); box-shadow: 0 5px 14px rgba(20, 50, 36, .25); cursor: pointer; z-index: 4; }
.fallback-marker.subway { background: var(--green); border-radius: 8px; }
.fallback-marker.route-stop { pointer-events: none; background: #f97316; }
.fallback-marker:hover { transform: translate(-50%, -50%) scale(1.18); }
.naver-route-label { display: block; transform: translate(-50%, -50%); padding: 4px 7px; border: 2px solid white; border-radius: 6px; color: white; box-shadow: 0 3px 9px rgba(20, 34, 28, .28); font-size: 11px; font-weight: 900; line-height: 1; white-space: nowrap; }
.naver-route-label.selected { padding: 5px 9px; font-size: 13px; }
.naver-route-hover { display: grid; gap: 3px; min-width: 68px; max-width: 220px; transform: translate(-50%, calc(-100% - 13px)); padding: 7px 9px; border: 2px solid var(--route-hover-color); border-radius: 8px; color: #26352e; background: rgba(255,255,255,.97); box-shadow: 0 5px 16px rgba(22,39,31,.22); pointer-events: none; white-space: nowrap; }
.naver-route-hover strong { color: var(--route-hover-color); font-size: 13px; line-height: 1; }
.naver-route-hover small { overflow: hidden; max-width: 200px; color: #53625a; font-size: 10px; text-overflow: ellipsis; }
.naver-selected-stop { width: 30px; height: 30px; display: grid; place-items: center; pointer-events: none; border: 3px solid white; border-radius: 50%; background: rgba(8, 122, 80, .22); box-shadow: 0 0 0 4px rgba(8, 122, 80, .16), 0 5px 13px rgba(20, 50, 36, .28); }
.naver-selected-stop::after { content: ''; width: 10px; height: 10px; border: 2px solid white; border-radius: 50%; background: var(--green); }
.naver-user-location { width: 22px; height: 22px; display: block; pointer-events: none; border: 4px solid white; border-radius: 50%; background: #1684ff; box-shadow: 0 0 0 7px rgba(22, 132, 255, .2), 0 3px 10px rgba(20, 50, 80, .3); }

@media (max-width: 980px) {
  .map-guide { display: none; }
}

@media (max-width: 720px) {
  .sidebar {
    top: auto;
    right: 6px;
    bottom: calc(var(--mobile-keyboard-inset, 0px) + max(6px, env(safe-area-inset-bottom)));
    left: 6px;
    width: auto;
    height: var(--mobile-medium-height, min(42vh, 360px));
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 36px auto minmax(0, 1fr);
    border-radius: 16px 16px 12px 12px;
    transition: height .24s cubic-bezier(.2, .8, .2, 1);
  }
  .sidebar[data-sheet-state="collapsed"] { height: 44px; }
  .sidebar[data-sheet-state="expanded"] {
    height: calc(var(--mobile-visible-height, 100dvh) - 12px - env(safe-area-inset-bottom));
  }
  .sidebar[data-search-active="true"] { grid-template-rows: 36px minmax(0, 1fr); }
  .sidebar[data-search-active="true"] .search-section { min-height: 0; overflow-y: auto; }
  .sidebar[data-search-active="true"] .search-form { position: sticky; z-index: 2; top: 0; }
  .sidebar[data-search-active="true"] .search-results { max-height: none; }
  .sidebar[data-search-active="true"] .search-result { min-height: 48px; padding: 9px; }
  .sidebar[data-search-active="true"] .panel-content { display: none; }
  .sidebar.is-dragging { transition: none; user-select: none; }
  .sidebar[data-sheet-state="collapsed"] .search-section,
  .sidebar[data-sheet-state="collapsed"] .panel-content { visibility: hidden; pointer-events: none; }
  .mobile-sheet-handle {
    display: grid;
    place-items: center;
    width: 100%;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: ns-resize;
    touch-action: none;
  }
  .mobile-sheet-handle:focus-visible { outline: 2px solid #5fae8e; outline-offset: -2px; }
  .mobile-sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: #bcc6c0; }
  .app-header { position: absolute; z-index: 1; top: 11px; left: 12px; padding: 0; pointer-events: none; }
  .eyebrow { display: none; }
  h1 { color: #68746e; font-family: inherit; font-size: 10px; letter-spacing: -.02em; }
  .search-section { min-width: 0; padding: 3px 8px 6px; overflow: hidden; border-bottom: 1px solid var(--line); }
  .view-mode-control { gap: 2px; margin-bottom: 7px; padding: 2px; border-radius: 8px; }
  .view-mode-control button { height: 27px; padding: 0 3px; border-radius: 6px; font-size: 9px; }
  .search-form { height: 34px; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; padding: 3px 4px 3px 8px; border-radius: 9px; }
  .search-icon { display: none; }
  .search-form input { font-size: 10px; }
  .search-form button { min-width: 42px; height: 28px; padding: 0 8px; border-radius: 7px; font-size: 9px; }
  .search-feedback { margin: 4px 2px 0; font-size: 8px; line-height: 1.25; }
  .search-results { max-height: 120px; gap: 4px; margin-top: 5px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .search-result { gap: 3px 6px; padding: 7px; border-radius: 8px; }
  .search-result-name { font-size: 10px; }
  .search-result-count, .search-result-meta { font-size: 8px; }
  .panel-content { min-width: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .empty-state { height: 100%; min-height: 0; padding: 14px; }
  .empty-state h2 { margin-bottom: 5px; font-size: 14px; }
  .empty-state p { font-size: 10px; line-height: 1.45; }
  .empty-icon { display: none; }
  .detail { padding: 9px 10px 14px; }
  .detail-heading { gap: 7px; }
  .detail-heading h2 { overflow: hidden; margin-bottom: 2px; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
  .detail-actions { gap: 5px; }
  .section-label, .muted { font-size: 9px; }
  .icon-button { width: 25px; height: 25px; font-size: 17px; }
  .segmented-control { padding: 2px; border-radius: 7px; }
  .segmented-control button { padding: 4px 6px; font-size: 8px; }
  .route-density-control { margin: 8px 0 -3px; font-size: 8px; }
  .route-density-control .segmented-control { min-width: 96px; }
  .section-header { gap: 6px; margin: 10px 0 6px; }
  .section-header h3 { font-size: 12px; }
  .section-description { display: none; }
  .count { font-size: 8px; }
  .route-list { gap: 5px; }
  .route-card { grid-template-columns: 3px minmax(0, 1fr); gap: 6px; padding: 7px; border-radius: 8px; }
  .route-main { gap: 3px; }
  .route-title-row { gap: 4px; }
  .route-name { font-size: 11px; }
  .route-type { padding: 1px 4px; font-size: 7px; }
  .route-description { font-size: 8px; }
  .route-headway { padding: 2px 4px; font-size: 8px; }
  .route-arrow { display: none; }
  .transfer-line-list { gap: 4px; margin: 7px 0; }
  .transfer-summary { gap: 3px; padding: 7px 8px; }
  .transfer-summary strong { font-size: 10px; }
  .transfer-summary span { font-size: 8px; }
  .transfer-stop-list { gap: 5px; }
  .transfer-stop-card { gap: 6px; padding: 7px; border-radius: 8px; }
  .radius-control { gap: 5px; margin-bottom: 7px; font-size: 8px; }
  .legend { display: none; }
}
