:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --panel: #121418;
  --raised: #191c22;
  --ink: #ebe6df;
  --text: #ebe6df;
  --muted: #9b958c;
  --faint: #6d675f;
  --line: rgba(255, 246, 236, 0.08);
  --line-strong: rgba(255, 246, 236, 0.16);
  --accent: #e0a36a;
  --accent-soft: rgba(224, 163, 106, 0.14);
  --danger: #e08a78;
  --ok: #a3c096;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; overflow: hidden; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { background: var(--bg); color: var(--ink); touch-action: manipulation; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(224, 163, 106, 0.28); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #322e29;
  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
}

.app {
  height: 100%;
  width: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: 46px 34px minmax(0, 1fr);
  grid-template-columns: var(--rail-w, 320px) minmax(0, 1fr) var(--inspector-w, 390px);
  background: var(--bg);
}

body.is-resizing-panes {
  cursor: col-resize;
  user-select: none;
}
body.is-resizing-panes.is-resizing-row {
  cursor: row-resize;
}

.topbar { grid-row: 1; grid-column: 1 / -1; }
.tabbar { grid-row: 2; grid-column: 2 / -1; border-left: 1px solid var(--line); }
.rail { grid-row: 2 / -1; grid-column: 1; }
.stage { grid-row: 3; grid-column: 2; }
.inspector { grid-row: 3; grid-column: 3; }

