:root {
  --bg: #08090c;
  --surface: #111319;
  --surface-2: #171a23;
  --surface-3: #1e222e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --dim: #6b7280;
  --gold: #e5c37c;
  --gold-soft: rgba(229, 195, 124, 0.14);
  --gold-border: rgba(229, 195, 124, 0.42);
  --green: #4ade80;
  --amber: #fbbf24;
  --sky: #38bdf8;
  --font-serif: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Inter", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.ambient-glow {
  position: fixed;
  top: -220px;
  left: 50%;
  transform: translateX(-50%);
  width: 1200px;
  height: 440px;
  background: radial-gradient(ellipse at center, rgba(229, 195, 124, 0.08) 0%, rgba(56, 189, 248, 0.03) 45%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

/* Slim Full-Width Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 9, 12, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 100%;
  padding: 6px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.top-left-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand-row { display: contents; }
.brand-row-actions { display: none; }
.topbar-collapsible { display: contents; }
.mobile-filter-btn { display: none; }
.mobile-fab { display: none; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(229, 195, 124, 0.25), rgba(229, 195, 124, 0.06));
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
}
.brand-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.brand-ver {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  padding: 1px 6px;
  border-radius: 99px;
}

.scope-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.scope-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: 0.15s;
}
.scope-btn:hover { color: var(--text); border-color: var(--border-strong); }
.scope-btn.active {
  background: var(--surface-3);
  border-color: var(--gold-border);
  color: var(--gold);
  font-weight: 600;
}
.scope-btn .cnt { font-family: var(--font-mono); font-size: 11px; opacity: 0.85; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
select, input[type="search"], input[type="text"] {
  font-family: inherit;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 10px;
  outline: none;
  transition: 0.15s;
}
select:focus, input[type="search"]:focus, input[type="text"]:focus { border-color: var(--gold-border); }

.search-box { position: relative; min-width: 190px; max-width: 290px; flex: 1; }
.search-box input { width: 100%; padding-right: 28px; }
.search-box kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  pointer-events: none;
}

.size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}
.size-control input[type="range"] {
  width: 78px;
  accent-color: var(--gold);
  cursor: pointer;
  margin: 0;
}
.size-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  min-width: 38px;
  text-align: right;
}

.view-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.vs-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s;
}
.vs-btn.active { background: var(--surface-3); color: var(--gold); font-weight: 600; }

.tray-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tray-trigger:hover { background: rgba(229, 195, 124, 0.22); }
.tray-count {
  background: var(--gold);
  color: #141008;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

/* Slim Category Bar */
.cat-bar {
  max-width: 100%;
  padding: 4px 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.cat-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.cat-rail::-webkit-scrollbar { display: none; }
.cat-pill {
  white-space: nowrap;
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s;
}
.cat-pill:hover { color: var(--text); border-color: var(--border-strong); }
.cat-pill.active {
  background: var(--gold-soft);
  border-color: var(--gold-border);
  color: var(--gold);
  font-weight: 600;
}
.cat-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.result-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Full-Bleed Visual Lookbook Grid */
.main-wrap {
  position: relative;
  z-index: 1;
  max-width: 100%;
  padding: 8px 12px 64px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-size, 120px), 1fr));
  gap: var(--tile-gap, 6px);
}
.gallery-grid.mode-compare {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
}

/* Pure-Visual Full-Bleed Card */
.style-card {
  position: relative;
  background: #0b0c10;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.gallery-grid.is-micro .style-card {
  border-radius: 7px;
}
.style-card:hover {
  transform: translateY(-2px);
  border-color: rgba(229, 195, 124, 0.65);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
  z-index: 3;
}
.style-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-border);
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #0a0b0f;
}
.gallery-grid.is-micro .card-media {
  aspect-ratio: 5 / 6;
}
.gallery-grid.is-ultra .card-media {
  aspect-ratio: 1 / 1;
}
.gallery-grid.mode-compare .card-media {
  aspect-ratio: 16 / 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: #06070a;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.style-card:hover .card-media img { transform: scale(1.04); }

.compare-slot { position: relative; width: 100%; height: 100%; overflow: hidden; }
.compare-slot-lbl {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(8, 9, 12, 0.78);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.compare-slot:last-child .compare-slot-lbl { left: auto; right: 8px; }

.card-overlay-top {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
  z-index: 2;
}
.gallery-grid.mode-compare .card-overlay-top { top: 34px; }

.p-mini-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(8, 9, 12, 0.76);
  color: #d1d5db;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  max-width: 68%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s;
}
.p-mini-badge.has-p { color: var(--gold); border-color: rgba(229, 195, 124, 0.34); }

.card-select-btn {
  pointer-events: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(8, 9, 12, 0.78);
  color: #f3f4f6;
  cursor: pointer;
  backdrop-filter: blur(8px);
  opacity: 0.75;
  transition: 0.15s;
}
.gallery-grid.is-micro .p-mini-badge,
.gallery-grid.is-micro .card-select-btn {
  opacity: 0;
}
.gallery-grid.is-micro .style-card:hover .p-mini-badge,
.gallery-grid.is-micro .style-card:hover .card-select-btn,
.gallery-grid.is-micro .card-select-btn.on {
  opacity: 1;
}
.style-card:hover .card-select-btn, .card-select-btn.on { opacity: 1; }
.card-select-btn:hover { border-color: var(--gold); color: var(--gold); }
.card-select-btn.on { background: var(--gold); border-color: var(--gold); color: #151107; }

/* Bottom Vignette Caption for 1-Second Scan */
.card-vignette {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 8px 7px;
  background: linear-gradient(to top, rgba(6, 7, 10, 0.94) 0%, rgba(6, 7, 10, 0.65) 58%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  z-index: 2;
}
.gallery-grid.is-micro .card-vignette { padding: 14px 6px 4px; }

.card-cap-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}
.card-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}
.card-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-grid.is-micro .card-num { font-size: 10px; }
.gallery-grid.is-micro .card-name { font-family: var(--font-sans); font-size: 11px; font-weight: 600; }
.gallery-grid.is-ultra .card-name { font-size: 10px; }

.card-cap-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: rgba(209, 213, 219, 0.78);
}
.gallery-grid.is-micro .card-cap-sub { display: none; }
.cap-tag-note { color: var(--amber); font-weight: 600; flex-shrink: 0; }
.cap-tag-rev { color: var(--sky); font-weight: 600; flex-shrink: 0; }

