:root {
  --r: 18px;
  --r-sm: 12px;
  --panel-w: 400px;
  --top-h: 64px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Yu Gothic", system-ui, sans-serif;
  --font-display: var(--font);
}

/* ===== 시원한 블루 테마 ===== */
.app {
  --paper: #EEF3F9;
  --card: #FFFFFF;
  --ink: #0C1628;
  --ink-2: #46546B;
  --ink-3: #8592A7;
  --line: #DEE6F0;
  --line-2: #C9D4E2;
  --accent: #0A6CFF;
  --accent-ink: #0656CC;
  --mint: #00968F;
  --shadow: 0 12px 32px rgba(16, 40, 80, .14);
  --shadow-sm: 0 2px 10px rgba(16, 40, 80, .10);
  --tile-filter: saturate(.85) brightness(1.03) hue-rotate(-4deg);
  --course-jongno: #0A6CFF;
  --course-mapo: #00A389;
  --course-gwangju: #7B5CFF;
  --course-daegu: #FF7A1A;
  --course-jeju: #00A9D6;
  --course-busan: #F0447A;
}


* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #0B1830;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
svg { display: block; }

/* ---------- 앱 프레임 ---------- */
.stage { height: 100dvh; display: grid; place-items: center; }
.app {
  position: relative;
  width: 100vw; height: 100dvh;
  background: var(--paper);
  overflow: hidden;
  container: app / inline-size;
}
/* 웹 화면에서도 앱이 브라우저 전체를 채움 */
body { background: #EEF3F9; }

#map { position: absolute; inset: 0; background: #EAE3D6; z-index: 0; }

/* ---------- 상단 ---------- */
.topbar {
  position: absolute; z-index: 20; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  background: linear-gradient(var(--paper) 55%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand strong { display: block; font-size: 21px; font-weight: 850; letter-spacing: .01em; line-height: 1.1; }
.brand small { display: block; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang { display: flex; background: var(--card); border-radius: 999px; padding: 3px; box-shadow: var(--shadow-sm); }
.lang button { min-width: 34px; height: 30px; padding: 0 8px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--ink-2); transition: background .2s, color .2s; }
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow-sm); display: grid; place-items: center; }
.icon-btn svg, .locate svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }

