:root {
  --bg: #07100c;
  --bg-elevated: #0a1510;
  --panel: rgba(13, 26, 19, .97);
  --panel-solid: #0d1a13;
  --panel-2: #12231a;
  --field: #08120d;
  --line: #213a2c;
  --line-strong: #315541;
  --text: #f1f7f1;
  --muted: #9aada0;
  --muted-soft: #73877a;
  --lime: #c8f85f;
  --lime-text: #b8ea50;
  --lime-dim: #88b637;
  --primary: #c8f85f;
  --primary-hover: #dcff8a;
  --primary-text: #0a130d;
  --orange: #ffb45c;
  --cyan: #6be0ce;
  --red: #ff7871;
  --topbar: rgba(7, 16, 12, .9);
  --panel-gradient: linear-gradient(145deg, rgba(15, 30, 22, .98), rgba(9, 19, 14, .98));
  --page-glow: rgba(67, 153, 100, .14);
  --grid-line: rgba(255, 255, 255, .016);
  --canvas-top: #0b1a13;
  --canvas-bottom: #07100c;
  --canvas-glow: rgba(86, 149, 104, .19);
  --canvas-grid: rgba(118, 159, 132, .12);
  --canvas-axis: rgba(200, 248, 95, .22);
  --canvas-selection: #edffaf;
  --overlay: rgba(5, 12, 8, .82);
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .16);
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f3f7f0;
  --bg-elevated: #e9f0e5;
  --panel: rgba(255, 255, 255, .96);
  --panel-solid: #ffffff;
  --panel-2: #edf4e9;
  --field: #f8fbf6;
  --line: #d5e1d1;
  --line-strong: #b7cbb2;
  --text: #18231b;
  --muted: #637267;
  --muted-soft: #7b8b7f;
  --lime: #527500;
  --lime-text: #527500;
  --lime-dim: #78982a;
  --primary: #b7df45;
  --primary-hover: #a8d331;
  --primary-text: #152006;
  --orange: #ad5b00;
  --cyan: #007e70;
  --red: #c43f3a;
  --topbar: rgba(248, 251, 246, .9);
  --panel-gradient: linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(246, 250, 244, .98));
  --page-glow: rgba(132, 181, 91, .17);
  --grid-line: rgba(42, 72, 48, .035);
  --canvas-top: #e9f2e5;
  --canvas-bottom: #dfeade;
  --canvas-glow: rgba(111, 164, 92, .24);
  --canvas-grid: rgba(48, 91, 59, .15);
  --canvas-axis: rgba(78, 112, 0, .32);
  --canvas-selection: #304900;
  --overlay: rgba(255, 255, 255, .86);
  --shadow: 0 18px 48px rgba(39, 69, 44, .12);
  --shadow-soft: 0 8px 24px rgba(39, 69, 44, .09);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}

body {
  background-image:
    radial-gradient(circle at 78% 6%, var(--page-glow), transparent 32%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 44px 44px, 44px 44px;
}

button,
input,
select,
textarea { font: inherit; }

button,
a { transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease; }

button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.padded { padding: 14px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: 0 0 26px color-mix(in srgb, var(--primary) 24%, transparent);
  font-size: 19px;
  font-weight: 900;
}

.brand b { display: block; font-size: 19px; line-height: 1; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font: 11px/1.2 var(--mono); letter-spacing: .15em; }

.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 23px;
  border-left: 1px solid var(--line);
  color: var(--lime-text);
  font: 11px var(--mono);
  letter-spacing: .04em;
}

.top-status em {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0;
}
.top-status em.ready { border-color: var(--lime-dim); color: var(--lime-text); }

.top-status i,
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}

.topbar nav { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.topbar nav a,
.topbar nav button {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font: 13px var(--mono);
  text-decoration: none;
}

.topbar nav a:hover,
.topbar nav button:hover { border-color: var(--line-strong); color: var(--lime-text); background: var(--panel-2); }
.theme-toggle { display: inline-flex; align-items: center; gap: 7px; }
.theme-toggle span { font-size: 15px; line-height: 1; }
.theme-toggle b { font-size: 13px; font-weight: 600; }

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  max-width: 1760px;
  margin: 0 auto;
  padding: 20px;
  transition: grid-template-columns .24s ease, gap .24s ease;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-gradient);
  box-shadow: var(--shadow);
}