/* Enlarged Inspector Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 5, 8, 0.84);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.inspector-modal, .tray-modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: min(1560px, 97vw);
  height: min(94vh, 960px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
}
.tray-modal { width: min(1200px, 95vw); height: min(88vh, 860px); }

.insp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.insp-head-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.insp-sid {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  padding: 2px 9px;
  border-radius: 7px;
}
.insp-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
}
.tray-sub { font-family: var(--font-sans); font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.insp-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.gold { color: var(--gold); border-color: var(--gold-border); background: var(--gold-soft); }
.pill.sky { color: var(--sky); border-color: rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.12); }

.insp-head-right { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.btn-icon:hover { border-color: var(--gold-border); color: var(--gold); }
.btn-select-hero {
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-select-hero.on { background: var(--gold); color: #151107; }

.insp-body {
  display: grid;
  grid-template-columns: 480px 1fr;
  flex: 1;
  min-height: 0;
}
.insp-stage {
  border-right: 1px solid var(--border);
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0c0e13;
}
.stage-mode-bar { display: flex; gap: 6px; }
.sm-btn {
  flex: 1;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
}
.sm-btn.active { background: var(--surface-3); color: var(--gold); border-color: var(--gold-border); font-weight: 600; }

.stage-canvas {
  background: #07080b;
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.stage-canvas.split-view { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; }
.stage-canvas img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.stage-split-cell { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #0c0e13; border-radius: 8px; overflow: hidden; }
.stage-split-cell span {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(8, 9, 12, 0.8);
  color: var(--text);
}

.stage-thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.st-thumb {
  height: 62px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #07080b;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.st-thumb.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.st-thumb img { width: 100%; height: 100%; object-fit: cover; }
.st-thumb span {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(0, 0, 0, 0.78);
  padding: 0 4px;
  border-radius: 3px;
}

.meta-cards { display: flex; flex-direction: column; gap: 8px; }
.meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
}
.meta-k { font-size: 11px; color: var(--dim); margin-bottom: 2px; }
.meta-v { font-size: 12px; color: #e5e7eb; }
.meta-v.accent-text { color: var(--amber); }

/* Right Panel */
.insp-panel {
  padding: 18px 22px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.studio-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.block-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hint-sub { font-size: 11px; font-weight: 400; color: var(--dim); }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-chip, .btn-outline {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: 0.15s;
}
.btn-chip:hover { border-color: var(--gold-border); color: var(--gold); }
.btn-chip.active { background: var(--surface-3); border-color: var(--gold-border); color: var(--gold); }
.btn-chip.gold { background: var(--gold-soft); border-color: var(--gold-border); color: var(--gold); font-weight: 600; }

.code-group { display: flex; flex-direction: column; gap: 8px; }
.code-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code-label { font-size: 12px; color: var(--muted); min-width: 112px; }
.code-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.code-pill {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--gold-border);
  background: rgba(229, 195, 124, 0.1);
  color: var(--gold);
  cursor: pointer;
}
.code-pill.sref { border-color: rgba(56, 189, 248, 0.42); background: rgba(56, 189, 248, 0.1); color: #7dd3fc; }
.code-pill.none { border-color: var(--border); background: var(--surface); color: var(--muted); font-weight: 400; cursor: default; font-size: 12px; }

.param-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.param-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.param-cell .pk { font-size: 11px; color: var(--dim); }
.param-cell .pv { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text); margin-top: 2px; }

