:root {
  color-scheme: dark;
  --ink: #f0f0f0;
  --muted: #9090b0;
  --line: rgba(255, 255, 255, 0.1);
  --paper: #0d0d0d;
  --panel: #1a1a2e;
  --accent: #00d4b8;
  --accent-strong: #00b8a0;
  --coral: #ff6b6b;
  --amber: #f2b544;
  --green: #22c55e;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0, 212, 184, 0.06), transparent 400px),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.3;
}

.tablist {
  display: grid;
  grid-template-columns: repeat(2, minmax(80px, 1fr));
  gap: 4px;
  min-width: 184px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.tablist.single-tab {
  grid-template-columns: 1fr;
  min-width: 100px;
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: var(--accent);
  color: #0d0d0d;
  box-shadow: 0 4px 16px rgba(0, 212, 184, 0.3);
}

.lang-toggle {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: border-color 160ms ease, color 160ms ease;
}

.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.builder-stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3);
}

.step-tab {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  text-align: left;
  transition: transform 160ms ease, background 160ms ease;
}

.step-tab:hover:not(:disabled):not(.is-active) {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.step-tab span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.step-tab strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.step-tab.is-active {
  border-color: rgba(0, 212, 184, 0.4);
  background: rgba(0, 212, 184, 0.1);
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(0, 212, 184, 0.15);
}

.step-tab.is-active span {
  background: var(--accent);
  color: #0d0d0d;
}

.step-tab:disabled {
  opacity: 0.55;
}

.builder-flow {
  display: grid;
}

.step-panel {
  display: none;
}

.step-panel.is-active {
  display: block;
}

.step-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px;
}

.profile-panel {
  grid-row: span 2;
  min-height: 420px;
}

.prompt-panel,
.import-panel,
.json-panel,
.share-panel {
  min-height: 270px;
}

.json-panel,
.import-panel,
.share-panel {
  width: min(920px, 100%);
  margin: 0 auto;
}

.panel,
.score-panel,
.quiz-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.panel:hover,
.score-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.json-details {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.json-details[open] {
  background: rgba(255, 255, 255, 0.04);
}

.json-details summary {
  min-height: 44px;
  padding: 12px 14px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.json-note {
  margin: 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.json-details textarea {
  min-height: 170px;
  margin: 0 14px 14px;
  width: calc(100% - 28px);
  flex: none;
}

.quiz-reveal {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(0, 212, 184, 0.25);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(0, 212, 184, 0.1), rgba(242, 181, 68, 0.06)),
    var(--panel);
  animation: reveal-in 260ms ease-out;
}

.quiz-reveal h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.quiz-reveal p:not(.eyebrow) {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 800;
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes result-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes confetti-rise {
  0% {
    opacity: 0;
    transform: translateY(22px) rotate(0deg);
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-92px) rotate(150deg);
  }
}

@keyframes low-score-lines {
  0% {
    opacity: 0;
    transform: translateX(18px) rotate(-18deg);
  }

  25% {
    opacity: 1;
  }

  100% {
    opacity: 0.55;
    transform: translateX(0) rotate(-18deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-reveal,
  .result-panel,
  .result-effect span {
    animation: none;
  }
}

.quiz-editor-details {
  border: 1px solid rgba(0, 212, 184, 0.22);
  border-radius: 14px;
  background: var(--panel);
}

.quiz-editor-details summary {
  min-height: 48px;
  padding: 13px 16px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.quiz-editor-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.quiz-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.editor-heading {
  display: grid;
  gap: 4px;
}

.editor-heading h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.editor-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.editor-question-stack {
  display: grid;
  gap: 12px;
}

.editor-question-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.editor-question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-correct-summary {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(0, 212, 184, 0.1);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}

.editor-field {
  display: grid;
  gap: 7px;
}

.editor-field > span,
.editor-choices legend {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.editor-field input,
.editor-field textarea,
.editor-choice input[type="text"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.editor-field textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.55;
}

.editor-field input:focus,
.editor-field textarea:focus,
.editor-choice input[type="text"]:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 212, 184, 0.2);
}

.editor-choices {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.editor-choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.editor-choice input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.share-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.share-url-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.share-url-row input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 212, 184, 0.2);
}

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

textarea {
  width: 100%;
  min-height: 180px;
  flex: 1;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  line-height: 1.62;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 212, 184, 0.2);
}

.action-row,
.quiz-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.icon-button {
  border-radius: 16px;
  font-weight: 800;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 18px;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0d0d0d;
  box-shadow: 0 8px 24px rgba(0, 212, 184, 0.3);
}

.primary-button:hover {
  transform: scale(1.02) translateY(-1px);
  box-shadow: 0 12px 32px rgba(0, 212, 184, 0.45);
}

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

.ghost-button:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 184, 0.08);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 10px;
}

