:root {
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', sans-serif;
  /* 객실(청룡 일반실): 회백색 벽, 밝은 회색 시트, 청록 선반 조명 */
  --wall-hi: #f1efea;
  --wall: #e4e1db;
  --wall-lo: #cfccc5;
  --rev-top: #b9b6b0;
  --rev: #d8d5cf;
  --rev-lo: #f2f0eb;
  --rack-glow: #8fd3c4;
  --seat: #a9a8a4;
  --seat-hi: #c9c8c3;
  --shell: #8d8c88;
  /* 발권 화면 */
  --k-bg: #eef1f5;
  --k-ink: #16202e;
  --k-sub: #5f6b7d;
  --k-line: #d5dbe5;
  --k-navy: #14306b;
  --k-blue: #1f4ea3;
  --ktx-c: #1f5fbf;
  --mgh-c: #c8323a;
  /* 종이(승차권) */
  --paper: #fbfaf6;
  --ink: #1d232b;
  --ink-2: #5b6370;
  --ticket-band: #2b5aa8;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ── 객실 ── */
#cabin { position: fixed; inset: 0; background: var(--wall); }
#outside, #blinds, #wall { position: absolute; inset: 0; }
#outside { width: 100%; height: 100%; }
#wall { pointer-events: none; }
#wall svg { display: block; width: 100%; height: 100%; }
#blinds { pointer-events: none; }
.blind { position: absolute; overflow: hidden; }
.blind i { position: absolute; left: 0; right: 0; top: 0; height: 100%; transform: translateY(-100%);
  background: repeating-linear-gradient(180deg, #d6d1c6 0 5px, #cfcabe 5px 6px);
  box-shadow: inset 0 -10px 12px -8px rgba(0,0,0,.25); transition: transform .9s cubic-bezier(.3,.7,.2,1); }
.blind i::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 9%; background: linear-gradient(#bdb8ad, #a8a397); }
.blind.me { pointer-events: auto; cursor: ns-resize; }
.blind.me i { pointer-events: none; }
.blind.dragging i { transition: none; }

/* 차내 모니터 자막(흰 바탕 + 파랑) */
#hud { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 12px; }
.lcd { width: min(420px, calc(100vw - 32px - 60px)); background: #fff; color: #10203a; box-shadow: 0 2px 10px rgba(0,0,0,.18); border: 1px solid rgba(0,0,0,.08); }
.lcd-top { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; background: #1f4ea3; color: #fff; font-size: 13px; }
.lcd-top span:first-child { font-weight: 600; }
.lcd-main { display: flex; justify-content: space-between; align-items: flex-end; padding: 10px 12px 6px; gap: 12px; }
.lcd-main small { display: block; font-size: 12px; color: #4f5d75; }
.lcd-next b { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin-right: 6px; }
.lcd-next em { font-style: normal; font-size: 13px; color: #4f5d75; }
.lcd-left { text-align: right; }
.lcd-left b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lcd-bar { position: relative; height: 18px; margin: 4px 16px 6px; }
.lcd-bar::before { content: ''; position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: #c9d3e6; }
#hud-stops i { position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: #fff; border: 2px solid #1f4ea3; }
#hud-stops i.past { background: #1f4ea3; }
#hud-me { position: absolute; top: 2px; width: 4px; height: 14px; margin-left: -2px; background: #e0484f; }
.lcd-sub { padding: 5px 12px 7px; font-size: 12.5px; color: #4f5d75; border-top: 1px solid #e3e8f1; min-height: 28px; }

#hud-buttons { display: flex; flex-direction: column; gap: 8px; }
.icon { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.12); background: rgba(255,255,255,.85); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: #2a3340; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover { background: #fff; }
.icon .hold { position: absolute; inset: 1px; width: 40px; height: 40px; transform: rotate(-90deg); }
.icon .hold circle { stroke: #e0484f; stroke-width: 3; stroke-dasharray: 107; stroke-dashoffset: 107; }
.icon.holding .hold circle { transition: stroke-dashoffset 1.2s linear; stroke-dashoffset: 0; }

.sound { position: relative; }
#sound-panel { position: absolute; left: 52px; bottom: 0; width: 230px; padding: 12px 14px; background: #fff; border: 1px solid rgba(0,0,0,.12); box-shadow: 0 4px 16px rgba(0,0,0,.15); display: grid; gap: 10px; }
#sound-panel label { display: grid; gap: 4px; font-size: 13px; color: #4f5d75; }
#sound-panel input { width: 100%; accent-color: #1f4ea3; }
.icon.muted svg { stroke: #9aa3b0; }

/* ── 발권 ── */
.overlay { position: fixed; inset: 0; z-index: 10; }
#board { background: var(--k-bg); color: var(--k-ink); overflow-y: auto; }
.kiosk-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; background: var(--k-navy); color: #fff; }
.kiosk-head h1 { margin: 0; display: flex; align-items: baseline; gap: 12px; font-weight: 400; }
.kiosk-head h1 b { font-size: 24px; font-weight: 700; }
.kiosk-head h1 span { font-size: 16px; color: #b8c6e0; }
.kiosk-side { display: flex; align-items: center; gap: 16px; }
.head-btn { min-height: 40px; padding: 0 14px; background: transparent; border: 1px solid rgba(255,255,255,.45); color: #fff; font-size: 15px; }
.head-btn:hover { background: rgba(255,255,255,.1); }
.kiosk-clock { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-bottom: 1px solid var(--k-line); }
.steps li { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; font-size: 15px; color: #8a93a3; border-right: 1px solid var(--k-line); }
.steps li:last-child { border-right: 0; }
.steps li i { font-style: normal; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid currentColor; font-size: 12px; font-weight: 600; }
.steps li.done { color: var(--k-blue); }
.steps li.now { background: var(--k-blue); color: #fff; font-weight: 600; }

.kiosk-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; max-width: 1320px; margin: 0 auto; padding: 24px; align-items: start; }
.k-title { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.k-title + .line-map { margin-top: 0; }
.trains { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.train-btn { position: relative; display: grid; gap: 6px; text-align: left; padding: 18px 20px 18px 24px; background: #fff; border: 2px solid var(--k-line); }
.train-btn::before { content: ''; position: absolute; left: -2px; top: -2px; bottom: -2px; width: 6px; background: var(--acc); opacity: .35; }
.train-btn.ktx { --acc: var(--ktx-c); }
.train-btn.mugunghwa { --acc: var(--mgh-c); }
.train-btn.on { border-color: var(--acc); }
.train-btn.on::before { opacity: 1; }
.train-btn.on::after { content: '✓'; position: absolute; right: 16px; top: 14px; width: 26px; height: 26px; display: grid; place-items: center; background: var(--acc); color: #fff; border-radius: 50%; font-size: 14px; }
.tb-name { font-size: 26px; font-weight: 700; color: var(--acc); letter-spacing: -.01em; }
.tb-kind { font-size: 14px; color: var(--k-sub); margin-top: -4px; }
.tb-facts { display: flex; gap: 14px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-note { font-size: 14px; color: var(--k-sub); line-height: 1.5; }
.train-btn:hover { border-color: var(--acc); }

/* 노선도: 가로. 역 이름은 위아래로 번갈아 둔다 */
.line-map { --acc: var(--ktx-c); position: relative; display: flex; background: #fff; border: 1px solid var(--k-line); padding: 8px 16px; }
.line-map.mugunghwa { --acc: var(--mgh-c); }
.lm-track { position: absolute; left: 40px; right: 40px; top: 50%; height: 4px; margin-top: -2px; background: var(--acc); opacity: .35; }
.st { position: relative; flex: 1 1 0; min-width: 0; height: 176px; border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; }
.st .dot { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #fff; border: 3px solid var(--acc); z-index: 1; }
.st b, .st small, .st .been { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.st b { font-size: 15px; font-weight: 600; }
.st small { font-size: 13px; color: var(--k-blue); font-variant-numeric: tabular-nums; font-weight: 500; }
.st .been { font-style: normal; font-size: 11px; color: #2f9a5f; }
.st.up b { bottom: calc(50% + 34px); }
.st.up small { bottom: calc(50% + 15px); }
.st.dn b { top: calc(50% + 15px); }
.st.dn small { top: calc(50% + 35px); }
.st.up .been { bottom: calc(50% + 54px); }
.st.dn .been { top: calc(50% + 56px); }
.st:hover .dot { transform: scale(1.25); }
.st.between .dot { background: var(--acc); opacity: .55; }
.st.from .dot, .st.to .dot { background: var(--acc); width: 26px; height: 26px; margin: -13px 0 0 -13px; box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--acc); }
.st.from b, .st.to b { color: var(--acc); font-size: 17px; font-weight: 700; }
.st.from small { color: var(--k-sub); }
.st.up.from small, .st.up.to small { bottom: calc(50% + 21px); }
.st.up.from b, .st.up.to b { bottom: calc(50% + 40px); }
.st.dn.from small, .st.dn.to small { top: calc(50% + 41px); }
.st.dn.from b, .st.dn.to b { top: calc(50% + 21px); }
.st.to small { font-weight: 700; }
.k-note { font-size: 12.5px; color: var(--k-sub); margin: 12px 0 0; }

.summary { position: sticky; top: 24px; z-index: 3; background: #fff; border: 1px solid var(--k-line); }
.sum-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; padding: 18px 18px 14px; border-bottom: 1px solid var(--k-line); }
.sum-route small { display: block; font-size: 12px; color: var(--k-sub); }
.sum-route b { font-size: 24px; font-weight: 700; }
.sum-route > div:last-child { text-align: right; }
.sum-arrow { color: var(--k-sub); font-size: 20px; padding-bottom: 2px; }
.sum-info { margin: 0; padding: 8px 18px; }
.sum-info div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f2f5; font-size: 15px; }
.sum-info div:last-child { border-bottom: 0; }
.sum-info dt { color: var(--k-sub); }
.sum-info dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
#sum-dur { color: var(--k-blue); font-size: 18px; }
.sum-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 12px 18px 18px; }
.k-primary, .k-ghost { min-height: 52px; padding: 0 16px; font-size: 17px; border: 1px solid var(--k-blue); }
.k-primary { background: var(--k-blue); color: #fff; font-weight: 600; }
.k-primary:disabled { background: #c9d0db; border-color: #c9d0db; cursor: default; }
.k-ghost { background: #fff; color: var(--k-blue); font-size: 15px; }

/* ── 승차권(감열지) ── */
.dim { background: rgba(8,12,20,.55); display: grid; place-items: center; padding: 16px; }
.ticket { width: min(520px, 100%); background: var(--paper); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.tk-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 18px; background: var(--ticket-band); color: #fff; }
.tk-head b { font-size: 18px; }
.tk-head span { font-size: 12px; letter-spacing: .08em; opacity: .85; }
.tk-head span:last-of-type { margin-left: auto; letter-spacing: 0; }
.tk-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 20px 18px 14px; gap: 8px; border-bottom: 1px dashed #c9c5ba; }
.tk-route > div:not(.tk-arrow) { display: flex; flex-direction: column; }
.tk-route > div:last-child { text-align: right; }
.tk-route b { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.tk-route em { font-style: normal; font-size: 13px; color: var(--ink-2); }
.tk-route span { font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 6px; }
.tk-arrow { font-size: 24px; color: var(--ink-2); }
.tk-grid { display: grid; grid-template-columns: repeat(4, 1fr); padding: 12px 18px; gap: 8px; border-bottom: 1px dashed #c9c5ba; }
.tk-grid small { display: block; font-size: 12px; color: var(--ink-2); }
.tk-grid b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tk-side { display: flex; align-items: center; gap: 6px; padding: 12px 18px; }
.tk-side span { font-size: 14px; color: var(--ink-2); margin-right: auto; }
.tk-side button { min-height: 40px; padding: 0 14px; border: 1px solid #c9c5ba; background: #fff; font-size: 15px; }
.tk-side button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tk-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.tk-actions button, .ghost, .primary { min-height: 44px; padding: 0 18px; font-size: 16px; border: 1px solid var(--ink); }
.ghost { background: transparent; }
.ghost.small { min-height: 32px; padding: 0 10px; font-size: 13px; margin-left: auto; border-color: rgba(255,255,255,.6); color: #fff; }
.primary { background: var(--ink); color: #fff; font-weight: 600; }
.ar-station { padding: 22px 18px 14px; border-bottom: 1px dashed #c9c5ba; }
.ar-station b { font-size: 36px; font-weight: 700; margin-right: 10px; }
.ar-station em { font-style: normal; color: var(--ink-2); }
.logbook { max-height: 80vh; display: flex; flex-direction: column; }
#log-sum { padding: 14px 18px; border-bottom: 1px dashed #c9c5ba; font-size: 15px; }
#log-list { list-style: none; margin: 0; padding: 0 18px 12px; overflow-y: auto; }
#log-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid #ece9e1; font-size: 15px; }
#log-list li small { grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; }

@media (max-width: 860px) {
  .kiosk-head { padding: 12px 16px; }
  .kiosk-head h1 b { font-size: 20px; }
  .kiosk-head h1 span { font-size: 14px; }
  .kiosk-clock { font-size: 20px; }
  .steps li { font-size: 13px; min-height: 42px; gap: 5px; }
  .kiosk-body { grid-template-columns: 1fr; padding: 16px 16px 200px; gap: 16px; }
  .trains { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
  .train-btn { padding: 14px 12px 14px 18px; }
  .tb-name { font-size: 21px; }
  .tb-facts { flex-direction: column; gap: 2px; font-size: 13.5px; }
  .tb-note { display: none; }
  /* 노선도: 세로 */
  .line-map { flex-direction: column; padding: 4px 0; }
  .lm-track { left: 31px; right: auto; top: 22px; bottom: 22px; width: 4px; height: auto; margin: 0 0 0 -2px; }
  .st { flex: none; height: 46px; flex-direction: row; }
  .st .dot { left: 31px; top: 50%; }
  .st b, .st small, .st .been { position: static; transform: none; }
  .st.up b, .st.dn b { margin-left: 56px; }
  .st small { margin-left: auto; padding-right: 16px; }
  .st .been { margin-left: 6px; }
  .summary { position: fixed; left: 0; right: 0; bottom: 0; top: auto; border: 0; border-top: 1px solid var(--k-line); box-shadow: 0 -4px 16px rgba(0,0,0,.08); padding-bottom: env(safe-area-inset-bottom); }
  .sum-route { padding: 10px 16px 8px; }
  .sum-route b { font-size: 19px; }
  .sum-info { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; padding: 0 16px; }
  .sum-info div { padding: 5px 0; font-size: 13.5px; }
  .sum-info div:nth-child(1), .sum-info div:nth-child(4) { display: none; }
  .sum-actions { padding: 8px 16px 12px; }
  .k-primary, .k-ghost { min-height: 46px; }
  .tk-route b { font-size: 24px; }
  .tk-grid { grid-template-columns: repeat(2, 1fr); }
  .lcd-next b, .lcd-left b { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .blind i { transition: none; }
}
