/* 발걸음 여행 웹 v0.8.0 — 중장년·어르신이 읽기 쉬운 화면
   기준: 본문 18px 이상, 터치 영역 56px 이상, 대비 4.5:1 이상, 아이콘에는 항상 글자 표시 */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --pine: #1F4D3A;
  --moss: #3E7D5A;
  --leaf: #DCEBE2;
  --sky: #2F6FA3;
  --sky-pale: #E3EEF7;
  --persimmon: #E8772E;
  --persimmon-ink: #A8470F;
  --mist: #EEF3F0;
  --paper: #FFFFFF;
  --ink: #17221D;
  --ink-2: #44524B;
  --line: #CBD8D0;
  --danger: #B3261E;

  --scale: 1;
  --fs-body: calc(18px * var(--scale));
  --fs-small: calc(16px * var(--scale));
  --fs-h3: calc(20px * var(--scale));
  --fs-h2: calc(24px * var(--scale));
  --fs-h1: calc(30px * var(--scale));
  --fs-display: calc(40px * var(--scale));

  --touch: 56px;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --tabbar: 76px;
  --player: 0px;
  --shadow: 0 1px 0 rgba(23, 34, 29, .06), 0 6px 20px -12px rgba(31, 77, 58, .35);
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}

html[data-contrast="high"] {
  --pine: #0C2E21; --moss: #0F5132; --sky: #0B4A80; --ink: #000; --ink-2: #1D2622;
  --line: #5D6B64; --mist: #FFFFFF; --leaf: #E7F2EB; --persimmon-ink: #7A2E00;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-body); line-height: 1.65;
  color: var(--ink); background: var(--mist); font-weight: 500;
  padding-bottom: calc(var(--tabbar) + var(--player) + env(safe-area-inset-bottom));
  word-break: keep-all; overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sky); text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.3; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-h1); font-weight: 800; }
