:root {
  --cream: #F7F3EC;
  --panel: #FFFDF9;
  --ink: #17140F;
  --ink-muted: #6B6459;
  --accent: #8B2635;
  --accent-soft: #F1E3E1;
  --line: #E4DDD0;
  --font-serif: "Noto Serif KR", serif;
  --font-body: "Pretendard", "IBM Plex Sans KR", sans-serif;
}
* { box-sizing: border-box; }
.mob-break { display: none; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font-body); font-size: 14px; min-height: 100vh; }
body { animation: pageIn .4s ease both; }
body.anim-settled { animation: none; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
body.leaving { animation: pageOut .28s ease both; }
@keyframes pageOut { to { opacity: 0; transform: translateY(-8px); } }

.topbar { padding: 20px max(28px, calc((100% - 1180px) / 2 + 28px)); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.topbar .mark { font-family: 'Space Grotesk'; font-weight: 700; font-size: 15px; letter-spacing: normal; text-decoration: none; color: var(--ink); }
.nav-links { display: flex; gap: 30px; font-size: 12px; letter-spacing: 0.03em; color: var(--ink-muted); }
.nav-links span { cursor: pointer; }
.nav-links span:hover { color: var(--accent); }
.nav-links span.active { color: var(--accent); font-weight: 700; cursor: default; }

.stage { max-width: 560px; margin: 0 auto; padding: 20px 28px 90px; }

.masthead { text-align: center; margin-bottom: 46px; }
.masthead .kicker { font-size: 11px; letter-spacing: 0.22em; color: var(--accent); text-transform: uppercase; margin-bottom: 14px; }
.masthead h1 { font-family: var(--font-serif); font-weight: 700; font-size: 40px; letter-spacing: -0.01em; margin-bottom: 12px; }
.masthead .sub { font-family: var(--font-serif); font-style: italic; font-size: 15px; color: var(--ink-muted); }
.inbox-fab {
  position: fixed; right: 22px; bottom: 26px; z-index: 55;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.55); color: var(--ink); text-decoration: none;
  border: 1px solid rgba(255,255,255,0.6);
  backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5);
  padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 20px rgba(23,20,15,0.16); cursor: pointer; transition: background .15s, transform .15s;
}
.inbox-fab svg { width: 16px; height: 16px; flex-shrink: 0; }
.inbox-fab:hover { background: rgba(255,255,255,0.75); transform: translateY(-2px); }

/* ===== Template picker ===== */
.tpl-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 40px; }
.tpl-btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 16px 6px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.tpl-btn .tpl-emoji { font-size: 20px; display: block; margin-bottom: 8px; }
.tpl-btn .tpl-label { font-size: 11px; color: var(--ink-muted); letter-spacing: 0.01em; }
.tpl-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.tpl-btn.selected .tpl-label { color: var(--accent); font-weight: 700; }
.tpl-btn:hover { border-color: var(--accent); }

.tpl-example { font-family: var(--font-serif); font-style: italic; font-size: 13.5px; color: var(--ink-muted); text-align: center; margin: -22px 0 40px; padding: 0 20px; line-height: 1.7; }

