:root {
  --parchment: #f3eee2;
  --ink: #1c1a14;
  --muted: #6b6755;
  --accent: #2f5442;
  --accent-hover: #244035;
  --accent-tint: #e8f0eb;
  --card: #faf7f0;
  --border: rgba(28, 26, 20, 0.14);
  --shadow: rgba(28, 26, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: radial-gradient(
    circle at top right,
    #ede3cf 0%,
    var(--parchment) 50%,
    #e6dcc8 100%
  );
  min-height: 100vh;
}

/* Texture overlay */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
    rgba(28, 26, 20, 0.06) 0.5px,
    transparent 0.5px
  );
  background-size: 3px 3px;
  opacity: 0.18;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
}

/* ── Intro ──────────────────────────────────────────────────────────────── */
.intro {
  max-width: 580px;
  margin: 0 auto;
  padding: 4rem 1.4rem 5rem;
  text-align: center;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: Georgia, serif;
}

h1 {
  margin: 0.3rem 0 0;
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.greek {
  margin: 0.4rem 0 0;
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.intro-body {
  margin: 1.4rem 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1rem;
}

.intro-note {
  margin: 1.8rem auto 2.2rem;
  max-width: 460px;
  font-style: italic;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.primary-btn {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0 auto 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.95rem 1.6rem;
  font-size: 0.98rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.primary-btn.disabled {
  opacity: 0.35;
  cursor: default;
}

.ghost-btn {
  display: inline-block;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.ghost-btn:hover {
  color: var(--ink);
  border-color: rgba(28, 26, 20, 0.4);
}

.ghost-btn.small {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
}

/* ── Question ───────────────────────────────────────────────────────────── */
.question-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 3rem 1.4rem 4rem;
}

.question-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.4rem;
  gap: 0.8rem;
}

.chapter-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  color: var(--accent);
  font-family: Georgia, serif;
  flex: 1;
}

.question-num {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.question-num .of {
  font-style: italic;
}

h2.question-text {
  margin: 0 0 1.8rem;
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Binary / multi-choice options */
.options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--card);
  transition:
    border-color 0.12s,
    background 0.12s;
  user-select: none;
}

.option:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.option.selected {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.option input[type="radio"] {
  /* Hidden — selection state tracked via .selected class */
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option span {
  font-size: 0.97rem;
  line-height: 1.45;
  color: var(--ink);
}

/* Proust text input */
textarea {
  display: block;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 110px;
  background: var(--card);
  color: var(--ink);
  margin-bottom: 1.6rem;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 84, 66, 0.12);
}

textarea::placeholder {
  color: #b0a88f;
  font-style: italic;
}

/* Nav row */
.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* ── Waiting ────────────────────────────────────────────────────────────── */
.waiting {
  text-align: center;
  padding: 6rem 1.4rem;
}

.waiting-label {
  font-size: 1.25rem;
  margin: 0;
  color: var(--ink);
}

.waiting-sub {
  color: var(--muted);
  margin: 0.5rem 0 2rem;
  font-style: italic;
  font-size: 0.95rem;
}

.waiting-dots {
  display: inline-flex;
  gap: 0.5rem;
}

.waiting-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.2;
  animation: pulse 1.2s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.waiting-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.3);
  }
}

/* ── Portrait ───────────────────────────────────────────────────────────── */
.portrait-wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 3.5rem 1.4rem 5rem;
}

.portrait-text {
  margin: 1.6rem 0 2.5rem;
  padding-left: 1.2rem;
  border-left: 3px solid var(--accent);
  font-size: 1.08rem;
  line-height: 1.75;
  font-style: italic;
  color: var(--ink);
  min-height: 1em; /* prevent layout jump before typewriter starts */
}

.portrait-footer {
  text-align: center;
}

.portrait-note {
  margin: 0 0 1.2rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Error ──────────────────────────────────────────────────────────────── */
.error-wrap {
  max-width: 500px;
  margin: 0 auto;
  padding: 4rem 1.4rem;
  text-align: center;
}

.error-msg {
  color: #8f3f2f;
  margin: 0 0 1.5rem;
  font-size: 0.98rem;
  line-height: 1.5;
}

.error-wrap .ghost-btn {
  display: block;
  max-width: 260px;
  margin: 0.7rem auto 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .intro {
    padding: 3rem 1.2rem 4rem;
  }

  .question-wrap {
    padding: 2rem 1rem 3rem;
  }

  .nav {
    justify-content: center;
  }

  .primary-btn {
    max-width: 100%;
  }
}

/* ── Chapter block (instrument label) ───────────────────────────────────── */
.chapter-block {
  flex: 1;
}

.chapter-instrument {
  margin: 0.15rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Scale options (compact) ────────────────────────────────────────────── */
.options.scale .option {
  padding: 0.6rem 0.85rem;
}

.options.scale .option span {
  font-size: 0.9rem;
}

/* ── Results ────────────────────────────────────────────────────────────── */
.results-wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 3rem 1.4rem 5rem;
}

.results-wrap h1 {
  margin: 0.3rem 0 2rem;
}

.result-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.3rem 1.4rem 1.1rem;
  margin-bottom: 1rem;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  gap: 0.5rem;
}

.result-label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.result-instrument {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

.result-desc {
  margin: 0.65rem 0 0;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--muted);
}

/* Myers-Briggs */
.mb-type-display {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.mb-labels-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.mb-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.mb-sep {
  color: var(--border);
  font-size: 0.75rem;
}

/* Big Five */
.trait-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.trait-row {
  display: grid;
  grid-template-columns: 8rem 1fr 3.8rem;
  align-items: center;
  gap: 0.7rem;
}

.trait-name {
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
}

.trait-bar-track {
  height: 5px;
  background: rgba(28, 26, 20, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.trait-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.trait-level {
  font-size: 0.75rem;
  text-align: right;
  font-style: italic;
}

.trait-level.high {
  color: var(--accent);
}
.trait-level.medium {
  color: var(--muted);
}
.trait-level.low {
  color: #8f6a50;
}

/* Enneagram */
.enn-type-display {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

/* Portrait result section */
.portrait-section .portrait-text {
  margin: 0 0 0.4rem;
  padding-left: 1.1rem;
  border-left: 3px solid var(--accent);
  font-size: 1.05rem;
  line-height: 1.75;
  font-style: italic;
  color: var(--ink);
  min-height: 2em;
}

.portrait-section .portrait-text .waiting-dots {
  display: inline-flex;
  vertical-align: middle;
}

.portrait-note {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.portrait-error {
  font-size: 0.9rem;
  color: #8f3f2f;
  font-style: normal;
}

.results-footer {
  text-align: center;
  padding-top: 1.2rem;
}

@media (max-width: 480px) {
  .results-wrap {
    padding: 2rem 1rem 4rem;
  }

  .trait-row {
    grid-template-columns: 6rem 1fr 3rem;
    gap: 0.5rem;
  }

  .trait-name {
    font-size: 0.78rem;
  }
}
