:root {
  color-scheme: light;
  --paper: #fff;
  --panel: #f0f9ff;
  --ink: #12344a;
  --muted: #4d6b80;
  --line: #cde6f5;
  --accent: #0369a1;
  --accent-dark: #075985;
  --sky: #38bdf8;
  --sky-hover: #0ea5e9;
  --focus: #0284c7;
  --radius: 9px;
  --shadow: 0 18px 50px rgba(12, 74, 110, 0.1);
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 3px;
}

::selection {
  color: var(--ink);
  background: #bae6fd;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1660px, 100%);
  margin: 0 auto;
  padding: 34px clamp(18px, 3vw, 52px) 24px;
}

.app-header,
.workspace,
.app-footer {
  width: 100%;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.eyebrow,
.section-index {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: inherit;
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 400;
  line-height: 0.94;
  letter-spacing: -0.045em;
}

h1 span {
  color: var(--muted);
  font-family: inherit;
  font-style: normal;
}

.header-actions,
.export-actions {
  display: flex;
  gap: 10px;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 19px;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.button-primary {
  color: var(--ink);
  background: var(--sky);
}

.button-primary:hover:not(:disabled) {
  background: var(--sky-hover);
}

.button-quiet,
.button-secondary {
  color: var(--accent-dark);
  border-color: var(--line);
  background: var(--paper);
}

.button-quiet:hover:not(:disabled),
.button-secondary:hover:not(:disabled) {
  border-color: var(--sky);
  background: var(--panel);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  align-items: start;
  gap: clamp(24px, 3vw, 46px);
}

.stage-column {
  min-width: 0;
}

.stage-toolbar,
.stage-footer,
.section-heading,
.range-field > span,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-toolbar {
  min-height: 38px;
  margin-bottom: 12px;
}

.segmented-control {
  display: inline-flex;
  gap: 3px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.segmented-control label {
  position: relative;
}

.segmented-control input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-width: 58px;
  min-height: 30px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.segmented-control input:checked + span {
  color: var(--ink);
  background: var(--sky);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 3px;
}

.render-meta,
.stage-footer,
.export-note,
.equation-note,
.app-footer {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.render-meta {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.canvas-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #080b14;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.canvas-frame[data-aspect="3:2"] {
  aspect-ratio: 3 / 2;
}

#trajectoryCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#trajectoryCanvas:active {
  cursor: grabbing;
}

.stage-mark,
.camera-hint,
.trace-button {
  position: absolute;
  z-index: 2;
}

.stage-mark {
  top: 18px;
  left: 19px;
  display: flex;
  gap: 9px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  mix-blend-mode: difference;
}

.stage-mark span + span::before {
  margin-right: 9px;
  content: "·";
}

.camera-hint {
  right: 18px;
  bottom: 18px;
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  mix-blend-mode: difference;
  pointer-events: none;
}

.trace-button {
  left: 15px;
  bottom: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--accent-dark);
  background: var(--paper);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.trace-button:hover:not(:disabled) {
  background: var(--panel);
}

.trace-button[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--sky);
  background: var(--sky);
}

.trace-icon {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.trace-button[aria-pressed="true"] .trace-icon {
  width: 8px;
  height: 10px;
  border: 0;
  border-right: 3px solid currentColor;
  border-left: 3px solid currentColor;
}

.render-progress {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(12, 74, 110, 0.2);
  backdrop-filter: blur(2px);
}

.render-progress span {
  position: absolute;
  top: 0;
  left: 0;
  width: 28%;
  height: 2px;
  background: var(--sky);
  animation: progress-sweep 1.1s ease-in-out infinite;
}

@keyframes progress-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(460%);
  }
}

.stage-footer {
  align-items: flex-start;
  padding: 12px 2px 0;
}

.stage-footer p {
  margin: 0;
}

.controls {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 12px 36px rgba(12, 74, 110, 0.06);
}

.control-section,
.equation-panel {
  padding: 21px 20px 22px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.93rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-index {
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 0.875rem;
}

.section-value {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.range-field,
.select-field {
  display: block;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
}

.range-field + .range-field,
.select-field + .range-field,
.camera-presets + .range-field {
  margin-top: 19px;
}

.range-bounds,
.range-field output {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 8px 0 0;
  accent-color: var(--accent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.background-fields + .range-field {
  margin-top: 19px;
}

.select-field span {
  display: block;
  margin-bottom: 7px;
}

.select-field select,
.number-grid input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
}

.select-field select:hover:not(:disabled),
.number-grid input:hover:not(:disabled) {
  border-color: var(--sky);
}

.select-field select {
  padding: 0 29px 0 10px;
  font-size: 0.875rem;
}

.full-width {
  width: 100%;
}

.advanced-controls {
  margin-top: 17px;
}

.advanced-controls summary,
.equation-panel summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
}

.advanced-controls[open] summary,
.equation-panel[open] summary {
  margin-bottom: 15px;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 13px;
}

.number-grid label {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.number-grid input {
  display: block;
  margin-top: 5px;
  padding: 0 8px;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.camera-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.camera-presets button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--paper);
  font-size: 0.875rem;
  font-weight: 700;
}

.camera-presets button:hover:not(:disabled) {
  border-color: var(--sky);
}

.camera-presets button[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--sky);
  background: var(--sky);
}

.text-button {
  border: 0;
  padding: 5px 0;
  color: var(--accent);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.export-actions {
  margin-top: 13px;
}

.export-actions .button {
  flex: 1;
}

.export-note {
  margin: 11px 0 0;
}

.equation-panel {
  border-bottom: 0;
}

.equations {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.equations p {
  margin: 5px 0;
}

.equations span {
  display: inline-block;
  width: 1.2em;
  color: var(--accent);
}

.equation-note {
  margin: 11px 0 0;
}

.app-footer {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  margin-top: 34px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.app-footer p {
  margin: 0;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 24px;
  }

  .controls .control-section,
  .equation-panel {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding-top: 24px;
  }

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

  .controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .controls > * {
    border-right: 1px solid var(--line);
  }

  .equation-panel {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .button {
    flex: 1;
  }

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

  .controls > * {
    border-right: 0;
  }

  .stage-footer {
    display: block;
  }

  .stage-footer p + p {
    margin-top: 4px;
  }

  .camera-hint {
    display: none;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .render-meta {
    min-height: 1em;
  }

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

  .stage-mark {
    top: 12px;
    left: 13px;
  }

  .trace-button {
    bottom: 10px;
    left: 10px;
  }
}

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

/* Match the portfolio while keeping the artwork the focus. */
body { font-size: 1rem; line-height: 1.5; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 20; padding: 12px 16px; background: var(--sky); color: var(--ink); }
.skip-link:focus { top: 12px; }
.studio-nav { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; margin-bottom: 28px; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.studio-nav a { text-decoration: none; }
.studio-nav a:hover { text-decoration: underline; }
.studio-intro { margin: 14px 0 0; color: var(--muted); max-width: 40rem; }
.app-header { align-items: center; }
h1 { line-height: 1.15; font-weight: 600; letter-spacing: -0.035em; }
.eyebrow, .section-index { font-size: 0.75rem; }
.stage-mark { font-size: 0.75rem; }
.stage-footer { flex-wrap: wrap; }
.stage-footer p { flex: 1 1 16rem; }
.range-field, .select-field { font-weight: 500; }
.select-field select, .number-grid input { min-height: 44px; font-size: 1rem; min-width: 0; }
.number-grid label, .field-grid > label { min-width: 0; }
.segmented-control span { min-height: 38px; }
.camera-presets button, .trace-button, .text-button { min-height: 44px; }
.equations { font-size: 1rem; }
.app-footer { text-transform: none; letter-spacing: 0; flex-wrap: wrap; }
#statusMessage[data-error="true"] { color: #a32626; }
.notice { padding: 16px; background: var(--panel); border: 1px solid var(--line); }
.system-description { margin: 12px 0 20px; color: var(--muted); font-size: 1rem; }
#parameterControls .range-field + .range-field { margin-top: 16px; }
.equations p { overflow-wrap: anywhere; }
@media (min-width: 861px) { .stage-column { position: sticky; top: 24px; } }
@media (max-width: 620px) { .app-header { align-items: stretch; } .app-footer { align-items: flex-start; flex-direction: column; } }