.formula-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  background: #0c0e13;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: #d1d5db;
  word-break: break-word;
}
.slot-chip {
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
}
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.slot-field { display: flex; flex-direction: column; gap: 4px; }
.slot-field label { font-size: 11px; color: var(--gold); font-family: var(--font-mono); }

.assembled-wrap {
  background: #0a0c10;
  border: 1px solid rgba(229, 195, 124, 0.25);
  border-radius: 9px;
  padding: 10px 12px;
}
.assembled-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.toggle-inline { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.assembled-code, .raw-prompt-box {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #f3f4f6;
}
.raw-prompt-box {
  background: #0c0e13;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: #cbd5e1;
}

.logic-list { display: flex; flex-direction: column; gap: 8px; }
.logic-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
}
.logic-item strong { color: var(--gold); margin-right: 6px; }

.kw-table-wrap { overflow-x: auto; }
.kw-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kw-table th, .kw-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.kw-table th { color: var(--dim); font-weight: 600; font-size: 11px; }
.kw-term-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 5px;
  padding: 2px 6px;
  cursor: pointer;
  text-align: left;
}
.kw-term-btn:hover { border-color: var(--gold); color: var(--gold); }

/* Selection Tray */
.tray-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tray-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.tray-thumb { width: 84px; height: 96px; border-radius: 8px; object-fit: cover; cursor: pointer; }
.tray-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tray-formula {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #cbd5e1;
  background: #0c0e13;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tray-row-actions { display: flex; flex-direction: column; gap: 6px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-title { font-family: var(--font-serif); font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* Lightbox & Toast */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 5, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; border: 1px solid var(--border-strong); }
.lightbox-cap {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
}
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 100;
  background: var(--gold);
  color: #161106;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .insp-body { grid-template-columns: 1fr; overflow-y: auto; }
  .insp-stage { border-right: 0; border-bottom: 1px solid var(--border); overflow-y: visible; }
  .insp-panel { overflow-y: visible; }
  .stage-canvas { height: 360px; }
  .param-grid { grid-template-columns: repeat(2, 1fr); }
  .tray-row { grid-template-columns: 68px 1fr; }
  .tray-row-actions { grid-column: 1 / -1; flex-direction: row; }
}

@media (max-width: 768px) {
  .topbar {
    position: relative;
    backdrop-filter: blur(12px);
  }
  .topbar-inner {
    padding: 8px 10px 6px;
    gap: 6px;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    max-width: 100%;
  }
  .top-left-cluster {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 6px;
    flex-direction: column;
    align-items: stretch;
  }
  .brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }
  .brand { min-width: 0; gap: 6px; }
  .brand-mark { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
  .brand-title { font-size: 13.5px; letter-spacing: 0.02em; }
  .brand-ver { display: none; }
  .brand-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  .desktop-only-tray { display: none; }
  .mobile-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
  }
  .mobile-filter-btn.active {
    border-color: var(--gold-border);
    color: var(--gold);
    background: var(--gold-soft);
  }
  .tray-trigger { padding: 5px 10px; font-size: 12px; }

  .scope-tabs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 5px;
  }
  .scope-tabs::-webkit-scrollbar { display: none; }
  .scope-btn { flex-shrink: 0; }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }
  .topbar:not(.filters-open) .topbar-actions { display: none; }
  .topbar.filters-open #topbarCollapsible {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    padding-top: 2px;
  }
  .topbar:not(.filters-open) .cat-right { display: none; }
  .topbar.filters-open .cat-right {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding-top: 4px;
  }

  .cat-bar {
    padding: 4px 10px 7px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
  }
  .cat-rail {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 5px;
    padding-bottom: 2px;
  }
  .cat-rail::-webkit-scrollbar { display: none; }
  .cat-pill { font-size: 11.5px; padding: 4px 10px; flex-shrink: 0; }

  .search-box { max-width: none; min-width: 0; width: 100%; flex: 1 0 100%; }
  .search-box kbd { display: none; }
  input[type="search"], input[type="text"], select { font-size: 16px; }
  .size-control { flex: 1; justify-content: space-between; }
  .size-control input[type="range"] { flex: 1; width: auto; }

  .main-wrap { padding: 6px 8px 72px; }
  .gallery-grid.mode-compare { grid-template-columns: 1fr; gap: 8px; }

  .mobile-fab {
    display: inline-flex;
    position: fixed;
    right: 14px;
    bottom: 20px;
    z-index: 40;
    align-items: center;
    gap: 4px;
    background: rgba(17, 19, 25, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--gold-border);
    color: var(--gold);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 13px;
    border-radius: 99px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    cursor: pointer;
  }

  .modal-backdrop { padding: 0; }
  .inspector-modal, .tray-modal {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .insp-header { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .insp-title { font-size: 15px; }
  .insp-stage { padding: 10px 12px; }
  .stage-canvas { height: 260px; }
  .stage-thumbs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .insp-panel { padding: 12px; gap: 12px; }
  .slots-grid { grid-template-columns: 1fr; }
  .code-label { min-width: 90px; }
}
