:root {
  --bg0: #f7f1e8;
  --bg1: #fffdf8;
  --ink: #2c241e;
  --muted: #6f6258;
  --accent: #e15a3c;
  --accent-2: #c47a12;
  --line: rgba(44, 36, 30, 0.12);
  --card: rgba(255, 252, 247, 0.94);
  --option-hover: #fff1e6;
  --glow-a: rgba(225, 90, 60, 0.22);
  --glow-b: rgba(244, 184, 92, 0.42);
  --glow-base: #f3ebe1;
  --progress-track: rgba(44, 36, 30, 0.08);
  --plank: linear-gradient(180deg, #e7c7a2 0%, #c9956a 55%, #a87448 100%);
  --toast-bg: #2c241e;
  --toast-ink: #fffaf4;
  --radius: 16px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

[data-theme="dark"] {
  --bg0: #161311;
  --bg1: #241c18;
  --ink: #f6efe6;
  --muted: #cbbbaa;
  --accent: #e07a5f;
  --accent-2: #f0c27a;
  --line: rgba(246, 239, 230, 0.14);
  --card: rgba(32, 26, 22, 0.92);
  --option-hover: #3a2c26;
  --glow-a: rgba(224, 122, 95, 0.28);
  --glow-b: rgba(240, 194, 122, 0.16);
  --glow-base: #120f0d;
  --progress-track: rgba(255, 255, 255, 0.08);
  --plank: linear-gradient(180deg, #6a4a34 0%, #3d291c 55%, #24160f 100%);
  --toast-bg: #2a211c;
  --toast-ink: #f6efe6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg0);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 8% -8%, var(--glow-a), transparent 55%),
    radial-gradient(ellipse 60% 40% at 92% 0%, var(--glow-b), transparent 50%),
    linear-gradient(180deg, var(--glow-base) 0%, var(--bg0) 42%, var(--bg0) 100%);
  z-index: 0;
}

.site-header,
.shell,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 8px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  font-family: inherit;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--accent-2);
  letter-spacing: 0.2em;
}

.park-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.park-link:hover { color: var(--ink); border-bottom-color: var(--line); }

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 20px 48px;
}

.shell:has(.panel-hub.active) {
  max-width: 920px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 32px;
  backdrop-filter: blur(8px);
  animation: rise 0.45s ease both;
}

.panel-hub {
  background: transparent;
  border: 0;
  padding-left: 0;
  padding-right: 0;
  backdrop-filter: none;
}

.panel[hidden] { display: none !important; }

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

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.35rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }

.lede {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1rem;
}

.nick-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.nick-form input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 14px;
}

.nick-form input[type="text"]:focus {
  outline: 2px solid rgba(196, 92, 62, 0.45);
  border-color: transparent;
}

.consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.consent-row input {
  margin-top: 3px;
  flex-shrink: 0;
}

.hint {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9a3d28);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  margin-top: 16px;
}

