:root {
  color-scheme: dark;
  /* design tokens (shared with Tweakpane theme below) */
  --text: #eee;
  --text-muted: rgba(238, 238, 238, 0.55);
  --accent: #4a9eff;
  --panel-bg: #0d0d0d;
  --panel-border: rgba(238, 238, 238, 0.10);
  --font-ui: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-size-sm: 11px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: #0a0a0a; color: var(--text-muted); font: 12px/1.5 var(--font-ui); overflow: hidden; }

#stage {
  position: fixed; inset: 0 360px 0 0;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  transition: inset 0.18s ease;
}
body.minimized #stage { inset: 0; padding: 0; }
body.minimized #canvas { box-shadow: none; }
#canvas { max-width: 100%; max-height: 100%; background: #000; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
body.minimized #canvas { max-width: 100vw; max-height: 100vh; }
#canvas.empty { display: none; }

/* SAM segmentation overlay — positioned by JS to sit exactly over the WebGPU
   canvas. pointer-events on only when segment mode is active. */
#sam-overlay {
  position: fixed; pointer-events: none;
  display: none;
  z-index: 50;
}
#sam-overlay.visible { display: block; }
#sam-overlay.interactive { pointer-events: auto; cursor: crosshair; }

#side {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px;
  background: #0d0d0d; border-left: 1px solid #1a1a1a;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.18s ease;
}
body.minimized #side { transform: translateX(100%); }

#toggle-panel {
  position: fixed; top: 10px; right: 10px; z-index: 200;
  width: 26px; height: 26px; border-radius: 4px;
  background: rgba(20,20,20,0.85); color: #aaa;
  border: 1px solid #2a2a2a; cursor: pointer;
  font: inherit; font-size: 13px; line-height: 22px;
  padding: 0;
}
#toggle-panel:hover { background: rgba(40,40,40,0.95); color: #fff; border-color: #444; }
body:not(.minimized) #toggle-panel { right: 370px; }

#slot-bar { padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 6px; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slots-3 { grid-template-columns: 1fr 1fr 1fr; }
.slot {
  aspect-ratio: 4/3; background: #1a1a1a; border: 1px solid #222;
  position: relative; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #555; font-size: 10px;
}
.slot:hover { border-color: #444; color: #888; }
.slot.drop-target { border-color: #4af; box-shadow: 0 0 0 1px #4af inset; }
.slot.drop-target * { pointer-events: none; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .lab { position: absolute; top: 3px; left: 4px; color: #fff;
  background: rgba(0,0,0,0.6); padding: 1px 5px; font-size: 9px; pointer-events: none; }
.row-btns { display: flex; gap: 4px; }
.row-btns button {
  flex: 1; background: #1a1a1a; color: #ccc; border: 1px solid #222;
  padding: 4px 6px; cursor: pointer; font: inherit; font-size: 10.5px;
}
.row-btns button:hover { background: #222; border-color: #444; color: #fff; }

#library-section {
  padding: 6px 10px 4px;
  border-top: 1px solid #1a1a1a;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 240px;
  flex-shrink: 0;
}
.library-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 9.5px; color: #666;
}
.library-title { color: #999; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
#library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 56px); gap: 4px;
  overflow-y: auto; padding-bottom: 4px;
  min-height: 24px;
}
.library-thumb {
  position: relative; width: 56px; height: 42px;
  border: 1px solid #222; border-radius: 2px; overflow: hidden;
  cursor: pointer; background: #111;
  transition: border-color 0.1s, transform 0.1s;
}
.library-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.library-thumb:hover { border-color: #4af; }
.library-thumb.in-A::before, .library-thumb.in-B::after {
  position: absolute; top: 1px; padding: 0 3px;
  font-size: 9px; line-height: 11px; background: rgba(70, 170, 255, 0.85); color: #000;
  font-weight: 600; pointer-events: none;
}
.library-thumb.in-A::before { content: 'A'; left: 1px; }
.library-thumb.in-B::after  { content: 'B'; right: 1px; }
.library-empty {
  grid-column: 1 / -1;
  color: #555; font-size: 10px; padding: 12px 4px; text-align: center;
}

#tp-host { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 10px; }

/* Collapsible "Source images (optional)" section, pinned to the bottom. */
#source-section { flex-shrink: 0; border-top: 1px solid var(--panel-border); max-height: 50%; overflow-y: auto; }
#source-section > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 8px 12px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); background: rgba(255,255,255,0.02);
}
#source-section > summary::-webkit-details-marker { display: none; }
#source-section > summary::before { content: '▸ '; }
#source-section[open] > summary::before { content: '▾ '; }
#source-section > summary:hover { color: var(--text); }

#filepicker { display: none; }

#gpu-error {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column;
  background: #0a0a0a; color: #ccc; padding: 32px; text-align: center;
  z-index: 1000; gap: 12px;
}
#gpu-error.show { display: flex; }
#gpu-error b { color: #fff; }
#gpu-error a { color: #4af; text-decoration: none; }

/* ── Tweakpane theme (shared "trans" theme — dark / translucent / monospace) ──
   Reusable across projects: set these --tp-* tokens on the pane container. */
#tp-host {
  --tp-base-font-family: var(--font-ui);
  --tp-base-background-color: var(--panel-bg);
  --tp-base-shadow-color: rgba(0, 0, 0, 0.4);
  --tp-label-foreground-color: var(--text-muted);
  --tp-container-foreground-color: var(--text);
  --tp-container-background-color: rgba(238, 238, 238, 0.05);
  --tp-container-background-color-hover: rgba(238, 238, 238, 0.1);
  --tp-container-background-color-focus: rgba(238, 238, 238, 0.12);
  --tp-container-background-color-active: rgba(238, 238, 238, 0.15);
  --tp-button-foreground-color: var(--text);
  --tp-button-background-color: rgba(238, 238, 238, 0.1);
  --tp-button-background-color-hover: rgba(238, 238, 238, 0.16);
  --tp-button-background-color-focus: rgba(238, 238, 238, 0.2);
  --tp-button-background-color-active: var(--accent);
  --tp-input-foreground-color: var(--text);
  --tp-input-background-color: rgba(0, 0, 0, 0.3);
  --tp-input-background-color-hover: rgba(0, 0, 0, 0.4);
  --tp-input-background-color-focus: rgba(0, 0, 0, 0.45);
  --tp-input-background-color-active: rgba(0, 0, 0, 0.5);
  --tp-groove-foreground-color: rgba(238, 238, 238, 0.1);
  --tp-monitor-foreground-color: var(--text-muted);
  --tp-monitor-background-color: rgba(0, 0, 0, 0.3);
}
.tp-dfwv { width: 100% !important; font-size: var(--font-size-sm); }
.tp-lblv { padding-top: 2px !important; padding-bottom: 2px !important; }

/* Highlight the currently-selected rating cell in mode-folder rating grids. */
.rating-active {
  background-color: #4af !important;
  color: #000 !important;
  font-weight: 600 !important;
}