.topbar, .rail, .inspector {
  border-color: var(--line);
  border-style: solid;
}

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-width: 0 0 1px;
  background: var(--panel);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.top-history {
  display: flex;
  align-items: center;
  gap: 5px;
}
.center-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--raised);
}
.tool-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tool-sep {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
  opacity: 0.7;
}
.tabbar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 10;
}
.design-tab {
  display: flex;
  align-items: center;
  max-width: 180px;
  min-width: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
}
.design-tab.current {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.design-tab-open {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 0 4px 0 10px;
  font-size: 12.5px;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  pointer-events: auto;
}
.design-tab-open:disabled { cursor: default; }
.tab-spin {
  width: 10px;
  height: 10px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tab-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes tab-spin {
  to { transform: rotate(360deg); }
}
.stop-btn {
  margin-left: 6px;
  border: 1px solid color-mix(in srgb, #e07a62 55%, var(--line));
  background: rgba(224, 122, 98, 0.12);
  color: #e7b0a2;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
}
.stop-btn:hover { color: #f3ece4; background: rgba(224, 122, 98, 0.22); }
.stop-composer {
  border-color: color-mix(in srgb, #e07a62 55%, var(--line)) !important;
  color: #e7b0a2 !important;
}
.thinking {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 246, 236, 0.03);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.thinking summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before {
  content: "▸ ";
  color: var(--accent);
}
.thinking[open] summary::before { content: "▾ "; }
.thinking pre {
  margin: 0;
  padding: 0 10px 10px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}
.thinking-live-note {
  color: var(--accent) !important;
  font-size: 12px !important;
}
.thinking-time {
  margin-left: 8px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.msg.live-reply .thinking { margin-top: 4px; }
.code-diff {
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 246, 236, 0.03);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.code-diff summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.code-diff summary::-webkit-details-marker { display: none; }
.code-diff summary::before {
  content: "▸ ";
  color: var(--accent);
}
.code-diff[open] summary::before { content: "▾ "; }
.code-diff-body {
  margin: 0;
  padding: 0 0 8px;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
}
.diff-line {
  display: block;
  white-space: pre-wrap;
  padding: 0 10px;
  color: var(--muted);
}
.diff-line.add { color: #a3c096; background: rgba(163, 192, 150, 0.08); }
.diff-line.del { color: #e08a78; background: rgba(224, 138, 120, 0.08); }
.diff-line.hunk { color: var(--accent); }
.monaco-change-line { background: rgba(163, 192, 150, 0.14) !important; }
.monaco-change-gutter {
  background: #a3c096;
  width: 3px !important;
  margin-left: 3px;
}
.think-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  flex: none;
}
.think-toggle input {
  accent-color: var(--accent);
}
.turn-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 10px 8px;
}
.turn-restore,
.turn-retry,
.turn-edit {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--faint);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.turn-restore:hover,
.turn-retry:hover,
.turn-edit:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.turn-retry:disabled,
.turn-edit:disabled {
  opacity: 0.4;
  cursor: default;
}
.tip-edit-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-turn.tip-editing {
  cursor: default;
}
.chat-turn.tip-editing:hover {
  background: rgba(224, 163, 106, 0.08);
}
.tip-prompt {
  margin: 0;
  white-space: pre-wrap;
}
.tip-prompt-editable {
  cursor: text;
  border-radius: 6px;
  margin: 0 -6px;
  padding: 4px 6px;
}
.tip-prompt-editable:hover {
  background: rgba(224, 163, 106, 0.1);
}
.tip-edit-box {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
  outline: none;
}
.tip-edit-box:focus {
  border-color: var(--accent);
}
.turn-retry {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.chat-turn .msg.assistant.failed p {
  color: #f0c7be;
}
.design-tab-name {
  width: 120px;
  margin: 4px 6px;
  border: 0;
  border-bottom: 1px solid var(--accent);
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  outline: none;
  padding: 2px 2px 1px;
}
.design-tab-x {
  border: 0;
  background: transparent;
  color: var(--faint);
  padding: 0 8px 0 2px;
  font-size: 14px;
  line-height: 1;
}
.design-tab-x:hover { color: var(--ink); }
.tab-plus {
  flex: 0 0 auto;
  align-self: center;
  width: 28px;
  height: 24px;
  margin: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}
.tab-plus:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 246, 236, 0.05);
}
.tab-plus:disabled { opacity: 0.4; cursor: default; }
.library { position: relative; }
.library-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  max-height: 380px;
  overflow: auto;
  padding: 6px;
  background: #16181d;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.library-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}
.library-row.current { background: rgba(224, 163, 106, 0.12); }
.library-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 7px 8px;
}
.library-open strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-open small { color: var(--faint); font-size: 11px; }
.library-x {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 16px;
  padding: 4px 8px;
}
.library-row:hover { background: rgba(255, 246, 236, 0.04); }
.library-row.current:hover { background: rgba(224, 163, 106, 0.16); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand svg { flex: none; display: block; }
.spacer { flex: 1; }
.top-actions { display: flex; gap: 6px; align-items: center; justify-self: end; }
.signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  flex: none;
  border-radius: 8px;
  border: 1px solid rgba(224, 163, 106, 0.42);
  background: rgba(224, 163, 106, 0.16);
  color: #f2c89b;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}
.signin-btn:hover {
  background: rgba(224, 163, 106, 0.26);
  border-color: rgba(224, 163, 106, 0.62);
}
.signin-btn svg { flex: none; width: 14px; height: 14px; }
.icon-btn {
  width: 34px;
  height: 30px;
  padding: 0;
  flex: none;
  display: inline-grid;
  place-items: center;
}
.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool-family {
  width: auto;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.icon-btn.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* TDC-55: Extrude + Revolve peer controls (same weight, labeled). */
.solid-features-strip {
  gap: 3px;
  padding: 1px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}
.solid-feature-btn.icon-btn {
  width: auto;
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
}
.solid-feature-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}
.ask .solid-feature-switch {
  order: -1;
}

.ghost, .solid, .texty {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.ghost:hover, .texty:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ghost:disabled, .solid:disabled, .texty:disabled { opacity: 0.4; cursor: default; }
.solid {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1c10;
  font-weight: 600;
}
.solid.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #2a1410;
}
.solid.danger:hover {
  filter: brightness(1.05);
}
.solid:hover:not(:disabled) { filter: brightness(1.05); }
.texty { border: 0; color: var(--muted); padding: 4px 6px; }

.rail, .inspector {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.rail { border-width: 0 1px 0 0; }
.inspector { border-width: 0 0 0 1px; }

.pane-resizer {
  position: absolute;
  z-index: 6;
  background: transparent;
}
.pane-resizer:hover,
.pane-resizer:active {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
.pane-resizer-col {
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
}
.rail-edge { right: -2px; }
.inspector-edge { left: -2px; }
.pane-resizer-row {
  position: relative;
  flex: 0 0 6px;
  width: 100%;
  height: 6px;
  cursor: row-resize;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid transparent;
}
.inspector-top {
  flex: 0 0 var(--inspector-split, 42%);
  min-height: 120px;
  max-height: calc(100% - 140px);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.program-pane-label {
  padding: 4px 10px !important;
  min-height: 28px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.program-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.occ-spinner-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}
.stop-build-btn {
  margin-left: 2px;
  padding: 0 6px !important;
  min-height: 0 !important;
  font-size: 10.5px !important;
  letter-spacing: 0.02em;
  color: var(--ink) !important;
  background: color-mix(in srgb, var(--raised) 80%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent) !important;
}
.occ-spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.8px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: occ-spin 0.68s linear infinite;
}
@keyframes occ-spin {
  to {
    transform: rotate(360deg);
  }
}
.program-pane-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.worker-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.worker-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.worker-status-active .worker-status-dot {
  background: #3d9a5f;
}
.worker-status-waking .worker-status-dot {
  background: var(--accent);
  animation: worker-pulse 1.1s ease-in-out infinite;
}
.worker-status-asleep .worker-status-dot {
  background: color-mix(in srgb, var(--faint) 70%, transparent);
}
.worker-status-label {
  font-variant-numeric: tabular-nums;
}
.worker-wake {
  letter-spacing: 0.08em;
  padding: 0 2px;
}
@keyframes worker-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.pane-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.rail-mode-tabs {
  display: flex;
  flex: none;
  height: 34px;
  box-sizing: border-box;
  gap: 4px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  align-items: stretch;
}
.rail-mode-tabs button {
  flex: 1;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rail-mode-tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.rail-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex: none;
}

.designs-pane {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px 18px;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.designs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}
.designs-view-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.designs-view-toggle button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
}
.designs-view-toggle button.active {
  color: var(--ink);
  background: var(--raised);
}
.designs-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: #c0cad6;
  min-height: 160px;
}
.designs-loading strong {
  color: var(--text);
  font-size: 13px;
}
.designs-loading span {
  font-size: 12px;
  max-width: 28ch;
  line-height: 1.4;
}
.designs-loading-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: #c0cad6;
}
.designs-loading-banner .occ-spinner {
  width: 14px;
  height: 14px;
}
.account-designs-sync-overlay {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
  background: rgba(10, 11, 14, 0.72);
}
.editor-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 9, 12, 0.92);
}
.editor-lock-card {
  max-width: 420px;
  width: 100%;
  background: rgba(22, 24, 30, 0.98);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.editor-lock-card strong {
  font-size: 16px;
}
.editor-lock-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #c0cad6;
}
.editor-lock-card em {
  font-style: normal;
  color: var(--text);
  font-weight: 600;
}
.editor-lock-hint {
  font-size: 12px !important;
  color: #8fa0b4 !important;
}
.editor-lock-card .solid {
  margin-top: 6px;
  align-self: flex-start;
}
.designs-empty {
  margin: 12px 8px 24px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
}
.designs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
  align-content: start;
}
.designs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
}
.design-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.design-card.current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
.design-card-open {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
}
.designs-list .design-card-open {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 36px 6px 6px;
}
.design-card-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  color: var(--muted);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.04em;
  overflow: hidden;
  background: var(--raised);
}
.design-card-thumb.has-photo {
  font-size: 0;
}
.design-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.designs-list .design-card-thumb {
  flex: none;
  width: 56px;
  height: 42px;
  aspect-ratio: auto;
  border-radius: 8px;
  font-size: 16px;
}
.design-card-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.designs-grid .design-card-meta {
  padding: 8px 10px 10px;
}
.design-card-open strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.design-card-open small {
  display: block;
  color: var(--faint);
  font-size: 11px;
}
.design-card-x,
.design-card-copy {
  position: absolute;
  top: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(12, 13, 16, 0.72);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.design-card-x {
  right: 6px;
  font-size: 16px;
}
.design-card-copy {
  right: 36px;
}
.designs-list .design-card-x,
.designs-list .design-card-copy {
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
}
.design-card-x:hover,
.design-card-copy:hover {
  color: var(--ink);
  background: rgba(12, 13, 16, 0.9);
}

.app.is-mobile-splitting .stage canvas {
  pointer-events: none;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px 20px;
  overscroll-behavior: contain;
}
.chat-turn {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  min-width: 0;
  overflow: hidden;
}
.chat-turn:hover { background: rgba(224, 163, 106, 0.05); }
.chat-turn:focus-visible { outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -1px; }
.chat-turn.timeline-tip { border-color: var(--line); }
.chat-turn.timeline-selected {
  background: rgba(224, 163, 106, 0.1);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.chat-turn .msg {
  padding: 10px 12px 8px;
  margin: 0;
  border: 0;
  border-radius: 0;
  cursor: inherit;
  background: transparent;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-turn .msg:hover { background: transparent; }
.chat-turn .msg + .msg { border-top: 1px solid var(--line); }
.msg .who {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}
.msg.user .who { color: var(--accent); }
.who-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.msg-timing {
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--faint);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.msg-model {
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--faint);
  opacity: 0.75;
  font-weight: 400;
}
.msg p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.msg-error {
  margin: 0;
  border: 1px solid rgba(224, 138, 120, 0.35);
  border-radius: 8px;
  background: rgba(28, 16, 14, 0.55);
  pointer-events: auto;
}
.msg-error summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #f0c7be;
}
.msg-error summary::-webkit-details-marker { display: none; }
.msg-error summary::before {
  content: "▸ ";
  color: var(--accent);
}
.msg-error[open] summary::before { content: "▾ "; }
.msg-error pre {
  margin: 0;
  padding: 0 10px 10px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #f0c7be;
}

.greeting {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 8px 10px 10px;
  background: var(--panel);
}
.composer-shell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--raised);
  padding: 8px 8px 6px;
  transition: border-color 0.15s ease;
}
.composer-shell:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
}
.composer textarea {
  width: 100%;
  resize: none;
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 4px 6px 6px;
  min-height: 44px;
  max-height: min(45vh, 420px);
  overflow-y: hidden;
  outline: none;
  line-height: 1.4;
  font-size: 14px;
}
.composer-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
.composer.drag-over .composer-shell {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line-strong));
  background: rgba(224, 163, 106, 0.08);
}
.composer-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  max-width: 100%;
}
.composer-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 11px;
  color: var(--muted);
}
.composer-attach-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  flex: none;
}
.composer-attach-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.composer-attach-chip button {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex: none;
}
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
}
.msg-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 11px;
  color: var(--muted);
}
.msg-attach img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex: none;
}
.msg-attach span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0 2px;
}
.composer-grow { flex: 1 1 auto; min-width: 4px; }
.composer-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}
.composer-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}
.composer-icon:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 246, 236, 0.06);
}
.composer-icon:disabled { opacity: 0.35; }
.composer-icon.on,
.composer-icon.think-btn.on {
  color: #f6c57a;
  background: rgba(246, 197, 122, 0.22);
  box-shadow: 0 0 0 1px rgba(246, 197, 122, 0.35), 0 0 14px rgba(224, 163, 106, 0.45);
}
.composer-icon.think-btn .think-bulb {
  fill: none;
}
.composer-icon.think-btn.on .think-bulb {
  fill: currentColor;
  stroke: #f8d7a0;
}
.composer-icon.think-btn.on svg {
  filter: drop-shadow(0 0 5px rgba(246, 197, 122, 0.95));
}
.composer-icon.stop-composer {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
}
.model-pick,
.think-level {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.model-pick {
  flex: 1.6 1 7.5rem;
}
.think-level {
  flex: 0.7 1 4.5rem;
}
.composer-model {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  padding: 0 6px;
  outline: none;
  cursor: pointer;
}
.composer-model:hover,
.composer-model:focus {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  background: var(--raised);
}
.composer-model:disabled {
  opacity: 0.35;
  cursor: default;
}
.composer-model option {
  background: var(--panel);
  color: var(--ink);
}
.composer-attach,
.composer-send {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0;
}
.composer-attach {
  background: rgba(255, 246, 236, 0.06);
  color: var(--muted);
}
.composer-attach:disabled { opacity: 0.45; }
.composer-send {
  background: var(--accent);
  color: #1a120c;
}
.composer-send:hover:not(:disabled) { filter: brightness(1.06); }
.composer-send:disabled {
  opacity: 0.35;
  cursor: default;
}

.mobile-split {
  display: none;
}
.includes {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}
.include {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
  max-width: min(132px, 100%);
  height: 22px;
  padding: 0 3px 0 6px;
  border: 1px dashed rgba(224, 163, 106, 0.5);
  background: rgba(224, 163, 106, 0.08);
  border-radius: 99px;
}
.include svg, .pill svg { width: 11px; height: 11px; flex: none; stroke: var(--accent); fill: none; stroke-width: 1.4; }
.include strong {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.include button { border: 0; background: transparent; color: var(--faint); font-size: 13px; line-height: 1; padding: 0 2px; }
.stage.has-error-console .ask {
  bottom: min(36vh, 220px);
}
.ask {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.ask strong { font-size: 12px; font-weight: 500; color: var(--accent); letter-spacing: 0.02em; }
.ask input:not([type="checkbox"]):not([type="radio"]) {
  width: 76px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 8px;
  outline: none;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
}
.ask input:not([type="checkbox"]):not([type="radio"]):focus { border-color: var(--accent); }
.ask em { font-style: normal; color: var(--faint); font-size: 11px; }
.ask-note { color: var(--faint); font-size: 11px; white-space: nowrap; }
.ask-with-options { flex-wrap: wrap; max-width: min(92vw, 760px); justify-content: center; row-gap: 6px; }
.ask-modes {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
  flex: 0 0 auto;
}
.ask-mode {
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 5px 10px;
  cursor: pointer;
}
.ask-mode + .ask-mode { border-left: 1px solid var(--line-strong); }
.ask-modes span.ask-mode {
  cursor: default;
  display: inline-flex;
  align-items: center;
}
.ask-mode .ask-mode-hit {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  padding: 0;
  cursor: pointer;
}
.ask-mode:hover { color: var(--ink); background: var(--raised); }
.ask-mode.on {
  background: rgba(224, 163, 106, 0.16);
  color: var(--accent);
}
.ask-mode .ask-clear {
  margin-left: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.text-wrap-ask {
  border-color: #e0a36a;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(224, 163, 106, 0.35);
  background: #1a1410;
  max-width: min(92vw, 560px);
}
.text-wrap-ask .ask-label {
  color: #f0c090;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.text-wrap-ask-msg {
  color: #f5e6d3;
  font-size: 12px;
  line-height: 1.35;
  max-width: 22rem;
}
.text-wrap-cta {
  background: #e0a36a !important;
  color: #1a1410 !important;
  font-weight: 700 !important;
  padding: 6px 12px !important;
}
.text-wrap-cta:hover {
  background: #f0c090 !important;
  color: #1a1410 !important;
}
.text-wrap-banner {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 640px);
  padding: 10px 14px;
  background: #2a1c12;
  border: 2px solid #e0a36a;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  color: #f5e6d3;
  font-size: 13px;
}
.text-wrap-banner strong {
  color: #f0c090;
  letter-spacing: 0.08em;
  font-size: 12px;
}
.text-wrap-banner-cancel {
  margin-left: auto;
  border: 1px solid #e0a36a;
  background: transparent;
  color: #f0c090;
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.text-wrap-banner-cancel:hover {
  background: rgba(224, 163, 106, 0.16);
}
.text-font-picker {
  position: relative;
  flex: 0 0 auto;
}
.text-font-btn {
  min-width: 7.5rem;
  max-width: 11rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.text-font-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  min-width: 12rem;
  max-height: 16rem;
  overflow: auto;
  padding: 4px 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #12151b;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.text-font-group + .text-font-group {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 4px;
}
.text-font-group-label {
  padding: 4px 10px 2px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.text-font-option {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  padding: 5px 10px;
  cursor: pointer;
}
.text-font-option:hover,
.text-font-option.on {
  background: rgba(224, 163, 106, 0.16);
  color: var(--accent);
}
/* Tool timeline & Unified CAD Feature Timeline Rail */
.chat-turn.tool-turn {
  margin: 0;
  border-radius: 9px;
}
.chat-turn.tool-turn .tool-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 10px;
  min-width: 0;
}
.chat-turn.tool-turn .tool-summary {
  flex: 1 1 120px;
  margin: 0;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text);
  word-break: normal;
  overflow-wrap: break-word;
}
.chat-turn.tool-turn .turn-restore {
  flex: 0 0 auto;
  white-space: nowrap;
}
.tool-summary-editable {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.tool-summary-editable:hover {
  background: rgba(224, 163, 106, 0.14);
  color: var(--text);
}
.tool-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.timeline-tool-edit-row {
  padding: 0 10px 8px 25px;
}
.tool-edit-input {
  width: 76px;
  min-width: 58px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.26);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  outline: none;
}
.tool-edit-input:focus {
  border-color: var(--accent);
}
.tool-edit-unit {
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chat-turn.tool-turn.tool-editing {
  cursor: default;
}

/* Unified Timeline Rail & Cards */
.timeline-rail-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-turn.timeline-card {
  position: relative;
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
}
/* Legacy AI card corner delete button */
.timeline-delete-x {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 18px;
  cursor: pointer;
  opacity: 0;
}
.chat-turn.timeline-card:hover .timeline-delete-x,
.chat-turn.timeline-card.timeline-active .timeline-delete-x {
  opacity: 1;
}
.timeline-delete-x:hover,
.timeline-delete-btn:hover {
  color: #f39c91;
  background: rgba(235, 118, 104, 0.18);
}
.timeline-delete-btn {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.chat-turn.timeline-card:hover .timeline-delete-btn,
.chat-turn.timeline-card.timeline-active .timeline-delete-btn {
  opacity: 1;
}
.chat-turn.timeline-card .msg.user .who {
  padding-right: 22px;
}
.timeline-card-top,
.timeline-card-meta,
.timeline-substeps,
.timeline-param-chips,
.timeline-substep,
.chat-turn.timeline-card .msg {
  cursor: pointer;
}
.chat-turn.timeline-card:hover {
  background: rgba(255, 255, 255, 0.038);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
}
.chat-turn.timeline-card.timeline-active {
  background: rgba(224, 163, 106, 0.06);
  border-color: color-mix(in srgb, var(--accent) 44%, var(--line));
}
.chat-turn.timeline-card.timeline-selected {
  background: rgba(224, 163, 106, 0.1);
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  box-shadow: 0 0 0 1px rgba(224, 163, 106, 0.18);
}
.chat-turn.timeline-card.timeline-future {
  opacity: 0.32;
  border-style: dashed;
  background: rgba(0, 0, 0, 0.18);
  filter: saturate(0.55);
}
.chat-turn.timeline-card.timeline-future:hover {
  opacity: 0.72;
  filter: saturate(0.85);
}
.chat-turn.timeline-card.timeline-future .timeline-feature-label,
.chat-turn.timeline-card.timeline-future .timeline-card-name,
.chat-turn.timeline-card.timeline-future .timeline-meta-text {
  color: var(--faint);
}
.timeline-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px 6px 10px;
  min-width: 0;
}
.timeline-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 7px 24px;
  min-width: 0;
}
.timeline-meta-text {
  font-size: 11px;
  color: var(--faint);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.timeline-card-name {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}
.timeline-feature-label {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}
.timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--faint);
  border: 1.5px solid transparent;
}
.timeline-dot.inline {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}
.timeline-dot.active {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(224, 163, 106, 0.75);
}
.timeline-dot.future {
  background: transparent;
  border-color: var(--faint);
}
.timeline-badge {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.timeline-badge.badge-sketch {
  background: rgba(92, 168, 255, 0.14);
  color: #8bc4ff;
  border-color: rgba(92, 168, 255, 0.28);
}
.timeline-badge.badge-extrude {
  background: rgba(224, 163, 106, 0.15);
  color: var(--accent);
  border-color: rgba(224, 163, 106, 0.3);
}
.timeline-badge.badge-cut {
  background: rgba(235, 118, 104, 0.15);
  color: #f39c91;
  border-color: rgba(235, 118, 104, 0.3);
}
.timeline-badge.badge-fillet,
.timeline-badge.badge-chamfer {
  background: rgba(163, 192, 150, 0.15);
  color: #b7d5aa;
  border-color: rgba(163, 192, 150, 0.3);
}
.timeline-badge.badge-plane {
  background: rgba(186, 148, 238, 0.15);
  color: #cfb2f6;
  border-color: rgba(186, 148, 238, 0.3);
}
.timeline-badge.badge-ai {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.3);
}
.timeline-badge.badge-init,
.timeline-badge.badge-body,
.timeline-badge.badge-move {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.3);
}
.timeline-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
}
.timeline-card-actions button {
  white-space: nowrap;
}
.timeline-expand-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 10.5px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.timeline-expand-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--text);
}
.timeline-substeps {
  border-top: 1px solid var(--line);
  padding: 5px 8px 6px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 0 8px 8px;
}
.timeline-expanded-content {
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  border-radius: 0 0 8px 8px;
}
.timeline-expanded-content .msg {
  padding: 8px 12px;
}
.timeline-substep {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--muted);
  min-width: 0;
  transition: background 0.1s ease, color 0.1s ease, opacity 0.1s ease;
}
.timeline-substep:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.timeline-substep.active {
  background: rgba(224, 163, 106, 0.14);
  color: var(--text);
}
.timeline-substep.future {
  opacity: 0.45;
}
.timeline-subdot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.timeline-subdot.active {
  background: var(--accent);
  box-shadow: 0 0 5px rgba(224, 163, 106, 0.7);
}
.timeline-subdot.future {
  background: transparent;
  border: 1px solid var(--faint);
}
.timeline-sublabel {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}
.timeline-dim-pill {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.timeline-dim-pill.editable {
  cursor: pointer;
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}
.timeline-dim-pill.editable:hover {
  background: rgba(224, 163, 106, 0.16);
  border-color: var(--accent);
}
.timeline-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px 7px 24px;
  min-width: 0;
}
.timeline-param-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.chat-turn.timeline-card > .timeline-param-chips {
  padding: 0 10px 7px 24px;
}
.top-actions .ghost.active,
.stagebar .ghost.active,
.stage-view-nav .ghost.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.stage-view-nav {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.stage-view-nav button {
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  border-color: var(--line-strong);
  color: var(--ink);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.stage-view-nav button:hover {
  background: var(--raised);
  color: var(--ink);
}
.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.shortcut-table th,
.shortcut-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.shortcut-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.shortcut-keys {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  white-space: nowrap;
  color: var(--ink);
}
.readout-action {
  pointer-events: auto;
  margin-top: 6px;
  align-self: flex-start;
}
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
  min-width: 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  max-width: 100%;
  border: 1px dashed rgba(224, 163, 106, 0.45);
  color: var(--muted);
  border-radius: 99px;
  padding: 2px 8px 2px 6px;
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.keynote { margin: 8px 2px 0; color: var(--faint); font-size: 11.5px; line-height: 1.4; }
.hint { color: var(--faint); font-size: 11px; }

.cmd-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  padding-top: min(18vh, 140px);
  background: rgba(6, 7, 10, 0.45);
}
.cmd-panel {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cmd-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.cmd-key {
  flex: none;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--raised);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.cmd-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}
.cmd-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: min(360px, 50vh);
  overflow: auto;
}
.cmd-empty {
  padding: 14px 12px;
  color: var(--faint);
  font-size: 13px;
}
.cmd-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  cursor: pointer;
}
.cmd-row strong {
  grid-column: 1;
  font-size: 13px;
  font-weight: 560;
}
.cmd-row span {
  grid-column: 1;
  color: var(--faint);
  font-size: 11px;
}
.cmd-row em {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.cmd-row:hover,
.cmd-row.active {
  background: rgba(224, 163, 106, 0.12);
}
.cmd-row.active strong { color: var(--accent); }
.cmd-row.stub {
  opacity: 0.45;
  cursor: default;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(900px 520px at 50% 42%, #1a1d24 0%, #0c0d10 68%);
  touch-action: none;
  overscroll-behavior: none;
}
.stage-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: auto;
  user-select: text;
  background: rgba(10, 11, 14, 0.88);
  /* no blur - keeps screen and text razor-sharp */
}
.stage-loading-error-box {
  max-width: min(640px, 90vw);
  background: rgba(36, 16, 18, 0.96);
  border: 1px solid rgba(242, 139, 130, 0.5);
  border-radius: 8px;
  padding: 14px 16px;
  color: #fce8e6;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: text;
  pointer-events: auto;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}
.stage-loading-error-pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  color: #f8c8c2;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 10px;
  border-radius: 6px;
}
.stage-loading-error-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stage-loading-spinner {
  width: 28px;
  height: 28px;
  border-width: 2.5px;
}
.stage-loading-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-align: center;
  padding: 0 18px;
}
.stage-loading-copy strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}
.stage-loading-copy span {
  font-size: 12px;
  color: #c0cad6;
  max-width: 48ch;
  line-height: 1.4;
}
.stage-loading-progress-bar {
  width: 260px;
  max-width: 80vw;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.stage-loading-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease-out;
}
.stage-loading-progress-fill.indeterminate {
  width: 36%;
  animation: stage-loading-indeterminate 1.1s ease-in-out infinite;
}
@keyframes stage-loading-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}
.stage-loading-recent-logs {
  margin-top: 10px;
  width: min(520px, 92vw);
  background: rgba(6, 7, 10, 0.88);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.4;
  text-align: left;
  max-height: 140px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.recent-log-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #9ab0c8;
}
.recent-log-stdout, .recent-log-info { color: #8da4be; }
.recent-log-stderr, .recent-log-error { color: #f28b82; }
.stagebar-busy-inline {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
  vertical-align: -2px;
}
.stagebar-busy-inline .occ-spinner {
  width: 12px;
  height: 12px;
}
.stage canvas {
  display: block;
  touch-action: none;
  /* Avoid iOS callout / selection while dragging the model */
  -webkit-user-select: none;
  user-select: none;
}
.stage.tool-measure canvas,
.stage.tool-dimension canvas {
  cursor: crosshair;
}
.viewcube-roll {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 8;
  display: flex;
  gap: 5px;
}
.viewcube-roll-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 248, 236, 0.22);
  background: rgba(24, 23, 21, 0.86);
  color: #f0ebe2;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.viewcube-roll-btn:hover {
  background: rgba(52, 48, 42, 0.95);
  border-color: rgba(255, 248, 236, 0.48);
}
.viewcube-edge-arrows {
  position: absolute;
  top: 82px;
  right: 84px;
  width: 0;
  height: 0;
  z-index: 8;
  pointer-events: none;
}
.viewcube-edge-btn {
  position: absolute;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid rgba(255, 248, 236, 0.22);
  background: rgba(24, 23, 21, 0.86);
  color: #f0ebe2;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.viewcube-edge-btn:hover {
  background: rgba(52, 48, 42, 0.96);
  border-color: rgba(255, 248, 236, 0.55);
  color: #f3dca2;
}
.viewcube-edge-btn.up {
  left: -9px;
  top: -43px;
}
.viewcube-edge-btn.down {
  left: -9px;
  top: 25px;
}
.viewcube-edge-btn.left {
  left: -43px;
  top: -9px;
}
.viewcube-edge-btn.right {
  left: 25px;
  top: -9px;
}
.mode-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  background: rgba(16, 18, 22, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}
.mode-cursor svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mode-cursor-measure {
  border-color: color-mix(in srgb, #6ec8ff 50%, var(--line));
}
.mode-cursor-measure svg { stroke: #6ec8ff; }
.mode-cursor-dimension svg { stroke: var(--accent); }
.preview-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: rgba(16, 18, 22, 0.9);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.move-hud {
  position: fixed;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 108px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(16, 18, 22, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
}
.move-hud.live {
  pointer-events: none;
  opacity: 0.92;
}
.move-hud input {
  width: 72px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 5px;
  background: #0c0e12;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 6px;
  outline: none;
}
.move-hud input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}
.move-hud-unit {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  min-width: 1.4em;
}
.move-hud-check,
.ask-check,
.ask label:has(input[type="checkbox"]),
label.ask-note:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.move-hud .move-hud-check input,
.ask .ask-check input,
.ask input[type="checkbox"],
.ask label input[type="checkbox"],
.stagebar-check input {
  width: 14px;
  min-width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
.move-hud-check:hover,
.ask-check:hover,
.ask label:has(input[type="checkbox"]):hover,
label.ask-note:has(input[type="checkbox"]):hover { color: var(--text); }
.dimension-hud {
  gap: 8px;
  min-width: 148px;
}
.dimension-hud-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.dimension-hud input {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.dimension-hud-hint {
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}
.readout {
  position: absolute;
  top: 48px;
  left: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.readout-kind {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.readout-value {
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.readout.measure {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
}
.readout.measure .readout-kind { color: var(--accent); }
.stagebar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.45);
}
.stagebar.stage-console {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-height: min(36vh, 280px);
  padding: 8px 8px 8px 10px;
  border-radius: 8px;
  background: rgba(28, 24, 26, 0.9);
  border: 1px solid rgba(232, 120, 100, 0.38);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  text-shadow: none;
}
.stage-console-body {
  flex: 1 1 auto;
  min-width: 0;
  max-height: min(32vh, 248px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f0c7be;
  font: inherit;
  text-align: left;
  cursor: copy;
  overflow: auto;
}
.stage-console-body:hover .stage-console-hint {
  color: var(--accent);
}
.stage-console-summary {
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.stage-console-full {
  margin: 0;
  width: 100%;
  max-height: min(24vh, 200px);
  overflow: auto;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(8, 9, 12, 0.55);
  color: #f3d0c8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
}
.stage-console-hint {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}
.stage-console-hint.on {
  color: var(--ok);
}
.stage-console-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: -2px -2px 0 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.stage-console-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.stagebar button {
  pointer-events: auto;
  text-shadow: none;
  background: rgba(12, 14, 18, 0.55);
  border-color: rgba(255, 246, 236, 0.14);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.stagebar.stage-console button {
  background: transparent;
  border: 0;
  backdrop-filter: none;
  white-space: normal;
}
.stagebar.stage-console .stage-console-close {
  white-space: nowrap;
}
.stagebar-status {
  min-width: 0;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.stagebar.stage-ok .stagebar-status { color: var(--ok); }
.stagebar.stage-busy .stagebar-status { color: var(--accent); }
.stagebar.stage-bad .stagebar-status { color: var(--danger); }
.stagebar-meta {
  color: rgba(155, 149, 140, 0.9);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  white-space: nowrap;
  justify-self: end;
}
.stagebar-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.stagebar-check input {
  margin: 0;
  accent-color: var(--accent);
}
.stagebar-check:hover { color: var(--text); }
.inspector-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--line);
  min-height: 36px;
}
.inspector-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  padding: 8px 10px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.inspector-tab:hover { color: var(--muted); }
.inspector-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.inspector-tab .tab-count {
  margin-left: 6px;
  letter-spacing: 0;
  color: var(--faint);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
}
.inspector-tab-action {
  margin-left: auto;
  font-size: 11px;
}

.bodies {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.body-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 2px;
}
.body-row-with-eye {
  grid-template-columns: 28px 1fr auto;
}
.body-eye-btn {
  margin-left: 2px;
}
.body-eye-spacer {
  width: 28px;
  height: 28px;
}
.body-main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.body-main .body-pick,
.body-main .body-rename {
  flex: 1 1 auto;
  min-width: 0;
}
/* Name over coords (taller rows); params chip stays to the right of that block. */
.body-params-toggle {
  flex: 0 0 auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.body-params-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}
.body-params-toggle.open {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
}
.body-block {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 2px;
}
.body-params-list {
  padding: 4px 10px 10px 36px;
  border-left: 2px solid rgba(167, 139, 250, 0.35);
  margin: 0 4px 8px 12px;
}
.body-params-list .param {
  margin-bottom: 8px;
}
.body-params-list .param label {
  font-size: 12px;
}
.body-more {
  position: relative;
}
.body-more-dots {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  transform: translateY(-1px);
}
.body-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 160px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel, #1a1d24);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.body-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 8px 10px;
  cursor: pointer;
}
.body-more-menu button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}
.body-more-menu button:disabled {
  opacity: 0.45;
  cursor: default;
}
.sketch-pick {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-width: 0;
  flex: 1 1 auto;
}
.sketch-pick:hover {
  background: rgba(255, 255, 255, 0.04);
}
.sketch-pick strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.sketch-stat-chips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
}
.sketch-chip {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  opacity: 0.85;
}
.sketch-chip svg {
  width: 12px;
  height: 12px;
  color: var(--faint);
  flex-shrink: 0;
}
.sketch-active-tag {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(224, 163, 106, 0.2);
  color: var(--accent);
  border: 1px solid rgba(224, 163, 106, 0.35);
  margin-left: auto;
}
.sketch-doc-block {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sketch-constraints-panel {
  margin: 0 0 10px;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: color-mix(in srgb, var(--panel, #1a1f26) 92%, #f59e0b 8%);
}
.sketch-constraints-panel-pinned {
  border: 1px solid color-mix(in srgb, #f59e0b 55%, var(--line));
  border-radius: 8px;
  margin: 0 0 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 color-mix(in srgb, #f59e0b 25%, transparent);
}
.sketch-constraints-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.sketch-constraints-head strong {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
}
.sketch-constraints-head span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.sketch-constraints-empty {
  margin: 4px 0 6px !important;
  font-size: 12px !important;
}
.sketch-constraint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sketch-constraint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  font-size: 12.5px;
}
.sketch-constraint-row:last-child {
  border-bottom: none;
}
.sketch-constraint-badge {
  flex: 0 0 18px;
  text-align: center;
  color: #f59e0b;
  font-weight: 700;
  font-size: 12px;
}
.sketch-constraint-title {
  flex: 1;
  min-width: 0;
  color: var(--ink);
}
.sketch-constraints-legend {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--muted);
}
.sketches-panel .sketch-curve-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sketch-curve-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.sketch-curve-row strong {
  font-weight: 600;
  color: #4fc3f7;
}
.sketch-curve-row span {
  color: var(--muted);
  font-size: 12px;
}
.sketch-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.body-row.selected {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: rgba(224, 163, 106, 0.08);
}
.body-row.hot:not(.selected) {
  border-color: color-mix(in srgb, #7eb6e8 50%, var(--line));
  background: rgba(126, 182, 232, 0.1);
}
.body-row.hidden-body {
  opacity: 0.55;
}
.body-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-right: 2px;
}
.body-menu-btn {
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
}
.body-menu {
  position: fixed;
  z-index: 40;
  min-width: 210px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.body-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.body-menu button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}
.body-menu button:disabled {
  opacity: 0.45;
  cursor: default;
}
.body-menu p {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}
.body-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.body-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.body-icon-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
}
.body-icon-btn.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: rgba(224, 163, 106, 0.1);
}
.body-icon-btn.danger:hover:not(:disabled) {
  color: #f0c7be;
  border-color: color-mix(in srgb, #c45c4a 40%, var(--line));
}
.body-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.analysis-list .body-hint {
  margin-bottom: 4px;
}
.body-pick {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.body-pick:hover { background: rgba(255, 255, 255, 0.04); }
.body-pick:disabled { opacity: 0.4; cursor: default; }
.body-pick strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.body-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.body-pick span {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.body-x { font-size: 11px; }
.body-hint { margin: 0 0 8px; }
.body-rename,
.param-rename {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px;
}

.params {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 8px;
}
.param { display: grid; grid-template-columns: 1fr 76px; gap: 6px 10px; align-items: center; margin-bottom: 10px; }
.param label {
  grid-column: 1;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  cursor: default;
}
.param label:hover { color: var(--text); }
.param-rename { grid-column: 1; }
.param input[type="number"],
.param input[type="text"] {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 6px;
  text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  outline: none;
}
.param input[type="number"]:focus,
.param input[type="text"]:focus { border-color: var(--accent); }
.param input[type="range"] { grid-column: 1; width: 100%; accent-color: var(--accent); }
.empty-note { color: var(--faint); font-size: 12.5px; line-height: 1.4; margin: 0 0 8px; }

.program {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}
.program .editor { flex: 1; min-height: 0; }

.program-console {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  flex-shrink: 0;
}
.program-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.program-console-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.program-console-toggle:hover {
  color: var(--text);
}
.program-console-arrow {
  font-size: 10px;
  opacity: 0.7;
}
.program-console-badge {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  color: var(--faint);
}
.program-console-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.program-console-progress {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
}
.program-console-body {
  height: 120px;
  max-height: 35vh;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg);
}
.program-console-empty {
  color: var(--faint);
  font-style: italic;
  padding: 4px 0;
}
.console-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.4;
  word-break: break-word;
}
.console-time {
  flex-shrink: 0;
  color: var(--faint);
  font-size: 10px;
}
.console-msg {
  flex: 1;
  color: var(--ink);
}
.console-line.console-info .console-msg {
  color: #78a9ff;
}
.console-line.console-stderr .console-msg,
.console-line.console-error .console-msg {
  color: #f28b82;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-width: 1px 0 0;
  border-style: solid;
  border-color: var(--line);
  background: var(--panel);
  color: var(--faint);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
}
.statusbar .message { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .bad { color: var(--danger); }
.statusbar .ok { color: var(--ok); }
.metrics { display: flex; align-items: center; gap: 14px; }
.build-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 5.5em;
  justify-content: flex-end;
}
.build-metric .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.model-pick select {
  appearance: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 22px 2px 8px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%),
    linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.model-pick select:hover,
.model-pick select:focus {
  color: var(--text);
  border-color: rgba(224, 163, 106, 0.45);
  outline: none;
}
.model-pick select:disabled {
  opacity: 0.5;
  cursor: default;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-gate {
  gap: 14px;
  text-align: center;
  padding: 28px 20px;
}
.auth-brand {
  font-size: 22px;
  letter-spacing: 0.04em;
}
.auth-copy {
  max-width: 280px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}
.auth-error {
  max-width: 320px;
  color: #f0c7be;
  font-size: 13px;
  margin: 0;
}

.boot {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px))
    max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  background: var(--bg);
  color: var(--muted);
}
.boot-card {
  width: min(100%, 25rem);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 92%, #000);
  box-shadow: var(--shadow);
  text-align: center;
}
.boot-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.boot-progress-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
  position: relative;
}
.boot-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffaa40);
  border-radius: 99px;
  transition: width 0.25s ease-out;
}
.boot-progress-bar.indeterminate {
  width: 38%;
  animation: boot-slide 1.5s infinite ease-in-out;
}
@keyframes boot-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
.boot-detail {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--accent);
}
.boot-card p {
  margin: 0;
  max-width: 20rem;
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.boot-sub {
  color: var(--faint);
  font-size: 12.5px !important;
}
.pulse, .dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--accent);
}
.pulse { box-shadow: 0 0 0 0 rgba(224, 163, 106, 0.55); animation: ping 1.6s infinite; }
.working { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; }
@keyframes ping {
  70% { box-shadow: 0 0 0 8px rgba(224, 163, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 163, 106, 0); }
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(6, 7, 10, 0.72);
  backdrop-filter: blur(2px);
  cursor: default;
}
.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 380px);
  max-height: min(calc(100dvh - 48px), 720px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  outline: none;
  overflow: hidden;
}
.modal-panel.modal-md { width: min(100%, 540px); height: min(84vh, 620px); max-height: min(84vh, 620px); }