.create-panel {
  position: sticky;
  top: 92px;
  align-self: start;
  min-width: 0;
  min-height: calc(100vh - 112px);
  padding: 23px;
  transition: opacity .18s ease, transform .24s ease;
}

.panel-title,
.section-head,
.review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.eyebrow {
  color: var(--lime-text);
  font: 11px var(--mono);
  font-weight: 600;
  letter-spacing: .14em;
}

h1,
h2,
h3,
p { margin: 0; }

.panel-title h1 { margin-top: 7px; font-size: 23px; line-height: 1.2; }
.step-badge { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font: 12px var(--mono); }

#createForm { margin-top: 23px; }
.world-name-field { display: block; margin-bottom: 14px; }
.world-name-field input { height: 44px; padding: 0 12px; font-size: 14px; }
.field-label,
#createForm label > span,
.inspector label > span,
.vector-label { display: block; margin-bottom: 8px; color: var(--muted); font: 12px var(--mono); }

textarea,
select,
input[type="text"],
input[type="search"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--field);
  color: var(--text);
}

textarea::placeholder,
input::placeholder { color: var(--muted-soft); }
textarea:focus,
select:focus,
input:focus { border-color: var(--lime-dim); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
textarea { min-height: 116px; padding: 13px 14px; resize: vertical; font-size: 14px; line-height: 1.6; }
select { height: 44px; padding: 0 11px; font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 18px; }
.select-wide { display: block; margin-top: 13px; }

.prompt-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.prompt-chips button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 12px var(--mono);
}
.prompt-chips button:hover { border-color: var(--lime-dim); background: color-mix(in srgb, var(--primary) 7%, transparent); color: var(--lime-text); }

.drop-zone {
  min-height: 132px;
  margin-top: 17px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: color-mix(in srgb, var(--primary) 2.5%, transparent);
  text-align: center;
}
.drop-zone.over,
.drop-zone:focus { border-color: var(--lime-dim); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.drop-icon {
  display: block;
  width: 31px;
  height: 31px;
  margin: 0 auto 9px;
  border: 1px solid var(--lime-dim);
  border-radius: 50%;
  color: var(--lime-text);
  font-size: 23px;
  line-height: 27px;
}
.drop-zone strong { display: block; font-size: 14px; }
.drop-zone small { display: block; margin-top: 7px; color: var(--muted); font: 11px var(--mono); }
.input-preview { display: flex; justify-content: center; gap: 6px; overflow: auto; margin-top: 11px; }
.input-preview:empty { display: none; }
.input-preview img { width: 52px; height: 44px; border: 1px solid var(--line-strong); border-radius: 6px; object-fit: cover; }

.primary {
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 800;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 12%, transparent);
}
.primary:hover:not(:disabled) { transform: translateY(-1px); background: var(--primary-hover); box-shadow: 0 11px 28px color-mix(in srgb, var(--primary) 18%, transparent); }
.primary:disabled { cursor: not-allowed; opacity: .4; box-shadow: none; }
.create-button { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 50px; margin-top: 16px; padding: 0 17px; font-size: 14px; }
.create-button b { font-size: 20px; }

.capability-card { margin-top: 19px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--field); }
.capability-card > div:first-child { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); }
.capability-card p { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.provider-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.provider-list span { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font: 11px var(--mono); }
.provider-list span.ready { border-color: var(--lime-dim); color: var(--lime-text); }

.recent-section { margin-top: 25px; }
.section-head h2 { margin-top: 5px; font-size: 18px; }
.section-head > span { color: var(--muted); font: 12px var(--mono); }
.recent-list { display: grid; gap: 8px; margin-top: 12px; }
.recent-world {
  width: 100%;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--field);
  color: var(--text);
  text-align: left;
}
.recent-world:hover,
.recent-world.active { border-color: var(--line-strong); background: var(--panel-2); }
.recent-world strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.recent-world span { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font: 11px var(--mono); }
.recent-world span b { color: var(--lime-text); font-weight: 600; }

