/* ==========================================================================
   둘만의 비밀 연애 교환일기 — style.css
   크림/로즈 톤 · 모바일 390×844 최적화 · 라이트/다크
   ========================================================================== */

:root {
  --bg: #fff7f2;
  --bg-2: #ffeef2;
  --card: #ffffff;
  --card-2: #fffaf7;
  --text: #3c2b30;
  --muted: #96797f;
  --line: #f2dfe2;
  --rose: #d9536f;
  --rose-2: #e8758c;
  --rose-soft: #ffe3e9;
  --rose-deep: #b93e58;
  --gold: #c9a227;
  --shadow: 0 10px 30px -12px rgba(184, 92, 112, .28);
  --shadow-soft: 0 4px 16px -8px rgba(184, 92, 112, .22);
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --serif: "Nanum Myeongjo", "AppleMyungjo", "Noto Serif KR", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #170f13;
  --bg-2: #21141a;
  --card: #251a20;
  --card-2: #2c1f26;
  --text: #f6e9ed;
  --muted: #bda1aa;
  --line: #3a2931;
  --rose: #f27a97;
  --rose-2: #ff9ab2;
  --rose-soft: #43202b;
  --rose-deep: #ffb3c5;
  --gold: #e3c45c;
  --shadow: 0 12px 34px -14px rgba(0, 0, 0, .6);
  --shadow-soft: 0 4px 16px -8px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  letter-spacing: -0.01em;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transition: background .25s ease, color .25s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(58% 38% at 82% 2%, rgba(255, 190, 205, .55), transparent 70%),
    radial-gradient(50% 34% at 8% 22%, rgba(255, 222, 196, .5), transparent 72%);
}

[data-theme="dark"] .dday-band {
  background:
    radial-gradient(120% 150% at 88% -30%, rgba(255, 255, 255, .09), transparent 62%),
    linear-gradient(140deg, var(--rose-soft), color-mix(in srgb, var(--rose-soft) 40%, var(--card)));
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(58% 38% at 82% 2%, rgba(150, 45, 75, .38), transparent 70%),
    radial-gradient(50% 34% at 8% 22%, rgba(120, 70, 40, .28), transparent 72%);
}

.glow { display: none; }

img { max-width: 100%; display: block; }

[hidden] { display: none !important; }

.skip {
  position: absolute; left: -9999px; top: 0;
}
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--card); padding: 8px 12px; border-radius: 8px; }

/* ---------- 레이아웃 ---------- */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) 18px calc(var(--safe-bottom) + 24px);
}

.room { padding-bottom: calc(var(--safe-bottom) + 104px); }

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo-mark { font-size: 22px; filter: drop-shadow(0 3px 6px rgba(217, 83, 111, .3)); }
.logo-text { font-family: var(--serif); font-size: 17px; letter-spacing: -.02em; }

.iconbtn {
  appearance: none; border: 1px solid var(--line);
  background: var(--card);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--text);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 17px; line-height: 1; cursor: pointer;
  display: inline-grid; place-items: center;
  transition: transform .12s ease, background .2s ease;
}
.iconbtn:active { transform: scale(.94); }
.iconbtn.small { width: 32px; height: 32px; font-size: 14px; }

/* ---------- 히어로 ---------- */
.hero { padding: 10px 2px 4px; text-align: center; }

.eyebrow {
  font-size: 10.5px; letter-spacing: .22em; color: var(--rose);
  font-weight: 700; margin: 0 0 12px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: 31px; line-height: 1.32; margin: 0 0 14px;
  letter-spacing: -.03em; font-weight: 400;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--rose), #f09a6a 70%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.lead { color: var(--muted); font-size: 14px; margin: 0 0 22px; line-height: 1.7; }

.hero-cards {
  position: relative; height: 188px; margin: 4px 0 16px;
}
.mini-card {
  position: absolute; width: 190px; padding: 12px 14px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
  text-align: left; font-size: 12.5px; line-height: 1.5;
}
.mini-card p { margin: 4px 0 6px; color: var(--text); }
.mini-card .mini-mood { font-size: 18px; }
.mini-card .mini-heart {
  display: inline-block; font-size: 11px; background: var(--rose-soft);
  color: var(--rose-deep); padding: 2px 7px; border-radius: 20px;
}
.mini-card.a { left: 4px; top: 6px; transform: rotate(-4deg); }
.mini-card.b { right: 4px; top: 58px; transform: rotate(3.2deg); background: var(--card-2); }

