:root {
  --ink: #111111;
  --ink-soft: #2a2a28;
  --muted: #5f5f5c;
  --paper: #f7f7f5;
  --paper-deep: #ebebe8;
  --navy: #111111;
  --teal: #D85A30;
  --teal-bright: #e36b42;
  --gold: #D85A30;
  --spark: #D85A30;
  --line: rgba(17, 17, 17, 0.12);
  --card: rgba(255, 255, 255, 0.78);
  --danger: #ad2f2f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.10);
  --radius: 18px;
  --font-display: "Source Serif 4", Georgia, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(216, 90, 48, 0.10), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(17, 17, 17, 0.05), transparent 50%),
    linear-gradient(180deg, #f3f3f0 0%, var(--paper) 45%, #efefed 100%);
  line-height: 1.5;
}

img {
  max-width: 100%;
}

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  max-width: 1120px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  font-style: normal;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: block;
}

.brand-text {
  color: var(--ink);
}

.brand-text em {
  font-style: normal;
  color: var(--spark);
}

.header-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 3rem;
}

.page-home {
  background: #111111;
}

.page-home .site-header {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(1120px, calc(100% - 2rem));
  max-width: none;
  z-index: 3;
}

.page-home .brand,
.page-home .brand-text,
.page-home .header-meta {
  color: rgba(247, 247, 245, 0.92);
}

.page-home .brand-text em {
  color: #F0A58A;
}

.page-home .site-footer {
  color: rgba(247, 247, 245, 0.55);
}

.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-content: center;
  overflow: hidden;
  color: #f7f4ef;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 72% 38%, rgba(216, 90, 48, 0.18), transparent 60%),
    radial-gradient(700px 480px at 100% 100%, rgba(216, 90, 48, 0.08), transparent 55%),
    linear-gradient(160deg, #111111 0%, #1a1a18 48%, #241611 100%);
  overflow: hidden;
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, rgba(17, 17, 17, 0.9) 0%, rgba(17, 17, 17, 0.55) 38%, rgba(17, 17, 17, 0.12) 68%, rgba(17, 17, 17, 0.45) 100%);
  pointer-events: none;
}

.hero-abstract {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero-plane-a {
  animation: planeDrift 16s ease-in-out infinite alternate;
  transform-origin: 90% 20%;
}

.hero-plane-b {
  animation: planeDrift 20s ease-in-out infinite alternate-reverse;
  transform-origin: 100% 100%;
}

.hero-rings {
  animation: ringPulse 12s ease-in-out infinite;
  transform-origin: 820px 340px;
}

.ring-plot {
  animation: plotBreathe 8s ease-in-out infinite;
  transform-origin: 0 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 6.5rem 0 4rem;
  display: grid;
  gap: 1.25rem;
  justify-items: start;
  animation: rise 0.85s ease both;
}

.hero-content > *:not(.hero-actions) {
  max-width: 34rem;
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: #fff;
  margin: 0;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1.2;
  margin: 0;
  color: rgba(247, 244, 239, 0.92);
}

.hero-content > p {
  margin: 0;
  color: rgba(247, 244, 239, 0.78);
  font-size: 1.1rem;
  max-width: 32rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.page-home .btn-primary {
  background: #f7f4ef;
  color: var(--navy);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.page-home .btn-primary:hover {
  background: #fff;
}

.page-home .btn-secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.page-home .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.85rem 1.4rem;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(10, 42, 67, 0.22);
}

.btn-primary:hover {
  background: #12385a;
}

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid rgba(10, 42, 67, 0.25);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.5);
}

.panel {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.meta-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
  max-width: 36rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.field .hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.field select,
.field input[type="text"],
.field input[type="password"] {
  font: inherit;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(11, 31, 51, 0.18);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

.field select:focus,
.field input:focus {
  outline: 2px solid rgba(15, 109, 106, 0.35);
  border-color: var(--teal);
}

/* Survey */
.survey-layout {
  display: grid;
  gap: 1.25rem;
  padding-top: 0.5rem;
}

.progress-bar {
  position: sticky;
  top: 0.75rem;
  z-index: 5;
  background: rgba(247, 244, 239, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 8px 24px rgba(10, 42, 67, 0.08);
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--paper-deep);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--navy), var(--teal-bright));
  border-radius: inherit;
  transition: width 0.25s ease;
}

.progress-label {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}

.pillar-section {
  scroll-margin-top: 5rem;
}

.pillar-section + .pillar-section {
  margin-top: 1.25rem;
}

.pillar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pillar-head h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  margin: 0;
  letter-spacing: -0.02em;
}

.pillar-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  width: 100%;
}

.question {
  margin: 0;
  padding: 1rem 0;
  border: 0;
  border-top: 1px solid var(--line);
  min-inline-size: 0;
}

.pillar-section .question:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.question legend {
  padding: 0;
  float: left;
  width: 100%;
}

.question legend + * {
  clear: both;
}

.question-prompt {
  font-weight: 600;
  margin: 0 0 0.85rem;
  color: var(--ink-soft);
}