/* ===== Form ===== */
.field { margin-bottom: 26px; }
.field label { display: block; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 8px; }
.field input[type="text"], .field textarea {
  width: 100%; border: none; border-bottom: 1px solid var(--line); background: transparent;
  font-family: var(--font-body); font-size: 15px; color: var(--ink); padding: 8px 2px; outline: none;
  transition: border-color .15s;
}
.field input[type="text"]:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: none; min-height: 130px; line-height: 1.8; font-family: var(--font-serif); }
.char-count { text-align: right; font-size: 11px; color: var(--ink-muted); margin-top: 6px; }
.char-count.over { color: var(--accent); font-weight: 700; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== Photo upload / draw ===== */
.photo-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.photo-tab-btn {
  border: 1px solid var(--line); background: var(--panel, #fff); border-radius: 20px; padding: 6px 14px;
  font-size: 12px; color: var(--ink-muted); cursor: pointer;
}
.photo-tab-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.photo-drop {
  border: 1px dashed var(--line); border-radius: 6px; padding: 22px; text-align: center;
  cursor: pointer; font-size: 12.5px; color: var(--ink-muted); transition: border-color .15s;
}
.photo-drop:hover { border-color: var(--accent); }
.photo-preview-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.photo-preview-row canvas { border: 1px solid var(--line); border-radius: 4px; image-rendering: pixelated; width: 72px; height: 72px; }
.photo-remove { font-size: 11.5px; color: var(--accent); cursor: pointer; text-decoration: underline; }

.draw-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.palette-swatch { width: 22px; height: 22px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; }
.palette-swatch.selected { border-color: var(--ink); }
.draw-canvas {
  border: 1px solid var(--line); border-radius: 6px; touch-action: none; cursor: crosshair;
  width: 100%; max-width: 336px; height: auto; aspect-ratio: 1 / 1; image-rendering: pixelated;
}
.draw-actions { margin-top: 10px; }

/* ===== Unlock time ===== */
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.preset-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 7px 14px;
  font-size: 12px; color: var(--ink); cursor: pointer;
}
.preset-btn.selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.field input[type="datetime-local"] {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  font-family: var(--font-body); font-size: 14px; color: var(--ink); padding: 10px 12px; outline: none;
}

/* ===== Buttons ===== */
.seal-btn {
  width: 100%; background: var(--ink); color: #fff; border: none; border-radius: 4px;
  padding: 16px; font-family: var(--font-serif); font-size: 16px; letter-spacing: 0.03em; cursor: pointer;
  transition: background .15s;
}
.seal-btn:hover { background: var(--accent); }
.seal-btn:disabled { background: var(--line); color: var(--ink-muted); cursor: not-allowed; }
.seal-btn:disabled:hover { background: var(--line); }

.disclaimer { font-size: 11px; color: var(--ink-muted); text-align: center; margin-top: 16px; line-height: 1.7; }
.irrevocable-warning { font-size: 12px; color: #A0522D; background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; line-height: 1.5; }

/* ===== Share result ===== */
.share-result { text-align: center; padding: 40px 0; }
.share-result .env-icon { font-size: 44px; margin-bottom: 18px; }
.share-result h2 { font-family: var(--font-serif); font-size: 22px; margin-bottom: 10px; }
.share-result p { font-size: 13px; color: var(--ink-muted); margin-bottom: 26px; line-height: 1.7; }
.link-box {
  display: flex; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
  margin-bottom: 16px; align-items: center;
}
.link-box input { flex: 1; border: none; background: transparent; font-size: 12px; color: var(--ink-muted); outline: none; }
.share-actions { display: flex; gap: 10px; justify-content: center; }
.ghost-btn { background: transparent; border: 1px solid var(--line); border-radius: 4px; padding: 12px 20px; font-size: 13px; color: var(--ink); cursor: pointer; }
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Locked / reveal screen ===== */
.envelope-stage { text-align: center; padding: 60px 0 20px; }
.envelope {
  width: 220px; height: 150px; margin: 0 auto 34px; position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 20px 40px rgba(23,20,15,0.08);
}
.envelope::before {
  content: ''; position: absolute; top: 0; left: 0; width: 0; height: 0;
  border-left: 110px solid transparent; border-right: 110px solid transparent; border-top: 78px solid var(--cream);
}
.envelope .seal { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); font-size: 26px; }
.envelope-stage h2 { font-family: var(--font-serif); font-size: 20px; margin-bottom: 10px; }
.envelope-stage .countdown { font-family: var(--font-serif); font-size: 28px; color: var(--accent); margin-bottom: 10px; letter-spacing: 0.02em; }
.envelope-stage .unlock-date { font-size: 12.5px; color: var(--ink-muted); }
.locked-inbox-note { margin-top: 32px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); line-height: 1.8; }
.locked-inbox-note a { color: var(--accent); text-decoration: underline; cursor: pointer; }
.locked-inbox-caption { display: block; font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.locked-share-block { margin-top: 28px; text-align: left; }

/* ===== Letter reveal ===== */
.compose-paper {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 32px 28px 6px; margin-bottom: 26px;
}
.letter-paper {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 48px 36px; animation: paperIn .6s ease both;
}
@keyframes paperIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.letter-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-muted); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 28px; }
.letter-title { font-family: var(--font-serif); font-size: 24px; margin-bottom: 22px; line-height: 1.4; }
.letter-body { font-family: var(--font-serif); font-size: 16px; line-height: 2; white-space: pre-wrap; margin-bottom: 30px; }
.letter-sign { text-align: right; font-family: var(--font-serif); font-style: italic; font-size: 14px; color: var(--ink-muted); }
.hidden-link-row { text-align: center; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.hidden-link-btn { display: inline-block; font-size: 12.5px; color: var(--accent); text-decoration: underline; cursor: pointer; }
.reveal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.letter-expiry-note { text-align: center; font-size: 11.5px; color: #A69679; margin-top: 14px; }

.letter-photo-wrap { text-align: center; margin: 8px 0 34px; }
.letter-photo-wrap canvas {
  width: 220px; height: 220px; image-rendering: pixelated; border: 10px solid #fff;
  box-shadow: 0 14px 30px rgba(23,20,15,0.16); opacity: 0; animation: polaroidIn 1.4s ease 0.5s both;
}
@keyframes polaroidIn { 0% { opacity: 0; transform: scale(0.9) rotate(-3deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: scale(1) rotate(-1.5deg); } }

.write-again { text-align: center; margin-top: 34px; }
.write-again a { font-size: 12.5px; color: var(--ink-muted); text-decoration: underline; cursor: pointer; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 12.5px; z-index: 999; opacity: 0; transition: opacity .3s ease;
  max-width: calc(100vw - 48px); text-align: center; line-height: 1.5;
}
.toast.show { opacity: 1; }

.bottom-nav { display: none; }

@media (max-width: 480px) {
  .tpl-row { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .masthead h1 { font-size: 32px; }
  .letter-paper { padding: 34px 22px; }
}

@media (max-width: 760px) {
  .mob-break { display: inline; }
  .nav-links { display: none; }
  body { padding-bottom: 78px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(247,243,236,0.94); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; color: var(--ink-muted); font-weight: 600; text-decoration: none; padding: 4px 0; cursor: pointer;
  }
  .bottom-nav a .bicon { font-size: 19px; line-height: 1; display: flex; align-items: center; justify-content: center; }
  .bottom-nav a .bicon svg { width: 20px; height: 20px; }
  .bottom-nav a.active { color: var(--accent); }
  .inbox-fab { bottom: 92px; right: 16px; padding: 10px 16px; font-size: 12px; }
}


/* ===== Inbox page ===== */
.inbox-steps { margin-bottom: 30px; }
.inbox-steps .step { display: flex; gap: 12px; margin-bottom: 14px; align-items: center; }
.inbox-steps .num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1;
}
.inbox-steps p { font-size: 13px; color: var(--ink-muted); line-height: 1.6; margin: 0; }

.inbox-add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.inbox-add-row input {
  flex: 1; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  font-family: var(--font-body); font-size: 13px; color: var(--ink); padding: 12px 14px; outline: none;
}
.inbox-add-row input:focus { border-color: var(--accent); }

.inbox-notify-row { margin-bottom: 24px; }
.notify-status {
  font-size: 12px; color: var(--ink-muted); background: var(--accent-soft); border-radius: 6px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.notify-status .ghost-btn { padding: 7px 14px; font-size: 12px; flex-shrink: 0; }

.inbox-empty {
  text-align: center; color: var(--ink-muted); font-size: 13px; padding: 50px 20px;
  border: 1px dashed var(--line); border-radius: 6px; line-height: 1.8;
}

.inbox-card {
  display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 16px 18px; margin-bottom: 10px;
}
.inbox-card-icon { font-size: 24px; flex-shrink: 0; }
.inbox-card-body { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.inbox-card-title { font-family: var(--font-serif); font-size: 15px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inbox-kind-tag { font-family: var(--font-body); font-size: 10.5px; font-weight: 600; color: var(--ink-muted); background: var(--line); padding: 2px 8px; border-radius: 99px; }
.inbox-kind-tag.sent { color: #fff; background: var(--accent); }
.inbox-card-who { font-size: 11.5px; color: var(--ink-muted); margin-bottom: 4px; }
.inbox-card-status { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.inbox-card-status.unlocked { color: #2f7a4f; }
.inbox-card-remove { font-size: 11px; color: var(--ink-muted); text-decoration: underline; cursor: pointer; flex-shrink: 0; }
.inbox-card-remove:hover { color: var(--accent); }
.inbox-pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.inbox-page-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 12.5px; cursor: pointer; }
.inbox-page-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }

@media (max-width: 600px) {
  .inbox-add-row { flex-direction: column; }
  .inbox-add-row .ghost-btn { width: 100%; }
  .notify-status { flex-direction: column; align-items: flex-start; }
  .notify-status .ghost-btn { width: 100%; }
  .inbox-card { padding: 14px 14px; gap: 10px; }
}

/* ===== 나에게 쓰기 / D-day 등록 ===== */
.toself-field { margin-bottom: 26px; }
.toself-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; text-transform: none; letter-spacing: normal; margin-bottom: 0; }
.toself-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
#ddayButtonArea:empty { display: none; }
.dday-pending { margin-top: 10px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-muted); }
.dday-pending b { color: var(--ink); }
.dday-pending-cancel { font-size: 11.5px; color: var(--ink-muted); text-decoration: underline; background: none; border: none; cursor: pointer; }
.dday-blocked { margin-top: 10px; font-size: 12.5px; color: var(--ink-muted); }

.post-modal-backdrop { position: fixed; inset: 0; background: rgba(20,17,10,0.4); z-index: 100; display: flex; align-items: center; justify-content: center; }
.post-modal { background: rgba(255,255,255,0.55); backdrop-filter: blur(14px) saturate(1.5); -webkit-backdrop-filter: blur(14px) saturate(1.5); border: 1px solid rgba(255,255,255,0.6); border-radius: 20px; padding: 24px 22px 26px; width: 100%; max-width: 360px; margin: 20px; transition: transform 0.15s ease; }
.post-modal h3 { font-family: var(--font-serif); font-size: 16px; margin-bottom: 16px; }
.post-modal input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; font-size: 14px; margin-bottom: 16px; font-family: inherit; }
.post-modal .row-actions { display: flex; gap: 8px; }
.post-modal .row-actions button { flex: 1; padding: 12px; border-radius: 8px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; }
.post-modal .btn-save { background: var(--ink); color: #fff; }
.post-modal .btn-cancel { background: var(--accent-soft); color: var(--ink); }
.dday-invite { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: center; }
.dday-invite p { font-size: 13px; color: var(--ink); margin-bottom: 12px; }
.dday-invite .row-actions { display: flex; gap: 8px; }
.dday-invite .row-actions button { flex: 1; padding: 11px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.dday-invite .btn-save { background: var(--ink); color: #fff; }
.dday-invite .btn-cancel { background: var(--accent-soft); color: var(--ink); }
.dday-invite-note { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 12.5px; color: var(--ink-muted); text-align: center; }
@media (max-width: 600px) {
  .post-modal-backdrop { align-items: flex-end; }
  .post-modal { border-radius: 20px 20px 0 0; margin: 0; max-width: 100%; }
}

/* D-day 도달 연출은 홈메인에서만 발생하므로(styles.css 참고), 여기서는 별도 스타일 불필요 */
