@font-face { font-family: "MaruBuri"; font-weight: 400; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Regular.woff2) format("woff2"); }
@font-face { font-family: "MaruBuri"; font-weight: 500; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Regular.woff2) format("woff2"); }
@font-face { font-family: "MaruBuri"; font-weight: 600; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-SemiBold.woff2) format("woff2"); }
@font-face { font-family: "MaruBuri"; font-weight: 700; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/MaruBuri/MaruBuri-Bold.woff2) format("woff2"); }
:root {
  color-scheme: light;
  --ink: #2f2925;
  --muted: #766d65;
  --accent: #a84445;
  --accent-dark: #883436;
  --paper: #fffaf5;
  --line: #e9ded3;
  --soft: #f6ede5;
  --shadow: 0 15px 35px rgba(78, 49, 36, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background: #f2ebe4;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #f2ebe4; }

body {
  word-break: keep-all;
  overflow-wrap: anywhere;
  min-width: 320px;
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 100% 0, rgba(208, 151, 126, 0.13), transparent 30%),
    var(--paper);
  box-shadow: 0 0 50px rgba(73, 54, 41, 0.08);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(168, 68, 69, 0.28);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 22px 12px;
}

.site-header p { margin: 0; font-size: 0.72rem; color: var(--muted); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 0;
  background: transparent;
  font-family: "MaruBuri", serif;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 48% 52%;
  color: #fff;
  background: var(--accent);
  font-size: 0.8rem;
}

main { padding: 12px 20px 36px; }
.screen { animation: rise 0.35s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.intro, .section-heading { padding: 24px 4px 22px; }
.eyebrow, .step {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-family: "MaruBuri", "Batang", serif;
  font-size: clamp(1.8rem, 8vw, 2.35rem);
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.intro p, .complete-heading p { margin: 12px 0 0; color: var(--muted); font-size: 0.92rem; }

.theme-fieldset { display: grid; gap: 11px; margin: 0; padding: 0; border: 0; }
.theme-option { position: relative; display: block; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option > span:nth-of-type(2) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 82px;
  padding: 13px 48px 13px 82px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 20px rgba(73, 50, 35, 0.07);
  transition: 0.2s ease;
}
.theme-option strong { font-size: 1.04rem; }
.theme-option small { margin-top: 2px; color: var(--muted); font-size: 0.77rem; }
.theme-option input:checked ~ span:nth-of-type(2) { border-color: var(--accent); background: #fffaf9; }
.theme-option input:focus-visible ~ span:nth-of-type(2) { outline: 3px solid rgba(168, 68, 69, 0.25); }

.theme-icon {
  position: absolute;
  z-index: 1;
  left: 16px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  transform: translateY(-50%);
  font-family: "MaruBuri", serif;
  font-size: 1.1rem;
  font-weight: 700;
}
.theme-icon--suneung { color: #fff; background: #53627d; }
.theme-icon--morning { color: #87552e; background: #f5d7a4; }
.theme-icon--birthday { color: #7d414b; background: #ebc6c5; }
.theme-icon--travel { color: #fff; background: #3f6b5e; }
.check {
  position: absolute;
  right: 17px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: transparent;
  background: #eee8e2;
  transform: translateY(-50%);
  font-size: 0.75rem;
}
.theme-option input:checked ~ .check { color: #fff; background: var(--accent); }

.dday-notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 13px 2px 4px;
  padding: 12px 16px;
  border-radius: 14px;
  color: #fff;
  background: #53627d;
  font-size: 0.78rem;
}
.dday-notice strong { font-size: 1.05rem; }

.form-grid { display: grid; gap: 17px; margin-top: 28px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label > span { font-weight: 750; font-size: 0.94rem; }
.form-grid label small { margin-left: 4px; color: #9b9189; font-weight: 500; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
  transition: border-color 0.2s;
}
input:focus, textarea:focus { border-color: var(--accent); outline: 0; }
textarea { min-height: 108px; resize: vertical; }
::placeholder { color: #aaa098; }
.message-field { position: relative; }
.message-field textarea { padding-bottom: 34px; }
.message-field output { position: absolute; right: 12px; bottom: 10px; color: #938981; font-size: 0.72rem; }

.primary-button, .secondary-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s, background 0.16s;
}
.primary-button { margin-top: 26px; color: #fff; background: var(--accent); box-shadow: 0 10px 24px rgba(168, 68, 69, 0.22); }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:active, .secondary-button:active { transform: scale(0.98); }
.primary-button:disabled, .secondary-button:disabled { opacity: 0.5; cursor: wait; }
.secondary-button { color: var(--accent-dark); background: #f3e5df; }

.back-button, .text-button {
  border: 0;
  padding: 8px 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 32px 0 20px;
  padding: 36px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}
.loading-card > span:last-child { color: var(--muted); font-size: 0.82rem; }
.spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border: 4px solid #f1dfd7;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 82px;
  margin: 25px 0;
  border: 1px dashed #d7cdc5;
  border-radius: 12px;
  color: #9d958e;
  background: #f8f4ef;
  font-size: 0.76rem;
}
.ad-slot small { margin-top: 12px; font-size: 0.5rem; letter-spacing: 0.15em; }
.ad-slot span { margin-bottom: 12px; }

#generated-text {
  position: relative;
  white-space: pre-line; /* 의미 단위 줄바꿈(\n)을 미리보기에도 그대로 */
  margin: 0 0 24px;
  padding: 24px 22px 22px;
  border-radius: 18px;
  color: #4b3b34;
  background: var(--soft);
  font-family: "MaruBuri", serif;
  font-size: 0.94rem;
  line-height: 1.8;
}
#generated-text::before { content: "“"; position: absolute; top: -11px; left: 13px; color: #d3a6a0; font-size: 3rem; }

.background-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.background-choice {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 15px;
  padding: 0;
  background: #e7ddd4;
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(62, 43, 32, 0.12);
}
.background-choice img { display: block; width: 100%; height: 100%; object-fit: cover; }
.background-choice.is-selected { border-color: var(--accent); }
.background-choice.is-selected::after {
  content: "✓";
  position: absolute;
  right: 8px;
  top: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}
.premium-choice {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: linear-gradient(145deg, #33293d, #9e665f);
}
.premium-choice .lock { font-size: 1.6rem; }
.premium-choice strong { font-size: 0.9rem; }
.premium-choice small { max-width: 120px; opacity: 0.8; font-size: 0.65rem; line-height: 1.45; }
.premium-choice.is-unlocked .lock, .premium-choice.is-unlocked strong, .premium-choice.is-unlocked small { display: none; }

.error-message { padding: 12px; border-radius: 10px; color: #8a3030; background: #fbe6e3; font-size: 0.8rem; }

.complete-heading { padding: 24px 4px 20px; text-align: center; }
.canvas-frame {
  overflow: hidden;
  border-radius: 19px;
  background: #ddd;
  box-shadow: 0 17px 40px rgba(51, 37, 31, 0.2);
}
#card-canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; }
.phrase-tools { margin-top: 18px; }
.edit-phrase-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  border: 2px solid #d8c3b7;
  border-radius: 15px;
  color: var(--accent-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}
.edit-phrase-button:hover { border-color: var(--accent); background: #fffaf9; }
.phrase-editor {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(73, 50, 35, 0.08);
}
.phrase-editor label { display: block; margin-bottom: 8px; font-weight: 800; }
.phrase-editor textarea { min-height: 190px; white-space: pre-wrap; line-height: 1.7; }
.phrase-edit-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.7rem;
}
.phrase-edit-meta output { flex: none; }
.phrase-edit-error { margin-bottom: 0; }
.phrase-edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.phrase-edit-actions .primary-button { margin: 0; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 26px; }
.action-grid .primary-button { margin: 0; }
.share-button { grid-column: 1 / -1; background: #3f775e; box-shadow: 0 10px 24px rgba(63, 119, 94, 0.2); }
.share-button:hover { background: #315f4a; }
.save-status { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); text-align: center; font-size: 0.75rem; }
.text-button { display: block; margin: 10px auto 0; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.save-help-button { margin-top: 4px; }
.link-share-panel {
  margin-top: 14px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: center;
}
.link-share-panel p { margin: 0 0 9px; color: var(--muted); font-size: 0.75rem; }
.link-share-panel > a { display: block; overflow-wrap: anywhere; color: var(--accent-dark); font-size: 0.74rem; line-height: 1.5; text-underline-offset: 3px; }
.link-share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.link-share-actions > button { min-height: 50px; margin: 0; font-size: 0.75rem; }
.kakao-link-button[hidden] + #copy-link-button { grid-column: 1 / -1; }
.delete-link-button { margin-top: 12px; font-size: 0.7rem; }

body.overlay-open { overflow: hidden; }
.image-fallback {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(106px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: rgba(17, 15, 14, 0.96);
}
.image-fallback-bar {
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 94px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: #fff;
  background: #24201e;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
.image-fallback-bar > div { display: grid; gap: 3px; }
.image-fallback-bar strong { font-size: 0.94rem; }
.image-fallback-bar span { color: #d8d2ce; font-size: 0.68rem; line-height: 1.45; }
.fallback-close-button {
  flex: none;
  min-width: 72px;
  min-height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  color: #fff;
  background: #5b514c;
  cursor: pointer;
  font-weight: 800;
}
.image-fallback > img {
  display: block;
  width: min(100%, 540px);
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
  -webkit-touch-callout: default;
  user-select: auto;
}

.site-footer { padding: 12px 20px max(28px, env(safe-area-inset-bottom)); color: #9a9189; text-align: center; font-size: 0.67rem; }
.site-footer p { margin: 0; }
.site-footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 14px; margin-top: 9px; }
.site-footer a { color: var(--muted); text-underline-offset: 3px; }

.doc-page { padding: 28px 24px 48px; }
.doc-page > header { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.doc-page h1 { font-size: clamp(1.75rem, 8vw, 2.25rem); }
.doc-page .doc-lead { margin: 13px 0 0; color: var(--muted); line-height: 1.75; }
.doc-page section { margin-top: 34px; }
.doc-page h2 { margin: 0 0 12px; font-family: "MaruBuri", "Batang", serif; font-size: 1.22rem; line-height: 1.45; }
.doc-page h3 { margin: 24px 0 8px; font-size: 1rem; }
.doc-page p { margin: 0 0 13px; font-size: 0.91rem; line-height: 1.85; }
.doc-page ul, .doc-page ol { margin: 0; padding-left: 1.35rem; }
.doc-page li { margin: 8px 0; font-size: 0.91rem; line-height: 1.75; }
.doc-page .theme-list, .doc-page .step-list { display: grid; gap: 12px; padding: 0; list-style: none; }
.doc-page .theme-list li, .doc-page .step-list li { margin: 0; padding: 17px 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.doc-page .theme-list strong, .doc-page .step-list strong { display: block; margin-bottom: 4px; color: var(--accent-dark); }
.doc-page .faq-list { margin: 0; }
.doc-page .faq-list div { padding: 22px 0; border-top: 1px solid var(--line); }
.doc-page .faq-list div:first-child { border-top: 0; padding-top: 0; }
.doc-page .faq-list dt { font-weight: 800; line-height: 1.55; }
.doc-page .faq-list dd { margin: 8px 0 0; color: #514943; font-size: 0.9rem; line-height: 1.8; }
.doc-page .policy-meta { padding: 15px 17px; border-radius: 14px; background: var(--soft); color: var(--muted); }
.doc-page a { color: var(--accent-dark); text-underline-offset: 3px; }

@media (max-width: 360px) {
  :root { font-size: 17px; }
  main { padding-inline: 15px; }
  .site-header { padding-inline: 17px; }
  .theme-option > span:nth-of-type(2) { padding-left: 76px; }
  .action-grid { grid-template-columns: 1fr; }
  .link-share-actions { grid-template-columns: 1fr; }
  .phrase-edit-meta { display: grid; gap: 3px; }
  .doc-page { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
