/* Layout: a large live canvas with a style gallery under it on the left, a dense instrument panel on the right; stacks on phones. Single dark studio look by choice. */
:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1d2029;
  --line: #2a2e3a;
  --fg: #e9ebf2;
  --muted: #8d93a6;
  --accent: #ff7a45;
  --ok: #4fd18b;
  --warn: #f2c14e;
  --bad: #ff5d6c;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --text: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--text); font-size: 14px; }
.app { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; min-height: 100%; padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); box-sizing: border-box; }
.stage { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; margin: 0; }
.brand span { color: var(--muted); font-weight: 500; }
.meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.frame { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-width: 100%; border: 1px solid var(--line); touch-action: none; }
.frame.ratio-1 { aspect-ratio: 1 / 1; max-height: 78vh; margin-inline: auto; width: 100%; }
.frame.ratio-9 { aspect-ratio: 9 / 16; max-height: 78vh; margin-inline: auto; }
.frame.ratio-21 { aspect-ratio: 21 / 9; }
canvas#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { position: absolute; left: 7%; right: 7%; bottom: 9%; pointer-events: none; }
.overlay h2 { font-family: var(--display); font-weight: 700; font-size: clamp(26px, 5.2vw, 72px); line-height: 0.98; letter-spacing: -0.02em; margin: 0 0 10px; text-wrap: balance; }
.overlay p { font-size: clamp(13px, 1.4vw, 18px); margin: 0; max-width: 46ch; opacity: 0.92; }
.overlay.off { display: none; }
.readout { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { font-family: var(--mono); font-size: 12px; padding: 5px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.chip b { color: var(--fg); font-weight: 500; }
.chip.pass { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.chip.pass b { color: var(--ok); }
.chip.mid b { color: var(--warn); }
.chip.fail b { color: var(--bad); }
.sect-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sect-h h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.sect-h span { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.style-btn, .preset { display: flex; flex-direction: column; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--fg); font: inherit; font-size: 12px; text-align: left; cursor: pointer; min-width: 0; }
.style-btn canvas, .preset i { display: block; width: 100%; height: 44px; border-radius: 6px; background: #000; }
.style-btn small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.style-btn:hover, .style-btn[aria-pressed="true"], .preset:hover, .preset[aria-pressed="true"] { border-color: var(--accent); }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 18px; min-width: 0; align-self: start; position: sticky; top: max(16px, env(safe-area-inset-top, 0px)); max-height: calc(100vh - 32px); overflow: auto; }
.group { display: flex; flex-direction: column; gap: 10px; }
.group > h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 9px; }
.seg.five { grid-template-columns: repeat(5, 1fr); }
.seg button { font: inherit; font-size: 12px; padding: 7px 2px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 600; }
.row { display: grid; grid-template-columns: 82px minmax(0, 1fr) 44px; align-items: center; gap: 10px; }
.row label { color: var(--muted); font-size: 12px; }
.row output { font-family: var(--mono); font-size: 11px; color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sw { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; }
.sw input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); border: 0; padding: 0; cursor: pointer; background: none; }
.mini { font: inherit; font-size: 18px; line-height: 1; width: 38px; height: 38px; border-radius: 10px; border: 1px dashed var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.btn { font: inherit; font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0d06; }
.btn:focus-visible, .seg button:focus-visible, .preset:focus-visible, .style-btn:focus-visible, .mini:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.txt, select.txt { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.code-wrap { display: none; flex-direction: column; gap: 8px; }
.code-wrap.on { display: flex; }
textarea.code { width: 100%; box-sizing: border-box; min-height: 160px; font-family: var(--mono); font-size: 11px; line-height: 1.5; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #0a0b0e; color: #c9cede; resize: vertical; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 5; }
.toast.on { opacity: 1; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; list-style: none; }
details.more > summary::before { content: "+ "; }
details.more[open] > summary::before { content: "– "; }
details.more > div { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
