:root {
  color-scheme: light;
  --ink: #181310;
  --ink-soft: #342a25;
  --paper: #f7efe2;
  --paper-strong: #fffaf0;
  --vermilion: #a83b2d;
  --vermilion-dark: #7d251d;
  --gold: #b89452;
  --muted: #756a62;
  --line: rgba(57, 39, 30, 0.16);
  --success: #356b50;
  --shadow: 0 14px 38px rgba(35, 22, 17, 0.12);
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: #0f0c0a; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(168, 59, 45, 0.3), transparent 36rem),
    #0f0c0a;
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: clip;
  background:
    linear-gradient(rgba(247, 239, 226, 0.94), rgba(247, 239, 226, 0.98)),
    repeating-linear-gradient(90deg, transparent 0 24px, rgba(168, 59, 45, 0.035) 25px 26px);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.42);
}

.topbar {
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px clamp(16px, 5vw, 22px);
  color: var(--paper-strong);
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-mark, .avatar-glyph {
  display: grid;
  place-items: center;
  border: 1px solid rgba(184, 148, 82, 0.68);
  border-radius: 50%;
  color: #f1dba8;
  background: #2b211d;
}

.brand-mark { width: 40px; height: 40px; }
.topbar h1 { margin: 2px 0 0; font-size: 16px; line-height: 1.3; }
.eyebrow { margin: 0; color: #d1b777; font-size: 10px; letter-spacing: 0.08em; }
.mode-badge { padding: 6px 8px; border: 1px solid rgba(247, 239, 226, 0.22); border-radius: 999px; font-size: 10px; white-space: nowrap; }

.chat-log { padding: 22px clamp(16px, 5vw, 22px) 12px; }

.message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 18px;
  animation: rise 260ms ease-out both;
}

.message.user-message { justify-content: flex-end; }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; object-fit: cover; border-radius: 50%; }
.bubble { max-width: 88%; padding: 13px 15px; border-radius: 4px 18px 18px; background: var(--paper-strong); box-shadow: 0 5px 18px rgba(38, 24, 18, 0.08); }
.user-message .bubble { color: white; border-radius: 18px 4px 18px 18px; background: var(--ink-soft); }
.bubble p { margin: 0 0 8px; line-height: 1.65; overflow-wrap: anywhere; }
.bubble p:last-child { margin-bottom: 0; }
.speaker { color: var(--vermilion-dark); font-size: 12px; font-weight: 800; }

.action-stage { padding: 2px clamp(16px, 5vw, 22px) calc(24px + env(safe-area-inset-bottom)); }
.stage-card, .system-card { width: 100%; border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 250, 240, 0.9); box-shadow: var(--shadow); }
.system-card { scroll-margin-top: 80px; }
.stage-card { padding: 18px; }
.system-card { margin: 0 0 20px; padding: 20px; animation: rise 280ms ease-out both; }
.stage-title { margin: 0 0 6px; font-size: 20px; line-height: 1.35; }
.stage-copy { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }

.primary-button, .secondary-button, .persona-card {
  min-height: 48px;
  border-radius: 14px;
  cursor: pointer;
}
.primary-button { width: 100%; padding: 13px 18px; border: 0; color: white; background: linear-gradient(135deg, var(--vermilion), var(--vermilion-dark)); box-shadow: 0 9px 22px rgba(125, 37, 29, 0.24); font-weight: 800; }
.primary-button:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; }
.secondary-button { width: 100%; margin-top: 10px; padding: 12px 16px; border: 1px solid var(--line); color: var(--ink); background: transparent; font-weight: 700; }
button:focus-visible, input:focus-visible { outline: 3px solid #2466b1; outline-offset: 3px; }

.persona-list { display: grid; gap: 12px; }
.persona-card { width: 100%; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 13px; padding: 10px; text-align: left; border: 1px solid var(--line); color: var(--ink); background: white; }
.persona-card img { width: 76px; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 11px; background: #e8dfd4; }
.persona-card strong { display: block; margin: 3px 0 2px; font-size: 17px; }
.persona-card small { display: block; color: var(--muted); line-height: 1.45; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { padding: 4px 7px; border-radius: 999px; color: var(--vermilion-dark); background: #f4ddd5; font-size: 11px; font-weight: 700; }

fieldset { min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
legend, label { display: block; margin-bottom: 8px; font-weight: 800; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: white; }
input[type="radio"] { width: 20px; height: 20px; accent-color: var(--vermilion); }
input[type="date"], input[type="time"], input[type="text"] { width: 100%; min-height: 50px; padding: 11px 12px; border: 1px solid #9b8c82; border-radius: 12px; color: var(--ink); background: white; }
.field-help { margin: -3px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.error-box { margin: 0 0 14px; padding: 12px; border-left: 4px solid var(--vermilion); color: #701e17; background: #fbe6df; line-height: 1.5; }
[hidden] { display: none !important; }

.validation-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px 14px; margin: 17px 0; }
.validation-grid dt { color: var(--muted); font-size: 13px; }
.validation-grid dd { margin: 0; text-align: right; font-weight: 750; overflow-wrap: anywhere; }
.verified { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-weight: 800; }

.pillar-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin: 16px 0; }
.pillar { padding: 10px 5px; text-align: center; border: 1px solid var(--line); border-radius: 12px; background: white; }
.pillar span { display: block; color: var(--muted); font-size: 11px; }
.pillar strong { display: block; margin-top: 5px; font-size: 18px; }
.element-list { display: grid; gap: 9px; margin: 18px 0; }
.element-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 28px; gap: 9px; align-items: center; }
.bar { height: 9px; overflow: hidden; border-radius: 999px; background: #e7ddd2; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--vermilion)); }
.element-count-0 { width: 0; }
.element-count-1 { width: 12.5%; }
.element-count-2 { width: 25%; }
.element-count-3 { width: 37.5%; }
.element-count-4 { width: 50%; }
.element-count-5 { width: 62.5%; }
.element-count-6 { width: 75%; }
.element-count-7 { width: 87.5%; }
.element-count-8 { width: 100%; }
.reading-card { margin-top: 10px; padding: 15px; border-radius: 14px; background: white; }
.reading-card h3 { margin: 0 0 8px; font-size: 16px; }
.reading-card p { margin: 0; line-height: 1.7; }
.evidence { display: inline-block; margin-top: 10px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }

.offer-card { color: var(--paper-strong); border-color: transparent; background: linear-gradient(155deg, #211915, #3b2821); }
.offer-card .stage-copy, .offer-card .fine-print { color: #d7c9ba; }
.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.price del { color: #b9aaa0; }
.price strong { color: #f1d18b; font-size: 28px; }
.chapter-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 16px 0; padding: 0; list-style: none; }
.chapter-preview li { min-width: 0; padding: 9px; border-radius: 9px; background: rgba(255, 255, 255, 0.07); overflow-wrap: anywhere; font-size: 12px; }
.fine-print { font-size: 12px; line-height: 1.55; }
.service-notice { margin: 0; padding: 18px clamp(16px, 5vw, 22px) calc(26px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 12px; line-height: 1.6; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
@media (min-width: 390px) { .chat-log, .action-stage { padding-left: 20px; padding-right: 20px; } }
@media (max-width: 359px) { .mode-badge { display: none; } .chapter-preview { grid-template-columns: 1fr; } }
