/* T-FINS-web restyle (assembly step, docs/ARCHITECTURE.md sections 7 and 11).
   Single-look dark instrument. Matte near-black canvas, off-white text, one
   restrained cool-white / faint-cyan accent for hover and focus. Hairline
   borders throughout. No light mode, no external CDNs, no web fonts (system
   stacks only). The three.js viewer is the centerpiece: a framed box on pure
   black so the fin reads like the wireframe wave reference. */

:root {
  /* Surfaces */
  --bg:          #0a0a0a;
  --panel:       #0c0c0c;
  --panel-glass: rgba(10, 10, 10, 0.72);
  --viewer-bg:   #000000;

  /* Ink */
  --text:  #e8e8e8;
  --muted: #8f8f8f;
  --faint: #5e5e5e;

  /* Hairlines */
  --line:   rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);

  /* One accent: cool white leaning faint cyan. Used only on hover / focus / active. */
  --accent:      #a7e0ea;
  --accent-dim:  rgba(167, 224, 234, 0.55);
  --accent-glow: rgba(167, 224, 234, 0.12);

  /* Error surface (kept subdued to fit the monochrome canvas) */
  --danger:      #f0a9a9;
  --danger-line: rgba(224, 120, 120, 0.30);
  --danger-bg:   rgba(70, 22, 22, 0.35);
  --warn:        #d8c48a;

  /* Type */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Roboto Mono", monospace;
}

/* ---- Reset / base ---------------------------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* background.png as a fixed, cover, heavily-darkened page canvas so every
     control stays legible over it. */
  background:
    linear-gradient(rgba(8, 8, 8, 0.87), rgba(8, 8, 8, 0.90)),
    #0a0a0a url("img/background.ec94bbeda492.png") center / cover no-repeat fixed;
}

img { max-width: 100%; display: block; }

::selection { background: var(--accent-glow); color: #fff; }

a { color: var(--accent); text-decoration: none; }

:focus-visible {
  outline: 1px solid var(--accent-dim);
  outline-offset: 2px;
}

/* ---- Header (banner.png hero band) ----------------------------------- */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 70px;
  padding: 0.85rem 1.6rem;
  border-bottom: 1px solid var(--line);
  /* banner.png (portrait wireframe wave) cropped to a short wide band and kept
     subtle under a dark overlay, the mark sitting on the wave. */
  background:
    linear-gradient(rgba(8, 8, 8, 0.55), rgba(9, 9, 9, 0.86)),
    #050505 url("img/banner.1f3a2c697f8f.png") 50% 44% / cover no-repeat;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
}
/* The Fit2Flow wordmark already carries the name, so no text wordmark beside it.
   The PNG is 128px tall, ~3.7x this display height. */
.brand-logo {
  height: 34px;
  width: auto;
  opacity: 0.95;
  flex: 0 0 auto;
}
.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--line-2);
}
.tagline {
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- App layout ------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.4rem 1.6rem 2.6rem;
}

/* ---- Controls panel -------------------------------------------------- */

.controls {
  background: var(--panel-glass);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.15rem 1.2rem 1.35rem;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.panel-head {
  margin-bottom: 1.05rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.panel-kicker {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}
.panel-title {
  margin: 0.4rem 0 0.25rem;
  font-weight: 500;
  font-size: 1.16rem;
  line-height: 1.1;
  letter-spacing: 0.01em;
}
.panel-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.1rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  min-width: 0;
}
.control--wide {
  margin-bottom: 1.1rem;
}

/* Uppercase micro-labels */
.micro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4em;
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1.3;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.micro .unit {
  color: var(--faint);
  letter-spacing: 0.1em;
}

/* ---- Range sliders (thin) ------------------------------------------- */

.control-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.control-row input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: var(--line-2);
}
input[type="range"]::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: var(--line-2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.9);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.6);
  transition: background 0.15s ease;
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:focus-visible::-moz-range-thumb {
  background: var(--accent);
}
input[type="range"]:focus-visible {
  outline: none;
}