h2 { font-size: var(--fs-h2); font-weight: 800; }
h3 { font-size: var(--fs-h3); font-weight: 700; }
p { margin: 0; }
.muted { color: var(--ink-2); font-size: var(--fs-small); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--persimmon); outline-offset: 3px; border-radius: 6px; }
svg.i { width: 26px; height: 26px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 앱 골격 ---------- */
.view { display: none; max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }
.view.active { display: block; }
.view[data-view="map"] { max-width: none; padding: 0; }

.topbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.topbar h1 { flex: 1; }
.back { min-width: var(--touch); min-height: var(--touch); border: 0; background: transparent; border-radius: 50%; display: grid; place-items: center; color: var(--pine); }

/* 하단 탭: 항상 글자와 함께 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-2); font-size: calc(15px * var(--scale)); font-weight: 700;
}
.tabbar a[aria-current="page"] { color: var(--pine); }
.tabbar a[aria-current="page"] svg { background: var(--leaf); border-radius: 12px; padding: 3px 10px; width: 46px; height: 32px; }

/* ---------- 버튼 ---------- */
.btn {
  min-height: var(--touch); padding: 12px 20px; border-radius: var(--r-md); border: 2px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; text-decoration: none;
  background: var(--pine); color: #fff; font-size: var(--fs-body);
}
.btn.secondary { background: var(--paper); color: var(--pine); border-color: var(--line); }
.btn.quiet { background: var(--leaf); color: var(--pine); }
.btn.accent { background: var(--persimmon); color: #1B0E05; }
.btn.danger { background: var(--paper); color: var(--danger); border-color: #E7B9B5; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack > * + * { margin-top: 12px; }

/* ---------- 홈: 등고선 히어로 (이 화면의 유일한 장식) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; color: #F4FBF6;
  background: var(--pine); padding: 26px 22px 22px; min-height: 250px;
}
.hero svg.contour { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero .contour path { fill: none; stroke: rgba(220, 235, 226, .18); stroke-width: 1.4; }
.hero .contour .trail { stroke: var(--persimmon); stroke-width: 3; stroke-dasharray: 2 9; stroke-linecap: round; }
.hero .contour .trail-end { fill: var(--persimmon); stroke: none; }
.hero-inner { position: relative; }
.hero .date { font-size: var(--fs-display); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.hero .weekday { font-size: var(--fs-h3); font-weight: 600; opacity: .9; }
.hero .greet { margin-top: 18px; font-size: var(--fs-h3); max-width: 22em; }
.hero .hero-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.accent { box-shadow: 0 6px 18px -8px rgba(0,0,0,.5); }
.weather-btn {
  position: absolute; top: 0; right: 0; min-height: 48px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: #fff; font-weight: 700; font-size: var(--fs-small);
}

.section { margin-top: 30px; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section > header a { font-weight: 700; font-size: var(--fs-small); }

/* 무엇을 찾으세요? — 아이콘 + 이름이 함께 있는 큰 버튼 */
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cat {
  min-height: 104px; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  color: var(--ink); font-weight: 700; font-size: var(--fs-small); line-height: 1.3; padding: 10px 6px; text-decoration: none;
}
.cat .dot { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--leaf); color: var(--pine); }
.cat[data-tone="sky"] .dot { background: var(--sky-pale); color: var(--sky); }
.cat[data-tone="warm"] .dot { background: #FCE7D6; color: var(--persimmon-ink); }
@media (max-width: 420px) { .cats { grid-template-columns: repeat(2, 1fr); } .cat { min-height: 88px; flex-direction: row; justify-content: flex-start; padding: 12px; text-align: left; } }

/* 목록 행 (카드 남발 대신) */
.list { background: var(--paper); border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; }
.item {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px; min-height: 72px; width: 100%;
  border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; color: inherit; text-decoration: none;
}
.list > .item:first-child { border-top: 0; }
.item:hover { background: #F6FAF7; }
.item .ico { width: 48px; height: 48px; border-radius: 14px; background: var(--leaf); color: var(--pine); display: grid; place-items: center; flex: none; overflow: hidden; }
.item .ico img { width: 100%; height: 100%; object-fit: cover; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; display: block; }
.item .sub { color: var(--ink-2); font-size: var(--fs-small); display: block; }
.item .end { color: var(--ink-2); font-weight: 700; font-size: var(--fs-small); white-space: nowrap; }
.empty { padding: 22px 18px; color: var(--ink-2); }
.empty .btn { margin-top: 12px; }

.panel { background: var(--paper); border-radius: var(--r-lg); border: 1px solid var(--line); padding: 20px; }
.panel + .panel { margin-top: 14px; }
.note { background: var(--sky-pale); color: #183B57; border-radius: var(--r-md); padding: 14px 16px; font-size: var(--fs-small); }
.warn { background: #FFF2E8; color: #5A2707; border-radius: var(--r-md); padding: 14px 16px; font-size: var(--fs-small); }

/* ---------- 지도 화면 ---------- */
.map-wrap { position: relative; height: calc(100vh - var(--tabbar) - var(--player)); height: calc(100dvh - var(--tabbar) - var(--player) - env(safe-area-inset-bottom)); }
#map { position: absolute; inset: 0; background: #DDE6E0; }
.map-top { position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.search {
  display: flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 18px; border: 1px solid var(--line);
  padding: 4px 4px 4px 14px; box-shadow: var(--shadow); max-width: 640px;
}
.search input { flex: 1; min-height: 52px; border: 0; outline: 0; background: transparent; font-size: var(--fs-body); min-width: 0; }
.search .btn { min-height: 48px; padding: 8px 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 48px; padding: 8px 16px 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow);
  font-size: var(--fs-small);
}
.chip svg.i { width: 22px; height: 22px; }
.chip[aria-pressed="true"] { background: var(--pine); color: #fff; border-color: var(--pine); }
.map-fabs { position: absolute; z-index: 500; right: 12px; display: flex; flex-direction: column; gap: 10px; bottom: calc(var(--sheet-peek, 120px) + 14px); transition: bottom .2s; }
.fab { width: var(--touch); height: var(--touch); border-radius: 18px; border: 1px solid var(--line); background: var(--paper); color: var(--pine); display: grid; place-items: center; box-shadow: var(--shadow); }
.fab.me { color: var(--persimmon-ink); }
.redo { position: absolute; z-index: 500; left: 50%; transform: translateX(-50%); top: 150px; }
.redo[hidden] { display: none; }

/* 아래에서 올라오는 결과 시트 */
.sheet {
  position: absolute; z-index: 600; left: 0; right: 0; bottom: 0; max-height: 58%; background: var(--paper);
  border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px -16px rgba(0,0,0,.4); display: flex; flex-direction: column;
  max-width: 760px; margin: 0 auto;
}
.sheet .grab { width: 100%; border: 0; background: transparent; padding: 10px 18px 6px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: left; }
.sheet .grab::before { content: ""; align-self: center; width: 48px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet .sheet-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sheet .sheet-body { overflow-y: auto; padding: 0 12px 14px; }
.sheet[data-state="peek"] .sheet-body { display: none; }
.sheet .list { border-radius: var(--r-md); }
.source { font-size: calc(14px * var(--scale)); color: var(--ink-2); padding: 8px 6px 0; }

.detail img.photo { width: 100%; max-height: 240px; object-fit: cover; border-radius: var(--r-md); background: var(--mist); }
.detail .kind { color: var(--moss); font-weight: 700; font-size: var(--fs-small); }
.detail .facts { margin: 12px 0; display: grid; gap: 6px; }
.detail .facts div { display: flex; gap: 10px; align-items: flex-start; }
.detail .desc { white-space: pre-line; margin-top: 10px; }
.detail .row .btn { flex: 1 1 140px; }

.leaflet-container { font-family: var(--font); font-size: 16px; }
.pin { width: 38px; height: 38px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); background: var(--pine); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); display: grid; place-items: center; }
.pin span { transform: rotate(45deg); color: #fff; font-size: 14px; font-weight: 800; }
.pin.sky { background: var(--sky); } .pin.warm { background: var(--persimmon-ink); } .pin.moss { background: var(--moss); }
.pin.active { background: var(--persimmon); width: 46px; height: 46px; }
.me-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--persimmon); border: 4px solid #fff; box-shadow: 0 0 0 8px rgba(232,119,46,.25); }

/* ---------- 이야기 화면 ---------- */
.story-title { font-size: var(--fs-h1); font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--paper); }
.stats div { padding: 12px 14px; border-left: 1px solid var(--line); }
.stats div:first-child { border-left: 0; }
.stats strong { display: block; font-size: var(--fs-h2); font-weight: 800; color: var(--pine); }
.route { background: var(--leaf); border-radius: var(--r-md); overflow: hidden; }
.route svg { display: block; width: 100%; height: 220px; }
.narrative { white-space: pre-wrap; line-height: 1.9; font-size: calc(19px * var(--scale)); max-width: 36em; }
.moment { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.moment:first-child { border-top: 0; }
.moment .when { font-weight: 800; color: var(--pine); font-size: var(--fs-small); line-height: 1.3; }
.moment img, .moment video { width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--r-md); background: var(--mist); margin-top: 10px; }
.moment audio { width: 100%; margin-top: 8px; }

/* ---------- 음악 ---------- */
.miniplayer {
  position: fixed; z-index: 39; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
  background: var(--pine); color: #fff; display: none; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; height: 68px;
}
.miniplayer.show { display: flex; }
body.has-player { --player: 68px; }
.miniplayer .meta { flex: 1; min-width: 0; border: 0; background: transparent; color: inherit; text-align: left; padding: 0; }
.miniplayer .meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.miniplayer .meta span { font-size: calc(14px * var(--scale)); opacity: .85; }
.miniplayer button.ctl { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.miniplayer button.ctl.main { background: var(--persimmon); color: #1B0E05; }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; margin-right: 6px; }
.eq i { width: 3px; background: var(--persimmon); animation: eq 1s infinite ease-in-out; }
.eq i:nth-child(2) { animation-delay: .2s } .eq i:nth-child(3) { animation-delay: .4s }
@keyframes eq { 0%,100% { height: 4px } 50% { height: 14px } }
.paused .eq i { animation: none; height: 4px; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 24px; text-align: center; background: var(--paper);
}
.drop.over { border-color: var(--persimmon); background: #FFF6EE; }
.track.playing .title { color: var(--persimmon-ink); }
.track .ctl { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--pine); display: grid; place-items: center; }
input[type="range"] { width: 100%; height: 44px; accent-color: var(--pine); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--paper); }
.seg button { min-height: var(--touch); border: 0; border-left: 1px solid var(--line); background: transparent; font-weight: 700; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--pine); color: #fff; }
.progress { display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; font-size: var(--fs-small); }
.progress span { white-space: nowrap; min-width: 3.2em; }
.progress span:last-child { text-align: right; }

/* ---------- 설정 ---------- */
.field { display: block; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
.field input { width: 100%; min-height: var(--touch); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; background: var(--paper); }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: var(--touch); }
.toggle input { width: 30px; height: 30px; accent-color: var(--pine); }

.toast {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + var(--player) + 18px);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: var(--r-md); max-width: calc(100% - 32px);
  font-weight: 600; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (min-width: 900px) {
  .sheet { left: 16px; right: auto; width: 420px; bottom: 16px; top: 140px; max-height: none; border-radius: 24px; }
  .sheet[data-state="peek"] { top: auto; }
  .map-fabs { bottom: 24px; }
}
