:root {
  --surface: #f7f3ef;
  --surface-low: #efe7e2;
  --surface-card: #ffffff;
  --text: #17191b;
  --muted: #5f5050;
  --primary: #1e7f52;
  --primary-2: #56b56d;
  --secondary: #0f5e3d;
  --tertiary: #48633b;
  --outline: #c7dccf;
  --outline-strong: #9fc5af;
  --shadow-soft: 0 14px 36px rgba(16, 53, 32, 0.08);
  --shadow-card: 0 20px 44px rgba(16, 53, 32, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Public Sans", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(960px 540px at 105% -5%, #c9f0d1 0%, transparent 60%),
    radial-gradient(760px 480px at -15% 5%, #dcefe9 0%, transparent 56%),
    linear-gradient(180deg, #f9f6f2 0%, var(--surface) 55%, #f1f6f1 100%);
  min-height: 100vh;
}

button,
select,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: rgba(247, 243, 239, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(198, 162, 150, 0.38);
  box-shadow: 0 6px 20px rgba(26, 14, 14, 0.08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.language-select {
  border: 1px solid transparent;
  border-radius: 10px;
  background: #e8e2db;
  padding: 10px 12px;
  color: #4f3c3e;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-link {
  align-items: center;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #176a43 0%, #47aa5f 100%);
  color: #fff;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 10px 20px rgba(23, 106, 67, 0.28);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy .eyebrow {
  text-transform: none;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
}

.eyebrow {
  margin: 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--secondary);
  text-transform: uppercase;
}

.topbar h1,
.panel h2,
.panel h3,
.nested h3 {
  margin: 0;
  letter-spacing: -0.02em;
}

.topbar h1 {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--secondary);
}

.panel h2 {
  font-size: 1.95rem;
  line-height: 1.08;
  font-weight: 900;
  color: var(--secondary);
}

.panel h3,
.nested h3 {
  font-size: 1.1rem;
  color: var(--secondary);
}

.icon-btn,
.primary,
.ghost {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.2s ease;
}

.icon-btn,
.ghost {
  background: #e8e2db;
  color: #4f3d3f;
  font-weight: 700;
  border-color: #dcc8bf;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(177, 33, 60, 0.3);
}

.icon-btn:hover,
.ghost:hover,
.primary:hover {
  transform: translateY(-1px);
}

.icon-btn:hover,
.ghost:hover {
  border-color: var(--outline-strong);
  background: #ece3dd;
}

.primary:hover {
  box-shadow: 0 16px 28px rgba(177, 33, 60, 0.38);
}

.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 14px 132px;
  display: grid;
  gap: 12px;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56) 0%, rgba(239, 231, 226, 0.86) 100%);
  border-radius: 22px;
  padding: 18px;
  border: 1px solid rgba(198, 162, 150, 0.36);
  box-shadow: var(--shadow-soft);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: reveal 0.38s ease;
}

.view.active.quiz-frame,
.view.active.results-frame {
  display: grid;
}

.editorial-hero {
  position: relative;
  overflow: hidden;
}