.settings-block + .settings-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.settings-heading {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
.settings-row.settings-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.settings-row select,
.settings-row input[type="number"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.settings-row select:focus,
.settings-row input[type="number"]:focus {
  border-color: var(--accent);
}
.settings-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-inline input[type="number"] {
  flex: 1;
  max-width: 140px;
}
.settings-label {
  color: var(--muted);
  font-size: 13px;
}
.settings-unit {
  color: var(--faint);
  font-size: 12px;
}
.settings-check {
  gap: 10px;
  min-height: 40px;
}
.settings-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.settings-note {
  margin: 0 0 4px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 14px 14px 0;
}
.modal-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.modal-x {
  border: 0;
  background: transparent;
  color: var(--faint);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}
.modal-x:hover { color: var(--ink); background: rgba(255, 246, 236, 0.05); }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 4px;
  -webkit-overflow-scrolling: touch;
}
.modal-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.modal-copy strong { color: var(--ink); font-weight: 600; }
.modal-name-input {
  display: block;
  width: 100%;
  margin-top: 10px;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 246, 236, 0.16);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.modal-name-input:focus {
  outline: 2px solid rgba(255, 196, 120, 0.45);
  outline-offset: 1px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  padding: 14px;
  border-top: 1px solid var(--line);
}
.modal-actions.stack {
  flex-direction: column;
  align-items: stretch;
}
.modal-actions.stack button {
  width: 100%;
  white-space: normal;
  line-height: 1.35;
  text-align: center;
}
.modal-panel .auth-error {
  max-width: none;
  margin-top: 10px;
}

/* Mobile chrome — hidden on desktop */
.mobile-dock,
.mobile-sheet-backdrop,
.mobile-sheet-handle,
.mobile-sheet-bar {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows:
      46px
      32px
      minmax(110px, var(--mobile-stage-fr, 0.42fr))
      16px
      minmax(160px, var(--mobile-chat-fr, 0.58fr))
      48px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .topbar {
    grid-row: 1;
    grid-column: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 0 8px;
    min-width: 0;
  }
  /* Left/right clusters keep their size; only the tool strip flexes and scrolls. */
  .topbar-left { flex: none; gap: 6px; }
  .topbar .brand svg { width: 20px; height: 20px; }
  .center-toolbar {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 4px;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .center-toolbar::-webkit-scrollbar { display: none; }
  .tabbar { grid-row: 2; grid-column: 1; border-left: 0; }
  .stage { grid-row: 3; grid-column: 1; min-height: 0; }
  .mobile-split {
    grid-row: 4;
    grid-column: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12;
    height: 16px;
    touch-action: none;
    cursor: row-resize;
    background: #101216;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    -webkit-user-select: none;
    user-select: none;
  }
  /* Fat invisible hit target for fingers */
  .mobile-split::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -12px;
    bottom: -12px;
  }
  .mobile-split span {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--line-strong);
    pointer-events: none;
  }
  .rail {
    grid-row: 5;
    grid-column: 1;
    border-width: 0;
    min-height: 0;
  }
  .mobile-dock {
    grid-row: 6;
    grid-column: 1;
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px;
    border-top: 1px solid var(--line);
    background: #101216;
    z-index: 8;
  }

  .desktop-only { display: none !important; }
  .brand { font-size: 14px; }
  .brand svg { width: 22px; height: 22px; }
  .top-actions { gap: 3px; flex: none; }
  .signin-btn { height: 26px; padding: 0 8px 0 6px; gap: 4px; font-size: 11px; }
  .signin-btn svg { width: 13px; height: 13px; }

  .pane-resizer-col { display: none !important; }
  .stagebar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .stage-view-nav {
    top: 8px;
    left: 8px;
  }
  .stagebar-meta { display: none; }
  .readout {
    top: 44px;
    left: 8px;
    min-width: 72px;
    padding: 6px 8px;
  }
  .composer textarea { font-size: 16px; } /* avoid iOS zoom on focus */
  .ask input,
  .param input,
  .inspector input,
  .inspector select,
  .inspector textarea {
    font-size: 16px !important;
  }
  .composer-model {
    font-size: 11px !important;
  }
  .messages {
    min-height: 0;
    overflow-x: hidden;
  }
  .msg,
  .msg p,
  .msg-error,
  .msg-error summary,
  .msg-error pre {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .msg-error summary {
    white-space: normal;
  }

  .modal-root {
    place-items: end center;
    padding: 0;
  }
  .modal-panel,
  .modal-panel.modal-md {
    width: 100%;
    max-width: 100%;
    max-height: min(88dvh, 720px);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .modal-body { padding-bottom: 12px; }

  .mobile-dock button {
    flex: 1 1 0;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--raised);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    padding: 0 6px;
  }
  .mobile-dock button.active {
    color: var(--ink);
    border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong));
    background: var(--accent-soft);
  }
  .mobile-dock button:disabled { opacity: 0.35; }

  .mobile-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
  }

  .inspector {
    /* Keep out of the 1-col grid so it doesn't spawn an extra track */
    grid-row: 1;
    grid-column: 1;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    height: min(78vh, 640px);
    max-height: calc(100dvh - 56px);
    z-index: 35;
    border-width: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow);
    transform: translateY(110%);
    transition: transform 0.22s ease;
    padding-bottom: env(safe-area-inset-bottom, 0);
    pointer-events: none;
    visibility: hidden;
  }
  .inspector.mobile-open {
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
  }

  .mobile-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 2px;
    flex: none;
  }
  .mobile-sheet-handle span {
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--line-strong);
  }
  .mobile-sheet-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 14px 10px;
    flex: none;
    border-bottom: 1px solid var(--line);
  }
  .mobile-sheet-bar strong {
    font-size: 14px;
    font-weight: 600;
  }

  /* Params / bodies sheet: hide the program pane */
  .inspector:not(.sheet-program) .program { display: none; }
  .inspector:not(.sheet-program) .inspector-top {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }
  /* Program sheet: hide params/bodies */
  .inspector.sheet-program .inspector-top { display: none; }
  .inspector.sheet-program .program {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .inspector.sheet-program .editor { flex: 1; min-height: 0; }

  .app.sheet-open .mobile-dock { opacity: 0.55; pointer-events: none; }
}

