:root {
  --bg: #f8f2ff;
  --panel: #ffffff;
  --panel-soft: #fffbff;
  --ink: #24193a;
  --muted: #62557d;
  --accent: #ea4d9b;
  --accent-dark: #8e2f9f;
  --accent-cool: #6b56db;
  --line: #e2d5ee;
  --line-strong: #ceb9e2;
  --shadow: 0 14px 36px rgba(38, 24, 62, 0.13);
  --hero-glow: radial-gradient(circle at 20% -12%, #ffc3eb 0%, transparent 34%);
  --hero-glow-2: radial-gradient(circle at 95% 0%, #d7d5ff 0%, transparent 30%);
  --hero-glow-3: radial-gradient(circle at 50% 100%, #ffd8f2 0%, transparent 38%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(248, 242, 255, 0.95)),
    var(--hero-glow),
    var(--hero-glow-2),
    var(--hero-glow-3),
    var(--bg);
  line-height: 1.4;
  min-height: 100vh;
}

.hero,
.layout,
.model-notes,
.reference,
.footer-note {
  width: min(1200px, calc(100vw - 2rem));
  margin-inline: auto;
}

.hero {
  padding: 2.25rem 0 1.1rem;
  animation: fade-rise 450ms ease both;
}

.eyebrow {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-dark);
  margin: 0;
}

.hero h1 {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  margin: 0.25rem 0;
  font-size: clamp(1.9rem, 3.2vw, 2.85rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero p {
  color: var(--muted);
  max-width: 70ch;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  animation: fade-rise 540ms ease both;
}

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.panel h2 {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  margin-top: 0;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.controls form {
  display: grid;
  gap: 0.85rem;
}

.how-to-use {
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff9ff;
  padding: 0.7rem;
}

.how-to-use h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.how-to-use p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.tooltip-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.label-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tooltip-trigger {
  appearance: none;
  border: none;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  cursor: help;
  position: relative;
  line-height: 1;
  padding: 0;
}

.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: min(300px, 72vw);
  background: linear-gradient(165deg, #2f1a4a, #4a2e67);
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 8px 22px rgba(36, 25, 58, 0.28);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  white-space: normal;
}

.tooltip-trigger::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.15rem);
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #3a2458;
  opacity: 0;
  pointer-events: none;
  z-index: 31;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before,
.tooltip-trigger:focus-visible::after,
.tooltip-trigger:focus-visible::before {
  opacity: 1;
}

.tooltip-trigger:focus-visible {
  outline: 2px solid #9f57cc;
  outline-offset: 2px;
}

.control-note {
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.35;
}

.control-note.sources {
  margin-top: -0.25rem;
}

.control-note a {
  color: #7b2ea3;
}

.focus-controls {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  background: linear-gradient(180deg, #fff7fe 0%, #fffcff 100%);
  display: grid;
  gap: 0.85rem;
}

.focus-controls h3 {
  margin: 0;
  font-size: 0.96rem;
}

.parameter-anchor-cards {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.parameter-anchor-card {
  border: 1px solid #eadbf4;
  border-radius: 10px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.78);
}

.parameter-anchor-title {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.parameter-anchor-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.96rem;
}

.parameter-anchor-card p:last-child {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.parameter-anchor-refs {
  margin-top: 0.45rem;
}

.footnote-token {
  display: inline-block;
  margin-right: 0.28rem;
  color: #7b2ea3;
  font-weight: 700;
  text-decoration: none;
}

.footnote-token:hover {
  text-decoration: underline;
}

.advanced-controls {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  padding: 0.15rem 0.75rem 0.75rem;
}

.advanced-controls summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.65rem 0;
}

.advanced-controls[open] summary {
  margin-bottom: 0.35rem;
}

.advanced-controls > label,
.advanced-controls > .beta-editor {
  margin-top: 0.75rem;
}

.beta-editor {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: linear-gradient(180deg, #fff6fe 0%, #fef7ff 100%);
}

.beta-editor h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.beta-preset-buttons {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.beta-preset-chip {
  border: 1px solid #ceb7e2;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.77rem;
  background: #fffcff;
  color: var(--ink);
  cursor: pointer;
  transition: all 160ms ease;
}

.beta-preset-chip.active {
  border-color: #9f57cc;
  color: #6d2c95;
  background: #f6edff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(162, 96, 210, 0.22);
}

.beta-mix-visual {
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 0.9rem;
  overflow: hidden;
  background: #f3ecfa;
  display: flex;
}

.beta-mix-segment {
  display: block;
  height: 100%;
}

.beta-custom-sliders {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.45rem;
}

.beta-slider-row {
  display: grid;
  gap: 0.25rem;
}

.beta-slider-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
}

.beta-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.beta-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  display: inline-block;
}

.beta-reset-button {
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  background: #fffcff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 160ms ease;
}

.beta-reset-button:hover {
  border-color: #9f57cc;
  transform: translateY(-1px);
}

output {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.value-with-unit {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.value-input {
  width: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
  color: var(--ink);
  background: #fffdff;
  -moz-appearance: textfield;
}

.value-input::-webkit-inner-spin-button,
.value-input::-webkit-outer-spin-button {
  opacity: 1;
  height: 1.2rem;
}

.value-input:focus {
  outline: 2px solid var(--accent-cool);
  outline-offset: 1px;
  border-color: var(--accent-cool);
}

.value-input.wide {
  width: 5.5rem;
}

.value-unit {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

input[type="range"] {
  width: 100%;
  accent-color: #be49df;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
  background: #fffdff;
  color: var(--ink);
  font: inherit;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fffdff;
}

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

.kpi strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.kpi.primary {
  background: linear-gradient(140deg, #6d55da 0%, #ab46cd 45%, #ea4d9b 100%);
  border: none;
  color: #fff;
  box-shadow: 0 12px 24px rgba(172, 70, 205, 0.28);
}

.kpi.primary p {
  color: #fce7fb;
}

.kpi.primary strong {
  font-size: 1.32rem;
}

.chart-grid {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem;
  background: linear-gradient(180deg, #ffffff 0%, #fffaff 100%);
}

.chart-card h3 {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  margin: 0.2rem 0 0.5rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.chart {
  width: 100%;
  min-height: 340px;
}

.chart-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.subchart-title {
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  margin: 0.8rem 0 0.35rem;
  font-size: 1rem;
}

.chart-secondary {
  min-height: 300px;
}

.constellation-chart {
  min-height: 380px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(164, 140, 216, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(37, 26, 59, 0.04), rgba(37, 26, 59, 0.1));
}

.constellation-canvas {
  width: 100%;
  height: 100%;
  min-height: 380px;
  display: block;
  border-radius: 14px;
}

.constellation-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  margin: 0.15rem 0 0.45rem;
}

.constellation-play-toggle {
  border: 1px solid var(--line);
  background: #fffdff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.constellation-play-toggle:hover {
  border-color: #9f57cc;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(146, 47, 159, 0.16);
}

.constellation-speed-control {
  margin: 0;
  min-width: min(330px, 100%);
  flex: 1;
}

.constellation-speed-control .value-input {
  font-size: 0.8rem;
  width: 3.5rem;
}

.constellation-family-cards {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.constellation-insights {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.constellation-insight-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: linear-gradient(180deg, #fff9ff 0%, #fffdfd 100%);
}

.constellation-insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.constellation-insight-head h4 {
  margin: 0;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.constellation-insight-head strong {
  font-size: 0.9rem;
}

.constellation-insight-card p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.constellation-insight-metric {
  margin-top: 0.55rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
}

.constellation-insight-metric span {
  color: var(--muted);
  font-size: 0.78rem;
}

.constellation-insight-metric strong {
  font-size: 0.88rem;
}

.constellation-insight-bar {
  margin-top: 0.35rem;
  height: 0.5rem;
  border-radius: 999px;
  overflow: hidden;
  background: #efe8f8;
}

.constellation-insight-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.constellation-family-card {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: linear-gradient(180deg, #fff9ff 0%, #fff5fd 100%);
}

.constellation-family-card h4 {
  margin: 0;
  font-size: 0.84rem;
}

.constellation-family-card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.reference-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.model-notes {
  margin-top: 1rem;
}

.reference h3 {
  margin: 0.2rem 0;
}

.reference ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.source-footnotes {
  margin-top: 1rem;
}

.source-footnotes > p {
  margin-top: -0.15rem;
  color: var(--muted);
}

.source-footnotes-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.source-footnote {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: linear-gradient(180deg, #fffefe 0%, #fff9ff 100%);
  scroll-margin-top: 1rem;
}

.source-footnote-id {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.source-footnote h3 {
  margin: 0.25rem 0 0.35rem;
  font-size: 0.98rem;
}

.source-footnote p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.source-footnote a,
.source-footnote-note {
  display: inline-block;
  margin-top: 0.45rem;
  color: #7b2ea3;
  font-size: 0.84rem;
  font-weight: 600;
}

.footer-note {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0 2rem;
  animation: fade-rise 700ms ease both;
}

.error {
  width: min(900px, calc(100vw - 2rem));
  margin: 2rem auto;
}

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

@media (prefers-reduced-motion: reduce) {
  .hero,
  .layout,
  .footer-note {
    animation: none;
  }
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: 340px 1fr;
  }

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

  .chart-wide {
    grid-column: 1 / -1;
  }

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

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