.editorial-hero::after {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 290px;
  height: 290px;
  background: radial-gradient(circle, rgba(177, 33, 60, 0.15) 0%, rgba(177, 33, 60, 0) 65%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #e8e2db;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
}

.subtitle,
.muted,
.hint,
.small-note {
  color: var(--muted);
}

.subtitle {
  margin: 10px 0 0;
  line-height: 1.55;
}

.feature-list {
  margin: 18px 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.feature-list li::marker {
  color: var(--primary);
}

.cta-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.pull-quote {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  color: var(--secondary);
  font-size: 1.06rem;
  font-style: italic;
  line-height: 1.45;
  border: 1px solid #f0e5e0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.quiz-frame,
.results-frame {
  gap: 16px;
}

.quiz-frame h2 {
  font-size: 1.45rem;
  line-height: 1.18;
}

.results-frame h2 {
  font-size: 1.75rem;
  line-height: 1.12;
}

.quiz-header,
.results-head {
  display: grid;
  gap: 12px;
}

.results-head > .mode-switch {
  max-width: 260px;
}

.results-actions {
  display: flex;
  justify-content: flex-start;
}

#exportPdfBtn {
  white-space: nowrap;
}

.charts-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.chart-card {
  min-height: 300px;
  box-shadow: inset 0 0 0 1px #f0e7e3;
}

.chart-card h3 {
  margin-bottom: 8px;
}

.chart-card canvas {
  width: 100%;
}

.progress-box {
  width: 100%;
  max-width: 220px;
}

.progress-track {
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: #e2d6d0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

#questionBody {
  display: grid;
  gap: 12px;
}

.option-list,
.ranked-list {
  display: grid;
  gap: 10px;
}

.option-card {
  border: 2px solid #efe4df;
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.12s ease, box-shadow 0.2s ease;
}

.option-card:hover {
  border-color: #d9bfba;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(52, 24, 24, 0.08);
}

.option-card.selected {
  border-color: var(--primary);
  box-shadow: 0 16px 30px rgba(177, 33, 60, 0.18);
}

.option-card strong {
  display: block;
}

.ranked-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rank-controls {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.rank-controls button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #e8e2db;
  color: #4f3d3f;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f2e8e3;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.75rem;
}

.pair-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.pair-center {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.scale-row {
  display: grid;
  gap: 8px;
}

.scale-row input[type="range"] {
  width: 100%;
}

.results-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.result-card {
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid #efe4df;
  box-shadow: var(--shadow-card);
}

.score {
  color: var(--primary);
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.metric-table {
  width: 100%;
  border-collapse: collapse;
}

.metric-table td {
  padding: 8px 0;
  border-bottom: 1px solid #efe9ea;
}

.nested {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #efe4df;
}

.two-col {
  display: grid;
  gap: 12px;
}

.simple-list {
  margin: 0;
  padding-left: 18px;
}

.warning {
  color: var(--tertiary);
}

.warning-badge {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff0e2;
  border: 1px solid #ffd2ad;
  color: #0f5e3d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.warning-text {
  margin-top: 10px;
  color: #0f5e3d;
  font-weight: 600;
}

.side-panel {
  display: none;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

body.debug-enabled .side-panel {
  display: block;
}

.debug-block {
  margin-bottom: 16px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.footer-shell {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(247, 243, 239, 0.9);
  backdrop-filter: blur(14px);
  display: none;
  border-top: 1px solid rgba(198, 162, 150, 0.38);
}

body[data-active-view="quizView"] .footer-shell {
  display: block;
}

.controls {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 10px;
}

.mode-switch {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.mode-switch label {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--secondary);
}

.mode-switch select {
  border: 1px solid #dcc8bf;
  border-radius: 10px;
  background: #e8e2db;
  padding: 9px 10px;
  width: 100%;
  max-width: 240px;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(177, 33, 60, 0.28);
  outline-offset: 2px;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding: 20px 22px 26px;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .quiz-header,
  .results-head {
    grid-template-columns: 1fr auto auto;
    align-items: end;
  }

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

  .quiz-frame h2 {
    font-size: 1.8rem;
  }

  .results-frame h2 {
    font-size: 2.1rem;
  }

  .pair-grid {
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }

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

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

  body.debug-enabled .side-panel {
    display: block;
    position: sticky;
    top: 84px;
    background: linear-gradient(180deg, #fff 0%, #f2ece8 100%);
    backdrop-filter: none;
  }

  .footer-shell {
    position: static;
    padding: 0 22px 22px;
    background: transparent;
    backdrop-filter: none;
  }

  body[data-active-view="quizView"] .footer-shell {
    display: block;
  }

  .controls {
    justify-content: end;
    margin-left: auto;
    max-width: 1080px;
    width: 360px;
  }
}

@media (max-width: 899px) {
  .topbar {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .brand-wrap {
    width: 100%;
  }

  .brand-copy h1 {
    font-size: 1.05rem;
  }

  .results-head {
    gap: 10px;
  }

  .results-head > .mode-switch,
  .results-actions {
    max-width: none;
    width: 100%;
  }

  .results-actions {
    position: sticky;
    top: 74px;
    z-index: 10;
    background: rgba(247, 243, 239, 0.94);
    margin: -4px -4px 2px;
    padding: 6px 4px;
    border-radius: 10px;
  }

  #exportPdfBtn {
    width: 100%;
  }

  .mode-switch select {
    max-width: none;
  }
}

@media (min-width: 1180px) {
  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
