:root {
  color-scheme: dark;
  --bg: #0d151d;
  --panel: #14212d;
  --line: #2b3b48;
  --ink: #eef2ed;
  --muted: #a4b4bd;
  --accent: #e7b87c;
  --mint: #8ac9bd;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a {
  color: var(--mint);
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
.file-label {
  border: 1px solid var(--line);
  background: #1d2e3c;
  border-radius: 7px;
  padding: 9px 12px;
  cursor: pointer;
}
button:hover,
.file-label:hover {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.primary {
  background: var(--accent);
  color: #17212a;
  border-color: var(--accent);
  font-weight: 700;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 4vw;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--ink);
}
nav {
  display: flex;
  gap: 22px;
  font-size: 13px;
}
nav a.active {
  color: var(--accent);
}
main {
  max-width: 1560px;
  margin: auto;
  padding: 30px 4vw;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--accent);
}
h1 {
  font-weight: 500;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -0.04em;
  margin: 10px 0;
}
h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
p {
  line-height: 1.6;
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 25px;
  margin-bottom: 24px;
}
.intro p {
  color: var(--muted);
  max-width: 650px;
  margin: 6px 0;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}
.viewer {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #182630;
}
.viewtop {
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  gap: 10px;
  background: #14212d;
}
.viewtop span {
  color: var(--muted);
  font-size: 12px;
}
.canvas-wrap {
  width: 100%;
  max-width: 100%;
  position: relative;
  aspect-ratio: 16/9;
  min-height: 260px;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}
.badge {
  position: absolute;
  bottom: 15px;
  left: 18px;
  background: #101922d9;
  padding: 7px 11px;
  border-radius: 5px;
  font-size: 12px;
  pointer-events: none;
}
.timeline {
  padding: 16px 18px;
  background: #14212d;
  border-top: 1px solid var(--line);
}
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.transport output {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-left: auto;
}
input[type="range"] {
  width: 100%;
  margin: 15px 0;
  accent-color: var(--accent);
}
.shots {
  display: flex;
  gap: 5px;
}
.shot {
  flex: 1;
  text-align: left;
  background: #234054;
  border-color: #345366;
  font-size: 12px;
}
.shot.active {
  background: #38515d;
  border-color: var(--mint);
}
aside,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
aside {
  max-height: 760px;
  overflow: auto;
}
.section-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 20px 0 10px;
}
.section-label:first-child {
  margin-top: 0;
}
.objects {
  display: grid;
  gap: 6px;
}
.objects button {
  text-align: left;
  font-size: 12px;
}
.objects button.active {
  border-color: var(--accent);
  background: #374047;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row > * {
  min-width: 0;
}
.fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fields label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}
input:not([type="range"]):not([type="file"]),
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0d1924;
  padding: 9px;
  width: 100%;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
#project-json {
  font:
    11px/1.5 ui-monospace,
    monospace;
  min-height: 250px;
}
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
.panel h2 {
  margin-bottom: 12px;
}
.panel .row {
  margin-top: 12px;
}
.panel textarea {
  min-height: 85px;
}
.file-label {
  display: inline-block;
  font-size: 12px;
}
#status {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--mint);
  background: #152731;
  font-size: 13px;
  min-height: 44px;
}
#status.error {
  border-color: #ee8f80;
  color: #ffb7aa;
}
#job-links {
  display: flex;
  gap: 15px;
  margin-top: 12px;
  font-size: 12px;
  flex-wrap: wrap;
}
.touch {
  display: flex;
  gap: 8px;
  position: absolute;
  bottom: 15px;
  right: 15px;
}
.touch button {
  background: #132638db;
}
.game-only {
  display: none;
}
body[data-kind="game"] .game-only {
  display: block;
}
body[data-kind="game"] .touch {
  display: flex;
}
body[data-kind="game"] .video-only {
  display: none;
}
details {
  margin-top: 18px;
}
summary {
  cursor: pointer;
  color: var(--muted);
  padding: 10px 0;
  font-size: 13px;
}
video {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 14px;
}
footer {
  color: var(--muted);
  font-size: 11px;
  margin: 22px 0;
}
input[type="file"] {
  max-width: 100%;
  font-size: 12px;
}
#wan-controls label {
  display: block;
  margin: 12px 0;
}
.help {
  max-width: 750px;
}
.pill {
  font-size: 11px;
  background: #21363c;
  border-radius: 20px;
  padding: 6px 10px;
  color: var(--mint);
}
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  aside {
    max-height: none;
  }
  .objects {
    grid-template-columns: repeat(2, 1fr);
  }
  .panels {
    grid-template-columns: 1fr;
  }
  .intro {
    display: block;
  }
  .intro .row {
    margin-top: 15px;
  }
  header {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }
  nav {
    gap: 14px;
    flex-wrap: wrap;
  }
  .canvas-wrap {
    min-height: 240px;
  }
  main {
    padding: 20px 4vw;
  }
  .viewtop {
    padding: 12px;
  }
  .touch {
    right: 6px;
    bottom: 8px;
  }
  .touch button {
    padding: 8px;
  }
  .badge {
    bottom: 56px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

.depth-generation {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.depth-generation label {
  font-size: 12px;
  color: var(--muted);
}

#depth-seed {
  width: 130px;
}
#blockout-comparison {
  margin-top: 16px;
}