/* ---- Numeric readouts (monospaced) ---------------------------------- */

input[type="number"] {
  flex: 0 0 auto;
  width: 66px;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: right;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-dim);
  background: rgba(167, 224, 234, 0.06);
}

/* ---- Select (foil family) ------------------------------------------- */

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select#input-family {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}
select#input-family:hover { border-color: var(--accent-dim); }
select#input-family:focus { outline: none; border-color: var(--accent-dim); }

/* ---- Stage (viewer + readout) --------------------------------------- */

.stage {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.viewer-frame {
  position: relative;
  background: var(--viewer-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
#viewer {
  width: 100%;
  height: 60vh;
  display: block;
}
/* Canvas fills the fixed-height frame via CSS, so three.js's setSize (called
   with updateStyle=false) only sizes the drawing buffer. Without an explicit
   CSS size the canvas renders at its device-pixel-ratio buffer size and keeps
   growing the frame through the ResizeObserver (the "viewer becomes massive"
   bug). A fixed height (not min-height) also lets height:100% resolve. */
#viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-toggle {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.55rem;
  background: var(--panel-glass);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.viewer-toggle:hover {
  color: var(--text);
  border-color: var(--line-2);
}
.viewer-toggle input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.viewer-hint {
  position: absolute;
  right: 0.7rem;
  bottom: 0.55rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  pointer-events: none;
  user-select: none;
}

/* ---- Metrics (monospaced readout) ----------------------------------- */

.readout {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;                     /* hairline dividers via the underlying line colour */
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.metric {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.9rem;
  background: var(--panel);
}
.metric-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.metric-value {
  font-family: var(--mono);
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---- Downloads ------------------------------------------------------- */

.downloads {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.downloads-label {
  margin-right: 0.25rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}
.btn-download {
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.btn-download:hover,
.btn-download:focus-visible {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}
.btn-download.secondary {
  color: var(--muted);
  border-color: var(--line);
}
.btn-download.secondary:hover,
.btn-download.secondary:focus-visible {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ---- Generate (primary action) --------------------------------------- */

.btn-generate {
  width: 100%;
  margin-top: 1.35rem;
  padding: 0.72rem 1rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-generate:hover,
.btn-generate:focus-visible {
  box-shadow: 0 0 0 4px var(--accent-glow);
  outline: none;
}
.btn-generate:disabled {
  opacity: 0.55;
  cursor: progress;
}
/* Params changed since the last render: pulse to invite a regenerate. */
.btn-generate.dirty {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- Mounting / grooves / output sections --------------------------- */
.mounting,
.grooves,
.output {
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}

/* Checkbox row (e.g. split-halves), with a disabled state when the option is
   not available for the current fin. */
.check-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-top: 0.9rem;
  cursor: pointer;
}
.check-row input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.check-row .micro-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.check-row.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.check-row.is-disabled input {
  cursor: not-allowed;
}

/* ---- SVG tile selectors (choice controls) --------------------------- */
/* Responsive grid: auto-fit + minmax means tiles wrap onto more rows on narrow
   screens and never overflow the panel (min-width:0 lets them shrink). */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.6rem 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.tile:hover {
  border-color: var(--line-2);
  background: rgba(255, 255, 255, 0.04);
}
/* Visually-hidden radio: the tile is the control; keyboard focus is mirrored
   onto the tile via :has(input:focus-visible). */
.tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tile:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.tile:has(input:focus-visible) {
  outline: 1px solid var(--accent-dim);
  outline-offset: 2px;
}
.tile-icon {
  width: 100%;
  max-width: 46px;
  height: 32px;
  object-fit: contain;
  opacity: 0.85;
}
.tile:has(input:checked) .tile-icon {
  opacity: 1;
}
.tile-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--text);
}
.tile-desc {
  font-size: 0.6rem;
  line-height: 1.25;
  color: var(--muted);
}

/* A tile group that does not apply to the current fin (e.g. Hand on a symmetric
   center fin): greyed, non-interactive, with an explanatory note. */
.control.is-disabled .tiles {
  opacity: 0.4;
  pointer-events: none;
}
.tiles-na-note {
  display: none;
  margin-top: 0.4rem;
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--faint);
}
.control.is-disabled .tiles-na-note {
  display: block;
}

/* ---- Header nav ----------------------------------------------------- */
.site-nav {
  margin-left: auto;
  display: flex;
  gap: 1.2rem;
}
.site-nav a {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
}

/* ---- Approach / "the idea" page ------------------------------------- */
.approach {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2.5rem 1.6rem 4rem;
}
.ap-hero {
  text-align: center;
  padding: 1.5rem 0 2.5rem;
}
.ap-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0.6rem 0 1rem;
}
.ap-lead {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}
.ap-cta {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.6rem;
}
.ap-cta a { text-decoration: none; }

.ap-shots {
  display: flex;
  flex-direction: column;
  gap: 2.6rem;
  margin: 3rem 0;
}
.ap-shot {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1.6rem;
  align-items: center;
  margin: 0;
}
.ap-shot:nth-child(even) {
  grid-template-columns: 1fr 1.45fr;
}
.ap-shot:nth-child(even) .ap-media {
  order: 2;
}
.ap-media {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}
.ap-shot figcaption h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
}
.ap-shot figcaption p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.ap-loop {
  margin: 3.5rem 0;
  text-align: center;
}
.ap-loop .panel-kicker {
  display: block;
  margin-bottom: 1rem;
}
/* Wide diagram: scrolls inside its own box on narrow screens (min-width keeps
   the text legible) so the page itself never scrolls sideways. */
.ap-diagram-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}
.ap-diagram {
  display: block;
  width: 100%;
  min-width: 640px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}

.ap-vision {
  max-width: 620px;
  margin: 3.5rem auto;
  text-align: center;
}
.ap-vision h2 {
  font-size: 1.35rem;
  font-weight: 500;
  margin: 0 0 0.7rem;
}
.ap-vision p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}
.ap-list {
  list-style: none;
  padding: 0;
  margin: 1.1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--text);
}

