@font-face {
  font-family: "CM Brush";
  src: url("/assets/fonts/NanumBrushScript-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "CM Body";
  src: url("/assets/fonts/NotoSansKR-Regular.ttf") format("truetype");
  font-weight: 400;
}
@font-face {
  font-family: "CM Body";
  src: url("/assets/fonts/NotoSansKR-Bold.ttf") format("truetype");
  font-weight: 700;
}

:root {
  --cream: #faf6ee;
  --paper: #ffffff;
  --ink: #2b2118;
  --ink-soft: #6b5d4f;
  --accent: #4a5d3a;
  --accent-dark: #34443f;
  --border: #e7ddcb;
  --danger: #b3403a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(43, 33, 24, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "CM Body", -apple-system, "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.3em; text-decoration: none; background: var(--cream);
}

main { max-width: 480px; margin: 0 auto; padding: 20px 16px 100px; }

h1, h2 { color: var(--ink); }
h2 { font-size: 1.15em; margin-bottom: 16px; }

.hint { color: var(--ink-soft); font-size: 0.88em; line-height: 1.5; }

.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.92em;
}
.flash-ok { background: #e9f2e3; color: var(--accent-dark); }
.flash-nudge { background: #fdf3e3; color: #7a5a1e; }
.flash-nudge a { color: inherit; font-weight: 700; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.92em; }

input[type="text"], input[type="file"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1em;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
}
textarea { resize: vertical; }

.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { background: #b7c2ac; cursor: not-allowed; }

.panel {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.thumb {
  position: relative; aspect-ratio: 9/16; border-radius: 10px; overflow: hidden;
  border: 3px solid transparent; cursor: pointer; transition: border-color .15s, transform .15s;
}
.thumb input { position: absolute; opacity: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.selected { border-color: var(--accent); transform: scale(0.96); }
.thumb-check {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; display: none;
  align-items: center; justify-content: center; font-size: 0.85em; font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.thumb.selected .thumb-check { display: flex; }

.upload-preview { margin-top: 10px; max-width: 160px; border-radius: 10px; display: block; border: 3px solid transparent; }
.upload-preview.selected-upload { border-color: var(--accent); }
.upload-preview[hidden] { display: none; }

.radio-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.95em; }
.radio-row audio { height: 32px; margin-left: auto; }
.consent-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.85em; color: var(--ink-soft); margin-top: 8px; }

.photo-field { text-align: center; }
.crop-frame {
  position: relative; width: 280px; height: 280px; margin: 0 auto 12px;
  border-radius: 50%; overflow: hidden; background: var(--cream);
  border: 2px solid var(--border); touch-action: none;
}
.crop-frame canvas { width: 100%; height: 100%; cursor: grab; display: block; }
.photo-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: 0.85em; background: var(--paper); pointer-events: none;
}
.photo-placeholder[hidden] { display: none; }
#zoom-range { max-width: 280px; margin: 0 auto 14px; display: block; }
.flash-error { background: #fbe6e4; color: var(--danger); }

.preview-wrap { margin-bottom: 20px; }

.card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ddd center/cover no-repeat;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.preview-scrim-top, .preview-scrim-bottom {
  position: absolute; left: 0; right: 0; pointer-events: none;
}
.preview-scrim-top { top: 0; height: 30%; background: linear-gradient(to bottom, rgba(0,0,0,.45), transparent); }
.preview-scrim-bottom { bottom: 0; height: 30%; background: linear-gradient(to top, rgba(0,0,0,.5), transparent); }
.preview-title {
  position: absolute; top: 5%; left: 7%; font-family: "CM Brush", cursive;
  font-size: 2.2em; color: #2b2118; white-space: pre-wrap;
}
.preview-body {
  position: absolute; top: 22%; left: 7%; right: 7%; text-align: center;
  color: #2b2118; font-size: 0.95em; line-height: 1.6; white-space: pre-wrap;
}
.preview-photo {
  position: absolute; width: 20%; aspect-ratio: 1; border-radius: 50%;
  object-fit: cover; border: 3px solid rgba(255,255,255,.9);
  right: 8%; bottom: 16%;
}
.preview-sig {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 4% 8%;
  background: rgba(20,15,10,.55); color: #fff; text-align: center; font-size: 0.82em; font-weight: 700;
}

.generate-status { margin-top: 14px; color: var(--ink-soft); }
.generate-status.error { color: var(--danger); }
.generate-result { margin-top: 16px; text-align: center; }
.generate-result video { width: 100%; max-width: 320px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }

.generate-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(43, 33, 24, 0.08);
  z-index: 10;
}
.generate-bar .btn { display: block; width: 100%; max-width: 480px; margin: 0 auto; }

.error-box { text-align: center; padding: 60px 20px; }
.error-code { font-size: 2em; font-weight: 700; color: var(--ink-soft); }