.hero-actions { display: grid; gap: 9px; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 15px;
  font-family: var(--sans); font-size: 15px; font-weight: 700;
  padding: 14px 18px; cursor: pointer; width: 100%;
  transition: transform .12s ease, filter .2s ease, background .2s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary {
  background: linear-gradient(135deg, var(--rose-2), var(--rose) 55%, var(--rose-deep));
  color: #fff; box-shadow: 0 10px 22px -10px rgba(217, 83, 111, .75);
}
.btn.primary:disabled { filter: grayscale(.4) brightness(.95); opacity: .7; }
.btn.ghost {
  background: var(--card);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  color: var(--text); border-color: var(--line);
}
.btn.text { background: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 10px; }
.btn.text.danger { color: var(--rose-deep); }
.btn.tiny { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn.continue {
  background: linear-gradient(135deg, #fff1f4, #ffe0e7);
  color: var(--rose-deep); border: 1px solid color-mix(in srgb, var(--rose) 26%, var(--line));
  box-shadow: var(--shadow-soft);
}
[data-theme="dark"] .btn.continue { background: linear-gradient(135deg, #34202a, #432330); }

.fine { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin: 12px 0 0; }
.fine b { color: var(--rose-deep); font-weight: 700; }

/* ---------- 광고 자리 ---------- */
.ad {
  margin: 26px 0; min-height: 74px;
  border: 1px dashed var(--line);
  border: 1px dashed color-mix(in srgb, var(--rose) 30%, var(--line));
  border-radius: 16px; background: var(--card);
  background: color-mix(in srgb, var(--card) 45%, transparent);
  display: grid; place-items: center;
}
.ad.slim { min-height: 52px; margin: 10px 0 14px; border-radius: 14px; }
.ad-note { font-size: 10.5px; letter-spacing: .12em; color: var(--muted); opacity: .75; }

/* ---------- 소개 ---------- */
.features { display: grid; gap: 12px; margin: 6px 0 10px; }
.feature {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-soft);
}
.feature h2 { font-size: 15px; margin: 6px 0 4px; font-weight: 700; letter-spacing: -.02em; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.f-ico { font-size: 20px; }

.foot { text-align: center; padding: 26px 4px 8px; color: var(--muted); font-size: 12px; }
.foot p { margin: 0 0 8px; }
.foot.small { padding: 18px 4px 4px; }

/* ---------- 방 헤더 ---------- */
.room-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 2px 10px;
  margin: 0 -18px; padding-left: 14px; padding-right: 14px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.room-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
.room-title span:first-child {
  font-family: var(--serif); font-size: 16.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pill {
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
  background: var(--rose-soft); color: var(--rose-deep);
  padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.head-actions { display: flex; gap: 6px; }
.head-actions .iconbtn { width: 34px; height: 34px; font-size: 15px; }

/* ---------- D-Day ---------- */
.dday-band {
  position: relative; margin: 16px 0 18px; padding: 20px 20px 18px;
  border-radius: var(--radius);
  background: var(--rose-soft);
  background:
    radial-gradient(120% 150% at 88% -30%, rgba(255, 255, 255, .5), transparent 60%),
    linear-gradient(140deg, var(--rose-soft), color-mix(in srgb, var(--rose-soft) 40%, var(--card)));
  border: 1px solid color-mix(in srgb, var(--rose) 18%, var(--line));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dday-main { display: flex; align-items: baseline; gap: 7px; }
.dday-label { font-size: 13px; color: var(--rose-deep); font-weight: 700; letter-spacing: -.01em; }
.dday-main strong {
  font-family: var(--serif); font-size: 44px; line-height: 1;
  color: var(--rose-deep); letter-spacing: -.04em;
}
.dday-unit { font-size: 13px; color: var(--rose-deep); font-weight: 700; }
.dday-meta {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  font-size: 12px; color: color-mix(in srgb, var(--rose-deep) 70%, var(--muted));
}
.dday-meta .dot { opacity: .5; }
.hearts { position: absolute; right: 14px; bottom: 12px; display: flex; gap: -2px; opacity: .5; }
.hearts i {
  font-style: normal; color: var(--rose); font-size: 15px;
  transform: rotate(-8deg); animation: beat 3.4s ease-in-out infinite;
}
.hearts i:nth-child(2) { animation-delay: .4s; transform: rotate(4deg) translateY(-4px); font-size: 12px; }
.hearts i:nth-child(3) { animation-delay: .9s; transform: rotate(-2deg); font-size: 9px; }
@keyframes beat {
  0%, 100% { opacity: .55; }
  45% { opacity: 1; }
}

/* ---------- 오늘의 질문 ---------- */
.q-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px 18px;
  box-shadow: var(--shadow-soft); margin-bottom: 22px;
}
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q-tag {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  color: var(--rose-deep); background: var(--rose-soft);
  padding: 4px 9px; border-radius: 20px;
}
.q-date { font-size: 11.5px; color: var(--muted); }
.q-text {
  font-family: var(--serif); font-size: 18px; line-height: 1.55;
  margin: 12px 0 14px; letter-spacing: -.02em;
}

.q-answer-mine {
  background: var(--rose-soft);
  background: color-mix(in srgb, var(--rose-soft) 55%, var(--card));
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.q-answer-mine .tag, .q-partner .tag {
  display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  color: var(--rose-deep); margin-bottom: 4px;
}
.q-input { display: grid; gap: 8px; }
.q-input textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card-2); color: var(--text); font-family: var(--sans);
  font-size: 14px; line-height: 1.6; padding: 11px 12px; resize: none;
  min-height: 62px;
}
.q-input textarea:focus { outline: 2px solid var(--rose-2); outline-offset: 1px; }
.q-input .btn { padding: 11px; font-size: 14px; border-radius: 13px; }

.q-partner {
  margin-top: 10px; padding: 11px 13px;
  border-radius: var(--radius-sm); background: var(--card-2);
  border: 1px solid var(--line); font-size: 13.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
/* 잠금 상태에서 답변을 숨기는 흐림 바 */
.blur-veil {
  margin-top: 10px; padding: 12px 13px; border-radius: var(--radius-sm);
  background: var(--rose-soft);
  background: linear-gradient(100deg, var(--card-2), var(--rose-soft));
  border: 1px dashed var(--rose-2);
  color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px;
}

/* ---------- 타임라인 ---------- */
.timeline { margin-top: 4px; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 10px; }
.tl-head h2 { font-size: 15px; margin: 0; letter-spacing: -.02em; }
.tl-count { font-size: 12px; color: var(--muted); }

.tl-day { margin: 18px 0 8px; display: flex; align-items: center; gap: 10px; }
.tl-day span {
  font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap;
  letter-spacing: .02em;
}
.tl-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.entry {
  position: relative;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px 12px;
  box-shadow: var(--shadow-soft); margin-bottom: 10px;
  animation: rise .28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.entry.mine { background: var(--card-2); border-color: var(--line); border-color: color-mix(in srgb, var(--rose) 16%, var(--line)); }

.entry-head { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 17px;
  background: var(--rose-soft); border: 1px solid color-mix(in srgb, var(--rose) 18%, var(--line));
}
.entry-who { flex: 1; min-width: 0; }
.entry-name { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.entry-name .tagmine {
  font-size: 9.5px; font-weight: 800; color: var(--rose-deep);
  background: var(--rose-soft); padding: 1px 5px; border-radius: 6px;
}
.entry-time { font-size: 11px; color: var(--muted); }
.entry-mood { font-size: 20px; flex: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,.08)); }

.entry-text {
  margin: 10px 2px 2px; font-size: 14.5px; line-height: 1.72;
  white-space: pre-wrap; word-break: break-word;
}

.reacts { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.react {
  appearance: none; cursor: pointer; font-family: var(--sans);
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 20px; padding: 4px 9px 4px 7px; font-size: 12px;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.react:active { transform: scale(.92); }
.react .em { font-size: 13.5px; filter: grayscale(.15); }
.react .n { font-size: 11px; font-weight: 700; }
.react[data-on="1"] {
  background: var(--rose-soft); border-color: var(--rose-2);
  border-color: color-mix(in srgb, var(--rose) 45%, var(--line));
  color: var(--rose-deep);
}
.react.own { cursor: default; opacity: .9; }
.react.static { cursor: default; }

.empty {
  text-align: center; padding: 26px 18px; border-radius: var(--radius);
  border: 1px dashed var(--line); color: var(--muted); font-size: 13px; line-height: 1.7;
}
.empty .big { display: block; font-size: 26px; margin-bottom: 8px; }

.skeleton { height: 88px; border-radius: var(--radius); background: var(--card-2); background: color-mix(in srgb, var(--card) 60%, var(--line)); margin-bottom: 10px; opacity: .6; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .65; } }

/* ---------- 하단 작성 바 ---------- */
.compose-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 18px calc(var(--safe-bottom) + 12px);
  background: var(--bg);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  max-width: 480px; margin: 0 auto;
}
.compose-bar .btn { box-shadow: 0 12px 26px -12px rgba(217,83,111,.8); }

/* ---------- 시트 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(46, 22, 30, .42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative; z-index: 1; width: 100%; max-width: 480px;
  max-height: 92vh;
  max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(var(--safe-bottom) + 20px);
  box-shadow: 0 -20px 50px -20px rgba(60, 30, 40, .4);
  animation: slide .28s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes slide { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-grip {
  width: 40px; height: 4px; border-radius: 4px; margin: 2px auto 12px;
  background: var(--line);
}
.sheet-title { font-family: var(--serif); font-size: 21px; margin: 0 0 6px; letter-spacing: -.02em; }
.sheet-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; line-height: 1.65; }

.field { display: block; margin-bottom: 13px; }
.flabel { display: block; font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.flabel .opt { font-style: normal; font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 2px; }
.fhint { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.55; }
.fhint.right { text-align: right; }

input[type="text"], input[type="tel"], input[type="date"], textarea {
  width: 100%; font-family: var(--sans); font-size: 15px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 13px; transition: border-color .15s ease, background .15s ease;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus {
  outline: none; border-color: color-mix(in srgb, var(--rose) 60%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rose) 12%, transparent);
}
textarea { resize: none; line-height: 1.65; }
::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.moods { display: flex; gap: 7px; overflow-x: auto; padding: 4px 0 10px; margin: 0 -2px; }
.mood {
  appearance: none; border: 1px solid var(--line); background: var(--card-2);
  width: 42px; height: 42px; border-radius: 14px; font-size: 21px; cursor: pointer;
  flex: none; display: grid; place-items: center; transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.mood[data-on="1"] {
  background: var(--rose-soft); border-color: var(--rose); transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 16px -10px rgba(217,83,111,.8);
}

.sheet-actions { display: flex; gap: 9px; margin-top: 16px; }
.sheet-actions .btn { padding: 13px; font-size: 14.5px; }
.sheet-actions.stack { display: grid; gap: 8px; }

.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 13.5px; margin: 4px 0 2px;
}

/* 초대 시트 */
.code-box {
  text-align: center; padding: 16px 10px 14px; border-radius: var(--radius);
  background: var(--rose-soft);
  background: linear-gradient(140deg, var(--rose-soft), color-mix(in srgb, var(--rose-soft) 30%, var(--card)));
  border: 1px solid var(--line);
  border: 1px solid color-mix(in srgb, var(--rose) 20%, var(--line));
  margin-bottom: 12px;
}
.code-label { display: block; font-size: 10.5px; letter-spacing: .16em; color: var(--rose-deep); font-weight: 800; }
.code {
  display: block; font-family: var(--serif); font-size: 36px; letter-spacing: .22em;
  color: var(--rose-deep); margin-top: 4px; padding-left: .22em;
}
.invite-link {
  font-size: 11.5px; color: var(--muted); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  word-break: break-all; line-height: 1.5; text-align: center;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 92px);
  transform: translate(-50%, 12px); z-index: 90;
  max-width: min(340px, calc(100vw - 36px));
  background: color-mix(in srgb, #2b1a20 92%, transparent); color: #fff8f5;
  font-size: 13px; line-height: 1.5; padding: 11px 16px; border-radius: 14px;
  box-shadow: 0 14px 30px -12px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease;
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
body.sheet-open .toast { bottom: auto; top: calc(var(--safe-top) + 14px); transform: translate(-50%, -12px); }
body.sheet-open .toast.on { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 아주 작은 화면(360 이하) 보정 */
@media (max-width: 360px) {
  .hero h1 { font-size: 27px; }
  .dday-main strong { font-size: 38px; }
  .code { font-size: 30px; }
}