/* Phones: the mark carries the brand, and edit/settings move behind one button,
   which frees the width the tool strip needs. */
@media (max-width: 640px) {
  .topbar .brand-name { display: none; }
  .topbar-left { gap: 6px; }
}

@media (max-width: 520px) {
  .app {
    grid-template-rows:
      46px
      34px
      minmax(110px, var(--mobile-stage-fr, 0.42fr))
      16px
      minmax(160px, var(--mobile-chat-fr, 0.58fr))
      48px;
  }
  .designs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tabbar {
    padding: 0 4px 0 6px;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .design-tab { max-width: 140px; }
  .design-tab-open {
    padding: 0 2px 0 8px;
    font-size: 12px;
  }
  /* Keep + reachable while tabs scroll */
  .tab-plus {
    position: sticky;
    right: 0;
    flex: 0 0 auto;
    margin-left: auto;
    background: #0e1014;
    box-shadow: -8px 0 10px -4px #0e1014;
  }
  .greeting { padding: 16px 14px; }
}

/* —— Landing / marketing —— */
.landing {
  position: fixed;
  inset: 0;
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(224, 163, 106, 0.12), transparent 55%),
    linear-gradient(165deg, #0a0b0e 0%, #12151c 45%, #0c0d10 100%);
  color: var(--ink);
}
.landing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
  background: rgba(10, 11, 14, 0.72);
  border-bottom: 1px solid var(--line);
}
.landing-brand { font-size: 15px; }
.landing-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}
.landing-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.landing-nav a:hover { color: var(--ink); }
.landing-nav-cta { padding: 8px 14px; }