.icon-button.is-copied {
  border-color: var(--green);
  color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(242, 181, 68, 0.55);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.status-line {
  min-height: 1.3em;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.quiz-progress-bar {
  display: none;
}

.quiz-progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.quiz-progress-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-progress-copy span {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.compact-meter {
  height: 6px;
}

.score-panel {
  position: sticky;
  top: 20px;
  padding: 22px;
}

.score-panel h2 {
  margin-bottom: 12px;
  font-size: 1.32rem;
}

.score-panel p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.score-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

.score-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--amber), var(--green));
  transition: width 220ms ease;
}

.quiz-panel {
  min-height: 520px;
  padding: 22px;
}

.empty-state {
  display: grid;
  min-height: 420px;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.empty-state h2 {
  font-size: 1.35rem;
}

.quiz-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.question-stack {
  display: grid;
  gap: 16px;
}

.question-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.question-card.is-answered {
  background: rgba(0, 212, 184, 0.05);
}

.question-card.is-missing {
  border-color: rgba(242, 95, 92, 0.72);
  box-shadow: 0 0 0 3px rgba(242, 95, 92, 0.1);
}

.question-kicker {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.question-text {
  margin-bottom: 0;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.45;
}

.selected-answer {
  display: none;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 212, 184, 0.08);
}

.question-card.is-answered .selected-answer {
  display: grid;
}

.selected-answer-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.selected-answer-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.change-answer-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.choices {
  display: grid;
  gap: 10px;
}

.question-card.is-answered:not(.is-editing) .choices {
  display: none;
}

.choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 160ms ease, background 160ms ease;
  cursor: pointer;
}

.choice:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 184, 0.06);
}

.choice input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.choice span {
  min-width: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.question-error {
  display: none;
  margin: -2px 0 0;
  color: #b42318;
  font-size: 0.86rem;
  font-weight: 800;
}

.question-card.is-missing .question-error {
  display: block;
}

.quiz-actions {
  justify-content: flex-end;
  padding-top: 6px;
}

.result-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 14px;
  min-height: 420px;
  align-content: center;
  padding: 24px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: var(--panel);
  isolation: isolate;
  animation: result-enter 260ms ease-out;
}

.result-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0;
  transition: opacity 180ms ease;
}

.result-panel.is-positive {
  border-color: rgba(0, 212, 184, 0.35);
  box-shadow: 0 18px 48px rgba(0, 212, 184, 0.15);
}

.result-panel.is-positive::before {
  opacity: 1;
  background:
    linear-gradient(135deg, rgba(0, 212, 184, 0.1), rgba(242, 181, 68, 0.08)),
    var(--panel);
}

.result-panel.is-neutral {
  border-color: rgba(0, 212, 184, 0.2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

.result-panel.is-neutral::before {
  opacity: 1;
  background:
    linear-gradient(135deg, rgba(0, 212, 184, 0.06), rgba(255, 255, 255, 0)),
    var(--panel);
}

.result-panel.is-negative {
  border-color: rgba(255, 107, 107, 0.35);
  box-shadow: 0 18px 48px rgba(255, 107, 107, 0.12);
}

.result-panel.is-negative::before {
  opacity: 1;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 107, 107, 0.06) 0 8px, transparent 8px 20px),
    var(--panel);
}

.result-panel h2 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.08;
}

.result-panel.is-positive h2 {
  color: var(--accent);
}

.result-panel.is-neutral h2 {
  color: var(--accent);
}

.result-panel.is-negative h2 {
  color: var(--coral);
}

.result-panel p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.result-detail {
  display: grid;
  gap: 10px;
  max-width: 760px;
}