.options {
  display: grid;
  gap: 0.55rem;
}

.option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(11, 31, 51, 0.12);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.option:hover {
  border-color: rgba(15, 109, 106, 0.45);
  background: rgba(255, 255, 255, 0.9);
}

.option:has(input:checked) {
  border-color: var(--teal);
  background: rgba(20, 145, 140, 0.08);
  box-shadow: inset 0 0 0 1px rgba(15, 109, 106, 0.2);
}

.option input {
  margin-top: 0.2rem;
  accent-color: var(--teal);
}

.option-stage {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.15rem;
}

.survey-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

.error-banner {
  display: none;
  background: rgba(155, 44, 44, 0.08);
  color: var(--danger);
  border: 1px solid rgba(155, 44, 44, 0.25);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.error-banner.visible {
  display: block;
}

/* Results */
.results-hero {
  display: grid;
  gap: 1.5rem;
  margin: 1rem 0 1.5rem;
}

@media (min-width: 860px) {
  .results-hero {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: stretch;
  }
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 109, 106, 0.12);
  color: var(--teal);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stage-badge.stage-1 { background: rgba(173, 47, 47, 0.1); color: #ad2f2f; }
.stage-badge.stage-2 { background: rgba(216, 90, 48, 0.14); color: #9b3f1f; }
.stage-badge.stage-3 { background: rgba(17, 17, 17, 0.08); color: #111111; }
.stage-badge.stage-4 { background: rgba(216, 90, 48, 0.18); color: #D85A30; }

.score-number {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 4.5rem);
  line-height: 1;
  margin: 0.4rem 0;
  letter-spacing: -0.03em;
}

.note {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--gold);
  background: rgba(196, 163, 90, 0.12);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.chart-panel {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.chart-head h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.chart-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
}

.chart-key {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-key li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-key span {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.08);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.75rem;
}

.pillar-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 760px) {
  .pillar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.pillar-card h3 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.pillar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pillar-card p {
  margin: 0;
  color: var(--ink-soft);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.chip {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(11, 31, 51, 0.06);
  color: var(--ink-soft);
}

/* Admin */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty-state {
  color: var(--muted);
  padding: 1rem 0;
}

.site-footer {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.footer-mark {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: block;
  opacity: 0.9;
}

/* Acronym glossary tips */
.ami-term {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: help;
  position: relative;
}

.ami-term-label {
  border-bottom: 1px solid rgba(216, 90, 48, 0.85);
  box-shadow: inset 0 -1px 0 rgba(216, 90, 48, 0.25);
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ami-term:hover .ami-term-label,
.ami-term:focus .ami-term-label,
.ami-term:focus-visible .ami-term-label {
  color: var(--spark);
  border-bottom-color: var(--spark);
  box-shadow: inset 0 -1px 0 rgba(216, 90, 48, 0.55);
  outline: none;
}

.ami-term:focus-visible {
  outline: none;
}

.ami-tip {
  position: fixed;
  z-index: 1000;
  width: min(22rem, calc(100vw - 1.5rem));
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 16px;
  background:
    radial-gradient(120px 80px at 100% 0%, rgba(216, 90, 48, 0.22), transparent 70%),
    linear-gradient(160deg, #1a1a18 0%, #111111 55%, #1c1410 100%);
  color: #f7f7f5;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 22px 50px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.18s ease;
  pointer-events: none;
}

.ami-tip.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ami-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #151513;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateX(-50%) rotate(45deg);
}

.ami-tip.is-below::before {
  top: -6px;
  bottom: auto;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ami-tip-spark {
  width: 10px;
  height: 10px;
  margin-bottom: 0.55rem;
  background: var(--spark);
  transform: rotate(45deg);
  box-shadow: 0 0 18px rgba(216, 90, 48, 0.55);
}

.ami-tip-term {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f0a58a;
}

.ami-tip-def {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: rgba(247, 247, 245, 0.88);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes planeDrift {
  from {
    transform: translate3d(0, 0, 0);
    opacity: 0.85;
  }
  to {
    transform: translate3d(-18px, 12px, 0);
    opacity: 1;
  }
}

@keyframes ringPulse {
  0%,
  100% {
    opacity: 0.85;
    transform: translate(820px, 340px) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(820px, 340px) scale(1.03);
  }
}

@keyframes plotBreathe {
  0%,
  100% {
    opacity: 0.9;
  }
  50% {
    opacity: 1;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .toolbar,
  .site-footer,
  .btn,
  .ami-tip {
    display: none !important;
  }

  .ami-term-label {
    border-bottom: 0;
    box-shadow: none;
  }

  .shell {
    width: 100%;
    margin: 0;
  }

  .panel {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .pillar-card {
    break-inside: avoid;
  }

  .hero-plane-a,
  .hero-plane-b,
  .hero-rings,
  .ring-plot {
    animation: none;
  }

  .page-home {
    background: #fff;
  }

  .page-home .brand,
  .page-home .header-meta,
  .hero,
  .hero-brand,
  .hero h1,
  .hero-content > p {
    color: #000;
  }
}