.landing-hero {
  position: relative;
  min-height: min(100vh, 900px);
  display: grid;
  align-items: end;
  padding: 0;
}
.landing-hero-stage {
  position: absolute;
  inset: 0;
}
.landing-hero-canvas,
.landing-studio-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.landing-hero-canvas:active,
.landing-studio-canvas:active { cursor: grabbing; }
.landing-hero-canvas > div,
.landing-studio-canvas > div {
  width: 100% !important;
  height: 100% !important;
}
.landing-hero-veil {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(10, 11, 14, 0.82) 0%, rgba(10, 11, 14, 0.42) 32%, rgba(10, 11, 14, 0.08) 58%, transparent 78%),
    linear-gradient(180deg, rgba(10, 11, 14, 0.28) 0%, transparent 24%, transparent 68%, rgba(10, 11, 14, 0.55) 100%);
}
.landing-orbit-hint {
  position: absolute;
  right: clamp(14px, 3vw, 36px);
  bottom: clamp(14px, 3vh, 28px);
  margin: 0;
  z-index: 2;
  pointer-events: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--faint);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.landing-hero-copy {
  position: relative;
  z-index: 2;
  max-width: 34rem;
  padding: clamp(48px, 10vh, 120px) clamp(18px, 4vw, 48px) clamp(40px, 8vh, 72px);
}
.landing-brand-mark {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 18px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.landing-brand-mark svg {
  flex: none;
  width: clamp(44px, 7.5vw, 58px);
  height: clamp(44px, 7.5vw, 58px);
}
.landing-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 3.8vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 550;
  max-width: 16ch;
}
.landing-lede {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 38ch;
}
.landing-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.landing-cta-secondary { text-decoration: none; padding: 10px 14px; }
.landing-error { color: var(--danger); margin: 12px 0 0; font-size: 13px; }