/* Reference-first video workflow; the shared 3D workshop remains below. */
[hidden] {
  display: none !important;
}
.video-creator {
  border: 1px solid #40504d;
  border-radius: 14px;
  background: linear-gradient(125deg, #172b30, #14212d 60%);
  padding: 24px;
  margin-bottom: 28px;
}
.creator-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.creator-heading h2 {
  font-size: 22px;
  margin: 8px 0 0;
}
.creator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  margin-top: 20px;
}
.creator-grid > *,
.reference-pair > * {
  min-width: 0;
}
.field-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}
#video-prompt {
  min-height: 110px;
}
.reference-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.reference-card {
  background: #0d1924;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
}
.reference-card > span {
  display: block;
  font-size: 12px;
  margin-bottom: 10px;
}
.reference-card b {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
}
.reference-card img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: contain;
  background: #080f15;
  border-radius: 5px;
  margin-bottom: 10px;
}
.reference-card p {
  min-height: 120px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.reference-card button,
.reference-card .file-label {
  font-size: 11px;
  padding: 7px;
  margin-top: 4px;
}
.text-button {
  background: transparent;
  border-color: transparent;
}
.creator-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  margin-top: 18px;
}
#video-source {
  max-height: 320px;
  width: 100%;
  background: #080f15;
}
.result-empty {
  aspect-ratio: 16/10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px;
  background: radial-gradient(ellipse at top right, #28484b, #0d1924 70%);
  border: 1px dashed #48615e;
  border-radius: 10px;
}
.result-empty h3 {
  font-weight: 450;
  font-size: 25px;
  line-height: 1.3;
  max-width: 400px;
}
.result-empty p {
  color: var(--muted);
  font-size: 13px;
  max-width: 390px;
}
#video-result {
  width: 100%;
  max-height: 480px;
  background: #080f15;
  margin: 0;
}
.video-job-status {
  border-left: 3px solid var(--mint);
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  background: #10202a;
  overflow-wrap: anywhere;
}
.video-job-status.error {
  border-color: #ee8f80;
  color: #ffb7aa;
}
#video-result-links {
  font-size: 12px;
  margin-bottom: 12px;
}
.cut-section {
  border-top: 1px solid var(--line);
  margin-top: 24px;
  padding-top: 12px;
}
.cut-section h3 {
  font-size: 16px;
  font-weight: 500;
}
#video-cut-list {
  padding-left: 22px;
}
#video-cut-list li {
  margin: 8px 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}
#video-cut-list button {
  padding: 4px 7px;
  margin-left: 5px;
}
.video-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 320px;
  overflow: auto;
}
.video-history button {
  display: flex;
  justify-content: space-between;
  text-align: left;
  gap: 12px;
  font-size: 12px;
}
.video-history button span {
  overflow-wrap: anywhere;
}
.video-history small {
  color: var(--muted);
  white-space: nowrap;
}
.blockout-heading {
  margin: 26px 0 18px;
}
.blockout-heading h2 {
  margin-top: 8px;
  font-size: 20px;
}
@media (max-width: 1000px) {
  .creator-grid {
    grid-template-columns: 1fr;
  }
  .video-creator {
    padding: 18px;
  }
}
@media (max-width: 480px) {
  .reference-pair {
    gap: 8px;
  }
  .reference-card {
    padding: 8px;
  }
  .reference-card img {
    height: 100px;
  }
  .creator-settings {
    gap: 0 8px;
  }
  .video-creator {
    padding: 14px;
  }
  .result-empty {
    padding: 20px;
  }
  .result-empty h3 {
    font-size: 22px;
  }
  .creator-heading h2 {
    font-size: 20px;
  }
}

