:root {
  color-scheme: light;
  --ink: #182229;
  --muted: #66747b;
  --quiet: #879399;
  --paper: #f4f1e9;
  --card: #fffefa;
  --rule: #dcd8cd;
  --rule-strong: #c7c1b4;
  --navy: #08131f;
  --teal: #087f8c;
  --teal-dark: #096872;
  --coral: #e75f4f;
  --cyan: #2bb7ca;
  --shadow: 0 16px 45px rgba(34, 41, 43, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 300px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.9), transparent 28rem),
    linear-gradient(180deg, #f7f4ed 0, var(--paper) 35rem);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.24;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}

button,
output {
  font: inherit;
}

button {
  min-height: 2.35rem;
  border: 1px solid var(--rule-strong);
  border-radius: 0.55rem;
  padding: 0.52rem 0.78rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled) {
  border-color: #8ba2a4;
  background: #fff;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

button:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 127, 140, 0.34);
  outline-offset: 3px;
}

a {
  color: var(--teal-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.site-header,
.explorer,
.usage-note {
  width: min(1480px, calc(100% - 3rem));
  margin-inline: auto;
}

.site-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  padding: 2.2rem 0 2rem;
  border-bottom: 1px solid var(--rule);
}

.back-link {
  grid-column: 1 / -1;
  width: max-content;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link span {
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 120ms ease;
}

.back-link:hover span {
  transform: translateX(-0.18rem);
}

.title-block {
  max-width: 64rem;
}

.eyebrow,
.panel-number {
  margin: 0 0 0.45rem;
  color: var(--teal-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: none;
  margin-bottom: 0.85rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 4.8vw, 4.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.96;
  white-space: nowrap;
}

.lede {
  max-width: 63rem;
  margin-bottom: 0;
  color: #506067;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.58;
}

.formula {
  white-space: nowrap;
  color: var(--ink);
}

.parameter-readout {
  min-width: 15.5rem;
  border-left: 2px solid var(--coral);
  padding: 0.3rem 0 0.3rem 1rem;
}

.parameter-readout__label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.parameter-readout__value {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.configuration-actions {
  display: flex;
  min-height: 2.35rem;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.copy-configuration {
  border-color: rgba(8, 127, 140, 0.48);
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 750;
}

.configuration-status {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.explorer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.2vw, 2rem);
  padding-block: clamp(1.2rem, 2.4vw, 2rem);
}

.plane-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(199, 193, 180, 0.9);
  border-radius: 1.05rem;
  background: rgba(255, 254, 250, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.plane-card__header {
  display: flex;
  min-height: 5rem;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1rem 1.15rem 0.9rem;
}

.plane-card h2,
.usage-note h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.panel-number {
  margin-bottom: 0.25rem;
  color: var(--quiet);
  font-size: 0.62rem;
}

.render-status {
  max-width: 58%;
  overflow: hidden;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--navy);
  isolation: isolate;
}

.canvas-shell::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.08);
  content: "";
  pointer-events: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#dynamical-canvas {
  cursor: grab;
}

#dynamical-canvas:active {
  cursor: grabbing;
}

.canvas-hint {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  z-index: 3;
  max-width: calc(100% - 1.3rem);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  color: rgba(239, 246, 247, 0.76);
  background: rgba(5, 12, 22, 0.65);
  font-size: 0.65rem;
  line-height: 1;
  pointer-events: none;
  backdrop-filter: blur(5px);
}

.progress-track {
  height: 3px;
  overflow: hidden;
  background: #d7d6cf;
}

.progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 120ms linear;
}

.progress-label {
  display: block;
  min-height: 1.9rem;
  padding: 0.48rem 1.15rem 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: minmax(9rem, 0.65fr) minmax(14rem, 1.35fr);
  gap: 0.85rem;
  padding: 1rem 1.15rem;
}

.controls--parameter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 0.75rem;
}

.control-group {
  display: flex;
  min-width: 0;
  gap: 0.5rem;
  flex-direction: column;
}

.control-group--wide {
  min-width: 0;
}

.controls--parameter .control-group--wide {
  grid-column: 1 / -1;
}

.control-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button-row,
.stepper {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.button-row {
  flex-wrap: wrap;
}

.button-muted {
  color: var(--muted);
  background: transparent;
}

.stepper {
  width: max-content;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.72);
}

.stepper button {
  width: 2.35rem;
  min-height: 2.25rem;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.05rem;
}

.stepper button:first-child {
  border-right: 1px solid var(--rule);
}

.stepper button:last-child {
  border-left: 1px solid var(--rule);
}

.stepper output {
  min-width: 2.6rem;
  color: #2f3b40;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.generator-key,
.parameter-key {
  display: flex;
  min-height: 2.9rem;
  gap: 0.7rem 1.1rem;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  padding: 0.75rem 1.15rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.swatch {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.28rem;
  border: 1px solid rgba(0, 0, 0, 0.13);
  border-radius: 50%;
  vertical-align: -0.04rem;
}

.swatch--f {
  background: #ff6b5c;
}

.swatch--g {
  background: #4bd6e8;
}

.swatch--survives {
  background: #173a76;
}

.swatch--separated {
  background: #f4f0e4;
}

.swatch--noncontracting {
  background: #131926;
}

.usage-note {
  display: grid;
  grid-template-columns: minmax(12rem, 0.55fr) minmax(18rem, 1.45fr);
  gap: 1rem 2rem;
  align-items: start;
  margin-bottom: 4rem;
  border-top: 1px solid var(--rule);
  padding: 2rem 0;
}

.usage-note .eyebrow {
  grid-column: 1 / -1;
  margin-bottom: -0.4rem;
}

.usage-note p:last-child {
  max-width: 58rem;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.noscript-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 10;
  border-radius: 0.7rem;
  padding: 1rem;
  color: white;
  background: #8f3027;
  text-align: center;
}

@media (max-width: 900px) {
  .site-header,
  .explorer,
  .usage-note {
    width: min(720px, calc(100% - 2rem));
  }

  .site-header {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }

  .back-link {
    grid-column: auto;
  }

  .parameter-readout {
    width: min(100%, 22rem);
  }

  .explorer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .site-header,
  .explorer,
  .usage-note {
    width: calc(100% - 1rem);
  }

  .site-header {
    padding-top: 1.1rem;
  }

  h1 {
    font-size: clamp(2rem, 10.5vw, 3.4rem);
  }

  .lede {
    font-size: 1rem;
  }

  .plane-card {
    border-radius: 0.8rem;
  }

  .plane-card__header {
    min-height: 4.4rem;
    padding-inline: 0.85rem;
  }

  .render-status {
    max-width: 52%;
  }

  .controls,
  .controls--parameter {
    grid-template-columns: 1fr;
    padding-inline: 0.85rem;
  }

  .controls--parameter .control-group--wide {
    grid-column: auto;
  }

  .generator-key,
  .parameter-key {
    padding-inline: 0.85rem;
  }

  .usage-note {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #3f4a4f;
    --rule: #8e8a81;
    --rule-strong: #6f6b64;
  }

  .plane-card {
    border-width: 2px;
  }
}
