/* DearAmigo — 엽서 같은 화면: 크림색 종이 · 우표 · 손글씨 쪽지. 다크 모드도 있다. */
:root {
  --bg: #f6efe3; --paper: #fffaf1; --panel: #fbf4e8; --panel2: #fffdf8;
  --ink: #2a221a; --ink2: #5e5246; --ink3: #8d7f70;
  --line: #e6dac8; --line2: #d8c8b1;
  --accent: #d0583a; --accentInk: #fff; --sea: #2f6f86; --sun: #e2a33b;
  --mine: #2f6f86; --mineInk: #fff; --theirs: #fff;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .08);
  --tabs: 62px; --r: 16px;
  --hand: 'Caveat', 'Segoe Print', cursive;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --paper: #211c16; --panel: #1c1813; --panel2: #262019;
    --ink: #f2e9dc; --ink2: #c8b9a6; --ink3: #8f8170;
    --line: #342c22; --line2: #45392c;
    --accent: #e8714f; --sea: #5aa3bd; --mine: #3d7f97; --theirs: #2a231b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --paper: #211c16; --panel: #1c1813; --panel2: #262019;
  --ink: #f2e9dc; --ink2: #c8b9a6; --ink3: #8f8170; --line: #342c22; --line2: #45392c;
  --accent: #e8714f; --sea: #5aa3bd; --mine: #3d7f97; --theirs: #2a231b; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
img { display: block; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 6px; }

.shell { max-width: 720px; margin: 0 auto; padding: 0 16px calc(var(--tabs) + 28px + env(safe-area-inset-bottom)); }
.shell.wide { max-width: 1180px; }
.main { padding-top: max(16px, env(safe-area-inset-top)); }

/* 하단 탭 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--tabs) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: center; gap: 4px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabs a { flex: 0 1 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--ink3); }
.tabs a.on { color: var(--accent); font-weight: 650; }

/* 머리 */
.logo { font: 650 30px/1 var(--serif); margin: 0; letter-spacing: -.01em; }
.logo i { font-style: italic; color: var(--accent); font-weight: 500; }
.logo sup { font: 600 10px var(--sans); color: var(--ink3); letter-spacing: .08em; text-transform: uppercase; margin-left: 4px; vertical-align: super; }
.home-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 0 8px; }
.tagline { margin: 0; font: italic 500 17px var(--serif); color: var(--ink2); }
.intro { margin: 6px 0 2px; color: var(--ink2); max-width: 560px; }
.intro-link { margin: 0 0 18px; }
.link { color: var(--sea); font-weight: 600; }
button.link { padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.muted { color: var(--ink3); }
.tiny { font-size: 12px; color: var(--ink3); line-height: 1.5; }
.foot { margin-top: 22px; text-align: center; }
.kicker { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.chip { display: inline-block; font: 700 10.5px var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--accentInk); background: var(--accent); padding: 2px 7px; border-radius: 999px; vertical-align: 2px; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--ink2); font-weight: 600; margin: 2px 0 8px -4px; }
.back svg { width: 20px; height: 20px; }

/* 얼굴 */
.face { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; background: var(--line); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--line2); }
.face img { width: 100%; height: 100%; object-fit: cover; }
.face b { font: 650 20px var(--serif); color: var(--ink2); }

