:root {
  color-scheme: light;
  --bg: #faf7f1;
  --ink: #202124;
  --muted: #64605d;
  --line: #d9d2c4;
  --panel: #fffdf8;
  --teal: #2f5f91;
  --teal-dark: #234a73;
  --berry: #b4473f;
  --gold: #b7832f;
  --sage: #587366;
  --shadow: 0 18px 45px rgba(26, 24, 20, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

a {
  color: var(--teal-dark);
  font-weight: 760;
  text-decoration-color: rgba(47, 95, 145, 0.28);
  text-underline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0.5rem;
  z-index: 20;
  transform: translateY(-150%);
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.75rem;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(32, 33, 36, 0.12);
  background: rgba(250, 247, 241, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #f2c14e;
  font-size: 0.62rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.nav-links a {
  max-width: 100%;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.48rem 0.75rem;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-weight: 680;
  font-size: 0.9rem;
  text-align: center;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  border-color: var(--ink);
  background: #fff;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 6px 2px 22px;
}

.project-note {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.25rem, 5vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.35rem, 2.3vw, 2.2rem);
}

h3 {
  font-size: 0.98rem;
}

.status-pill,
.version-badge {
  border: 1px solid rgba(47, 95, 145, 0.25);
  border-radius: 999px;
  background: #eaf3f7;
  color: var(--teal-dark);
  padding: 0.35rem 0.62rem;
  font-size: 0.78rem;
  font-weight: 820;
  white-space: nowrap;
}

.public-info {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(230px, 0.82fr) minmax(230px, 0.82fr);
  gap: 12px;
  margin-bottom: 18px;
}

.info-card,
.control-panel,
.visual-panel,
.plot-card,
.readout-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.info-card {
  padding: 14px;
  box-shadow: 0 10px 26px rgba(26, 24, 20, 0.05);
}

.info-card h2 {
  max-width: 20ch;
  font-size: clamp(1.2rem, 2.1vw, 1.8rem);
  line-height: 1.02;
}

.info-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.info-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.info-kicker {
  color: var(--berry);
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel {
  position: sticky;
  top: 80px;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.visual-panel {
  min-width: 0;
  padding: 20px;
}

.field-label {
  display: block;
  margin-bottom: -6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

select,
button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 720;
}

button {
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: rgba(47, 95, 145, 0.42);
}

.control-group {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.subsection-title {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 820;
  text-transform: uppercase;
}

.parameter-grid {
  display: grid;
  grid-template-columns: minmax(4.8rem, 0.9fr) minmax(0, 1fr) minmax(0, 1fr) 3.2rem;
  gap: 8px;
  align-items: center;
}

.parameter-header,
.parameter-name,
.fix-toggle {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 820;
}

.parameter-header {
  text-transform: uppercase;
}

.parameter-name {
  line-height: 1.15;
}

.parameter-slider {
  display: grid;
  gap: 4px;
}

.parameter-slider span {
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.parameter-slider input:disabled {
  opacity: 0.42;
}

.parameter-name.is-disabled,
.parameter-slider.is-disabled,
.fix-toggle.is-disabled {
  opacity: 0.5;
}

.parameter-slider.is-fixed span {
  color: var(--muted);
}

.fix-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.fix-toggle input {
  accent-color: var(--teal);
}

.slider-block {
  display: grid;
  gap: 8px;
}

.slider-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.slider-name {
  font-weight: 780;
}

.slider-role,
.range-limits {
  color: var(--muted);
  font-size: 0.82rem;
}

.slider-value {
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.range-limits {
  display: flex;
  justify-content: space-between;
}

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

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 999px;
}

.swatch.baseline {
  background: #64748b;
}

.swatch.current {
  background: var(--teal);
}

.swatch.quantile {
  background: var(--gold);
}

.annotation {
  border-left: 4px solid var(--sage);
  margin-bottom: 16px;
  padding: 9px 12px;
  background: #f2f6f0;
  color: #3b463d;
  font-weight: 720;
}

.plot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.plot-card {
  min-width: 0;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(26, 24, 20, 0.05);
}

.plot-card h3 {
  margin-bottom: 10px;
}

svg {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.axis text {
  fill: var(--muted);
  font-size: 12px;
}

.axis line,
.axis path,
.grid-line {
  stroke: #ded9ce;
  stroke-width: 1;
}

.baseline-path {
  fill: none;
  stroke: #64748b;
  stroke-width: 2.2;
  stroke-dasharray: 7 7;
}

.current-path {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.threshold-line {
  stroke: var(--berry);
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.fan-line {
  fill: none;
  stroke: rgba(183, 131, 47, 0.7);
  stroke-width: 2;
}

.fan-line.median {
  stroke: var(--teal);
  stroke-width: 3;
}

.quantile-guide {
  stroke: rgba(183, 131, 47, 0.25);
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
}

.readout-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.readout-card {
  padding: 12px;
  box-shadow: 0 10px 26px rgba(26, 24, 20, 0.04);
}

.readout-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  text-transform: uppercase;
}

.readout-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.formula-card {
  grid-column: span 2;
}

.formula-card strong {
  font-size: 0.88rem;
  line-height: 1.35;
}

:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .site-header,
  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links,
  .legend {
    justify-content: flex-start;
  }

  .public-info,
  .workspace,
  .plot-grid,
  .readout-grid {
    grid-template-columns: 1fr;
  }

  .formula-card {
    grid-column: auto;
  }

  .control-panel {
    position: static;
  }
}

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

  h1 {
    font-size: 2.7rem;
  }

  .visual-panel,
  .control-panel {
    padding: 14px;
  }

  .parameter-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .parameter-header {
    display: none;
  }

  .parameter-name {
    margin-top: 8px;
  }

  svg {
    min-height: 260px;
  }
}
