/* Studio preview — shared by every Three.js TSL pack. */
:root {
  color-scheme: dark;
  --bg: #0a0b0e;
  --panel: #111318;
  --panel-2: #161920;
  --line: #23262e;
  --line-strong: #31353f;
  --text: #ecebe7;
  --muted: #9b9ba5;
  --faint: #6c6d77;
  --accent: #8d7dff;
  --accent-soft: #8d7dff26;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

/* Buttons */
.ghost, .primary, .icon, select {
  height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--panel-2); padding: 0 12px; font-size: 13px; transition: border-color .15s, background .15s;
}
.ghost:hover, .icon:hover, select:hover { border-color: #4a4f5c; background: #1c2029; }
.primary { background: var(--accent); border-color: var(--accent); color: #0b0a14; font-weight: 600; }
.primary:hover { background: #a094ff; border-color: #a094ff; }
.icon { width: 34px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; line-height: 1; }
.wide { width: 100%; }
.ghost, .primary { white-space: nowrap; }
.short { display: none; }
.badge { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.fine { font-size: 12px; color: var(--faint); }

/* Landing */
.landing { max-width: 1480px; margin: 0 auto; padding: clamp(28px, 5vw, 64px) clamp(18px, 4vw, 48px) 40px; }
.hero { max-width: 760px; margin-bottom: clamp(28px, 4vw, 48px); }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.hero h1 { font-size: clamp(32px, 4.6vw, 60px); line-height: 1.04; letter-spacing: -.03em; font-weight: 600; }
.tagline { margin-top: 16px; font-size: clamp(15px, 1.4vw, 18px); color: var(--muted); max-width: 640px; }
.facts { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.facts li { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); text-align: left; transition: transform .2s, border-color .2s, box-shadow .2s; }
.card:hover { transform: translateY(-3px); border-color: #3d4250; box-shadow: 0 18px 40px -18px #000; }
.card img { display: block; width: 100%; aspect-ratio: var(--thumb-ratio, 16 / 10); object-fit: cover; background: #000; }
.card-body { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.card-title { font-weight: 600; font-size: 14px; }
.card-sub { margin-top: 3px; font-size: 12px; color: var(--faint); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.site-footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--faint); }

/* Studio */
.studio { height: 100dvh; display: flex; flex-direction: column; }
.topbar { flex: none; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.switcher { display: flex; align-items: center; gap: 6px; margin: 0 auto; min-width: 0; }
.switcher select { min-width: 220px; max-width: 46vw; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.stage-wrap { min-width: 0; display: flex; flex-direction: column; background: #000; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage-hint { position: absolute; left: 16px; bottom: 12px; font-size: 12px; color: #ffffffa0; text-shadow: 0 1px 6px #000; pointer-events: none; }
.stage-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.stage-bar-left, .stage-bar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { height: 32px; padding: 0 12px; border: 0; border-right: 1px solid var(--line-strong); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.segmented .label { padding: 0 10px; display: inline-flex; align-items: center; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); border-right: 1px solid var(--line-strong); background: var(--panel); }

/* Headline legibility demo */
.headline-demo { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 clamp(24px, 7vw, 110px); pointer-events: none; color: #fff; }
.headline-demo.dark { color: #0d0e12; }
.demo-eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; opacity: .75; margin-bottom: 14px; }
.headline-demo h2 { font-size: clamp(28px, 4.4vw, 64px); line-height: 1.03; letter-spacing: -.035em; font-weight: 650; max-width: 14ch; }
.demo-sub { margin-top: 16px; font-size: clamp(14px, 1.3vw, 18px); opacity: .8; max-width: 44ch; }
.demo-actions { margin-top: 26px; display: flex; gap: 10px; }
.demo-btn { padding: 11px 18px; border-radius: 999px; border: 1px solid currentColor; font-size: 14px; font-weight: 600; }
.headline-demo .demo-btn.solid { background: #fff; color: #0d0e12; border-color: #fff; }
.headline-demo.dark .demo-btn.solid { background: #0d0e12; color: #fff; border-color: #0d0e12; }

/* Inspector */
.inspector { min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; scrollbar-color: #3a3e49 transparent; }
.inspector-head { padding: 18px 18px 6px; }
.inspector-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.inspector-head p { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.panel { padding: 14px 18px; border-top: 1px solid var(--line); }
.panel h3 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.chip:hover { color: var(--text); border-color: #4a4f5c; }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.control { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; padding: 7px 0; }
.control-name { font-size: 12.5px; color: var(--text); user-select: none; cursor: default; display: flex; align-items: center; gap: 6px; }
.control-name.modified::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.control input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); height: 18px; margin: 0; }
.number { width: 64px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); padding: 0 6px; font: 12px var(--mono); text-align: right; color: var(--muted); }
.color-control { grid-template-columns: auto 1fr auto; }
.swatch { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 7px; background: none; overflow: hidden; }
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 6px; }
.swatch::-moz-color-swatch { border: 0; border-radius: 6px; }
.hex { width: 86px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); padding: 0 8px; font: 12px var(--mono); color: var(--muted); text-transform: lowercase; }
.inspector-foot { padding: 14px 18px 22px; border-top: 1px solid var(--line); display: grid; gap: 10px; }

/* Code dialog */
.code-dialog { width: min(760px, calc(100vw - 32px)); border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px -20px #000; }
.code-dialog::backdrop { background: #05060acc; backdrop-filter: blur(3px); }
.code-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 18px 8px; }
.code-head h2 { font-size: 16px; font-weight: 600; }
.tabs { display: flex; gap: 4px; padding: 6px 18px 0; border-bottom: 1px solid var(--line); }
.tabs button { height: 34px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 13px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.code { margin: 0; padding: 16px 18px; max-height: 52vh; overflow: auto; background: #0b0c10; font: 12.5px/1.6 var(--mono); color: #d9d7f5; white-space: pre; }
.code-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

.error { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 32px)); background: #2a1215; border: 1px solid #6b2a31; color: #ffd6da; padding: 10px 14px; border-radius: 10px; font-size: 13px; }

/* Small screens: stage on top, inspector below. */
@media (max-width: 900px) {
  .studio { height: auto; min-height: 100dvh; }
  .workspace { grid-template-columns: 1fr; }
  .stage { height: 62vh; flex: none; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .switcher select { min-width: 0; max-width: 40vw; }
  .topbar { gap: 8px; padding: 0 10px; }
  #backend { display: none; }
}
@media (max-width: 520px) {
  .gallery { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-sub { display: none; }
  .topbar .long { display: none; }
  .topbar .short { display: inline; }
  .topbar { gap: 6px; }
  .switcher { gap: 4px; }
  .switcher select { max-width: none; flex: 1; }
  .switcher { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