.ap-pricing {
  max-width: 620px;
  margin: 2rem auto 0;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}
.ap-pricing strong {
  color: var(--accent);
  font-weight: 500;
}

.ap-honest {
  margin: 3rem 0;
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}
.ap-honest p {
  max-width: 72ch;
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.65;
}
.ap-made {
  max-width: 72ch;
  margin: 3rem auto 0;
}
.ap-made p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0.7rem 0 0;
}
.ap-repo {
  margin-top: 1.1rem !important;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}
.ap-repo a {
  color: var(--accent);
}

.ap-foot {
  text-align: center;
  margin-top: 3rem;
}
.ap-foot a { text-decoration: none; }

@media (max-width: 720px) {
  .ap-shot,
  .ap-shot:nth-child(even) {
    grid-template-columns: 1fr;
  }
  .ap-shot:nth-child(even) .ap-media {
    order: 0;
  }
}
.section-kicker {
  display: block;
  margin-bottom: 0.85rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}

/* ---- Technical preview image ---------------------------------------- */
.preview {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.preview-cap {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.preview-sub { color: var(--faint); }
.preview-img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg);            /* fingen v0.1.1 renders the preview dark */
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: opacity 0.2s ease;
}
.preview-img:not([src]) { display: none; }   /* hidden until the first render */
.preview-img.loading { opacity: 0.5; }