.review-column { min-width: 0; }
.review-head { min-height: 80px; align-items: center; padding: 4px 4px 17px; }
.world-title-row { display: flex; align-items: center; gap: 10px; }
.review-head h2 { margin-top: 7px; font-size: 27px; line-height: 1.15; }
.title-edit-button { align-self: end; margin-bottom: 2px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.title-edit-button:hover { border-color: var(--line-strong); color: var(--lime-text); }
.review-head p { margin-top: 8px; color: var(--muted); font: 12px var(--mono); }
.review-actions { display: flex; align-items: center; gap: 9px; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.status-pill.running { border-color: color-mix(in srgb, var(--cyan) 55%, var(--line)); color: var(--cyan); }
.status-pill.pass,
.status-pill.published { border-color: var(--lime-dim); color: var(--lime-text); }
.status-pill.fail { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); color: var(--red); }
.ghost-button { padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text); font: 13px var(--mono); text-decoration: none; }
.ghost-button:hover:not(:disabled):not(.disabled) { border-color: var(--lime-dim); background: var(--panel-2); color: var(--lime-text); }
.ghost-button:disabled,
.ghost-button.disabled { pointer-events: none; opacity: .36; }
.primary.small { height: 39px; padding: 0 17px; font: 13px var(--mono); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 390px); height: clamp(720px, 78vh, 840px); overflow: hidden; transition: grid-template-columns .24s ease; }
.viewport-wrap { display: grid; grid-template-rows: 50px minmax(0, 1fr) 76px; min-width: 0; border-right: 1px solid var(--line); }
.viewport-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--line); }
.view-tabs,
.camera-tools { display: flex; gap: 6px; }
.view-tabs button,
.camera-tools button { padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: 12px var(--mono); }
.view-tabs button.active { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--lime-text); }
.camera-tools button:hover { background: var(--panel-2); color: var(--text); }
.camera-tools .panel-toggle { border: 1px solid var(--line); background: var(--field); color: var(--lime-text); }
.camera-tools .panel-toggle:hover { border-color: var(--line-strong); }
.compare-opacity { display: flex; align-items: center; gap: 6px; padding: 0 7px; color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.compare-opacity input { width: 72px; accent-color: var(--primary); }

.viewport {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, var(--canvas-glow), transparent 44%), linear-gradient(var(--canvas-top), var(--canvas-bottom));
}
.viewport:fullscreen { width: 100vw; height: 100vh; background: var(--canvas-bottom); }
.world-viewer,
.world-renderer-mount { position: absolute; inset: 0; width: 100%; height: 100%; }
.world-viewer { z-index: 1; overflow: hidden; }
.world-renderer-mount { min-width: 1px; min-height: 1px; overflow: hidden; }
.world-reference-backdrop { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; filter: saturate(.96) brightness(.92); }
.world-reference-backdrop[hidden] { display: none; }
.world-webgl-canvas { position: relative; z-index: 1; display: block; width: 100%; height: 100%; outline: none; touch-action: none; cursor: grab; }
.world-webgl-canvas:active { cursor: grabbing; }
.viewer-status { position: absolute; z-index: 6; top: 50%; left: 50%; display: flex; width: min(360px, calc(100% - 36px)); flex-direction: column; align-items: center; gap: 9px; padding: 20px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--overlay); box-shadow: var(--shadow); text-align: center; transform: translate(-50%, -50%); backdrop-filter: blur(14px); }
.viewer-status strong { color: var(--text); font-size: 16px; }
.viewer-status span { color: var(--muted); font: 12px var(--mono); line-height: 1.5; }
.viewer-status.error { border-color: color-mix(in srgb, var(--red) 58%, var(--line)); }
.viewer-status.error strong { color: var(--red); }
.viewer-status.error .viewer-spinner,
.viewer-status.error .viewer-progress { display: none; }
.viewer-spinner { width: 34px; height: 34px; border: 3px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: viewer-spin .8s linear infinite; }
.viewer-progress { width: 100%; height: 6px; overflow: hidden; border-radius: 99px; background: var(--field); }
.viewer-progress i { display: block; width: 8%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan)); transition: width .2s ease; }
.viewer-status .ghost-button { margin-top: 3px; padding: 8px 11px; }
.viewer-badge { position: absolute; z-index: 5; top: 14px; left: 14px; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--overlay); box-shadow: var(--shadow-soft); color: var(--lime-text); font: 11px var(--mono); pointer-events: none; backdrop-filter: blur(10px); }
.viewer-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.viewer-badge.quality-failed { color: #ff8c83; border-color: #c64f49; }
.viewer-badge.quality-failed i { background: #ff8c83; box-shadow: none; }
.empty-state { position: absolute; z-index: 8; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); pointer-events: none; }
.empty-state strong { color: var(--text); font-size: 18px; }
.empty-state span { max-width: 420px; font-size: 13px; line-height: 1.5; text-align: center; }
.empty-state.running .orbit-symbol { animation: build-float 2.2s ease-in-out infinite; }
.empty-state.running .orbit-symbol::before { animation: build-orbit-x 2.5s linear infinite; }
.empty-state.running .orbit-symbol::after { animation: build-orbit-y 3.1s linear infinite reverse; }
.orbit-symbol { position: relative; display: grid; place-items: center; width: 80px; height: 80px; margin-bottom: 7px; }
.orbit-symbol::before,
.orbit-symbol::after,
.orbit-symbol i { position: absolute; inset: 10px; border: 1px solid var(--line-strong); border-radius: 50%; content: ""; transform: rotateX(65deg); }
.orbit-symbol::after { transform: rotateY(65deg); }
.orbit-symbol i:first-child { transform: rotate(45deg) rotateX(65deg); }
.orbit-symbol b { color: var(--lime-text); font: 800 27px var(--mono); }
.build-progress { display: grid; grid-template-columns: minmax(180px, 280px) 42px; align-items: center; gap: 10px; width: min(330px, 72%); margin-top: 5px; }
.build-progress > div { height: 7px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--field); }
.build-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan)); box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 40%, transparent); transition: width .35s ease; }
.build-progress b { color: var(--lime-text); font: 12px var(--mono); text-align: right; }

