/* 테마: config.js 의 theme 값 (blush | sage | sky | classic) */
:root {
  color-scheme: light;
  --radius: 18px;
  --serif: 'MapoFlowerIsland', 'Apple SD Gothic Neo', serif;
  --sans: 'Gowun Dodum', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --user-text: var(--text);
  --shadow: 0 1px 2px rgba(60, 30, 30, .05), 0 6px 20px rgba(60, 30, 30, .06);
}
/* 블러시: 화사한 핑크 */
:root, :root[data-theme="blush"] {
  --bg: #FFF9F8; --surface: #FFFFFF; --surface-2: #FBEFEE; --border: #F2E1DF;
  --text: #3B2F30; --muted: #A08C8B; --accent: #E07C86; --accent-soft: #FDE9EA;
  --user-bubble: #FDE3E4; --bg-glow: radial-gradient(120% 60% at 50% 0%, #FFEDEE 0%, #FFF9F8 60%);
}
/* 세이지: 싱그러운 그린 */
:root[data-theme="sage"] {
  --bg: #F8FAF6; --surface: #FFFFFF; --surface-2: #EEF3EC; --border: #DFE8DC;
  --text: #2D3530; --muted: #7D8B80; --accent: #6F9A78; --accent-soft: #E5F0E7;
  --user-bubble: #E3EFE4; --bg-glow: radial-gradient(120% 60% at 50% 0%, #EAF3E8 0%, #F8FAF6 60%);
}
/* 스카이: 밝은 메신저 느낌 */
:root[data-theme="sky"] {
  --bg: #F6F9FE; --surface: #FFFFFF; --surface-2: #EDF2FB; --border: #DEE6F3;
  --text: #24304A; --muted: #7E8AA3; --accent: #4F7FE0; --accent-soft: #E3ECFC;
  --user-bubble: #4F7FE0; --user-text: #FFFFFF; --bg-glow: radial-gradient(120% 60% at 50% 0%, #E6EEFD 0%, #F6F9FE 60%);
}
/* 클래식: 아이보리·테라코타 (밝은 톤) */
:root[data-theme="classic"] {
  --bg: #FCFBF8; --surface: #FFFFFF; --surface-2: #F5F2EC; --border: #EEE8DE;
  --text: #2F2B26; --muted: #8C8579; --accent: #CC7A5C; --accent-soft: #FAEDE6;
  --user-bubble: #F3EEE6; --bg-glow: radial-gradient(120% 60% at 50% 0%, #FFF3EA 0%, #FCFBF8 60%);
  --shadow: 0 1px 2px rgba(80, 50, 30, .04), 0 6px 20px rgba(80, 50, 30, .05);
}
/* 클래식(처음 버전, 진한 톤) */
:root[data-theme="classic-dark"] {
  --bg: #F5F3EE; --surface: #FFFFFF; --surface-2: #EFECE4; --border: #E3DED3;
  --text: #2B2A27; --muted: #7A766C; --accent: #B5654A; --accent-soft: #F3E4DC;
  --user-bubble: #EAE6DC; --bg-glow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 15.5px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { max-width: 640px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; }

/* 상단바 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 8px; }
.mark { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2; }
.title { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.icon-btn { border: 0; background: transparent; padding: 8px; border-radius: 10px; color: var(--muted); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg, .send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 대화 영역 */
.chat { position: relative; flex: 1; overflow-y: auto; padding: 20px 16px 28px; overscroll-behavior: contain; touch-action: pan-y; }
.msg { margin-bottom: 22px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-text); padding: 9px 14px; border-radius: 18px 18px 4px 18px; max-width: 80%;
}
.msg.bot { display: flex; gap: 10px; align-items: flex-start; }
.msg.bot .avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft);
  display: grid; place-items: center; margin-top: 2px;
}
.msg.bot .avatar svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.2; }
.msg.bot .body { flex: 1; min-width: 0; }
.body > * + * { margin-top: 12px; }
.body p { margin: 0; white-space: pre-line; }
.body h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13.5px; }
.fade { animation: rise .4s ease both; }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* 카드 */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
.card h4 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.big-date { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.4; }
.dday { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.family { display: grid; gap: 6px; }
.family div { display: flex; justify-content: space-between; gap: 8px; }
.family b { font-weight: 600; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 9px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text);
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; }
.btn.block { width: 100%; justify-content: center; }