.btn-share {
  background: var(--bg1);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-share:hover {
  border-color: rgba(232, 184, 109, 0.45);
}

.quiz-progress {
  height: 4px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.quiz-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.quiz-meta {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  text-align: left;
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-option:hover {
  border-color: rgba(196, 92, 62, 0.55);
  background: var(--option-hover);
}

.quiz-options--mbti {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.quiz-option--mbti {
  text-align: center;
  padding: 12px 8px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.quiz-options--chips {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quiz-option--chip {
  text-align: center;
  padding: 12px 10px;
}

.quiz-option--chip.is-selected {
  border-color: var(--accent-2);
  background: rgba(232, 184, 109, 0.16);
  box-shadow: inset 0 0 0 1px rgba(232, 184, 109, 0.35);
}

.quiz-multi-hint {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.quiz-multi-next {
  grid-column: 1 / -1;
  margin-top: 8px;
  width: 100%;
}

.quiz-multi-next:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.result-sections {
  display: grid;
  gap: 16px;
  margin: 0 0 24px;
}

.result-section {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 18, 24, 0.45);
}

.result-section-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--accent-2);
}

.result-section-body {
  margin: 0 0 0.75em;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.65;
}

.result-section-body:last-of-type {
  margin-bottom: 0;
}

.result-section-list {
  margin: 10px 0 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-section-list li {
  margin: 0.35em 0;
}

.score-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.score-list li {
  display: grid;
  grid-template-columns: minmax(96px, 1.2fr) 1fr 40px;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}

.score-track {
  height: 8px;
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
}

.share-box {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-bottom: 20px;
}

.share-label {
  margin: 0 0 12px;
  font-weight: 600;
}

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

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer a { color: var(--accent-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-ink);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

.bookshelf {
  margin: 8px 0 28px;
}

.shelf-row {
  position: relative;
  padding: 8px 4px 0;
}

.shelf-books {
  list-style: none;
  margin: 0;
  padding: 0 8px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 16px;
  min-height: 220px;
}

.shelf-plank {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  border-radius: 2px;
  background: var(--plank);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(232, 184, 109, 0.18);
}

.book-slot { position: relative; z-index: 1; }

.book-slot--loading,
.book-slot--empty {
  width: 100%;
  color: var(--muted);
  font-size: 0.92rem;
  padding-bottom: 8px;
}

.book {
  --book-h: 200px;
  --book-w: 132px;
  width: var(--book-w);
  height: var(--book-h);
  border: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: block;
  text-align: left;
  color: var(--ink);
  background: transparent;
  transform-origin: center bottom;
  transition: transform 0.22s ease, filter 0.22s ease;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
}

.book:hover,
.book:focus-visible {
  transform: translateY(-10px) rotate(-1.5deg);
  outline: none;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45));
}

.book-cover {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.book-cover::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35), transparent);
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(242, 235, 227, 0.12);
  border-radius: 2px;
  pointer-events: none;
}

.book--tone-ember .book-cover {
  background: linear-gradient(160deg, #5c2a1f 0%, #2a1612 55%, #1a100e 100%);
}
.book--tone-ink .book-cover {
  background: linear-gradient(160deg, #243044 0%, #151b26 55%, #0e1218 100%);
}
.book--tone-moss .book-cover {
  background: linear-gradient(160deg, #2f3d2a 0%, #1a2218 55%, #10140f 100%);
}
.book--tone-wine .book-cover {
  background: linear-gradient(160deg, #4a1f32 0%, #241018 55%, #140c10 100%);
}

.book-badge {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
  border: 1px solid rgba(232, 184, 109, 0.35);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}

.book-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 10px 0 6px;
}

.book-sub {
  position: relative;
  z-index: 1;
  font-size: 0.72rem;
  color: rgba(242, 235, 227, 0.72);
  line-height: 1.35;
}

.book-meta {
  position: relative;
  z-index: 1;
  font-size: 0.7rem;
  color: rgba(163, 154, 144, 0.95);
  margin-top: auto;
}

@media (max-width: 480px) {
  .book { --book-h: 176px; --book-w: 112px; }
  .book-title { font-size: 0.95rem; }
}

.park-promo {
  margin-top: 8px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(232, 184, 109, 0.28);
  background: linear-gradient(135deg, rgba(196, 92, 62, 0.14), rgba(23, 28, 38, 0.6));
}

.park-promo-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.park-promo-body {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

body.is-embed .park-link,
body.is-embed .park-promo,
body.is-embed #site-footer {
  display: none !important;
}

/* embed에서도 책장↔테스트 이동은 허용 */
body.is-embed #back-to-hub,
body.is-embed #result-to-hub {
  display: inline-flex !important;
}

/* 앱 설치 안내 — PC에서만. PC는 공유·파크 이동 불가 */
.app-guide {
  display: none;
  margin-top: 12px;
  margin-bottom: 20px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.app-guide-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.app-guide-body {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.app-guide-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-guide-stores img {
  display: block;
  width: 150px;
  height: auto;
}

body.is-pc .app-guide {
  display: block;
}

body.is-pc .share-box,
body.is-pc .park-link,
body.is-pc .park-promo,
body.is-pc .park-footer-link,
body.is-pc .result-park-actions {
  display: none !important;
}

body.is-embed .site-header {
  padding-top: max(12px, env(safe-area-inset-top));
}

body.is-embed .shell {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

@media (max-width: 480px) {
  .panel { padding: 22px 18px 26px; }
  .score-list li { grid-template-columns: 72px 1fr 36px; font-size: 0.82rem; }
  .quiz-options--mbti { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .quiz-option--mbti { padding: 10px 4px; font-size: 0.82rem; }
  .quiz-options--chips { grid-template-columns: 1fr 1fr; }
}
