:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel-2: #0f1726;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eefc;
  --muted: #93a0b8;
  --sky: #38bdf8;
  --violet: #8b5cf6;
  --rose: #fb7185;
  --green: #34d399;
  --amber: #fbbf24;
  --header-h: 70px;
  --sidebar-w: min(400px, 30vw);
  --scroll-track: #152238;
  --scroll-thumb: #38bdf8;
  --scroll-thumb-hover: #7dd3fc;
}

* { box-sizing: border-box; }
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid var(--scroll-track);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}
html, body {
  margin: 0;
  height: 100%;
  max-width: 100vw;
  overflow: hidden; /* app shell scrolls internally; keeps Arrangements fixed */
}
body {
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.15), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(139, 92, 246, 0.12), transparent 55%),
    var(--bg);
}
img, svg, video, canvas { max-width: 100%; }
.min-w-0 { min-width: 0; }

#app {
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 100vw;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.72rem; }

.topbar {
  position: relative; z-index: 20;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 0.75rem; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  background: rgba(11, 18, 32, 0.92);
  max-width: 100vw;
}
.brand { display: flex; gap: 0.75rem; align-items: center; min-width: 0; flex: 1; }
.brand-logos {
  display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0;
}
.brand-text { min-width: 0; }
.logo {
  width: 2.25rem; height: 2.25rem; min-width: 2.25rem; min-height: 2.25rem;
  border-radius: 0.75rem;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--sky), var(--green));
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
  flex-shrink: 0;
}
.logo svg { width: 1.15rem; height: 1.15rem; display: block; }
.partner-logo {
  height: 2.25rem; width: auto; max-width: 4.5rem;
  object-fit: contain; object-position: center; display: block; flex-shrink: 0;
}
.topbar h1 {
  margin: 0; font-size: 1rem;
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  overflow: hidden;
}
.sub {
  margin: 0.15rem 0 0; font-size: 0.72rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.badge, .pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border-radius: 999px; padding: 0.15rem 0.55rem;
  font-size: 0.7rem; background: rgba(56, 189, 248, 0.15); color: #bae6fd;
}
.badge.amber { background: rgba(251, 191, 36, 0.15); color: #fde68a; }
.badge.violet { background: rgba(139, 92, 246, 0.18); color: #ddd6fe; }
.badge.sky { background: rgba(56, 189, 248, 0.15); color: #bae6fd; }
.badge.green { background: rgba(52, 211, 153, 0.15); color: #a7f3d0; }
.badge.rose { background: rgba(251, 113, 133, 0.15); color: #fecdd3; }
.pill::before {
  content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
}
.viewport-pill::before { background: var(--sky); box-shadow: 0 0 8px var(--sky); }
.btn {
  border: 1px solid var(--line); border-radius: 0.65rem;
  padding: 0.5rem 0.9rem; font-weight: 600; font-size: 0.8rem;
  cursor: pointer; color: var(--text); background: #1a2438;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  border: none;
  background: linear-gradient(90deg, var(--sky), var(--violet));
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.25);
}
.btn.danger { background: rgba(251, 113, 133, 0.9); border: none; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 0.25rem 0.5rem; font-size: 0.7rem; font-weight: 500; }
.btn.active-enlarge {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

#progress-bar { height: 2px; background: transparent; flex-shrink: 0; }
#boot, #error { flex-shrink: 0; }
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--violet), var(--rose));
  transition: width 0.35s ease;
}
.boot, .error {
  margin: 2rem auto; max-width: 40rem; padding: 1.25rem;
  border-radius: 1rem; border: 1px solid var(--line); background: var(--panel);
}
.error { color: #fecdd3; border-color: rgba(251, 113, 133, 0.35); }

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  max-width: 100vw;
  overflow: hidden;
}
.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background: rgba(11, 18, 32, 0.35);
}
/* Arrangements stays fixed at top — kept compact vs Geometry / SLM / … */
.sidebar-pinned {
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.55);
  z-index: 2;
}
.sidebar-pinned > .card {
  margin: 0;
  padding: 0.55rem 0.65rem;
}
.sidebar-pinned .panel-head {
  margin-bottom: 0.4rem;
}
.sidebar-pinned .panel-head h2 { font-size: 0.78rem; }
.sidebar-pinned .panel-sub { font-size: 0.65rem; }
.sidebar-pinned .panel-body {
  margin-top: 0;
}
.sidebar-pinned .panel-body.collapsed {
  display: none;
}
/* Other controls scroll under the fixed Arrangements block */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.arr-scroll {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}
.main {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

.card {
  background: rgba(18, 26, 43, 0.92);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.9rem;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.65rem; cursor: pointer; user-select: none;
}
.panel-head h2 { margin: 0; font-size: 0.85rem; }
.panel-sub { margin: 0.2rem 0 0; font-size: 0.7rem; color: var(--muted); }
.panel-body.collapsed { display: none; }
.chevron { color: var(--muted); font-size: 0.75rem; transition: transform 0.15s; }
.chevron.open { transform: rotate(90deg); }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.55rem; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: end; }
.field input[type="number"], .field select, .field input[type="text"] {
  border-radius: 0.5rem; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  padding: 0.45rem 0.55rem; font-size: 0.85rem; width: 100%;
}
.slider-row { margin-bottom: 0.7rem; }
.slider-top {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-size: 0.72rem; color: var(--muted); margin-bottom: 0.25rem;
}
.slider-top strong { color: var(--text); font-weight: 600; }
.slider-top .val { color: #bae6fd; font-variant-numeric: tabular-nums; }
.slider-row input[type="range"] {
  width: 100%; accent-color: var(--sky); cursor: pointer;
}
.slider-row.rose input[type="range"] { accent-color: var(--rose); }
.slider-row.green input[type="range"] { accent-color: var(--green); }
.hint { font-size: 0.8125rem; color: #cbd5e1; margin-top: 0.15rem; line-height: 1.45; }
.model-notes-card .model-notes p { margin: 0.45rem 0; color: #e2e8f0; font-size: 0.86rem; line-height: 1.5; }
.model-notes-card .model-notes b { color: #f8fafc; }
.model-notes-card code { font-size: 0.8em; }
.model-notes {
  font-size: 0.78rem;
  line-height: 1.45;
  color: #cbd5e1;
}
.model-notes-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #93a0b8;
  margin-bottom: 0.35rem;
}
.model-notes p { margin: 0.2rem 0; }

.checks { display: flex; flex-wrap: wrap; gap: 0.55rem; font-size: 0.8rem; }
.checks label { display: flex; gap: 0.35rem; align-items: center; cursor: pointer; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem;
  background: rgba(6, 10, 18, 0.55); border: 1px solid var(--line);
  border-radius: 0.6rem; padding: 0.25rem; margin-bottom: 0.65rem;
}
.seg.seg-4 { grid-template-columns: 1fr 1fr; }
.seg button {
  border: 0; border-radius: 0.45rem; padding: 0.4rem 0.5rem;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 0.75rem; font-weight: 600;
}
.seg button.active { background: rgba(56, 189, 248, 0.18); color: #e0f2fe; }
.seg.rose button.active { background: rgba(251, 113, 133, 0.18); color: #fecdd3; }

.preset-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem;
  background: rgba(6, 10, 18, 0.55); border: 1px solid var(--line);
  border-radius: 0.6rem; padding: 0.25rem; margin-bottom: 0.65rem;
}
.preset-row button {
  border: 0; border-radius: 0.4rem; padding: 0.4rem 0.2rem;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.7rem; font-weight: 600; text-transform: capitalize;
}
.preset-row button.active {
  background: rgba(251, 113, 133, 0.2); color: #fecdd3;
  box-shadow: inset 0 0 0 1px rgba(251, 113, 133, 0.35);
}

.arr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  align-content: start;
}
.arr-card {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.4rem 0.45rem 0.35rem;
  background: rgba(6, 10, 18, 0.45);
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}
.arr-card.selected {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.1);
}
.arr-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}
.arr-id {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.35rem;
  background: #1c2538;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #e8eefc;
}
.arr-card.selected .arr-id {
  background: var(--sky);
  color: #0b1220;
}
.arr-nl {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: #c4b5fd;
  letter-spacing: 0.02em;
}
.arr-line {
  font-size: 0.68rem;
  font-weight: 600;
  color: #e8eefc;
  line-height: 1.25;
}
.arr-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
}
.arr-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 0.3rem;
  padding: 0.08rem 0.35rem;
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1.2;
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}
.arr-chip.sky { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.arr-chip.violet { background: rgba(139, 92, 246, 0.16); color: #c4b5fd; }
.arr-chip.green { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.arr-chip.amber { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.arr-card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.35rem;
  margin-top: 0.3rem;
}
.arr-plane {
  flex: 1;
  min-width: 0;
  font-size: 0.55rem;
  line-height: 1.25;
  color: #64748b;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.arr-enlarge {
  width: 1.45rem; height: 1.45rem; border-radius: 0.35rem;
  border: 1px solid var(--line); background: #1a2438; color: var(--muted);
  cursor: pointer; font-size: 0.7rem; line-height: 1;
  flex-shrink: 0;
}
.arr-enlarge:hover, .arr-enlarge.active { color: #e0f2fe; border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.18); }

.mask-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.mask-grid button {
  border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.45rem 0;
  background: #1a2438; color: var(--muted); cursor: pointer; font-family: ui-monospace, monospace;
}
.mask-grid button.active { background: var(--sky); color: #0b1220; font-weight: 700; border-color: transparent; }

.upload-box {
  display: flex; flex-direction: column; gap: 0.45rem;
}
.upload-box .file-name {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: #7dd3fc;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.upload-error { color: #fda4af; font-size: 0.7rem; }

.icon-row { display: flex; gap: 0.3rem; }
.icon-btn {
  width: 2.1rem; height: 2.1rem; border-radius: 0.5rem; border: 1px solid var(--line);
  background: #1a2438; color: var(--muted); cursor: pointer;
}
.icon-btn:hover, .icon-btn.active { color: white; border-color: rgba(56, 189, 248, 0.45); }
.enlarge-btn.active { color: #7dd3fc; background: rgba(56, 189, 248, 0.18); }

.subcard {
  border: 1px solid var(--line); border-radius: 0.65rem;
  background: rgba(6, 10, 18, 0.45); padding: 0.65rem; margin-top: 0.55rem;
}
.subcard + .subcard { margin-top: 0.45rem; }
.toggle {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 0.35rem 0; font-size: 0.78rem;
}
.toggle .desc { font-size: 0.65rem; color: var(--muted); margin-top: 0.15rem; }
.toggle input { accent-color: var(--rose); width: 1rem; height: 1rem; margin-top: 0.15rem; }

.thermal-grid {
  display: grid; grid-template-columns: 2.5rem 1fr 1fr; gap: 0.4rem; align-items: end;
  margin-top: 0.35rem;
}
.crystal-tag { font-family: ui-monospace, monospace; font-size: 0.7rem; color: #c4b5fd; padding-bottom: 0.45rem; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 0.9rem; }
.top-row { align-items: stretch; }
.status-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.status-card .metrics { margin-bottom: 0.5rem; }
.status-card .path { margin-top: auto; }
.image-head {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.6rem; align-items: flex-start;
}
.image-box {
  aspect-ratio: 1; border-radius: 0.7rem; overflow: hidden;
  background: #060a12; display: grid; place-items: center;
  color: var(--muted); font-size: 0.8rem;
}
.image-box img { width: 100%; height: 100%; object-fit: contain; display: block; image-rendering: pixelated; }
.metrics {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem;
  font-size: 0.85rem; margin-bottom: 0.7rem;
}
@media (min-width: 900px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.metrics > div {
  background: rgba(6, 10, 18, 0.55); border: 1px solid var(--line);
  border-radius: 0.55rem; padding: 0.45rem 0.55rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem; color: #fde68a; margin-top: 0.25rem;
  padding: 0.45rem 0.55rem; border-radius: 0.5rem;
  background: rgba(6, 10, 18, 0.55); border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.log-card {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  margin-top: 0.25rem;
  clear: both;
  background: rgba(18, 26, 43, 0.98);
}
.log-head {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.45rem;
}
.log {
  margin: 0; min-height: 6.5rem; max-height: 10rem; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem; line-height: 1.45;
  background: rgba(6, 10, 18, 0.7); border: 1px solid var(--line);
  border-radius: 0.55rem; padding: 0.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.diagnostics-card {
  flex: 0 0 auto;
  margin-top: 0.35rem;
  background: rgba(18, 26, 43, 0.98);
}
.diagnostics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.diagnostics-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.diag-select {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.diag-select select {
  background: #1a2438;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.35rem 0.5rem;
}
.diag-kpi {
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
  line-height: 1.45;
}
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 0.75rem;
}
.diag-panel {
  background: rgba(6, 10, 18, 0.45);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem 0.75rem;
  min-width: 0;
}
.diag-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.diag-panel-head h3 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
}
.diag-panel h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.stage-ladder-card {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  background: rgba(18, 26, 43, 0.98);
}
.stage-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0.35rem 0 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(6, 10, 18, 0.45);
}
.stage-status-row #diag-stage-hint {
  margin: 0;
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}
.stage-ladder-card #diag-stage-kpi {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(6, 10, 18, 0.55);
  border-radius: 0.45rem;
}
.diag-panel canvas,
.stage-ladder-card canvas {
  image-rendering: auto;
}
.enlarge-body img.chart-hires {
  image-rendering: auto;
  object-fit: contain;
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: 100%;
}
.enlarge-chart-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 0.35rem;
  box-sizing: border-box;
  padding: 0.25rem;
}
.enlarge-chart-wrap canvas {
  width: 100%;
  height: auto;
  flex: 1 1 auto;
  min-height: 360px;
  cursor: crosshair;
  background: #0a1220;
  border-radius: 0.45rem;
  display: block;
}
.enlarge-chart-hint {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.72rem;
}
.enlarge-chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 9rem;
  max-width: 18rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.enlarge-chart-tip.hidden { display: none; }
.enlarge-chart-tip .tip-x {
  margin-bottom: 0.3rem;
  color: #94a3b8;
}
.enlarge-chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}
.enlarge-chart-tip .swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 0.12rem;
  flex: 0 0 auto;
}
.enlarge-body .stage-enlarge-single {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  gap: 0.5rem;
  min-height: 0;
}
.enlarge-body .stage-enlarge-single .meta {
  font-size: 0.9rem;
  color: var(--muted);
  flex: 0 0 auto;
}
.enlarge-img-frame {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  flex: 1 1 auto;
  min-width: 0;
  min-height: min(70vh, 640px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04080f;
  border-radius: 0.55rem;
  overflow: hidden;
  box-sizing: border-box;
}
.enlarge-img-frame img,
.enlarge-img-frame img.diag-enlarge-img,
.enlarge-img-frame img.pixelated {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: contain !important;
  image-rendering: pixelated;
  display: block;
}
.enlarge-img-frame img.smooth {
  image-rendering: auto !important;
}
.enlarge-body:has(.enlarge-img-frame),
.enlarge-body:has(.enlarge-chart-wrap),
.enlarge-body:has(.stage-enlarge-single) {
  align-items: stretch;
  justify-content: stretch;
  padding: 0.5rem;
}
.diag-panel canvas {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(6, 10, 18, 0.55);
  border-radius: 0.45rem;
}
.diag-table {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}
.diag-table table {
  width: 100%;
  border-collapse: collapse;
}
.diag-table th, .diag-table td {
  text-align: left;
  padding: 0.2rem 0.35rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.diag-table th { color: var(--text); font-weight: 600; }
.diag-image-box {
  min-height: 11rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0.55rem;
  overflow: hidden;
  padding: 0.45rem;
}
.diag-image-box.muted {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}
.diag-image-box img {
  width: min(100%, 16rem);
  max-height: 14rem;
  object-fit: contain;
  image-rendering: pixelated;
  background: #060a12;
  border-radius: 0.35rem;
}
.diag-map-stats {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.3;
  text-align: center;
}
.diag-map-note {
  font-size: 0.68rem;
  color: #fbbf24;
  text-align: center;
}
/* Enlarged diagnostic images must fill .enlarge-img-frame (never stay at native px size). */
.diag-stages-wrap { margin-top: 0.75rem; }
.diag-stage-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.55rem;
  margin: 0.55rem 0 0.75rem;
}
.diag-panel-wide {
  grid-column: 1 / -1;
}
.diag-arch-strip {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 6rem;
}
.diag-arch-strip.muted {
  color: var(--muted);
  font-size: 0.75rem;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.diag-arch-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.45rem;
  align-items: start;
}
.diag-arch-row-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #cbd5e1;
  padding-top: 0.35rem;
}
.diag-arch-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}
.diag-arch-thumb {
  background: rgba(6, 10, 18, 0.55);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.35rem;
  min-width: 0;
}
.diag-arch-thumb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.diag-arch-thumb-head strong {
  display: block;
  font-size: 0.68rem;
  min-width: 0;
  line-height: 1.25;
  margin: 0;
}
.diag-arch-thumb-head .enlarge-btn {
  flex: 0 0 auto;
}
.diag-arch-thumb strong {
  display: block;
  font-size: 0.68rem;
  margin-bottom: 0.25rem;
  line-height: 1.25;
}
.diag-arch-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #060a12;
  border-radius: 0.3rem;
  image-rendering: pixelated;
}
.diag-arch-thumb .meta {
  margin-top: 0.25rem;
  font-size: 0.64rem;
  color: var(--muted);
  line-height: 1.25;
}
.diag-arch-thumb .tiny {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}
@media (max-width: 900px) {
  .diag-arch-thumbs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.diag-stage-card {
  background: rgba(6, 10, 18, 0.55);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.4rem;
  min-width: 0;
}
.diag-stage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.diag-stage-card-head strong {
  display: block;
  font-size: 0.72rem;
  min-width: 0;
  line-height: 1.25;
  margin: 0;
}
.diag-stage-card-head .enlarge-btn {
  flex: 0 0 auto;
}
.diag-stage-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #060a12;
  border-radius: 0.35rem;
  image-rendering: pixelated;
}
.diag-stage-card .meta {
  margin-top: 0.3rem;
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.35;
}

.credits-card {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  background: rgba(18, 26, 43, 0.98);
}
.credits-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.65rem;
}
.credits-affil {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 52rem;
}
.credits-affil strong {
  color: var(--text);
  font-weight: 600;
}
.credits-logo {
  height: 2.4rem;
  width: auto;
  max-width: 5.5rem;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.95;
}
.credits-names {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.credits-names li {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 18, 0.55);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.2;
}

.team-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.team-modal.hidden { display: none !important; }
.team-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(4px);
}
.team-modal-panel {
  position: relative;
  z-index: 1;
  width: min(36rem, 100%);
  max-height: min(80vh, 36rem);
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.team-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.team-modal-head h2 {
  margin: 0;
  font-size: 1rem;
}
.section-title {
  display: flex; align-items: center; gap: 0.45rem;
  margin: 0 0 0.55rem; font-size: 0.9rem; flex-wrap: wrap;
}
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; }
.dot.ideal { background: var(--green); }
.dot.noisy { background: var(--rose); }
.image-grid {
  display: grid; gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.tile .image-box { min-height: 180px; }
.tile .stats {
  font-size: 0.7rem; color: var(--muted); margin-top: 0.4rem;
  overflow-wrap: anywhere;
}

.sim-panel {
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.sim-normal {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.lab-card {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  background: rgba(18, 26, 43, 0.98);
}
.release-card {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  background: rgba(14, 22, 36, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.18);
}
.release-checklist {
  margin: 0.55rem 0 0;
  padding: 0 0 0 1.1rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #cbd5e1;
}
.release-checklist li.muted {
  list-style: none;
  margin-left: -1.1rem;
  margin-top: 0.35rem;
  opacity: 0.75;
  font-size: 0.78rem;
}
/* Keep underlying layout/scroll in place; enlarge is a fixed overlay. */
.workspace.has-enlarge .sim-normal {
  visibility: hidden;
}
.enlarge-view {
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 0.9rem;
  background: rgba(18, 26, 43, 0.97);
  padding: 0.75rem;
  flex: 1;
  width: 100%;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-sizing: border-box;
}
.enlarge-view:not(.hidden) {
  position: fixed;
  z-index: 60;
  top: var(--header-h, 70px);
  left: var(--sidebar-w, 320px);
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  margin: 0.65rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}
.enlarge-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
  flex-shrink: 0;
}
.enlarge-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060a12;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  overflow: hidden;
  padding: 0.35rem;
}
.enlarge-body.enlarge-body-light {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.35);
}
/* White canvas only for arrangement A–D architecture figures */
.enlarge-body.enlarge-body-light .enlarge-img-frame {
  background: #ffffff;
}
.enlarge-view.is-architecture {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(148, 163, 184, 0.45);
}
.enlarge-view.is-architecture #enlarge-title,
.enlarge-view.is-architecture #enlarge-sub {
  color: #0f172a;
}
.enlarge-view.is-architecture #enlarge-sub {
  color: #475569;
}
.enlarge-body img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: auto;
  display: block;
}
.enlarge-body img.pixelated { image-rendering: pixelated; }

@media (max-width: 1100px) {
  html, body, #app {
    height: auto;
    max-height: none;
    overflow: auto;
  }
  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
    flex: none;
  }
  .sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-pinned {
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .sidebar-scroll {
    overflow: visible;
    flex: none;
  }
  .main {
    height: auto;
    overflow: visible;
  }
  .grid-2 { grid-template-columns: 1fr; }
  .viewport-pill { display: none; }
  .partner-logo {
    max-width: 3.2rem;
    height: auto;
    max-height: 1.85rem;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
  }
  .logo {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    flex-shrink: 0;
  }
  .logo svg { display: block; width: 100%; height: 100%; }
  .brand-logos { flex-wrap: wrap; align-items: center; }
  .topbar { flex-wrap: wrap; gap: 0.55rem; align-items: flex-start; }
  .topbar h1 { font-size: 1rem; line-height: 1.25; }
  .actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .enlarge-view:not(.hidden) {
    left: 0;
    margin: 0.45rem;
  }
}