/* 갤러리 */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 14px; overflow: hidden; }
.gallery button { border: 0; padding: 0; aspect-ratio: 1; background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 폼 */
.field { display: grid; gap: 4px; }
.field + .field { margin-top: 10px; }
.field label { font-size: 13px; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: 10px; padding: 9px 12px; outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px; border-radius: 8px; font-size: 14px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.form-actions { margin-top: 14px; }
.err { color: #C0392B; font-size: 13px; min-height: 1em; margin-top: 6px; }

/* 축하의 말 */
.gb-list { display: grid; gap: 8px; }
.gb-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.gb-item .meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.gb-item .meta b { color: var(--text); font-weight: 600; }
.gb-item p { margin: 4px 0 0; white-space: pre-line; word-break: break-word; }
.gb-item .del { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 2px 4px; }
.gb-del { display: flex; gap: 6px; margin-top: 8px; }
.gb-del .input { padding: 5px 10px; }

/* 오시는 길 */
.addr { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.transport { display: grid; gap: 10px; }
.transport p { white-space: pre-line; margin: 2px 0 0; }

/* 계좌 */
.acc-group { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.acc-group + .acc-group { margin-top: 8px; }
.acc-group summary { list-style: none; padding: 13px 16px; font-weight: 600; display: flex; justify-content: space-between; cursor: pointer; }
.acc-group summary::-webkit-details-marker { display: none; }
.acc-group summary::after { content: '⌄'; color: var(--muted); transition: transform .2s; }
.acc-group[open] summary::after { transform: rotate(180deg); }
.acc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.acc-row small { display: block; color: var(--muted); font-size: 12.5px; }

/* 하객 사진 */
.upload-drop {
  display: grid; place-items: center; gap: 4px; padding: 22px 12px; border: 1.5px dashed var(--border);
  border-radius: 14px; text-align: center; color: var(--muted); background: var(--bg); cursor: pointer;
}
.upload-drop strong { color: var(--text); font-weight: 600; }
.upload-drop input { display: none; }
.progress { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.mine { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mine .ph { position: relative; aspect-ratio: 1; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.mine img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mine .x {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 24px; padding: 0;
}

/* 하단 입력부 */
.composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 85%, transparent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 99px;
  padding: 6px 13px; font-size: 13.5px; white-space: nowrap; color: var(--text);
}
.chip.used { color: var(--muted); }
.chip.used::before { content: '✓ '; color: var(--accent); }
.chip.next { border-color: var(--accent); }
.inputbox {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow);
}
.inputbox input { flex: 1; border: 0; outline: none; background: transparent; padding: 6px 0; min-width: 0; font-size: 16px; }
.send { flex: none; width: 34px; height: 34px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; }
.hint { margin: 6px 0 0; text-align: center; font-size: 12px; color: var(--muted); transition: opacity .4s; }
.hint.gone { opacity: 0; }

/* 라이트박스 */
.lightbox { position: fixed; inset: 0; background: rgba(15, 12, 10, .94); display: grid; place-items: center; z-index: 50; touch-action: none; }
.lightbox[hidden] { display: none; }
.lightbox { overflow: hidden; }
.lightbox img { max-width: 100vw; max-height: 86vh; object-fit: contain; transform-origin: center; transition: transform .15s ease-out; will-change: transform; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lightbox.zoomed img { transition: none; }
.lightbox.zoomed .lb-count { opacity: 0; }
.lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; border: 0; background: rgba(255,255,255,.15); color: #fff; width: 38px; height: 38px; border-radius: 50%; }
.lb-count { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); color: #ddd; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 140px; transform: translate(-50%, 10px); background: #2B2A27; color: #fff;
  padding: 8px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.card > div > .field:first-child { margin-top: 10px; }
@keyframes flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 3px var(--accent); } }
.bubble.flash { animation: flash 1s ease; }
.gb-head { margin: 4px 0 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.gb-wrap .btn.block { margin-top: 8px; }
.gb-item p.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.gb-item .more { border: 0; background: none; padding: 2px 0 0; font-size: 13px; color: var(--accent); }
.gb-item .more[hidden] { display: none; }
[hidden] { display: none !important; }
.map-card { display: block; position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.map-box { height: 200px; background: var(--surface-2); }
.map-box * { pointer-events: none; }
.map-placeholder { height: 100%; display: grid; place-content: center; text-align: center; gap: 2px;
  background: repeating-linear-gradient(45deg, var(--surface-2) 0 12px, var(--bg) 12px 24px); }
.map-placeholder span { font-size: 13px; color: var(--muted); }
.map-open { position: absolute; right: 8px; bottom: 8px; z-index: 2; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; box-shadow: var(--shadow); }
.map-label { background: #fff; color: #2B2A27; border: 1px solid #ddd; border-radius: 99px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.15); }

/* 화사함 보강 */
body { background: var(--bg-glow, none), var(--bg); background-attachment: fixed; }
.topbar, .composer { background: transparent; }
.topbar { backdrop-filter: saturate(1.2) blur(8px); -webkit-backdrop-filter: saturate(1.2) blur(8px); background: color-mix(in srgb, var(--bg) 70%, transparent); }
.composer { background: linear-gradient(to top, var(--bg) 80%, transparent); }
.chip.next { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.used::before { color: var(--accent); }
.dday { background: var(--accent); color: #fff; }

/* 첫 화면 커버 사진 */
.cover { position: relative; border-radius: 22px; overflow: hidden; aspect-ratio: 4 / 5; box-shadow: var(--shadow); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.5), rgba(0,0,0,0) 55%); }
.cover-text { position: absolute; left: 0; right: 0; bottom: 18px; z-index: 1; text-align: center; color: #fff; }
.cover-text .names { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .02em; }
.cover-text .when { font-size: 13.5px; opacity: .92; margin-top: 2px; }
.cover-text .names.en-serif { font-family: 'Cormorant Garamond', serif; font-style: italic; font-weight: 500; font-size: 32px; letter-spacing: .01em; }
.cover-text .names.en-script { font-family: 'Pinyon Script', cursive; font-weight: 400; font-size: 38px; letter-spacing: 0; }

/* 커버 아래 여백 */
.body > .cover { margin-bottom: 14px; }

/* 달력 + 카운트다운 */
.cal-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.cal-title b { font-family: var(--serif); font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; row-gap: 4px; font-size: 14px; }
.cal-grid span { height: 34px; line-height: 34px; }
.cal-w { color: var(--muted); font-size: 12px; }
.cal-grid .sun { color: #D9534F; }
.cal-d.on { background: var(--accent); color: #fff !important; border-radius: 50%; width: 34px; margin: 0 auto; font-weight: 600; }
.cd-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.cd { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cd-box { background: var(--surface-2); border-radius: 12px; padding: 8px 0; text-align: center; }
.cd-box b { display: block; font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }
.cd-box small { color: var(--muted); font-size: 11.5px; }
.cd-msg { text-align: center; margin: 0 0 10px !important; font-size: 13.5px; color: var(--muted); }

/* 예식 순서 */
.timeline { list-style: none; margin: 4px 0 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 50px; top: 8px; bottom: 8px; border-left: 1.5px solid var(--border); }
.timeline li { display: flex; gap: 16px; align-items: flex-start; padding: 6px 0; position: relative; }
.timeline time { width: 42px; flex: none; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: 14px; padding-top: 1px; }
.timeline li::before { content: ''; position: absolute; left: 46px; top: 13px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); }
.timeline li > div { padding-left: 8px; }
.timeline small { display: block; color: var(--muted); font-size: 13px; }
.cal-alt { display: inline-block; margin-top: 8px; font-size: 12.5px; }
.faq-img { width: 100%; max-width: 280px; border-radius: 14px; display: block; }
.upload-drop.disabled { opacity: .5; }
.map-app { gap: 7px; }
.map-app-icon { width: 20px; height: 20px; border-radius: 5px; flex: none; object-fit: cover; }
.map-app-icon.pin { display: grid; place-items: center; background: var(--accent-soft); }
.map-app-icon.pin svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.map-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.map-row .btn { justify-content: center; padding: 9px 6px; font-size: 13.5px; }
.map-row .btn.map-app { gap: 4px; padding: 6px 4px; font-size: 12px; white-space: nowrap; border-radius: 10px; }
.map-row .map-app-icon { width: 16px; height: 16px; border-radius: 4px; }
.map-row .map-app-icon.pin svg { width: 11px; height: 11px; }

/* 첫 화면 (인트로) */
.intro { display: none; }
.app.is-intro .chat { display: none; }
.app.is-intro .intro {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-top: auto; padding: 0 24px 22px; animation: rise .6s ease both;
}
.app.is-intro .composer { margin-bottom: auto; background: none; }
.app.is-intro .chips { flex-wrap: wrap; justify-content: center; overflow: visible; order: 2; padding: 10px 0 0; }
.app.is-intro .composer { display: flex; flex-direction: column; }
.app.is-intro .inputbox { order: 1; }
.app.is-intro .hint { display: none; }
.intro-mark { width: 54px; height: 54px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; margin-bottom: 18px; }
.intro-mark svg { width: 32px; height: 32px; fill: none; stroke: var(--accent); stroke-width: 2; }
.intro h1 { font-family: var(--serif); font-size: 30px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.intro-sub { margin: 10px 0 0; font-size: 15px; }
.intro-when { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.intro-open { margin-top: 18px; border-radius: 99px; padding: 8px 18px; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }

/* 첫 화면 사진 */
.intro-photo { width: 168px; aspect-ratio: 4 / 5; border-radius: 84px 84px 18px 18px; overflow: hidden; margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(80, 50, 30, .16); border: 4px solid var(--surface); }
.intro-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.intro-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.intro-bg img { width: 100%; height: 100%; object-fit: cover; }
.intro-bg::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 10%, transparent) 0%, color-mix(in srgb, var(--bg) 55%, transparent) 35%, var(--bg) 62%); }
.app.intro-has-bg { position: relative; z-index: 1; }
.app.intro-has-bg .topbar { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom-color: transparent; }
.app.intro-has-bg .intro { margin-top: auto; padding-top: 40vh; }
.gallery-more { margin-top: 8px; }

/* 확대 막기 보조: 두 번 탭 확대 끄기, 입력칸 포커스 시 iOS 자동 확대 방지(16px 이상) */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.input, textarea.input, select.input, .inputbox input { font-size: 16px; }