.result-effect {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.result-effect span {
  position: absolute;
  display: block;
  width: 8px;
  height: 24px;
  border-radius: 3px;
  opacity: 0;
}

.result-panel.is-positive .result-effect span {
  background: var(--amber);
  animation: confetti-rise 900ms ease-out both;
}

.result-panel.is-positive .result-effect span:nth-child(2n) {
  background: var(--green);
}

.result-panel.is-positive .result-effect span:nth-child(1) { left: 10%; top: 70%; animation-delay: 20ms; }
.result-panel.is-positive .result-effect span:nth-child(2) { left: 24%; top: 62%; animation-delay: 100ms; }
.result-panel.is-positive .result-effect span:nth-child(3) { left: 46%; top: 78%; animation-delay: 50ms; }
.result-panel.is-positive .result-effect span:nth-child(4) { left: 68%; top: 66%; animation-delay: 140ms; }
.result-panel.is-positive .result-effect span:nth-child(5) { left: 82%; top: 74%; animation-delay: 80ms; }
.result-panel.is-positive .result-effect span:nth-child(6) { left: 92%; top: 58%; animation-delay: 180ms; }

.result-panel.is-negative .result-effect span {
  right: 20px;
  width: 42px;
  height: 3px;
  background: rgba(242, 95, 92, 0.34);
  transform: rotate(-18deg);
  animation: low-score-lines 900ms ease-out both;
}

.result-panel.is-negative .result-effect span:nth-child(1) { top: 42px; animation-delay: 0ms; }
.result-panel.is-negative .result-effect span:nth-child(2) { top: 58px; right: 48px; animation-delay: 70ms; }
.result-panel.is-negative .result-effect span:nth-child(3) { top: 74px; right: 76px; animation-delay: 140ms; }
.result-panel.is-negative .result-effect span:nth-child(n+4) {
  display: none;
}

.answer-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-left: 4px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  line-height: 1.5;
}

.answer-badge {
  align-self: start;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.answer-body {
  display: grid;
  gap: 8px;
}

.answer-body p {
  display: grid;
  gap: 2px;
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.5;
}

.answer-body strong {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.answer-explanation {
  padding-top: 4px;
}

.answer-row.is-correct {
  border-left-color: var(--green);
}

.answer-row.is-correct .answer-badge {
  color: var(--green);
  background: rgba(34, 197, 94, 0.12);
}

.answer-row.is-wrong {
  border-left-color: var(--coral);
}

.answer-row.is-wrong .answer-badge {
  color: var(--coral);
  background: rgba(255, 107, 107, 0.12);
}

.qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.qr-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.qr-modal h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
}

.qr-modal canvas {
  border-radius: 8px;
  display: block;
}

.qr-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.qr-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

@media (max-width: 860px) {
  .builder-stepper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-tab {
    min-height: auto;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls {
    justify-content: space-between;
  }

  .tablist {
    flex: 1;
  }

  .step-grid,
  .quiz-layout {
    grid-template-columns: 1fr;
  }

  .quiz-progress-bar:not([hidden]) {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 28px rgba(36, 49, 66, 0.12);
    backdrop-filter: blur(10px);
  }

  .score-panel {
    display: none;
  }

  /* [LOW-7] merged from duplicate @media (max-width: 860px) block — dark theme override */
  .quiz-progress-bar:not([hidden]) {
    background: rgba(26, 26, 46, 0.94);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .panel,
  .quiz-panel,
  .score-panel {
    padding: 14px;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .quiz-actions {
    justify-content: stretch;
  }

  .builder-stepper,
  .selected-answer,
  .answer-row,
  .share-url-row {
    grid-template-columns: 1fr;
  }

  .change-answer-button {
    justify-self: start;
  }

  .answer-badge {
    justify-self: start;
  }
}

/* ---- AI buttons ---- */

.ai-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.ai-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 184, 0.07);
  transform: scale(1.02);
}

.ai-button--copy {
  color: var(--muted);
}

.ai-button--copy:hover {
  color: var(--accent);
}

.ai-button.is-copied {
  border-color: var(--green);
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}

@media (max-width: 520px) {
  .ai-buttons {
    flex-direction: column;
  }

  .ai-button {
    width: 100%;
  }
}

/* ---- P0-2: Score animation ---- */

.score-emoji-pop {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 6rem;
  pointer-events: none;
  z-index: 9999;
  animation: emojiPop 1.8s ease-out forwards;
}

@keyframes emojiPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* ---- P0-3: Share result button ---- */

.share-result-btn {
  background: linear-gradient(135deg, #00d4b8, #7c3aed);
  border-color: transparent;
  color: white;
}

.share-result-btn:hover {
  background: linear-gradient(135deg, #00b8a0, #6d28d9);
  border-color: transparent;
  box-shadow: 0 12px 32px rgba(0, 212, 184, 0.4);
  transform: scale(1.02) translateY(-1px);
}

/* ---- P0-1: Result message editor ---- */

.result-message-editor {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(0, 212, 184, 0.2);
  border-radius: 14px;
  background: rgba(0, 212, 184, 0.04);
  margin-top: 8px;
}

.editor-heading-sub {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.35;
}

.editor-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* [LOW-7] @media (max-width: 860px) dark theme override merged into the block above */

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 184, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(0, 212, 184, 0); }
}

.btn-pulse {
  animation: btnPulse 0.8s ease-in-out 3;
}

.participant-count {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.ranking-display {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 12px 0;
  font-family: "Space Mono", monospace;
  font-size: 0.85rem;
  color: var(--accent);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 8px;
}
