:root {
  --ink: #111214;
  --paper: #f7f2e8;
  --white: #fefcf7;
  --red: #e24c32;
  --blue: #1f5b8d;
  --yellow: #f2d34a;
  --green: #2f8a4b;
  --shadow: 0 16px 0 rgba(17, 18, 20, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Avenir Next", "Futura", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #fff8ef 0%, #f4efe6 45%, #f7e9dc 100%);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -25vh -10vw;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(17, 18, 20, 0.05) 0 1px,
      transparent 1px 120px
    ),
    repeating-linear-gradient(
      180deg,
      rgba(17, 18, 20, 0.05) 0 1px,
      transparent 1px 120px
    ),
    linear-gradient(120deg, rgba(255, 255, 255, 0.9), rgba(244, 233, 223, 0.85));
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  width: 280px;
  height: 280px;
  top: -80px;
  right: -60px;
  border: 2px solid rgba(17, 18, 20, 0.12);
  background: linear-gradient(140deg, rgba(226, 76, 50, 0.2), rgba(31, 91, 141, 0.18));
  transform: rotate(8deg);
  z-index: -1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.app-shell,
.survey-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: grid;
  gap: 32px;
}

.survey-shell {
  max-width: 980px;
}

.retest-gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(17, 18, 20, 0.5);
  z-index: 20;
}

.retest-gate[hidden] {
  display: none;
}

.retest-panel {
  width: min(92vw, 460px);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.retest-title {
  font-size: 20px;
  font-weight: 700;
}

.retest-note {
  font-size: 13px;
  color: rgba(17, 18, 20, 0.7);
}

.retest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.survey-card.is-blocked {
  opacity: 0.35;
  filter: grayscale(0.2);
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  display: grid;
  place-items: center;
  font-family: "Instrument Serif", "Georgia", serif;
  font-size: 20px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}

.brand-title {
  font-size: 18px;
  font-weight: 600;
}

.brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.75;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.share-status {
  font-size: 12px;
  color: rgba(17, 18, 20, 0.7);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: var(--white);
}

.btn {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  background: var(--white);
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn.primary {
  background: var(--red);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--white);
}

h1 {
  margin: 12px 0;
  font-family: "Instrument Serif", "Georgia", serif;
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.05;
}

.hero p {
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 20px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-meta {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.meta-card {
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--white);
}

.meta-card strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.mondrian-board {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 70px;
  gap: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.tile {
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--white);
}

.tile.red { background: var(--red); }
.tile.blue { background: var(--blue); }
.tile.yellow { background: var(--yellow); }
.tile.green { background: var(--green); }
.tile.dark { background: var(--ink); }
.tile.tall { grid-row: span 2; }
.tile.wide { grid-column: span 2; }

.note-card {
  margin-top: 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--paper);
  display: grid;
  gap: 10px;
}

.panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.panel h2 {
  margin: 0;
  font-family: "Instrument Serif", "Georgia", serif;
  font-size: 26px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.card {
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 16px;
  background: var(--paper);
  display: grid;
  gap: 8px;
  min-height: 120px;
}

.card strong {
  font-size: 16px;
}

.card.muted {
  background: var(--white);
  border-style: dashed;
}

.card-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--yellow);
  width: fit-content;
}

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

.step-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--paper);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  background: var(--paper);
}

.footer {
  font-size: 12px;
  color: rgba(17, 18, 20, 0.7);
  display: grid;
  gap: 6px;
}

.survey-top {
  display: grid;
  gap: 14px;
}

.survey-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.survey-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pill {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--white);
  font-size: 12px;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 10%;
  background: var(--blue);
  transition: width 0.25s ease;
}

.survey-card {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.question-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.question-id,
.question-type {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  text-transform: uppercase;
  background: var(--paper);
}

.question-title {
  font-family: "Instrument Serif", "Georgia", serif;
  font-size: clamp(24px, 3.6vw, 34px);
  margin: 0;
  line-height: 1.2;
}

.question-subtitle {
  margin: 0;
  color: rgba(17, 18, 20, 0.72);
  font-size: 14px;
}

.question-subtitle.is-error {
  color: var(--red);
}

.options-grid {
  display: grid;
  gap: 12px;
}

.option {
  position: relative;
  display: block;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option span {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.option span::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--white);
  flex-shrink: 0;
}

.option input:checked + span {
  background: var(--yellow);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.option input:checked + span::before {
  background: var(--ink);
}

.option:focus-within span {
  outline: 3px solid rgba(31, 91, 141, 0.35);
  outline-offset: 2px;
}

.survey-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.survey-actions .btn {
  min-width: 120px;
}

.fineprint {
  margin: 0;
  font-size: 12px;
  color: rgba(17, 18, 20, 0.7);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.reveal {
  animation: rise 0.7s ease both;
  animation-delay: var(--delay, 0ms);
}

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

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .panels,
  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .option span,
  .progress-bar span {
    animation: none;
    transition: none;
  }
}
