:root {
  --paper: #FAF8F0;
  --ink: #212644;
  --ink2: #373E60;
  --yellow: #FFCF48;
  --muted: #5B605F;
  --line: #D8D7CB;
  --chip: #ECE9DF;
  --switch: #EBE9DF;
  --code-dot-line: #9E760F;
  --accent-text: #795814;
  --focus: #995700;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Segoe UI', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); }
body {
  color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  word-break: keep-all; overflow-wrap: anywhere; overscroll-behavior-y: none;
}
h1, h2, h3, p, dl, dd { margin: 0; }
img, video { display: block; max-width: 100%; }
a { color: inherit; }
button {
  font: inherit; color: inherit; background: transparent; border: 0; margin: 0; padding: 0;
  cursor: pointer; appearance: none; min-height: 44px; letter-spacing: -0.02em; line-height: 1.27;
  word-break: keep-all; overflow-wrap: anywhere;
}
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 19px; height: 19px; flex: none; display: inline-block; vertical-align: middle; }

/* ---------- 앱 골격: 실제 화면 높이 + 안전 영역 ---------- */
.app {
  max-width: 480px; margin: 0 auto; background: var(--paper);
  height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  position: relative;
}
@media (min-width: 520px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
  min-height: 57px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.075em; font-size: 23px; }
.mark { width: 23px; height: 26px; border-radius: 2px 11px 11px 2px; background: var(--ink); position: relative; flex: none; }
.mark::after { content: ''; position: absolute; left: 5px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); }
.lang { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; padding: 0 6px; min-width: 44px; }
.lang .ico { width: 15px; height: 15px; }
.main { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative; outline: none; }
.main.fixed { overflow: hidden; display: flex; flex-direction: column; }