.regions {
  position: absolute; z-index: 19; left: 0; right: 0; top: calc(var(--top-h) + env(safe-area-inset-top));
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 14px 8px; scrollbar-width: none;
}
.regions::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm);
  font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
}
.chip em { font-style: normal; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chip[aria-pressed="true"] em { color: rgba(255,255,255,.8); }

.locate {
  position: absolute; z-index: 15; right: 14px;
  bottom: calc(var(--sheet-h, 50%) + 12px);
  width: 42px; height: 42px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; transition: bottom .3s ease;
}

/* ---------- 패널: 모바일은 바텀시트 ---------- */
.panel {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: 0;
  height: var(--sheet-h, 50%);
  background: var(--card);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(52,38,20,.18);
  display: flex; flex-direction: column;
  transition: height .32s cubic-bezier(.2,.8,.2,1);
}
.app[data-sheet="peek"] { --sheet-h: 152px; }
.app[data-sheet="half"] { --sheet-h: 48%; }
.app[data-sheet="full"] { --sheet-h: calc(100% - 64px - env(safe-area-inset-top)); }
.panel.dragging { transition: none; }
.handle { flex: none; height: 26px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.handle span { width: 42px; height: 5px; border-radius: 5px; background: var(--line-2); }
.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

/* ---------- 넓은 앱 화면: 사이드 패널 ---------- */
@container app (min-width: 760px) {
  .topbar { background: var(--paper); border-bottom: 1px solid var(--line); padding: 12px 18px; height: var(--top-h); }
  .brand small { font-size: 12.5px; }
  .regions { top: var(--top-h); left: 0; width: var(--panel-w); padding: 12px 16px 10px; background: var(--card); flex-wrap: wrap; overflow: visible; border-right: 1px solid var(--line); }
  .regions .chip { box-shadow: none; background: var(--paper); }
  .regions .chip[aria-pressed="true"] { background: var(--accent); }
  #map { left: var(--panel-w); top: var(--top-h); }
  .panel {
    top: calc(var(--top-h) + var(--regions-h, 92px)); left: 0; right: auto; bottom: 0;
    width: var(--panel-w); height: auto !important; border-radius: 0; box-shadow: none;
    border-right: 1px solid var(--line);
  }
  .handle { display: none; }
  .panel-body { padding-top: 6px; }
  .locate { bottom: 24px !important; right: 24px; }
  .detail .hero { margin: 0 -16px; border-radius: 0; }
}
@container app (min-width: 1100px) { .regions, #map, .panel { --panel-w: 440px; } }
@container app (min-width: 1500px) { .regions, #map, .panel { --panel-w: 480px; } }

/* ---------- 목록 ---------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 10px; }
.list-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.list-head span { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.course { margin-bottom: 16px; }
.course-h { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.course-h i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.course-h b { font-size: 14.5px; font-weight: 800; }
.course-h small { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.place-row {
  width: 100%; display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; text-align: left;
  padding: 8px; border-radius: var(--r-sm); position: relative;
}
.place-row:hover, .place-row:focus-visible { background: var(--paper); outline: none; }
.place-row + .place-row::before { content: ""; position: absolute; left: 44px; top: -8px; height: 16px; border-left: 2px dashed color-mix(in srgb, var(--c) 55%, transparent); }
.thumb { width: 72px; height: 72px; border-radius: var(--r-sm); object-fit: cover; background: var(--line); }
.thumb-wrap { position: relative; }
.num { position: absolute; left: -4px; top: -4px; width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--card); }
.row-main { min-width: 0; }
.row-main b { display: block; font-size: 15.5px; font-weight: 750; line-height: 1.25; }
.row-main .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; font-weight: 600; }
.row-main p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-credit { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }

/* ---------- 상세 ---------- */
.detail { animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.detail-nav { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 2px 0 8px; background: var(--card); }
.back { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px 0 8px; border-radius: 999px; background: var(--paper); font-size: 13px; font-weight: 700; }
.back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.steps { display: flex; gap: 6px; }
.steps button { width: 32px; height: 32px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; }
.steps button:disabled { opacity: .35; cursor: default; }
.steps svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; }

.hero { position: relative; border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 10; background: var(--line); }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.credit {
  position: absolute; left: 10px; bottom: 10px; right: 10px; width: fit-content; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: rgba(20,16,12,.62); backdrop-filter: blur(6px); color: #fff; font-size: 11.5px; text-decoration: none; line-height: 1.3;
}
.credit svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 2; flex: none; }
.credit span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 8px; }
.tag { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--paper); color: var(--ink-2); }
.tag.course-tag { background: color-mix(in srgb, var(--c) 14%, var(--card)); color: color-mix(in srgb, var(--c) 80%, #000); }
.detail h1 { margin: 0; font-size: 25px; font-weight: 850; line-height: 1.2; letter-spacing: -.01em; }
.ko-name { margin-top: 4px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.lead { margin: 10px 0 0; font-size: 15px; color: var(--accent-ink); font-weight: 700; line-height: 1.45; }

.addr {
  margin-top: 16px; padding: 14px; border-radius: var(--r); background: var(--paper);
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
}
.addr small { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.addr .ko { font-size: 15px; font-weight: 750; margin-top: 3px; user-select: all; word-break: keep-all; }
.addr .en { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.copy-btn { height: 40px; padding: 0 14px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.copy-btn svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2; }

.facts { margin: 12px 0 0; display: grid; gap: 8px; }
.fact { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.fact svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; margin-top: 1px; }

.sec { margin-top: 20px; }
.sec h3 { margin: 0 0 6px; font-size: 13px; font-weight: 800; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink); }
.tip { padding: 14px; border-radius: var(--r); background: color-mix(in srgb, var(--mint) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--mint) 22%, transparent); }
.tip h3 { color: var(--mint); }
.badge { font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; padding: 3px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.flitto { color: #1A73E8; background: #E8F0FE; }
.badge.fallback { color: #8A6D1F; background: #FBF1D6; }
.badge.source { color: var(--ink-3); background: var(--paper); }
.skel { display: block; height: 14px; border-radius: 6px; margin: 6px 0; background: linear-gradient(90deg, var(--line), var(--paper), var(--line)); background-size: 200% 100%; animation: sh 1.2s infinite linear; }
.skel.short { width: 60%; }
@keyframes sh { to { background-position: -200% 0; } }

.dir { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dir a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--r-sm); background: var(--paper); text-decoration: none; font-size: 12.5px; font-weight: 700; text-align: center; }
.dir a img { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; }
.driver-btn { margin-top: 10px; width: 100%; height: 48px; border-radius: var(--r-sm); background: var(--accent); color: #fff; font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.driver-btn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; }

/* ---------- 오버레이 (출처 / 기사님 카드) ---------- */
.overlay { position: absolute; inset: 0; z-index: 60; background: rgba(20,16,12,.5); display: grid; place-items: end center; animation: fade .2s; }
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; max-height: 86%; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
@container app (min-width: 760px) { .overlay { place-items: center; } .modal { border-radius: 24px; } }
.modal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-h h2 { margin: 0; font-size: 19px; }
.modal-h button { width: 34px; height: 34px; border-radius: 50%; background: var(--paper); font-size: 18px; }
.modal > p { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.cred { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cred img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.cred b { display: block; font-size: 14px; }
.cred span { color: var(--ink-2); }
.cred a { color: var(--accent-ink); font-weight: 700; }
.cred.plain { grid-template-columns: 1fr; }

.driver { position: absolute; inset: 0; z-index: 70; background: #fff; display: flex; flex-direction: column; padding: calc(28px + env(safe-area-inset-top)) 24px 28px; animation: fade .2s; }
.driver .say { font-size: clamp(26px, 8cqi, 52px); font-weight: 900; line-height: 1.2; }
.driver .dest { margin-top: 28px; padding: 22px; border-radius: 22px; background: var(--paper); }
.driver .dest b { display: block; font-size: clamp(30px, 10cqi, 64px); font-weight: 900; color: var(--accent); line-height: 1.15; word-break: keep-all; }
.driver .dest p { margin: 12px 0 0; font-size: clamp(18px, 5cqi, 28px); font-weight: 700; word-break: keep-all; }
.driver .hint { margin-top: auto; color: var(--ink-3); font-size: 14px; }
.driver button { margin-top: 14px; height: 50px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-weight: 800; }

.toast {
  position: absolute; z-index: 80; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 지도 마커 ---------- */
.leaflet-container { font-family: var(--font); background: #EAE3D6; }
.pin { width: 40px; height: 44px; position: relative; transition: transform .2s; transform-origin: 50% 90%; cursor: pointer; }
.pin b { position: absolute; left: 0; right: 0; top: 0; text-align: center; font-size: 30px; line-height: 36px; font-weight: 400;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 2px #fff) drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.pin::after { content: ""; position: absolute; left: 50%; bottom: 1px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); box-sizing: border-box; }
.pin.active { transform: scale(1.35); z-index: 999; }
.pin.active b { animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes pulse { 50% { transform: scale(1.8); opacity: 0; } }
.pin-label.leaflet-tooltip { background: var(--card); border: 0; border-radius: 8px; padding: 3px 8px; font-weight: 750; font-size: 12px; color: var(--ink); box-shadow: var(--shadow-sm); }
.pin-label.leaflet-tooltip::before { display: none; }
.hide-labels .pin-label { display: none; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1A73E8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }
.leaflet-control-zoom { display: none; }
@container app (min-width: 760px) { .leaflet-control-zoom { display: block; } }
.leaflet-control-attribution { font-size: 10px; }
.app[data-sheet] .leaflet-bottom { bottom: var(--sheet-h, 50%); transition: bottom .3s; }
@container app (min-width: 760px) { .app[data-sheet] .leaflet-bottom { bottom: 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.base-tiles { filter: saturate(1.08) contrast(1.02); }

/* ---------- 공통: 테마 버튼 / 경로선 ---------- */
.sound-btn[aria-pressed="false"] .on, .sound-btn[aria-pressed="true"] .off { display: none; }
.sound-btn[aria-pressed="true"] { background: var(--accent); }
.sound-btn[aria-pressed="true"] svg { stroke: #fff; }
.sound-btn.playing::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1s ease-out infinite; }
@keyframes ring { from { opacity: .9; transform: scale(.85); } to { opacity: 0; transform: scale(1.25); } }
.icon-btn { position: relative; }
.route-jongno { stroke: var(--course-jongno); } .route-mapo { stroke: var(--course-mapo); } .route-gwangju { stroke: var(--course-gwangju); }
.route-daegu { stroke: var(--course-daegu); } .route-jeju { stroke: var(--course-jeju); } .route-busan { stroke: var(--course-busan); }

/* ---------- 포인트 ---------- */
.app .chip[aria-pressed="true"] { background: var(--ink); }
.app .copy-btn { background: var(--accent); }
.app .driver-btn { background: linear-gradient(135deg, #0A6CFF, #00B2FF); }
.app .tip { background: #E9F8F6; border-color: #BFEAE4; }

/* ---------- 좁은 앱 화면 (파일 끝에 두어 우선 적용) ---------- */
.brand strong { white-space: nowrap; }
@container app (max-width: 440px) {
  .brand small { display: none; }
  .brand strong { font-size: 19px; }
  .top-actions { gap: 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .lang button { min-width: 28px; padding: 0 5px; }
  .topbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
}