@keyframes build-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes build-orbit-x {
  from { transform: rotate(0deg) rotateX(65deg); }
  to { transform: rotate(360deg) rotateX(65deg); }
}
@keyframes build-orbit-y {
  from { transform: rotate(0deg) rotateY(65deg); }
  to { transform: rotate(360deg) rotateY(65deg); }
}
@keyframes viewer-spin { to { transform: rotate(360deg); } }
.viewport-hint { position: absolute; z-index: 4; bottom: 13px; left: 14px; color: var(--muted-soft); font: 11px var(--mono); pointer-events: none; }
.viewport-stats { position: absolute; z-index: 4; right: 14px; bottom: 12px; display: flex; gap: 6px; pointer-events: none; }
.viewport-stats span { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--overlay); color: var(--muted); font: 11px var(--mono); backdrop-filter: blur(8px); }

.source-view { position: absolute; z-index: 9; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px; background: var(--canvas-bottom); }
.source-view > div { display: flex; max-width: 100%; max-height: 85%; gap: 14px; overflow: auto; }
.source-view img { max-width: min(80%, 580px); max-height: 410px; border: 1px solid var(--line-strong); border-radius: 10px; object-fit: contain; box-shadow: var(--shadow-soft); }
.source-view p { margin-top: 15px; color: var(--muted); font-size: 13px; }
.reference-compare { position: absolute; z-index: 3; inset: 0; display: none; width: 100%; height: 100%; object-fit: contain; object-position: center; pointer-events: none; }
.viewport.compare-split .reference-compare { display: block; clip-path: inset(0 50% 0 0); }
.viewport.compare-overlay .reference-compare { display: block; opacity: var(--compare-opacity, .5); }
.split-divider { position: absolute; z-index: 7; top: 0; bottom: 0; left: 50%; display: none; width: 1px; background: var(--primary); box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent); pointer-events: none; }
.split-divider span { position: absolute; top: 12px; padding: 4px 7px; border-radius: 5px; background: var(--overlay); color: var(--lime-text); font: 11px var(--mono); white-space: nowrap; }
.split-divider span:first-child { right: 8px; }
.split-divider span:last-child { left: 8px; }
.viewport.compare-split .split-divider { display: block; }