.nav {
  display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav:empty { display: none; }
.nav button {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 620; color: var(--muted); min-height: 52px; padding: 4px;
}
.nav button[aria-current="page"] { color: var(--ink); font-weight: 750; }
.nav button[aria-current="page"]::before { content: ''; position: absolute; top: 0; width: 32px; height: 3px; background: var(--ink); border-radius: 0 0 2px 2px; }
.nav .solo { grid-column: 1 / -1; color: var(--ink); font-weight: 700; }
.nav .ico { width: 18px; height: 18px; }

/* ---------- 알림(되돌리기) ---------- */
.notice { display: none; }
.notice.on {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px 6px 16px; min-height: 44px; background: var(--ink2); color: #fff; font-size: 14px;
}
.notice button { text-decoration: underline; font-weight: 750; padding: 0 10px; min-width: 44px; color: #fff; }

/* ---------- 공통 요소 ---------- */
.pad { padding: 23px 20px; }
.code { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; line-height: 1.35; letter-spacing: .12em; }
.code::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); border: 1px solid var(--code-dot-line); flex: none; }
.cta, .outline, .linkbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border-radius: 10px; padding: 11px 12px; font-size: 16px; font-weight: 720; min-height: 48px;
  text-decoration: none; text-align: center;
}
.cta { background: var(--yellow); color: var(--ink); }
.cta.is-saved { background: var(--ink); color: #fff; }
.outline { background: var(--paper); color: var(--ink); border: 1px solid #A4A59C; }
.linkbtn { background: var(--ink); color: #fff; }
.textbtn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 650; padding: 4px 6px; min-width: 44px; }
.textbtn .ico { width: 16px; height: 16px; }

/* ---------- 첫 화면 ---------- */
.home-title { font-size: clamp(40px, 11vw, 51px); font-weight: 800; line-height: 1.06; letter-spacing: -0.075em; margin: 15px 0 10px; }
.home-title .dot { color: #AD6900; }
.intro { font-size: 15px; line-height: 1.5; color: var(--muted); font-weight: 500; }
.postcard { background: var(--ink); color: #fff; margin: 19px 0 16px; border-radius: 4px; overflow: hidden; position: relative; }
.post-img { height: clamp(150px, 46vw, 210px); position: relative; }
.post-img > img { width: 100%; height: 100%; object-fit: cover; }
.sticker { position: absolute; top: 13px; left: 13px; background: var(--yellow); color: var(--ink); padding: 5px 8px; font-size: 11px; font-weight: 750; letter-spacing: .08em; transform: rotate(-3deg); }
.mini { position: absolute; right: 10px; bottom: 12px; width: 31%; background: var(--paper); padding: 4px 4px 3px; transform: rotate(5deg); box-shadow: 1px 3px 8px #090A1A55; }
.mini img { height: 56px; width: 100%; object-fit: cover; }
.mini span { display: block; color: var(--ink); font-size: 11px; font-weight: 730; line-height: 1.25; padding: 3px 1px 0; }
.caption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 13px; font-size: 13px; font-weight: 650; }
.caption span:last-child { font-size: 11px; color: #EBDFA1; letter-spacing: .07em; white-space: nowrap; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }
.credits { margin-top: 22px; font-size: 12px; line-height: 1.7; color: #575B64; }
.credits summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 650; }
.credits a { color: #343D65; }
.credits p { margin-bottom: 6px; }

/* ---------- 숏폼 탐색 ---------- */
.media {
  position: relative; flex: 1 1 auto; min-height: 240px; background: var(--ink); color: #fff;
  overflow: hidden; isolation: isolate; display: flex; align-items: flex-end;
  touch-action: pan-x pinch-zoom; user-select: none; -webkit-user-select: none;
}
.media > .photo, .media > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.media > video { opacity: 0; transition: opacity .25s; }
.media > video.on { opacity: 1; }
.media::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, #07091468 0, transparent 31%, #080A1210 40%, #070914E8 91%); }
.count { position: absolute; top: 14px; left: 16px; border-radius: 5px; padding: 5px 8px; background: #181B30D9; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.still { position: absolute; top: 14px; right: 14px; padding: 4px 7px; border-radius: 4px; background: #181B30D9; font-size: 11px; }
.feedtext { padding: 70px 20px 20px; width: 100%; }
.feedtext .code { font-size: 12px; letter-spacing: .01em; }
.feedtext h2 { font-size: 31px; line-height: 1.13; letter-spacing: -0.055em; font-weight: 780; margin: 8px 0; }
.feedtext p { font-size: 15px; line-height: 1.4; }
.vbtn {
  position: absolute; right: 12px; bottom: 14px; z-index: 2; width: 44px; height: 44px; border-radius: 50%;
  background: #181B30D9; color: #fff; display: grid; place-items: center;
}
.vbtn[hidden] { display: none; }
.vretry {
  position: absolute; right: 12px; top: 50px; z-index: 2; min-height: 40px; padding: 0 12px; border-radius: 999px;
  background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 750; display: inline-flex; align-items: center; gap: 6px;
}
.vretry[hidden] { display: none; }
.media.has-vbtn .feedtext { padding-right: 64px; }
.feedactions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 16px 4px; flex: none; }
.steprow { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 2px; flex: none; }

/* ---------- 상세 ---------- */
.detailback { padding: 0 10px; }
.detailmedia { min-height: 0; flex: none; position: relative; height: clamp(170px, 48vw, 240px); background: var(--ink); overflow: hidden; display: block; }
.detailmedia.is-video { height: auto; aspect-ratio: 9 / 16; max-height: 62vh; }
.detailmedia::before { display: none; }
.detailbody { padding: 17px 20px 24px; }
.detailbody .dtitle, .sectiontitle { font-size: 29px; line-height: 1.16; font-weight: 780; letter-spacing: -0.055em; margin: 8px 0; }
.desc { font-size: 15px; line-height: 1.5; color: #464953; }
.info { margin: 14px 0; border-top: 1px solid var(--line); }
.info div { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 9px 0; font-size: 14px; line-height: 1.45; border-bottom: 1px solid var(--line); }
.info dt { color: var(--muted); font-weight: 630; }
.info small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.photocredit { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.photocredit a { color: #343D65; }

/* ---------- 저장한 장소 ---------- */
.titlebar { padding: 20px 20px 0; }
.sectiontitle .n { color: var(--accent-text); }
.switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 14px; padding: 3px; background: var(--switch); border-radius: 10px; }
.switch button { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; font-weight: 700; border-radius: 7px; }
.switch button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 4px #20264120; }
.list { list-style: none; margin: 0; padding: 4px 20px 24px; }
.item { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.itemmain { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; }
.thumb { width: 57px; height: 65px; object-fit: cover; border-radius: 5px; flex: none; background: var(--chip); }
.sub { display: block; font-size: 12px; color: var(--muted); line-height: 1.5; }
.iname { display: block; font-size: 17px; font-weight: 740; line-height: 1.28; margin-top: 2px; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; flex: none; border-radius: 8px; }
.empty { min-height: 280px; display: grid; align-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px 20px; }
.emicon { width: 55px; height: 55px; border-radius: 16px; background: #F3E6B8; display: grid; place-items: center; }
.emicon .ico { width: 26px; height: 26px; }
.empty strong { font-size: 20px; letter-spacing: -0.05em; }
.empty p { font-size: 14px; color: var(--muted); }
.empty .cta { width: auto; padding: 11px 22px; }

/* ---------- 지도 ---------- */
.mapwrap { padding: 14px 16px 24px; }
.mapbox { position: relative; height: clamp(200px, 36vh, 340px); border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: #EEEAE0; }
#map, .mapbox .leaflet-container { position: absolute; inset: 0; background: #EEEAE0; font-family: var(--font); }
.mapstate {
  position: absolute; inset: 0; z-index: 800; display: grid; place-content: center; justify-items: center; gap: 10px;
  text-align: center; padding: 20px; background: #EEEAE0;
}
.mapstate[hidden] { display: none; }
.mapstate strong { font-size: 17px; letter-spacing: -0.03em; }
.mapstate p { font-size: 13px; color: var(--muted); max-width: 26em; }
.mapstate .cta { width: auto; padding: 10px 20px; min-height: 44px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.choices { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; }
.chip { flex: 1 1 130px; min-width: 0; overflow-wrap: break-word; word-break: keep-all; min-height: 44px; border-radius: 6px; padding: 6px 8px; font-size: 13px; font-weight: 650; background: var(--chip); text-align: center; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.mapname { display: inline-flex; align-items: center; gap: 6px; text-align: left; font-weight: 760; font-size: 19px; letter-spacing: -0.04em; }
.mapname .ico { width: 16px; height: 16px; }
.loc { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 10px; }
.loc .ko { display: block; color: var(--ink); }
.copyrow { display: flex; justify-content: center; margin-top: 4px; }
.copyfield { width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-size: 15px; border: 1px solid #A4A59C; border-radius: 8px; background: #fff; color: var(--ink); }
.copyhint { font-size: 13px; color: var(--muted); margin-top: 8px; }

.pin { width: 44px; height: 44px; display: grid; place-items: center; }
.pin span {
  width: 30px; height: 30px; border-radius: 50% 50% 2px 50%; transform: rotate(45deg);
  background: var(--ink); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff, 0 2px 6px #0005;
}
.pin em { transform: rotate(-45deg); font-style: normal; font-weight: 800; font-size: 14px; font-family: var(--font); }
.pin.sel span { background: var(--yellow); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 0 2px 8px #0006; width: 34px; height: 34px; }
.leaflet-marker-icon:focus-visible { outline: 3px solid var(--focus); }

@media (max-width: 370px) {
  .pad, .titlebar { padding-left: 15px; padding-right: 15px; }
  .feedtext h2 { font-size: 27px; }
  .list { padding-left: 15px; padding-right: 15px; }
  .detailbody { padding-left: 15px; padding-right: 15px; }
  .feedactions { padding-left: 12px; padding-right: 12px; }
}
@media (max-height: 620px) {
  .feedtext { padding-top: 48px; padding-bottom: 14px; }
  .feedtext h2 { font-size: 25px; margin: 6px 0; }
  .media { min-height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; }
}
