:root {
  --background: #f7f4ef;
  --surface: #ffffff;
  --text: #202124;
  --muted: #6b625a;
  --accent: #7c5cff;
  --accent-dark: #5a3fd2;
  --accent-secondary: #31d0c6;
  --border: #e6ded4;
  --shadow: 0 20px 60px rgba(32, 33, 36, 0.1);
  --radius: 24px;
  --header-height: 56px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(124, 92, 255, 0.12), transparent 32rem),
    var(--background);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 32px;
}

.app-shell,
.app-nav {
  width: min(920px, 100%);
}

/* ---------- Sticky compact header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

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

/* Flat, single-color logo (no gradient / no shadow) */
.logo-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--accent-dark);
}

.wordmark {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.language-switcher button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 4px;
  font: inherit;
  font-size: 0.85rem;
  border-radius: 0;
}

.language-switcher button:hover,
.language-switcher button:focus-visible,
.language-switcher .language-option-active {
  background: transparent;
  color: var(--accent-dark);
  transform: none;
}

.language-switcher .language-option-active {
  font-weight: 800;
}

.language-divider {
  color: var(--border);
}

/* ---------- Layout ---------- */

.app-shell {
  padding: 20px 20px 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0 0 12px;
  line-height: 1.15;
}

h2 {
  font-size: clamp(1.4rem, 3.6vw, 2rem);
}

.card p {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.welcome-description {
  white-space: pre-line;
}

.screen {
  display: none;
}

.screen-active {
  display: block;
}

.card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 32px);
}

.checklist {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--accent-dark);
}

.choice-summary,
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.choice-summary p {
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 0;
  padding: 12px 14px;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px 20px;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button:active {
  transform: scale(0.97);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 16px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px;
}

legend {
  color: var(--muted);
  font-weight: 700;
  padding: 0 8px;
}

.progress-row {
  margin-bottom: 16px;
}

.progress-label {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece6dd;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
}

.result-card {
  text-align: center;
}

/* Reserved space for the matched creator-type SVG character */
.profile-character {
  width: 160px;
  height: 160px;
  margin: 0 auto 20px;
  border: 1px dashed var(--border);
  border-radius: 20px;
  background: rgba(124, 92, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-character:has(.profile-character-image) {
  border-style: solid;
  background: transparent;
}

.profile-character-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- Result screen: type chips ---------- */

.profile-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 16px;
}

.profile-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 18px;
  border-radius: 16px;
  background: rgba(124, 92, 255, 0.08);
  border: 1px solid var(--border);
}

.chip-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.chip-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.result-description {
  max-width: 46em;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Result screen: score bars ---------- */

.score-bars {
  display: grid;
  gap: 8px;
  margin: 20px 0;
  text-align: left;
}

.score-bar-row {
  display: grid;
  grid-template-columns: 6.5em 1fr 2.5em;
  align-items: center;
  gap: 10px;
}

.score-bar-label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #ece6dd;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
}

.score-bar-value {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

/* ---------- Result screen: strength / growth tags ---------- */

.tag-groups {
  display: grid;
  gap: 14px;
  margin: 20px 0;
  text-align: left;
}

.tag-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
}

.tag-group-label .icon {
  width: 18px;
  height: 18px;
  color: var(--accent-dark);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.1);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- Result screen: EQ / performance diverging bars ---------- */

.tone-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.tone-section-title {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.tone-bars {
  display: grid;
  gap: 8px;
}

.tone-bar-row {
  display: grid;
  grid-template-columns: 6.5em 1fr;
  align-items: center;
  gap: 10px;
}

.tone-bar-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.tone-bar-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #ece6dd;
  overflow: hidden;
}

.tone-bar-track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(32, 33, 36, 0.15);
}

.tone-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
}

.tone-bar-fill-positive {
  background: var(--accent);
}

.tone-bar-fill-negative {
  background: var(--accent-secondary);
}

.tone-note {
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--muted);
}

.prompt-genre-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 0.82rem;
  color: var(--muted);
}

.prompt-genre-row select {
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Bottom nav (thumb-friendly on mobile) ---------- */

.app-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding: 0 20px;
}

.app-nav button {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.app-nav button:hover,
.app-nav button:focus-visible {
  background: #f0ecff;
}

#question-category,
#question-axis {
  display: none;
}

body[data-current-screen="welcome"] #previous-question-button,
body[data-current-screen="welcome"] #next-question-button,
body[data-current-screen="test"] #start-test-button,
body[data-current-screen="result"] #start-test-button,
body[data-current-screen="result"] #previous-question-button,
body[data-current-screen="result"] #next-question-button {
  display: none;
}

@media (min-width: 720px) {
  #answer-options {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #answer-options legend {
    grid-column: 1 / -1;
  }
}

/* ---------- Audio UI ---------- */

.playback-audio {
  width: 100%;
  margin: 4px 0 12px;
  border-radius: 999px;
}

.now-playing {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--accent-dark);
  min-height: 1.4em;
}

.audio-oscilloscope {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 56px;
  margin: 0 auto 16px;
  background: #f0ecff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  :root {
    --header-height: 48px;
  }

  .site-header {
    padding: 0 14px;
  }

  .wordmark {
    font-size: 0.92rem;
  }

  .language-switcher button {
    font-size: 0.78rem;
  }

  .app-shell {
    padding: 14px 14px 0;
  }

  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .choice-summary {
    grid-template-columns: 1fr;
  }

  .profile-character {
    width: 128px;
    height: 128px;
  }

  .app-nav {
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    margin-top: 16px;
  }
}

.link-button {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 8px;
  text-decoration: underline;
}

.link-button:hover,
.link-button:focus-visible {
  background: transparent;
  color: var(--accent-dark);
  transform: none;
}

/* ---------- Prompt preview box ---------- */

.prompt-preview-wrapper {
  position: relative;
  margin-top: 16px;
}

#prompt-preview {
  width: 100%;
  min-height: 160px;
  padding: 16px 52px 16px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(124, 92, 255, 0.05);
  color: var(--text);
  font: 15px/1.7 Inter, ui-sans-serif, system-ui, sans-serif;
  resize: vertical;
  box-sizing: border-box;
}

#prompt-preview:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.prompt-inline-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-dark);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(32, 33, 36, 0.08);
}

.prompt-inline-copy:hover,
.prompt-inline-copy:focus-visible {
  background: #f0ecff;
  transform: none;
}

@media (max-width: 640px) {
  #prompt-preview {
    min-height: 200px;
    font-size: 16px;
  }

  .prompt-inline-copy {
    width: 40px;
    height: 40px;
  }
}
