:root {
  --bg: #f6f1e7;
  --bg-deep: #eadfcd;
  --paper: rgba(255, 251, 245, 0.9);
  --panel: rgba(255, 255, 255, 0.72);
  --line: rgba(72, 54, 34, 0.12);
  --text: #2f241a;
  --muted: #786856;
  --accent: #8a5f3b;
  --accent-strong: #6f4529;
  --sage: #5d7a62;
  --gold: #c39156;
  --danger: #b54c40;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 20px 48px rgba(77, 56, 29, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "SUIT Variable", "Pretendard Variable", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(195, 145, 86, 0.16), transparent 30%),
    linear-gradient(180deg, #fbf7ef 0%, var(--bg) 55%, var(--bg-deep) 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: rgba(255, 250, 244, 0.7);
  backdrop-filter: blur(18px);
  overflow-x: hidden;
}

.app-header,
.panel,
.record-panel,
.chat-panel,
.chat-input-panel,
.hero-card,
.booklet-card,
.install-banner,
.sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.app-header {
  margin: 14px 14px 10px;
  padding: 14px 16px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup img {
  width: 54px;
  height: 54px;
  padding: 6px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 229, 213, 0.92));
  border: 1px solid rgba(72, 54, 34, 0.16);
  box-shadow: 0 10px 20px rgba(72, 54, 34, 0.1);
  filter: contrast(1.08) saturate(1.08);
}

.ilwon-symbol {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 7px 7px 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 252, 243, 0.98), rgba(240, 229, 213, 0.92));
  border: 1px solid rgba(195, 145, 86, 0.18);
  box-shadow: 0 10px 20px rgba(72, 54, 34, 0.1);
}