.landing-studio {
  padding: 64px clamp(18px, 3vw, 40px) 24px;
  max-width: 1320px;
  margin: 0 auto;
}
.landing-studio-intro {
  max-width: 42rem;
  margin-bottom: 22px;
}
.landing-studio-frame {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: #0c0d10;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: 42px 30px minmax(380px, 62vh);
}
.landing-studio-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: #101216;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.landing-studio-design {
  color: var(--ink);
  font-weight: 560;
}
.landing-studio-tools {
  margin-left: auto;
  display: flex;
  gap: 10px;
  color: var(--faint);
}
.landing-studio-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  background: #0e1014;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
}
.landing-studio-tabs span {
  padding: 6px 10px;
  border-radius: 6px 6px 0 0;
}
.landing-studio-tabs .active {
  color: var(--ink);
  background: rgba(255, 246, 236, 0.05);
}
.landing-studio-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 250px;
  min-height: 0;
}
.landing-studio-rail,
.landing-studio-inspector {
  border-right: 1px solid var(--line);
  background: #121418;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.landing-studio-inspector { border-right: 0; border-left: 1px solid var(--line); }
.landing-studio-rail-head {
  padding: 10px 12px 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}
.landing-studio-msg {
  margin: 0 10px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.landing-studio-msg.user {
  background: rgba(224, 163, 106, 0.1);
  color: var(--ink);
}
.landing-studio-msg.assistant {
  background: rgba(255, 246, 236, 0.04);
}
.landing-studio-composer {
  margin: auto 10px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--faint);
  font-size: 12px;
}
.landing-studio-stage {
  position: relative;
  min-width: 0;
  background: #101318;
}
.landing-studio-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.landing-studio-canvas:active { cursor: grabbing; }
.landing-studio-status {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 11px;
  color: var(--faint);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  pointer-events: none;
}
.landing-studio-code {
  margin: 0 10px;
  padding: 10px;
  border-radius: 8px;
  background: #0e1014;
  border: 1px solid var(--line);
  color: #c9c2b6;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  overflow: auto;
  flex: 1;
  min-height: 0;
  white-space: pre;
}
.landing-studio-params {
  padding: 10px;
  display: grid;
  gap: 8px;
}
.landing-studio-params label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.landing-studio-params i {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) 28%, var(--line-strong) 28%);
}
.landing-studio-params em {
  font-style: normal;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  min-width: 2.2em;
  text-align: right;
}

.landing-shots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 22px;
}
.landing-shot {
  margin: 0;
}
.landing-shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #101318;
}
.landing-shot figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.landing-why,
.landing-pricing {
  padding: 56px clamp(18px, 4vw, 48px) 24px;
  max-width: 1080px;
}
.landing-why h2,
.landing-pricing h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.02em;
}
.landing-section-lede {
  margin: 0 0 28px;
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.5;
}
.landing-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}
.landing-points li {
  display: grid;
  gap: 4px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.landing-points strong {
  font-size: 15px;
  font-weight: 600;
}
.landing-points span {
  color: var(--muted);
  line-height: 1.5;
  max-width: 58ch;
}

.landing-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.landing-plan {
  border: 1px solid var(--line);
  background: rgba(18, 20, 24, 0.65);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}
.landing-plan.featured {
  border-color: rgba(224, 163, 106, 0.45);
  background: linear-gradient(180deg, rgba(224, 163, 106, 0.1), rgba(18, 20, 24, 0.8));
}
.landing-plan h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.landing-price {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.03em;
  font-weight: 550;
}
.landing-price span {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.landing-plan ul {
  margin: 0 0 8px;
  padding: 0 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}
.landing-plan button,
.landing-plan a.ghost {
  text-align: center;
  text-decoration: none;
}

.landing-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 36px clamp(18px, 4vw, 48px) 48px;
  color: var(--faint);
  font-size: 13px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 16px;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.settings-tabs button {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.settings-tabs button.active {
  background: var(--raised);
  color: var(--ink);
}
.usage-plan { margin: 0 0 4px; }
.usage-meter-block {
  margin: 0 0 14px;
}
.usage-meter-secondary {
  opacity: 0.85;
}
.usage-meter-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.usage-meter-head strong {
  color: var(--ink);
  font-weight: 560;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  text-align: right;
}
.usage-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 246, 236, 0.08);
  overflow: hidden;
}
.usage-bar.thin { height: 5px; }
.usage-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c48a4a, var(--accent));
  min-width: 0;
}
.usage-admin {
  margin: 18px 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.usage-admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.usage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 10px;
}
.auth-back {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}


