:root {
  --ink: #0f172a;
  --muted: #5b6474;
  --bg: #ffffff;
  --panel: #f3f5f9;
  --line: #e4e7ee;
  --red: #cd2e3a;
  --blue: #0047a0;
  --navy: #0b1730;
  --sky: #eef4ff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .16);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
button { font: inherit; cursor: pointer; color: inherit; }
a { color: var(--blue); }

/* ---------- header ---------- */
.top { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: var(--navy); color: #fff; position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.brand b { color: #ff8f9c; }
.brand-ic { width: 28px; height: 28px; display: block; }
.top-right { display: flex; align-items: center; gap: 8px; }
/* 지금 서울: 시각 · 날씨 (app.js renderSeoulNow) */
.seoul-now { flex: 1; min-width: 0; margin: 0 12px; text-align: center; color: #d6deec; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seoul-now .sn-flag { display: none; }
.chip-btn { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 6px 12px; font-size: 14px; white-space: nowrap; }
.chip-btn.on { background: #fff; color: var(--navy); }
.lang-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12); color: #fff; font-size: 14px; white-space: nowrap; cursor: pointer; }
.lang-pick:focus-within { outline: 2px solid #fff; outline-offset: 2px; }
.lang-pick .globe { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.lang-pick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; border: 0; }
html:lang(ko) body { word-break: keep-all; overflow-wrap: break-word; }
.brand { white-space: nowrap; flex: none; }
/* 좁은 화면: 언어·위치 버튼은 아이콘만 */
@media (max-width: 640px) {
  .top { padding: 0 12px; }
  .brand { font-size: 18px; }
  .brand-ic { width: 26px; height: 26px; }
  .top-right { gap: 6px; }
  .seoul-now { margin: 0 6px; font-size: 12px; line-height: 1.3; white-space: normal; }
  .seoul-now .sn-city, .seoul-now .sn-dot { display: none; }
  .seoul-now .sn-flag { display: inline; }
  .seoul-now .sn-wx { display: block; white-space: nowrap; }
  .lang-pick { width: 34px; padding: 0; justify-content: center; }
  .lang-pick span, .lb-text { display: none; }
  #locBtn { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 15px; }
}
.round-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12); color: #fff; font-weight: 700; }

/* ---------- layout ---------- */
.layout { height: calc(100vh - 56px); height: calc(100dvh - 56px); }
.feed-col { height: 100%; overflow-y: auto; background: var(--bg); }
.detail { position: relative; }
.map-box { position: absolute; inset: 0; background: var(--navy); }   /* 지구본 둘레 = 밤하늘 */
#map { position: absolute; inset: 0; }

/* ---------- feed header ---------- */
.feed-head { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px 14px 10px; }
.today-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.today-line { margin: 0; font-size: 13px; color: var(--muted); }
.today-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.today-line .new { color: var(--red); }
.seg { display: inline-flex; background: var(--panel); border-radius: 999px; padding: 3px; flex: none; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 650; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 14px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- feed posts ---------- */
.feed { max-width: 540px; margin: 0 auto; padding: 0 0 48px; }
.day-head { margin: 18px 14px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.post { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 6px; transition: background .2s; scroll-margin-top: 96px; }
.post.active { background: #fff6f7; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.ava { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: none; }
.ava img { width: 100%; height: 100%; display: block; }
.post-head b { display: block; font-size: 14px; line-height: 1.2; }
.post-head small { color: var(--muted); font-size: 12px; }
.new-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; }
.post-photo { display: block; position: relative; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; background: #d9dee7; overflow: hidden; }
.post-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.post-photo:hover img { transform: scale(1.02); }
.screen-tag { position: absolute; left: 12px; top: 12px; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255,255,255,.92); color: var(--navy); font-size: 13px; font-weight: 650; padding: 5px 11px; border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.kv .scene { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; }
/* 한국어 한 마디 */
.kv.word { background: #fff; border: 1px solid #f3c4ca; }
.kv.word .kw { font-size: 19px; font-weight: 700; margin-right: 4px; }
.kv.word .rr { font-style: italic; color: var(--muted); }
.kv.word .say { margin-left: 8px; border: 0; background: #fff; border-radius: 999px; width: 32px; height: 32px; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.15); cursor: pointer; vertical-align: middle; }
.kv.word .say:active { transform: scale(.94); }
.reveal-tag { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; background: rgba(11,23,48,.82); color: #fff; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px; }
.post-actions { display: flex; align-items: center; gap: 2px; padding: 6px 8px 0; }
.icon-btn { width: 42px; height: 42px; border: 0; background: none; border-radius: 50%; font-size: 24px; line-height: 1; display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel); }
.icon-btn.on { color: var(--red); }
.dist { margin-left: auto; padding-right: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dist b { color: var(--blue); }
.post-body { padding: 2px 14px 0; }
.hook { margin: 0; font-size: 15px; }
.hook b { margin-right: 4px; }
.where { margin: 4px 0 0; color: var(--blue); font-size: 14px; font-weight: 650; }
.post-detail { display: none; padding-top: 4px; }   /* 휴대폰은 아래 시트에 설명이 나와서 숨김 */
.post-detail .alt { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.post-detail .why { font-size: 15px; }
.post-detail .actions { margin: 12px 0 4px; }
.see-btn { border: 0; background: none; color: var(--red); font-weight: 700; padding: 6px 0 0; font-size: 14px; }
.empty { color: var(--muted); padding: 30px 16px; text-align: center; }

/* ---------- info card ---------- */
.info { background: #fff; padding: 18px; }
.area-chip { display: inline-block; background: var(--panel); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.info h2 { font-size: 22px; line-height: 1.25; margin: 8px 0 0; letter-spacing: -.01em; }
.info .ko { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.distance-box { display: flex; align-items: center; gap: 10px; background: var(--sky); border-radius: 12px; padding: 10px 12px; margin: 12px 0 14px; font-size: 14px; }
.distance-box b { font-size: 20px; color: var(--blue); white-space: nowrap; }
.distance-box .link { margin-left: auto; border: 0; background: none; color: var(--blue); font-weight: 650; font-size: 13px; padding: 0; text-decoration: underline; }
.why { margin: 0 0 14px; }
.kv { background: var(--panel); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 15px; }
.kv b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; padding: 10px 14px; font-weight: 650; font-size: 15px; text-decoration: none; border: 1px solid transparent; }
.btn.primary { background: var(--red); color: #fff; }
.btn.naver { background: #03c75a; color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost.on { color: var(--red); border-color: #f2b8bd; background: #fff5f6; }
.btn.block { width: 100%; }
.credit { color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
.intro h2 { margin-top: 0; }
.intro p { color: var(--muted); }
.close-x { display: none; }

/* ---------- map markers ---------- */
.pin { width: 28px; height: 34px; }
.pin i { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--red); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.base-mark { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.base-mark .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(0,71,160,.18), 0 2px 6px rgba(0,0,0,.3); }
.base-mark.city .dot { background: var(--navy); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.base-mark span { margin-top: 4px; background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.maplibregl-popup-content { border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.map-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); background: #e8eef5; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: 20px; padding: 22px; max-width: 440px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(11,23,48,.55); }
dialog h2 { margin: 0 0 8px; }
dialog ol { padding-left: 20px; margin: 0 0 10px; }
dialog li { margin-bottom: 4px; }
dialog .note { background: #effaf3; border-radius: 10px; padding: 8px 10px; font-size: 14px; }
dialog .fine { color: var(--muted); font-size: 12px; }
dialog .btn { width: 100%; margin-top: 6px; padding: 12px; }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

/* ---------- wide screens: feed with captions left, map right ---------- */
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(420px, 52%) 1fr; grid-template-rows: minmax(0, 1fr); }
  .feed-col { border-right: 1px solid var(--line); }
  /* 사진 + 버튼 줄 + 제목 줄까지 한 화면에 들어오게: 사진 높이 = 화면 높이 - 272px(머리글·필터·글쓴이·버튼·제목 줄), 폭은 그 3:2 */
  .feed { max-width: min(1000px, calc((100vh - 272px) * 1.5)); max-width: min(1000px, calc((100dvh - 272px) * 1.5)); }
  .post-photo { aspect-ratio: 3 / 2; }
  .day-head { margin: 10px 14px 6px; }
  /* 필터를 한 줄로: 오늘 새 사진 · 지역 칩 · 정렬 */
  .feed-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
  .today-row { display: contents; }
  .today-line { white-space: nowrap; }
  .chips { flex: 1; min-width: 0; order: 1; }
  .seg { order: 2; }
  .post-head { padding: 6px 14px; }
  .post { scroll-margin-top: 52px; }
  .info { display: none; }          /* 설명은 사진 아래(.post-detail)에 나온다 */
  .post-detail { display: block; }
}

/* ---------- phones: feed full screen, details slide up ---------- */
@media (max-width: 899px) {
  .detail { position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; top: 7vh; display: flex; flex-direction: column; background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(15,23,42,.25); overflow: hidden; transform: translateY(105%); transition: transform .3s ease; }
  .detail.open { transform: none; }
  .map-box { position: relative; inset: auto; flex: none; height: 36vh; }
  .info { flex: 1; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .close-x { display: grid; place-items: center; position: absolute; z-index: 5; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(11,23,48,.8); color: #fff; font-size: 18px; }
}