/* ---- Parameter hover help (HTMX popup) ------------------------------ */
.help {
  position: relative;
  display: inline-flex;
  margin-left: 0.35em;
  vertical-align: middle;
}
.help-dot {
  width: 15px;
  height: 15px;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  cursor: help;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.help-dot:hover,
.help-dot:focus-visible {
  color: var(--accent);
  border-color: var(--accent-dim);
  outline: none;
}
.help-pop {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  z-index: 30;
  width: 260px;
  max-width: 78vw;
  padding: 0.7rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  /* reset the uppercase/tracked .micro label styling for readable copy */
  font-family: var(--sans);
  text-transform: none;
  letter-spacing: normal;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
  pointer-events: none;
}
.help:hover .help-pop,
.help:focus-within .help-pop {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.help-card { display: flex; flex-direction: column; gap: 0.5rem; }
.help-img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.help-text {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text);
}

/* ---- Quiz: trigger button, modal, editable radar -------------------- */
.btn-quiz {
  width: 100%;
  margin-bottom: 1.15rem;
  padding: 0.65rem 1rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--accent-dim);
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-quiz:hover,
.btn-quiz:focus-visible {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  outline: none;
}

body.modal-open { overflow: hidden; }

.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 6, 8, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.quiz-card {
  width: 100%;
  max-width: 660px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.5rem 1.6rem 1.7rem;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}
.quiz-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.quiz-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.quiz-close:hover,
.quiz-close:focus-visible { color: var(--accent); border-color: var(--accent-dim); outline: none; }
.quiz-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  margin: 1.2rem 0 0.4rem;
}
.quiz-radar { margin-top: 1rem; }
.radar { width: 100%; margin-top: 0.4rem; }
.radar-svg { display: block; width: 100%; height: auto; touch-action: none; }
.radar-ring,
.radar-spoke { fill: none; stroke: var(--line-2); stroke-width: 1; }
.radar-axis-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.radar-scale { fill: var(--faint); font-family: var(--mono); font-size: 9px; }
.radar-poly {
  fill: rgba(167, 224, 234, 0.13);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.radar-handle {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2;
  cursor: grab;
  transition: fill 0.12s ease;
}
.radar-handle:hover,
.radar-handle:focus-visible { fill: var(--accent); outline: none; }
.radar-value {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  text-anchor: middle;
  pointer-events: none;
}
.quiz-foot { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.35rem; }
.quiz-result { margin: 0; font-family: var(--mono); font-size: 0.74rem; color: var(--accent); }

/* Preview / not-implemented banner (amber, subdued to fit the dark canvas). */
.quiz-notice {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(216, 196, 138, 0.32);
  border-radius: 4px;
  background: rgba(70, 60, 30, 0.28);
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text);
}
.quiz-notice-tag {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--warn);
}

@media (max-width: 560px) {
  .quiz-row { grid-template-columns: 1fr; }
}

/* ---- Error banner + warnings ---------------------------------------- */

.error-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 4px;
  color: var(--danger);
  font-size: 0.83rem;
}
.error-tag {
  flex: 0 0 auto;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--danger-line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--danger);
}
#error-message { min-width: 0; }

.warnings {
  padding: 0.5rem 0.75rem;
  border-left: 2px solid var(--warn);
  background: rgba(216, 196, 138, 0.06);
  color: var(--warn);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

/* ---- Responsive ------------------------------------------------------ */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    padding: 1.1rem 1.1rem 2rem;
  }
  /* Viewer on top when stacked; controls follow. */
  .stage { order: 1; }
  .controls { order: 2; }
  #viewer { height: 52vh; }
}

@media (max-width: 480px) {
  .site-header { padding: 0.75rem 1.1rem; }
  .brand-sep, .tagline { display: none; }
  .control-grid { grid-template-columns: 1fr; }
  #viewer { height: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- optimizer live feedback (quiz) --------------------------------------- */
.quiz-progress { display: flex; align-items: center; gap: 0.6rem; }
.quiz-progress-track {
  flex: 1; height: 4px; border-radius: 2px; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.quiz-progress-fill {
  height: 100%; width: 0; background: var(--accent);
  transition: width 0.6s ease;
}
.quiz-progress-label {
  font-family: var(--mono); font-size: 0.68rem; color: var(--muted);
  white-space: nowrap;
}
/* The optimizer's current best, converging under the editable target web. */
.radar-poly--live {
  fill: color-mix(in srgb, var(--accent) 22%, transparent);
  stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: none;
}