.ilwon-symbol--compact {
  width: 64px;
  min-width: 64px;
  padding: 8px 8px 10px;
  border-color: rgba(195, 145, 86, 0.26);
  box-shadow:
    0 12px 24px rgba(72, 54, 34, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.ilwon-symbol--image-only {
  width: 54px;
  min-width: 54px;
  padding: 8px;
  gap: 0;
}

.ilwon-symbol__label {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: #8d671f;
  line-height: 1;
}

.ilwon-symbol__image {
  width: 34px;
  height: 34px;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.8),
    0 8px 14px rgba(143, 102, 37, 0.2);
}

.ilwon-symbol--image-only .ilwon-symbol__image {
  width: 38px;
  height: 38px;
}

.auth-sheet-brand {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.auth-ilwon-symbol {
  width: 78px;
  min-width: 78px;
  gap: 8px;
  padding: 10px 10px 12px;
  border-radius: 22px;
  border-color: rgba(195, 145, 86, 0.28);
  box-shadow:
    0 14px 28px rgba(72, 54, 34, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.auth-ilwon-symbol .ilwon-symbol__label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
}

.auth-ilwon-symbol .ilwon-symbol__image {
  width: 44px;
  height: 44px;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.82),
    0 10px 18px rgba(143, 102, 37, 0.22);
}

.brand-meta {
  min-width: 0;
  display: grid;
  gap: 6px;
  justify-items: start;
}

.brand-meta strong {
  font-size: 0.92rem;
  line-height: 1.2;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.sync-badge[data-tone="neutral"] {
  background: rgba(120, 104, 86, 0.12);
  color: var(--muted);
}

.sync-badge[data-tone="pending"] {
  background: rgba(195, 145, 86, 0.14);
  color: #8a5f3b;
  border-color: rgba(138, 95, 59, 0.16);
}

.sync-badge[data-tone="success"] {
  background: rgba(93, 122, 98, 0.14);
  color: #48614d;
  border-color: rgba(93, 122, 98, 0.18);
}

.sync-badge[data-tone="error"] {
  background: rgba(181, 76, 64, 0.12);
  color: var(--danger);
  border-color: rgba(181, 76, 64, 0.18);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
strong {
  margin: 0;
  font-family: "Noto Serif KR", "Bookk Myungjo", serif;
}

h1 {
  font-size: 1.2rem;
}

h2 {
  font-size: 1.4rem;
  line-height: 1.35;
  word-break: keep-all;
}

h3 {
  font-size: 1.06rem;
  line-height: 1.45;
  word-break: keep-all;
}

.support-copy,
.question-card,
.story-card p,
.chapter-card p,
.timeline-item p,
.tip-card p,
.sheet-body,
#recordStatusText,
#recordPreviewText {
  color: var(--muted);
  line-height: 1.7;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.circle-button,
.nav-item,
.ghost-button,
.secondary-button,
.primary-button {
  transition: transform 0.16s ease, background 0.16s ease;
}

.circle-button,
.nav-item:hover,
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.circle-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  color: var(--text);
}

.install-banner {
  margin: 0 14px 10px;
  padding: 14px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.install-banner.is-hidden,
.screen,
.sheet-overlay.is-hidden,
.audio-player.is-hidden {
  display: none;
}

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

.app-main {
  min-height: 0;
  overflow: hidden;
}

.screen {
  height: 100%;
  padding: 0 14px 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.is-active {
  display: grid;
  gap: 14px;
  align-content: start;
}

.hero-card,
.booklet-card {
  border-radius: var(--radius-xl);
  padding: 22px 20px;
}

.hero-card {
  background: linear-gradient(135deg, #33261b, #5d3a22);
  color: #fff6ef;
}

.hero-card .eyebrow,
.hero-card .support-copy {
  color: rgba(255, 244, 234, 0.78);
}

.panel,
.record-panel,
.chat-panel,
.chat-input-panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.session-panel {
  display: grid;
  gap: 6px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.question-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  word-break: keep-all;
}

.topic-grid,
.chapter-list,
.story-list,
.timeline-list,
.tip-list,
.metrics-grid {
  display: grid;
  gap: 12px;
}

.topic-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.topic-card,
.chapter-card,
.story-card,
.timeline-item,
.tip-card,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.topic-card,
.story-card {
  width: 100%;
  text-align: left;
  color: var(--text);
}

.topic-card {
  display: grid;
  gap: 8px;
  text-align: left;
}

.topic-card strong {
  display: block;
  line-height: 1.45;
  word-break: keep-all;
}

.topic-card.is-active,
.nav-item.is-active {
  background: linear-gradient(135deg, rgba(138, 95, 59, 0.18), rgba(195, 145, 86, 0.1));
}

.topic-chip-row,
.suggestion-row {
  display: grid;
  gap: 8px;
  padding-bottom: 2px;
}

.topic-chip-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.suggestion-row {
  grid-template-columns: 1fr;
}

.topic-chip,
.suggestion-chip {
  width: 100%;
  min-width: 0;
  white-space: normal;
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: center;
  line-height: 1.4;
  word-break: keep-all;
}

.topic-chip.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff7f0;
}

.record-panel {
  text-align: center;
  display: grid;
  gap: 16px;
}

.record-orbit {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(138, 95, 59, 0.18);
  pointer-events: none;
}

.record-orbit.is-recording .orbit-ring {
  animation: pulse 1.6s ease infinite;
}

.record-button {
  position: relative;
  z-index: 1;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff7f0;
  font-weight: 700;
  box-shadow: 0 18px 32px rgba(111, 69, 41, 0.28);
}

.record-status {
  display: grid;
  gap: 8px;
}

#recordTimer {
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.record-toolbar,
.button-stack.horizontal {
  display: grid;
  gap: 10px;
}

.record-toolbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.button-stack.horizontal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-toolbar > *,
.button-stack.horizontal > * {
  min-width: 0;
  white-space: normal;
  line-height: 1.35;
}

textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(72, 54, 34, 0.18);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 16px;
  color: var(--text);
  resize: vertical;
  min-height: 112px;
}

input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(72, 54, 34, 0.18);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 16px;
  color: var(--text);
}

textarea:focus {
  outline: none;
  border-color: rgba(138, 95, 59, 0.48);
  box-shadow: 0 0 0 4px rgba(195, 145, 86, 0.12);
}

input:focus {
  outline: none;
  border-color: rgba(138, 95, 59, 0.48);
  box-shadow: 0 0 0 4px rgba(195, 145, 86, 0.12);
}

.audio-player {
  width: 100%;
  margin-top: 10px;
}

.chat-panel {
  min-height: 320px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.chat-messages {
  display: grid;
  gap: 12px;
}

.chat-message {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.chat-message.ai .chat-bubble {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, var(--sage), #446049);
  color: #f6fbf7;
}

.chat-input-panel {
  display: grid;
  gap: 12px;
}

.chapter-card,
.story-card,
.timeline-item,
.tip-card,
.metric-card {
  display: grid;
  gap: 8px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(72, 54, 34, 0.08);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--accent));
}

.metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.primary-button,
.secondary-button,
.ghost-button {
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
}

.danger-button {
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  background: rgba(181, 76, 64, 0.14);
  color: var(--danger);
  border: 1px solid rgba(181, 76, 64, 0.22);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff7f0;
}

.secondary-button {
  background: rgba(138, 95, 59, 0.12);
  color: var(--accent);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  border: 1px solid var(--line);
}

.block {
  width: 100%;
}

.button-stack {
  display: grid;
  gap: 10px;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  background: rgba(248, 242, 233, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.nav-item {
  min-height: 46px;
  border-radius: 16px;
  background: transparent;
  color: rgba(47, 36, 26, 0.82);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav-item.is-active {
  color: var(--accent);
  font-weight: 800;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(39, 29, 19, 0.5);
  padding: 16px;
  display: grid;
  align-items: end;
  z-index: 20;
}

.auth-overlay {
  align-items: center;
}

.sheet {
  border-radius: 24px 24px 18px 18px;
  padding: 18px;
  max-height: min(78vh, 720px);
  overflow-y: auto;
}

.auth-sheet {
  border-radius: 24px;
  max-width: 420px;
  width: min(100%, 420px);
  justify-self: center;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.sheet-body {
  display: grid;
  gap: 12px;
}

.sheet-body p {
  margin: 0;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-flow-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(138, 95, 59, 0.08);
  border: 1px solid rgba(138, 95, 59, 0.16);
}

.auth-flow-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-helper {
  margin-top: -4px;
  font-size: 0.82rem;
}

.auth-actions {
  margin-top: 6px;
}

.auth-actions .secondary-button,
.auth-actions .primary-button {
  width: 100%;
}

.input-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.auth-sheet textarea.input-field {
  min-height: 92px;
  resize: vertical;
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 280px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(47, 36, 26, 0.9);
  color: #fff8f1;
  box-shadow: 0 18px 28px rgba(47, 36, 26, 0.2);
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

@media (max-width: 380px) {
  .app-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .brand-meta {
    width: 100%;
    order: 3;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.02);
    opacity: 1;
  }
}