/* The forest remains the existing studio: focus mode only rearranges its UI. */
.forest-controls[hidden] { display: none; }
.forest-controls { display:flex; align-items:end; justify-content:space-between; gap:24px; padding:12px 0 24px; }
.forest-controls h2 { font-size:clamp(28px,3vw,44px); font-weight:500; letter-spacing:-.04em; margin:7px 0; }
.forest-controls p { color:#a9b7ac; margin:0; }
.forest-options { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.forest-options label { display:flex; gap:8px; align-items:center; font-size:13px; }
.forest-options input { width:auto; accent-color:#a7bd83; }
body.forest-focus { background:#101813; }
.forest-focus main { max-width:1680px; }
.forest-focus main > :not(.workspace):not(.forest-controls) { display:none; }
.forest-focus .workspace { grid-template-columns:minmax(0,1fr); }
.forest-focus .workspace > aside { display:none; }
.forest-focus .viewer { border-color:#364438; border-radius:10px; }
.forest-focus .viewtop { display:none; }
.forest-active .canvas-wrap { background:#26352a; }
.forest-focus .canvas-wrap { aspect-ratio:16/9; max-height:calc(100vh - 290px); min-height:300px; }
.forest-active .timeline { background:#18231c; }
.forest-active .badge { background:#0b140d80; color:#e3e8da; font-size:11px; letter-spacing:.06em; }
.forest-focus #shots { display:none; }
.viewer:fullscreen { display:flex; flex-direction:column; background:#101813; width:100vw; height:100vh; }
.viewer:fullscreen .canvas-wrap { flex:1; max-height:none; min-height:0; aspect-ratio:auto; }
.viewer:fullscreen .viewtop { display:none; }
@media(max-width:700px) {
  .forest-controls { align-items:start; flex-direction:column; gap:18px; }
  .forest-options { gap:9px; }
  .forest-options button { padding:9px 10px; }
  .forest-focus .canvas-wrap { min-height:360px; max-height:none; aspect-ratio:4/5; }
  .forest-focus .transport { gap:6px; }
  .forest-focus .transport button { padding:8px 10px; }
}
.creek-active.forest-focus .workspace { max-width:680px; margin-inline:auto; }
.creek-active.forest-focus .canvas-wrap { aspect-ratio:2/3; max-height:none; min-height:0; }
.creek-active.forest-focus .viewer:fullscreen { max-width:none; }
.creek-active.forest-focus .viewer:fullscreen .canvas-wrap { aspect-ratio:auto; }

.project-library{margin:0 0 20px;padding:16px;border:1px solid var(--line);border-radius:8px;background:var(--panel)}
.project-library summary{cursor:pointer;font-weight:600}.project-library p{color:var(--muted);font-size:13px}.project-library .row{flex-wrap:wrap}.project-library select{max-width:100%;min-width:0}

.game-hud{padding:1rem;background:#101716;border-top:1px solid #35423b;overflow-wrap:anywhere}.game-hud[hidden]{display:none}.game-hud p{margin:.3rem 0 .7rem}.game-stats{font-size:.85rem;color:#bed0c0;margin-bottom:.8rem}.game-actions{display:flex;flex-wrap:wrap;gap:.45rem;margin:.6rem 0}.game-actions button{min-height:40px}.game-hud ol{max-height:220px;overflow:auto;font-size:.8rem;padding-left:1.5rem}.game-hud li{margin:.4rem 0}

.scene-agent-panel { display:flex; flex-wrap:wrap; gap:.6rem; align-items:center; padding:.75rem; background:#101010; border:1px solid #333; color:#eee; }
.scene-agent-panel[hidden] { display:none; }
.scene-agent-panel textarea { flex:1 1 16rem; min-width:0; background:#080808; color:inherit; }
.scene-agent-panel select { max-width:100%; }
.scene-agent-panel p { flex-basis:100%; margin:0; font-size:.85rem; }

.generated-assets-panel { padding:1rem; border-top:1px solid #333; }
.generated-assets-panel textarea { display:block; width:100%; max-width:100%; box-sizing:border-box; margin:.5rem 0; }
.generated-assets-panel input { max-width:100%; }

.reference-model-panel { padding:12px; margin-top:12px; border:1px solid #52646a; border-radius:8px; }
.reference-model-panel[hidden] { display:none; }
.reference-orbit-controls { display:flex; flex-wrap:wrap; gap:14px; }
.reference-orbit-controls label { display:flex; flex-direction:column; flex:1 1 160px; min-width:0; }
.reference-orbit-controls input { width:100%; }
.image-reconstruction .canvas-wrap { position:sticky; top:0; z-index:5; height:300px; min-height:240px; aspect-ratio:auto; background:#fff; }
.image-reconstruction .reference-model-panel { margin:0; }
.image-reconstruction .reference-model-panel p { font-size:13px; line-height:1.5; }
@media(max-width:650px) {
 .image-reconstruction .canvas-wrap { height:240px; min-height:240px; }
 .reference-orbit-controls { gap:5px; }
 .reference-orbit-controls label { flex-basis:100%; font-size:12px; }
 .reference-model-panel button { padding:7px; font-size:12px; }
}
.image-reconstruction #scene { touch-action:none; cursor:grab; }
.image-reconstruction #scene:active { cursor:grabbing; }

.reference-parts-editor { clear:both; margin-top:12px; padding-top:10px; border-top:1px solid #506076; }
.reference-parts-editor summary { cursor:pointer; font-weight:600; }
.reference-parts-editor label { display:block; margin:8px 0; }
.reference-parts-editor input,.reference-parts-editor select { max-width:100%; box-sizing:border-box; }
.reference-parts-editor input[type=text],.reference-parts-editor select { width:100%; }
.reference-part-outline { display:block; width:100%; max-width:360px; height:auto; cursor:crosshair; image-rendering:pixelated; background:white; border:1px solid #637180; }
.reference-parts-editor button { margin:4px; white-space:normal; }
.reference-parts-status { overflow-wrap:anywhere; }

.multiview-evidence { clear:both; padding-top:12px; }
.multiview-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:8px; }
.multiview-grid figure { margin:0; min-width:0; }
.multiview-grid img { display:block; width:100%; aspect-ratio:1; object-fit:contain; background:white; }
.multiview-grid figcaption { font-size:12px; padding:4px 0; }

#video-model-status { overflow-wrap: anywhere; }

.viewer.reference-mill:not(:fullscreen) .canvas-wrap { aspect-ratio: var(--authored-aspect); min-height: 0; }

#mill-inspection { padding: .6rem 1rem; border-top: 1px solid #53615d; }
#mill-inspection .row { flex-wrap: wrap; align-items: center; }
#mill-inspection details { margin-top: .45rem; }
#mill-inspection p { max-width: 70ch; }
#mill-reading { font-variant-numeric: tabular-nums; }

body[data-kind="game"] .viewer.mill-mechanics .touch, .mill-mechanics #scene-badge { display:none; }

body.mill-watch { background:#121a1a; }
.mill-watch main { max-width:1380px; margin:auto; padding:8px 12px; }
.mill-watch main > :not(.workspace), .mill-watch .workspace > :not(.viewer),
.mill-watch .viewer > :not(.canvas-wrap,.viewtop,.timeline), .mill-watch #shot-name,
.mill-watch .timeline > :not(.transport,#scrub), .mill-watch #scene-badge,
body.mill-watch .viewer .touch { display:none; }
.mill-watch .workspace { display:block; }
.mill-watch .viewer { background:#16201e; }
.mill-watch .viewtop { align-items:center; flex-wrap:wrap; background:transparent; }
.mill-watch .viewer .canvas-wrap { width:min(100%,calc((100svh - 185px) * var(--authored-aspect))); margin:auto; aspect-ratio:var(--authored-aspect); min-height:0; max-height:none; }
.mill-watch .timeline { padding:8px 15px; }

.original-image-gallery {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:12px 0}
.original-image-gallery a {display:grid;gap:4px;font-size:.875rem;color:inherit;text-decoration:underline}
.original-image-gallery img {width:100%;aspect-ratio:3/2;object-fit:contain}

.image-component-panel {margin:8px 0;padding:10px 14px}
.image-component-panel select {margin:8px 0}
.component-views {display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:8px;align-items:center;max-width:580px}
.component-views canvas {display:block;width:100%;height:auto;min-height:0;border-radius:4px;background:#202b32;background-size:100% 100%}
.component-views canvas:first-child {touch-action:none;cursor:grab}
.component-tools {display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:8px 0}
.component-tools input {width:90px}

.scene-blockout-map {display:block;width:min(100%,650px);height:auto;margin:8px 0;cursor:crosshair;background-size:100% 100%;background-repeat:no-repeat}
.scene-blockout-legend {display:flex;flex-wrap:wrap;gap:4px;margin-bottom:10px}
.scene-blockout-legend button {display:inline-flex;align-items:center;gap:5px;font-size:.8em}
.scene-blockout-legend button[aria-pressed=true] {outline:2px solid currentColor}
.scene-blockout-legend span {width:.8em;height:.8em;border-radius:2px}
.image-cloud canvas {width:min(100%,560px);height:auto;background:#16232c;touch-action:none;cursor:grab}
.image-cloud input {display:block;width:min(100%,560px)}
.image-cloud output {display:block;margin:.4em 0}
