/* 기본 설정 */
:root {
  color-scheme: light;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  color: #172033; background: #f3f6fb; font-synthesis: none; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --border: #e1e7ef; --muted: #64748b; --surface: #fff; --accent: #174ea6;
  --shadow: 0 8px 24px rgb(15 23 42 / 10%);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #8ab4f8; outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-header { z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; flex: 0 0 auto; border-radius: 11px; background: #174ea6; color: white; font-size: 15px; font-weight: 900; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-copy strong { font-size: 15px; letter-spacing: -.035em; }
.brand-copy span, .header-hint { color: var(--muted); font-size: 12px; }
.header-hint { margin: 0; white-space: nowrap; }
.line-navigation { z-index: 4; flex: 0 0 auto; overflow-x: auto; padding: 10px 16px; background: white; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.line-selector { display: flex; align-items: center; gap: 7px; width: max-content; min-height: 34px; }
.line-selector-button { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 7px 12px; border: 1px solid #dfe5ee; border-radius: 999px; background: #fff; color: #334155; font-size: 12px; font-weight: 650; white-space: nowrap; transition: background-color .15s, color .15s, border-color .15s; }
.line-selector-button:hover { border-color: #94a3b8; background: #f8fafc; }
.line-selector-button[aria-pressed="true"] { border-color: #172033; background: #172033; color: #fff; }
.line-color-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; }
.workspace { position: relative; display: flex; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.map-viewport { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; background-color: #f8fafc; background-image: radial-gradient(#d5deea 1.2px, transparent 1.2px); background-size: 24px 24px; cursor: grab; touch-action: none; }
.map-viewport.is-dragging { cursor: grabbing; }
.map-canvas { position: absolute; top: 0; left: 0; width: max-content; height: max-content; transform-origin: top left; will-change: transform; }
.map-artwork { width: 1150px; min-height: 400px; }
.map-artwork svg { display: block; width: 1150px; max-width: none; height: auto; overflow: visible; }
.map-artwork svg text { cursor: pointer; }
.loading-message, .error-message { max-width: 540px; margin: 24px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: white; color: #475569; font-size: 14px; line-height: 1.6; }
.error-message { border-color: #f4cf86; background: #fff8e8; color: #854d0e; }
.map-search { position: absolute; z-index: 3; top: 16px; left: 16px; width: min(440px, calc(100% - 32px)); padding: 12px; border: 1px solid rgb(226 232 240 / 95%); border-radius: 14px; background: rgb(255 255 255 / 96%); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.search-form { display: flex; gap: 8px; }
.search-form input { min-width: 0; width: 100%; height: 40px; padding: 0 12px; border: 1px solid #d5deea; border-radius: 9px; background: white; color: #172033; font-size: 13px; }
.primary-button { flex: 0 0 auto; padding: 0 15px; border: 0; border-radius: 9px; background: #172033; color: white; font-size: 13px; font-weight: 700; }
.primary-button:hover { background: #2c3d59; }
.search-help { margin: 8px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.map-controls { position: absolute; z-index: 3; right: 18px; bottom: 18px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 15px; background: rgb(255 255 255 / 96%); box-shadow: var(--shadow); }
.icon-button { display: grid; width: 40px; height: 38px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #334155; font-size: 23px; font-weight: 650; }
.icon-button:hover { background: #f1f5f9; }
.zoom-indicator { padding: 5px 0; color: #64748b; text-align: center; font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; }
.control-divider { height: 1px; margin: 2px 4px; background: var(--border); }
.reset-button { font-size: 25px; }
.station-panel { z-index: 6; display: flex; flex: 0 0 380px; flex-direction: column; width: 380px; min-width: 0; overflow: hidden; border-left: 1px solid var(--border); background: white; }
.station-panel[aria-hidden="true"] { display: none; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 20px 18px; border-bottom: 1px solid #edf0f5; background: #f8fafc; }
.panel-heading { min-width: 0; }
.station-line-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.station-line-badge { padding: 4px 8px; border-radius: 6px; color: white; font-size: 11px; font-weight: 750; }
.station-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 9px; }
.station-title-row h2 { margin: 0; font-size: 27px; font-weight: 850; letter-spacing: -.045em; overflow-wrap: anywhere; }
.station-code { padding: 3px 6px; border-radius: 5px; background: #e8edf4; color: #475569; font-size: 10px; font-weight: 750; }
.close-button { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; background: #e9eef5; color: #334155; font-size: 25px; line-height: 1; }
.close-button:hover { background: #dce4ef; }
.panel-content { flex: 1 1 auto; overflow-y: auto; padding: 20px; }
.panel-section { padding: 2px 0 22px; }
.panel-section + .panel-section { padding-top: 20px; border-top: 1px solid #edf0f5; }
.panel-section h3 { margin: 0 0 12px; color: #334155; font-size: 12px; font-weight: 800; letter-spacing: .015em; }
.section-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.section-heading h3 { margin: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d97706; }
.status-badge { margin-left: auto; padding: 4px 7px; border: 1px solid #f2d5a1; border-radius: 6px; background: #fff8e8; color: #92400e; font-size: 10px; font-weight: 750; }
.information-card { padding: 13px; border: 1px solid #e4e9f1; border-radius: 11px; background: #f8fafc; color: #596579; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.transfer-line-list { display: flex; flex-wrap: wrap; gap: 8px; }
.transfer-line-item { display: inline-flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid #e3e8ef; border-radius: 10px; background: #f8fafc; color: #334155; font-size: 12px; font-weight: 650; }
.muted-text { margin: 0; color: var(--muted); font-size: 12px; }
.panel-mobile-handle { display: none; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; border-top: 1px solid var(--border); background: white; color: #64748b; font-size: 10px; }
@media (max-width: 760px) {
  .app-header { min-height: 58px; padding: 8px 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy span { font-size: 10px; }
  .header-hint { display: none; }
  .line-navigation { padding: 8px 10px; }
  .line-selector { gap: 6px; }
  .line-selector-button { min-height: 32px; padding: 6px 10px; font-size: 11px; }
  .map-search { top: 10px; left: 10px; width: min(390px, calc(100% - 20px)); padding: 9px; }
  .search-form input { height: 38px; font-size: 12px; }
  .primary-button { padding: 0 11px; font-size: 12px; }
  .search-help { font-size: 10px; }
  .map-controls { right: 10px; bottom: 12px; }
  .station-panel { position: absolute; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(78%, 650px); border-top: 1px solid var(--border); border-left: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 28px rgb(15 23 42 / 12%); }
  .panel-mobile-handle { display: block; width: 42px; height: 4px; flex: 0 0 auto; margin: 9px auto 0; border-radius: 99px; background: #cbd5e1; }
  .panel-header { padding: 14px 17px; }
  .station-title-row h2 { font-size: 23px; }
  .panel-content { padding: 15px 17px; }
  .app-footer { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* 실시간 도착정보 카드 */
.arrival-item { padding: 12px; border: 1px solid #e2e8f0; border-radius: 11px; background: #fff; }
.arrival-item + .arrival-item { margin-top: 8px; }
.arrival-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.arrival-line { color: #172033; font-size: 12px; font-weight: 800; }
.arrival-direction { color: #64748b; font-size: 11px; }
.arrival-message { margin: 8px 0 0; color: #174ea6; font-size: 13px; font-weight: 750; line-height: 1.5; overflow-wrap: anywhere; }
.arrival-destination, .arrival-updated { margin: 6px 0 0; color: #64748b; font-size: 10px; line-height: 1.5; }
.arrival-empty { margin: 0; color: #596579; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.arrival-last-train { display: inline-block; margin-top: 8px; padding: 3px 6px; border-radius: 5px; background: #fff1f2; color: #be123c; font-size: 10px; font-weight: 800; }



.refresh-button { margin-left: 0; padding: 4px 7px; border: 1px solid #dbe3ed; border-radius: 6px; background: #fff; color: #334155; font-size: 10px; font-weight: 700; }
.refresh-button:hover { background: #f1f5f9; }
.refresh-button:disabled { cursor: wait; opacity: .6; }

.train-detail-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 0; padding: 7px 0; border-bottom: 1px solid #e4e9f1; font-size: 12px; line-height: 1.5; }
.train-detail-row:last-child { border-bottom: 0; }
.train-detail-row strong { flex: 0 0 90px; color: #475569; font-weight: 750; }
.train-detail-row span { text-align: right; overflow-wrap: anywhere; }
.train-marker { cursor: pointer; }
.train-marker:focus { outline: none; filter: drop-shadow(0 0 2px #174ea6); }

@media (max-width: 760px) {
  .app-footer { flex-wrap: wrap; justify-content: flex-start; gap: 4px 12px; font-size: 9px; }
}

/* SVG 한글 역명 가독성과 터치 제스처 */
.map-artwork svg { font-family: "Noto Sans KR", "Malgun Gothic", sans-serif; }
.map-artwork svg text { font-family: "Noto Sans KR", "Malgun Gothic", sans-serif; }
.map-viewport { touch-action: none; -webkit-user-select: none; user-select: none; }
.map-viewport input, .map-viewport button { -webkit-user-select: auto; user-select: auto; }
