:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: #0a0a0a; color: #ccc; font: 12px/1.5 -apple-system, system-ui, monospace; 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; }

#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; }
.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; }

#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; }

.tp-dfwv { width: 100% !important; font-family: -apple-system, system-ui, monospace; font-size: 10.5px; }
.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;
}