/* 도시 엽서 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.postcard { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s ease; border: 1px solid var(--line); }
.postcard:hover { transform: translateY(-2px); }
.pc-thumb { position: relative; aspect-ratio: 16 / 8; background: linear-gradient(135deg, var(--sea), #8bb7c4); }
.pc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.postcard.asleep .pc-thumb img { filter: saturate(.7) brightness(.85); }
.pc-live { position: absolute; left: 10px; top: 10px; font: 700 10.5px var(--sans); letter-spacing: .08em; color: #fff; background: rgba(208, 40, 30, .85); padding: 2px 7px; border-radius: 4px; }
.pc-live:empty { display: none; }
.stamp { position: absolute; right: 10px; bottom: -18px; background: var(--paper); padding: 6px 10px 5px; border-radius: 4px; text-align: center; box-shadow: var(--shadow);
  outline: 2px dashed var(--line2); outline-offset: -5px; transform: rotate(2.5deg); }
.stamp b { display: block; font: 650 16px/1.1 var(--serif); }
.stamp small { font-size: 10px; color: var(--ink3); text-transform: uppercase; letter-spacing: .08em; }
.pc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.pc-who { display: flex; gap: 10px; align-items: center; padding-right: 90px; }
.pc-who b { display: block; font: 650 18px/1.2 var(--serif); }
.pc-who .muted { font-size: 13px; line-height: 1.35; display: block; }
.pc-now { display: flex; gap: 12px; align-items: baseline; font-size: 14px; color: var(--ink2); }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.pc-doing { margin: 0; font-size: 13.5px; color: var(--ink3); }
.pc-note { margin: 0; font: 600 21px/1.2 var(--hand); color: var(--ink); }
.pc-note.muted { font: 13.5px/1.4 var(--sans); color: var(--ink3); font-style: italic; }

/* 한 도시 */
.city { display: grid; gap: 18px; }
@media (min-width: 980px) {
  .city { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .chat { position: sticky; top: 14px; max-height: calc(100vh - 28px - var(--tabs)); }
}
.city-title { font: 650 28px/1.15 var(--serif); margin: 0 0 12px; }
.city-title i { font-style: italic; font-weight: 500; color: var(--ink3); }
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.stage iframe, .stage #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cam-off { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #e9e1d4; background: linear-gradient(160deg, #2f4b57, #1b2a31); padding: 20px; }
.cam-off p { margin: 2px 0; }
.strip { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 10px 2px 0; font-size: 14px; color: var(--ink2); }
.strip .sep { color: var(--line2); }
.live-dot { font: 700 11px var(--sans); letter-spacing: .08em; color: #d0281e; }
.live-dot.off { color: var(--ink3); }
.cam-credit { margin: 4px 2px 0; }
.cam-credit a { text-decoration: underline; text-underline-offset: 2px; }

.note { margin-top: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px 20px; }
.note-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.note-head b { display: block; font: 650 18px var(--serif); }
.note-head .muted, .note-head .doing { display: block; font-size: 13px; }
.doing { color: var(--sea); }
.note h2 { font: 650 22px/1.25 var(--serif); margin: 0 0 6px; }
.hand { font: 500 23px/34px var(--hand); color: var(--ink); background-image: repeating-linear-gradient(transparent 0 33px, color-mix(in srgb, var(--sea) 12%, transparent) 33px 34px); }
.hand p { padding-bottom: 0; }
.hand p { margin: 0 0 34px; } .hand p:last-child { margin: 0; }
.week { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 18px; }
.week summary { cursor: pointer; padding: 10px 0; font-weight: 650; color: var(--ink2); }
.old-note { border-top: 1px dashed var(--line2); padding: 14px 0 6px; }
.old-note h3 { font: 650 18px var(--serif); margin: 0 0 4px; }

/* 대화 */
.chat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 420px; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-head b { font: 650 17px var(--serif); }
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 260px; max-height: 60vh; }
@media (min-width: 980px) { .msgs { max-height: none; } }
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg .b { padding: 9px 13px; border-radius: 16px; line-height: 1.45; }
.msg .b p { margin: 0 0 6px; } .msg .b p:last-child { margin: 0; }
.msg time { font-size: 10.5px; color: var(--ink3); margin: 3px 6px 0; }
.msg.theirs { align-self: flex-start; }
.msg.theirs .b { background: var(--theirs); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .b { background: var(--mine); color: var(--mineInk); border-bottom-right-radius: 5px; }
.msg.care .b { background: var(--panel2); color: var(--ink); border: 1.5px solid var(--sun); }
.typing .b { display: flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.msg-err { align-self: center; margin: 0; font-size: 13px; color: var(--accent); text-align: center; }
.chat-empty { margin: auto; text-align: center; display: grid; justify-items: center; gap: 10px; padding: 18px; color: var(--ink2); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--panel2); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line2); background: var(--paper); color: var(--ink); border-radius: 18px; padding: 9px 14px; font: inherit; line-height: 1.4; max-height: 140px; }
.composer textarea:focus { outline: none; border-color: var(--sea); }
.disclose { margin: 0; padding: 8px 14px 12px; }

/* 쪽지 모음 */
.note-card { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.nc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.nc-head b { display: block; font: 650 16px var(--serif); }
.nc-head .muted { font-size: 12.5px; }
.note-card h3 { font: 650 20px var(--serif); margin: 0 0 4px; }

/* 버튼 · 시트 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 20px; border-radius: 999px; font-weight: 650; }
.btn-cta { background: var(--accent); color: var(--accentInk); }
.btn-ghost { border: 1px solid var(--line2); color: var(--ink2); }
.btn-danger { background: #b3362a; color: #fff; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; height: 42px; padding: 0; flex: none; }
.btn-icon svg { width: 20px; height: 20px; }
.btn:disabled { opacity: .5; }
.overlay, .modal { position: fixed; inset: 0; z-index: 120; background: rgba(30, 20, 10, .45); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.modal[hidden] { display: none; }
@media (min-width: 640px) { .overlay, .modal { align-items: center; } }
.sheet { position: relative; width: min(440px, 100%); background: var(--panel2); border-radius: 20px; padding: 22px 20px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow: auto; }
.sheet h2 { font: 650 22px var(--serif); margin: 0; padding-right: 26px; }
.sheet p { margin: 0; }
.sheet-x { position: absolute; right: 14px; top: 12px; font-size: 26px; line-height: 1; color: var(--ink3); }
.sheet textarea { border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; font: inherit; background: var(--paper); color: var(--ink); resize: vertical; }
.gbtn { min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.keep { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13.5px; color: var(--ink2); }
.warn { color: var(--accent); font-weight: 600; }
.err { color: #b3362a; margin: 0; font-size: 14px; }
.fb-stars { display: flex; gap: 4px; }
.fb-stars button { font-size: 30px; color: var(--line2); }
.fb-stars button.on { color: var(--sun); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 200;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; transition: .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--ink2); padding: 40px 12px; }

/* 입장 암호 · 나이 */
.dw-gate { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.gate-card .logo { font-size: 38px; margin-bottom: 6px; }
.gate-card p { margin: 0; color: var(--ink2); }
.gate-card input { border: 1px solid var(--line2); border-radius: 999px; padding: 12px 18px; font: inherit; background: var(--paper); color: var(--ink); text-align: center; }

/* Me */
.me-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 10px 0 16px; box-shadow: var(--shadow); }
.me-card b { display: block; font: 650 19px var(--serif); margin-bottom: 4px; }
.menu { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 22px; }
.menu > a, .menu > button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.menu > :last-child { border-bottom: 0; }
.menu svg { width: 18px; height: 18px; color: var(--ink3); }
.menu .danger { color: #b3362a; }
.sisters { margin-bottom: 16px; }
.sisters-title { font: 650 16px var(--serif); margin: 0 0 10px; }
.sisters-title a { text-decoration: underline; text-underline-offset: 2px; }
.sister-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.sister { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.sister img { grid-row: span 2; border-radius: 22%; background: #fff; }
.sister b { font-size: 14px; }
.sister span { font-size: 12px; color: var(--ink3); line-height: 1.35; }

/* 안내 */
.guide h1 { font: 650 30px var(--serif); margin: 0 0 10px; }
.guide h2 { font: 650 20px var(--serif); margin: 22px 0 6px; }
.guide ol { padding-left: 20px; line-height: 1.6; }
.guide li { margin-bottom: 6px; }
.steps3 { display: grid; gap: 10px; margin: 16px 0; }
@media (min-width: 640px) { .steps3 { grid-template-columns: repeat(3, 1fr); } }
.steps3 > div { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.steps3 i { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-style: normal; font-weight: 700; font-size: 13px; }
.steps3 b { display: block; margin: 8px 0 4px; font: 650 17px var(--serif); }
.steps3 p { margin: 0; font-size: 14px; color: var(--ink2); }
.guide > .btn { margin-top: 18px; }

/* 앱 설치 팝업 (시리즈 공통 install.js) */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.dwi { position: fixed; left: 0; right: 0; bottom: 0; z-index: 140; display: flex; justify-content: center; padding: 0 12px calc(var(--tabs) + 12px + env(safe-area-inset-bottom)); pointer-events: none; animation: fadeUp .4s ease both; }
.dwi-card { pointer-events: auto; width: min(440px, 100%); background: var(--panel2); color: var(--ink); border: 1px solid var(--line2); border-radius: 18px; padding: 16px 16px 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 12px; }
.dwi-head { display: flex; gap: 12px; align-items: flex-start; }
.dwi-head img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.dwi-head b { display: block; font-weight: 700; font-size: 16px; }
.dwi-head p { margin: 3px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink2); }
.dwi-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.dwi-btn { padding: 9px 14px; border-radius: 999px; font-size: 13px; }
.dwi-main { background: var(--accent); color: var(--accentInk); font-weight: 650; }
.dwi-ghost { border: 1px solid var(--line2); color: var(--ink2); }
.dwi-more { font-size: 13.5px; color: var(--ink); }
.dwi-steps { margin: 0; padding-left: 20px; line-height: 1.9; list-style: decimal; }
.dwi-ico { display: inline-flex; vertical-align: -4px; padding: 2px 4px; border-radius: 6px; background: var(--bg); color: #2f7fd8; }
.dwi-guide { margin: 0 0 8px; line-height: 1.6; }