/* ==========================================================================
   STEP Reconstruct Studio Modal & Dual Viewport
   ========================================================================== */

.reconstruct-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(224, 163, 106, 0.3) !important;
  border-radius: 6px;
  padding: 3px 8px !important;
  font-size: 11px !important;
  font-weight: 500;
  transition: all 0.15s ease;
}

.reconstruct-trigger-btn:hover {
  background: rgba(224, 163, 106, 0.25) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.reconstruct-bolt {
  display: inline-block;
  line-height: 1;
}

.reconstruct-trigger-btn.reconstruct-running {
  background: rgba(224, 163, 106, 0.22) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  box-shadow: 0 0 0 1px rgba(224, 163, 106, 0.25);
}

.reconstruct-trigger-btn.reconstruct-running .reconstruct-bolt {
  animation: reconstruct-bolt-pulse 1.1s ease-in-out infinite;
}

.reconstruct-trigger-btn.reconstruct-done {
  background: rgba(90, 180, 120, 0.18) !important;
  border-color: rgba(90, 180, 120, 0.55) !important;
  color: #8fd9a8 !important;
}

@keyframes reconstruct-bolt-pulse {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    transform: scale(1.35) rotate(-12deg);
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(224, 163, 106, 0.85));
  }
  70% {
    transform: scale(1.1) rotate(8deg);
  }
}

.step-badge {
  display: inline-block;
  margin-right: 0.4em;
  padding: 0.05em 0.35em;
  border-radius: 3px;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: 0.12em;
  color: #0f172a;
  background: #fbbf24;
}

.code-badge {
  display: inline-block;
  margin-right: 0.35em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: -0.04em;
  vertical-align: 0.05em;
  color: #a78bfa;
}

.body-pick strong {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.design-recon-badge {
  color: #d97706;
  font-weight: 700;
  font-size: 0.85em;
}

.bake-step-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(235, 115, 60, 0.12) !important;
  color: #ff9153 !important;
  border: 1px solid rgba(235, 115, 60, 0.35) !important;
  border-radius: 6px;
  padding: 3px 8px !important;
  font-size: 11px !important;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bake-step-btn:hover:not(:disabled) {
  background: rgba(235, 115, 60, 0.28) !important;
  color: #fff !important;
  border-color: #ff9153 !important;
}

.bake-step-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bake-step-btn.baked-success {
  background: rgba(80, 200, 120, 0.2) !important;
  color: #70e498 !important;
  border-color: rgba(80, 200, 120, 0.5) !important;
}

.reconstruct-studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 8, 0.82);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.reconstruct-studio-overlay.maximized {
  padding: 0;
  place-items: stretch;
}

.reconstruct-studio-panel {
  display: flex;
  flex-direction: column;
  width: 96vw;
  max-width: 1720px;
  height: 92vh;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.reconstruct-studio-panel.maximized {
  width: 100vw;
  max-width: none;
  height: 100vh;
  border-radius: 0;
  border: 0;
}

.reconstruct-studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.reconstruct-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.reconstruct-studio-badge {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.reconstruct-solid-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reconstruct-engine-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reconstruct-engine-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--faint);
  text-transform: uppercase;
}

.reconstruct-engine-options {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--raised);
}

.reconstruct-engine-option {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.4;
}

.reconstruct-engine-option:hover:not(:disabled) {
  color: var(--ink);
}

.reconstruct-engine-option.active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.22);
}

.reconstruct-engine-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.reconstruct-engine-beta {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-left: 2px;
  vertical-align: super;
}

.reconstruct-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.reconstruct-select {
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  outline: none;
  max-width: 220px;
}

.reconstruct-settings-dropdown .reconstruct-select {
  width: 100%;
  max-width: none;
}

.reconstruct-select:focus {
  border-color: var(--accent);
}

.reconstruct-header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.reconstruct-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.stat-value.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.stat-limit {
  color: var(--faint);
  font-weight: 500;
}

.reconstruct-setting-hint {
  display: block;
  margin-top: 6px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
}

.reconstruct-stat-item.status-pill {
  background: var(--raised);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.reconstruct-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reconstruct-btn {
  background: var(--raised);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reconstruct-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: #fff;
}

.reconstruct-btn.active {
  background: rgba(163, 192, 150, 0.15);
  border-color: var(--ok);
  color: var(--ok);
}

.reconstruct-btn.btn-primary {
  background: var(--accent);
  color: #121418;
  border-color: var(--accent);
  font-weight: 600;
}

.reconstruct-btn.btn-primary:hover {
  filter: brightness(1.1);
  color: #000;
}

.reconstruct-btn.btn-danger {
  background: rgba(224, 138, 120, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.reconstruct-btn.btn-apply {
  background: rgba(163, 192, 150, 0.2);
  border-color: var(--ok);
  color: var(--ok);
  font-weight: 600;
}

.reconstruct-btn.btn-apply:hover {
  background: var(--ok);
  color: #0e1014;
}

.reconstruct-close-btn {
  background: transparent;
  border: 0;
  color: var(--faint);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}

.reconstruct-close-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.reconstruct-settings-popover-anchor {
  position: relative;
}

.reconstruct-settings-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 200;
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reconstruct-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.reconstruct-close-sm {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  line-height: 1;
}

.reconstruct-close-sm:hover {
  color: var(--ink);
}

.reconstruct-setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reconstruct-setting-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.reconstruct-radio-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reconstruct-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
  user-select: none;
}

.reconstruct-radio-label:hover {
  background: rgba(255, 255, 255, 0.05);
}

.reconstruct-radio-label input[type="radio"] {
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--accent);
}

.reconstruct-radio-label .radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reconstruct-radio-label .radio-text strong {
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
}

.reconstruct-radio-label .radio-text small {
  font-size: 11px;
  color: var(--faint);
  line-height: 1.3;
}

.reconstruct-studio-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #090a0d;
}

.reconstruct-viewports-split {
  flex: 1 1 54%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  min-height: 0;
}

.reconstruct-viewport-pane {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0c0e12;
}

.viewport-badge-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 20, 24, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.viewport-badge-tag.target-badge {
  color: #8da4be;
  border-color: rgba(141, 164, 190, 0.3);
}

.viewport-badge-tag.candidate-badge {
  color: var(--accent);
  border-color: rgba(224, 163, 106, 0.3);
}

.badge-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.reconstruct-viewport-box {
  width: 100%;
  height: 100%;
}

.reconstruct-bottom-split {
  flex: 1 1 46%;
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 8px;
  padding: 0 8px 8px;
  min-height: 0;
}

.reconstruct-code-pane,
.reconstruct-history-pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}

.pane-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.subhead-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.subhead-hint {
  font-size: 11px;
  color: var(--muted);
}

.reconstruct-monaco-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.reconstruct-steps-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reconstruct-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s ease;
}

.reconstruct-step-item:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.02);
}

.reconstruct-step-item.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.reconstruct-step-item.completed:not(.current) {
  border-color: rgba(163, 192, 150, 0.3);
}

.reconstruct-step-item.finished {
  border-color: rgba(163, 192, 150, 0.6);
  background: rgba(163, 192, 150, 0.08);
}

.reconstruct-step-item.finished:hover {
  background: rgba(163, 192, 150, 0.15);
  border-color: var(--ok);
}

.reconstruct-step-item.finished.current {
  border-color: var(--ok);
  background: rgba(163, 192, 150, 0.18);
}

.reconstruct-step-item.finished .step-icon.finished-icon {
  background: var(--ok);
  color: #10141a;
  border-color: var(--ok);
  font-size: 11px;
}

.step-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  flex: 0 0 auto;
}

.reconstruct-step-item.completed .step-icon {
  background: rgba(163, 192, 150, 0.2);
  color: var(--ok);
  border-color: var(--ok);
}

.reconstruct-step-item.current .step-icon {
  background: var(--accent);
  color: #121418;
  border-color: var(--accent);
}

.step-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.step-score {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.step-snippet {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reconstruct-tips-box {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  flex: 0 0 auto;
}

.tips-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  margin-right: 4px;
  animation: pulseAnim 1.2s infinite ease-in-out;
}

@keyframes pulseAnim {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.spinner-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spinDot 0.8s linear infinite;
}

@keyframes spinDot {
  to { transform: rotate(360deg); }
}

.text-ok { color: var(--ok); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--muted); }

.reconstruct-viewport-empty-notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(14, 16, 20, 0.88);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
  max-width: 80%;
}

.empty-icon {
  font-size: 26px;
}