.pipeline-rail { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 12px 15px; border-top: 1px solid var(--line); background: var(--field); scrollbar-gutter: stable; }
.pipeline-step { display: flex; flex: 0 0 auto; align-items: center; min-width: max-content; }
.pipeline-step:not(:last-child)::after { flex: 0 0 clamp(18px, 1.8vw, 34px); height: 1px; margin: 0 8px; background: var(--line); content: ""; }
.pipeline-step i { flex: none; width: 10px; height: 10px; border: 1px solid var(--line-strong); border-radius: 50%; }
.pipeline-step span { margin-left: 7px; color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.pipeline-step.done i { border-color: var(--primary); background: var(--primary); box-shadow: 0 0 8px color-mix(in srgb, var(--primary) 48%, transparent); }
.pipeline-step.done span { color: var(--lime-text); }
.pipeline-step.current i { border-color: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.pipeline-step.current span { color: var(--cyan); }

.workspace-sidebar { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--bg-elevated); transition: opacity .18s ease, transform .24s ease; }
.sidebar-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--field); }
.sidebar-tabs button { min-width: 0; height: 37px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font: 12px var(--mono); }
.sidebar-tabs button:hover { border-color: var(--line); color: var(--text); }
.sidebar-tabs button.active { border-color: var(--line-strong); background: var(--panel); box-shadow: var(--shadow-soft); color: var(--lime-text); }
.sidebar-pane { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.asset-panel { display: grid; grid-template-rows: auto minmax(140px, 1fr) auto; overflow: hidden; background: transparent; }
.asset-panel-head { padding: 16px; border-bottom: 1px solid var(--line); }
.asset-panel-head > div { display: flex; align-items: end; justify-content: space-between; }
.asset-panel-head h3 { margin-top: 4px; font-size: 17px; }
.asset-panel-head h3 b { color: var(--lime-text); font: 13px var(--mono); }
#assetSearch { height: 38px; margin-top: 12px; padding: 0 11px; font-size: 12px; }
.asset-list { overflow: auto; padding: 8px; }
.asset-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.asset-row:hover,
.asset-row.active { border-color: var(--line); background: var(--panel-2); }
.asset-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: color-mix(in srgb, var(--primary) 9%, transparent); color: var(--lime-text); font: 11px var(--mono); font-weight: 700; }
.asset-row strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.asset-row small { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font: 11px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.asset-row > span:last-child { color: var(--orange); font: 11px var(--mono); }

.inspector { max-height: 360px; overflow: auto; padding: 16px; border-top: 1px solid var(--line); }
.inspector-content { display: block; }
.inspector.empty .inspector-content { display: none; }
.inspector:not(.empty) .inspector-placeholder { display: none; }
.inspector-placeholder { padding: 22px 12px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.inspector-title { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.inspector-title span { color: var(--lime-text); font: 11px var(--mono); }
.inspector-title h3 { margin-top: 4px; font-size: 16px; }
.inspector-title > span { align-self: start; padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; }
.inspector input[type="text"],
.inspector input[type="number"] { height: 36px; padding: 0 9px; font: 11px var(--mono); }
.vector-label { display: flex; justify-content: space-between; margin: 12px 0 7px; }
.vector-label small { color: var(--muted-soft); font-size: 11px; }
.vector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.check-row { display: flex !important; align-items: center; gap: 8px; margin-top: 13px; color: var(--text) !important; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.check-row span { margin: 0 !important; color: var(--text) !important; font-size: 12px !important; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 14px; }
.inspector-actions button { height: 39px; border: 1px solid var(--line-strong); border-radius: 8px; background: transparent; color: var(--text); font: 12px var(--mono); }
.inspector-actions button:hover { background: var(--panel-2); }
.inspector-actions .primary { border: 0; background: var(--primary); color: var(--primary-text); }

.qa-panel,
.trace-panel { padding: 18px; background: var(--bg-elevated); }
.history-panel { padding: 18px; background: var(--bg-elevated); }
.history-panel #historySearch { height: 40px; margin-top: 16px; padding: 0 11px; font-size: 12px; }
.history-list { padding-bottom: 8px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.metric-grid > div { padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.metric-grid small { display: block; color: var(--muted); font: 11px var(--mono); }
.metric-grid b { display: block; margin-top: 7px; color: var(--text); font: 21px var(--mono); }
.gate-list { display: grid; grid-template-columns: 1fr; gap: 7px; margin-top: 14px; }
.gate { display: flex; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.gate i { display: grid; place-items: center; flex: none; width: 17px; height: 17px; border-radius: 50%; font: 11px var(--mono); font-style: normal; }
.gate.pass i { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--lime-text); }
.gate.fail i { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.gate div { min-width: 0; }
.phase0-evidence { margin: 14px 0; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.phase0-evidence > strong { display: block; margin-bottom: 9px; font: 11px var(--mono); }
.phase0-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.phase0-compare a { position: relative; display: block; overflow: hidden; min-height: 88px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--canvas-bottom); }
.phase0-compare img { display: block; width: 100%; height: 108px; object-fit: contain; }
.phase0-compare small { position: absolute; right: 5px; bottom: 5px; padding: 3px 5px; border-radius: 4px; background: var(--overlay); color: var(--text); font: 11px var(--mono); }
.production-feedback { margin: 14px 0; padding: 11px; border: 1px solid color-mix(in srgb, var(--orange) 55%, var(--line)); border-radius: 9px; background: color-mix(in srgb, var(--orange) 7%, var(--field)); }
.production-feedback > strong { display: block; margin-bottom: 7px; color: var(--text); font: 12px var(--mono); }
.production-feedback ul { display: grid; gap: 6px; margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.gate strong { display: block; font-size: 12px; }
.gate small { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font: 11px var(--mono); text-overflow: ellipsis; white-space: nowrap; }

.progress-track { height: 6px; overflow: hidden; margin-top: 17px; border-radius: 5px; background: var(--field); }
.progress-track i { display: block; width: 0; height: 100%; background: var(--primary); transition: width .3s; }
.event-list { display: grid; gap: 0; margin-top: 14px; }
.event { display: grid; grid-template-columns: 12px 96px minmax(0, 1fr); align-items: start; gap: 9px; padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.event i { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--line-strong); }
.event.done i { background: var(--lime-dim); }
.event b { color: var(--text); font: 11px var(--mono); }
.event span { color: var(--muted); font-size: 12px; line-height: 1.4; }

#toast { position: fixed; bottom: 28px; left: 50%; z-index: 50; padding: 12px 18px; border-radius: 9px; background: var(--primary); box-shadow: var(--shadow); color: var(--primary-text); font: 12px var(--mono); opacity: 0; transform: translate(-50%, 80px); transition: .25s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); color: #fff; }

@media (min-width: 961px) {
  html,
  body { height: 100%; overflow: hidden; }
  .app-shell {
    height: calc(100dvh - 72px);
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }
  .create-panel {
    position: static;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .review-column {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .workspace { height: clamp(520px, calc(100dvh - 190px), 760px); }
  .app-shell.layout-left-collapsed { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .app-shell.layout-left-collapsed .create-panel {
    display: none;
  }
  .workspace.layout-right-collapsed { grid-template-columns: minmax(0, 1fr) 0; }
  .workspace.layout-right-collapsed .viewport-wrap { border-right: 0; }
  .workspace.layout-right-collapsed .workspace-sidebar {
    display: none;
  }
}

@media (max-width: 1220px) {
  .app-shell { grid-template-columns: 320px minmax(0, 1fr); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(330px, 350px); }
  .top-status em { display: none; }
}

@media (max-width: 960px) {
  .topbar { padding: 0 15px; }
  .top-status { display: none; }
  .app-shell { display: block; padding: 12px; }
  .create-panel { position: static; min-height: auto; }
  .review-column { margin-top: 21px; }
  .review-head { align-items: flex-start; flex-direction: column; }
  .review-actions { flex-wrap: wrap; width: 100%; }
  .workspace { display: block; height: auto; }
  .viewport-wrap { height: 680px; border-right: 0; }
  .workspace-sidebar { height: 640px; border-top: 1px solid var(--line); }
  .app-shell.layout-left-collapsed .create-panel,
  .workspace.layout-right-collapsed .workspace-sidebar { display: none; }
}

@media (max-width: 620px) {
  html,
  body { font-size: 14px; }
  .topbar { height: 64px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand small,
  .topbar nav > a,
  #refreshBtn { display: none; }
  .theme-toggle b { display: inline; }
  .app-shell { padding: 8px; }
  .create-panel { padding: 18px; }
  .two-col { grid-template-columns: 1fr; }
  .review-head h2 { font-size: 23px; }
  .workspace { border-radius: 11px; }
  .viewport-wrap { grid-template-rows: 48px minmax(0, 1fr) 72px; height: 540px; }
  .pipeline-step { min-width: max-content; }
  .pipeline-step span { font-size: 11px; }
  .viewport-hint { display: none; }
  .viewport-stats { right: 9px; bottom: 9px; }
  .metric-grid,
  .gate-list { grid-template-columns: 1fr 1fr; }
  .gate strong { font-size: 11px; }
  .source-view { padding: 14px; }
  .review-actions .status-pill { order: -1; }
}

@media (max-width: 420px) {
  .metric-grid,
  .gate-list { grid-template-columns: 1fr; }
  .review-actions { gap: 6px; }
  .ghost-button,
  .primary.small { flex: 1; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