.empty-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.reconstruct-select-sm { max-width: 130px; }
.reconstruct-phase-text {
  display: inline-block;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.reconstruct-history-pane .reconstruct-steps-list { flex: 1 1 55%; min-height: 0; }
.reconstruct-empty-steps { color: var(--muted); font-size: 12px; padding: 6px; }
.reconstruct-inventory {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.reconstruct-log {
  flex: 1 1 45%;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.5;
  background: #0b0c0f;
}
.reconstruct-log-line { white-space: pre-wrap; color: var(--faint); }
.reconstruct-log-line .log-t { color: #4d4a45; }
.reconstruct-log-line.log-status { color: var(--muted); }
.reconstruct-log-line.log-step { color: var(--ok); }
.reconstruct-log-line.log-error { color: var(--danger); }
.reconstruct-log-line.log-info { color: #8da4be; }

.account-dropdown-menu {
  position: absolute;
  top: 36px;
  right: 0;
  z-index: 1000;
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.account-dropdown-header {
  padding: 6px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-dropdown-header strong {
  font-size: 13px;
  color: var(--text);
}
.account-dropdown-header span {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.account-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.account-dropdown-item:hover {
  background: var(--raised);
}
.account-dropdown-signout {
  color: #f28b82;
}

/* Stationary Sketch Plane Picker Overlay */
.sketch-plane-picker-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 900;
  pointer-events: auto;
  user-select: none;
  background: rgba(18, 22, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 16px 20px 20px;
  width: 440px;
  max-width: 90vw;
  backdrop-filter: blur(12px);
  animation: pickerFadeIn 0.15s ease-out;
}

@keyframes pickerFadeIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.sketch-plane-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sketch-plane-picker-title {
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.sketch-plane-picker-esc {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sketch-plane-picker-esc:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.sketch-plane-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sketch-plane-picker-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  color: inherit;
  outline: none;
}

.sketch-plane-picker-btn:hover,
.sketch-plane-picker-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.sketch-plane-picker-btn.plane-xy:hover,
.sketch-plane-picker-btn.plane-xy:focus-visible {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
}

.sketch-plane-picker-btn.plane-xz:hover,
.sketch-plane-picker-btn.plane-xz:focus-visible {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.14);
}

.sketch-plane-picker-btn.plane-yz:hover,
.sketch-plane-picker-btn.plane-yz:focus-visible {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.14);
}

.sketch-plane-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.plane-xy .sketch-plane-icon-badge {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.plane-xz .sketch-plane-icon-badge {
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.plane-yz .sketch-plane-icon-badge {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.sketch-plane-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sketch-plane-label {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
}

.sketch-plane-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.sketch-plane-key {
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}


/* Top Toolbar Dropdown Menus */
.top-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Phones only: edit + settings live behind this one button. */

.top-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 42px;
  height: 32px;
  padding: 0 4px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink);
}

.top-dropdown-trigger svg,
.top-dropdown-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: currentColor;
}

.top-dropdown-trigger svg circle[fill="currentColor"],
.top-dropdown-item svg circle[fill="currentColor"] {
  fill: currentColor;
  stroke: none;
}

.top-dropdown-caret {
  width: 8px !important;
  height: 6px !important;
  opacity: 0.75;
  margin-left: 1px;
}

.top-dropdown-finish-btn {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  color: #7cc4ff;
  border-color: rgba(77, 170, 252, 0.4);
  background: rgba(77, 170, 252, 0.12);
  cursor: pointer;
}

.top-dropdown-finish-btn:hover {
  background: rgba(77, 170, 252, 0.22);
}

.top-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  min-width: 230px;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-dropdown-section {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding: 6px 10px 3px;
  user-select: none;
}

.top-dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}

.top-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.top-dropdown-item:hover {
  background: var(--raised);
  color: var(--accent);
}

.top-dropdown-item:disabled {
  opacity: 0.38;
  cursor: default;
  background: transparent;
  color: var(--faint);
}

.top-dropdown-item:hover svg {
  color: var(--accent);
}

.top-dropdown-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.top-dropdown-item.active svg {
  color: var(--accent);
}

.top-dropdown-label {
  flex: 1;
  white-space: nowrap;
}

.top-dropdown-kbd {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--muted);
  border: 1px solid var(--line);
}


/* Modern Compact Sketch HUD */
.sketch-hud-field {
  display: inline-flex;
  align-items: center;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  height: 28px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sketch-hud-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.sketch-hud-field input {
  width: 66px !important;
  height: 100% !important;
  background: transparent !important;
  border: none !important;
  padding: 0 4px 0 8px !important;
  outline: none !important;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px !important;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
}

.sketch-hud-field input::placeholder {
  color: rgba(243, 236, 228, 0.4);
}

.sketch-hud-unit {
  font-size: 11px;
  font-weight: 600;
  color: rgba(243, 236, 228, 0.55);
  padding-right: 7px;
  padding-left: 2px;
  user-select: none;
}


/* Interactive 2D sketch dimension callouts */
.sketch-dim-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 7px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  pointer-events: auto;
  white-space: nowrap;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  z-index: 10;
}

.sketch-dim-pill:hover,
.sketch-dim-pill.hovered {
  border-color: var(--accent);
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
  color: var(--ink);
}

.sketch-dim-pill.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
  color: var(--accent);
}

.sketch-dim-pill.dragging {
  cursor: grabbing;
}

.sketch-dim-input {
  width: 54px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 4px;
  text-align: center;
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
}

.sketch-dim-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}

.sketch-dim-del:hover {
  background: #ef4444;
  color: #ffffff;
}

.sketch-dim-cursor-badge {
  background: rgba(15, 23, 42, 0.92);
  border: 1.5px solid #ffd54f;
  border-radius: 4px;
  padding: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sketch-dim-pill.preview {
  pointer-events: none;
  opacity: 0.92;
  border-style: dashed;
}

/* --- Touch layouts: tool menus must escape the scrolling tool strip -----------
   Placed at the end of the file so they win over the base .top-dropdown rules. */
@media (max-width: 900px) {
  .top-dropdown-trigger { width: 40px; height: 34px; }
  .top-dropdown-menu {
    position: fixed;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100vw - 16px), 380px);
    min-width: 0;
    max-height: calc(100dvh - 130px);
    z-index: 320;
  }
  .top-dropdown-item { min-height: 40px; }
  .top-dropdown-section { padding-top: 8px; }
}

/* --- Collapsing the top bar on phones/tablets -------------------------------
   Base hides the overflow button; the media block below re-shows it. Kept last
   in the file, and scoped with .topbar so it outranks the desktop rules above. */
.topbar .mobile-more { display: none !important; }

@media (max-width: 900px) {
  .topbar .mobile-more { display: inline-flex !important; }
  .topbar .top-history { display: none !important; }
  .topbar .settings-btn { display: none !important; }
}

/* Appearance & Theme Settings */
.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-card:hover {
  border-color: var(--accent);
}
.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(224, 163, 106, 0.25);
}
.theme-card-preview {
  height: 52px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.theme-card-cube {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid;
}
.theme-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.theme-card-desc {
  font-size: 11px;
  color: var(--faint);
  margin-top: 2px;
  line-height: 1.3;
}
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.color-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.color-picker-row input[type="color"] {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 0;
}
.btn-outline-small {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-outline-small:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Unified Stage Console */
.unified-console {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  max-width: min(860px, calc(100% - 24px));
  margin: 0 auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  overflow: hidden;
  pointer-events: auto;
}
.unified-console.is-error {
  border-color: rgba(242, 139, 130, 0.5);
  background: color-mix(in srgb, var(--panel) 90%, #f28b82 10%);
}
.unified-console-bar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  user-select: none;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: background 0.12s;
}
.unified-console-bar:hover {
  background: var(--raised);
}
.unified-console.open .unified-console-bar {
  border-bottom: 1px solid var(--line);
}
.unified-console-bar:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.unified-console-chevron {
  color: var(--faint);
  font-size: 10px;
  line-height: 1;
}
.unified-console-bar:hover .unified-console-chevron {
  color: var(--ink);
}
.unified-console-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.unified-console-status {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: 11px;
}
.unified-console-status.error-text {
  color: #f28b82;
  font-weight: 500;
}
.unified-console-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.unified-console-badge {
  font-size: 9.5px;
  background: var(--raised);
  padding: 1px 5px;
  border-radius: 8px;
  color: var(--faint);
  border: 1px solid var(--line);
}
.unified-console-badge.is-bad {
  color: #f28b82;
  border-color: rgba(242, 139, 130, 0.4);
}
.unified-console-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
}
.unified-console-meta {
  color: var(--faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unified-console-tools-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.unified-console-collapse {
  font-size: 10.5px;
  padding: 1px 6px;
  color: var(--muted);
}
.unified-console-collapse:hover {
  color: var(--ink);
}
.unified-console-body {
  height: 150px;
  max-height: 35vh;
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.unified-console-err-box {
  padding: 8px;
  border-radius: 6px;
  background: rgba(242, 139, 130, 0.1);
  border: 1px solid rgba(242, 139, 130, 0.25);
  margin-bottom: 6px;
}
.unified-console-err-msg {
  color: #f28b82;
  font-weight: 600;
  margin-bottom: 4px;
}
.unified-console-err-trace {
  color: #f28b82;
  opacity: 0.85;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 90px;
  overflow-y: auto;
}

/* Body Right-Click Context Menu */
.body-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 190px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  user-select: none;
  max-height: 85vh;
  overflow-y: auto;
}
.body-context-header {
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.body-context-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.body-context-sub {
  font-size: 10px;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
}
.body-context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}
.body-context-item:hover {
  background: var(--raised);
  color: var(--accent);
}
.body-context-item.danger:hover {
  color: var(--danger);
}
.body-color-popover {
  padding: 6px;
}
.body-color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.body-color-dot-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}
.body-color-dot-btn:hover {
  transform: scale(1.18);
  border-color: var(--ink);
}
.body-color-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.body-color-custom-row input[type="color"] {
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 0;
}

