/* ==========================================================================
   SH0X AI MODEL STUDIO — ULTRA PRO DESIGN SYSTEM & LAYOUT ARCHITECTURE
   Professional Desktop Dark Theme for Windows & Chrome
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS & SYSTEM VARIABLES
   -------------------------------------------------------------------------- */
:root {
  /* Layout Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Border Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 9999px;

  /* Heights */
  --header-height: 54px;
  --control-height: 36px;
  --control-height-sm: 30px;
  --control-height-xs: 24px;

  /* Color Palette: Obsidian Dark Luxury Theme */
  --bg-app: #080a0f;
  --bg-header: rgba(14, 18, 26, 0.96);
  --bg-panel: #0e121a;
  --bg-panel-subtle: #121622;
  --bg-card: #151a24;
  --bg-card-hover: #1b212e;
  --bg-surface: #1e2535;
  --bg-input: #0b0e14;
  --bg-glass: rgba(255, 255, 255, 0.035);

  /* Border Colors */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.11);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-focus: #6366f1;

  /* Accent Colors & Glows */
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  --accent-indigo: #6366f1;
  --accent-indigo-hover: #4f46e5;
  --accent-indigo-glow: rgba(99, 102, 241, 0.35);
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-rose: #ef4444;
  --accent-cyan: #06b6d4;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow-indigo: 0 0 16px rgba(99, 102, 241, 0.35);
  --shadow-glow-gold: 0 0 16px rgba(245, 158, 11, 0.3);
}

/* --------------------------------------------------------------------------
   2. RESET & GLOBAL DARK SCROLLBARS
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Global Dark Windows Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
*::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   3. APP SHELL & TOP NAVIGATION HEADER
   -------------------------------------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

.app-header {
  height: var(--header-height);
  max-width: 100vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  z-index: 50;
  gap: var(--space-3);
  user-select: none;
  overflow: hidden;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex-shrink: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.window-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.brand-gem {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.4));
  flex-shrink: 0;
}

.brand-gem svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  text-transform: uppercase;
  white-space: nowrap;
}

.model-badge-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(245, 158, 11, 0.09);
  border: 1px solid rgba(245, 158, 11, 0.28);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.model-badge-pill:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald-glow);
  animation: pulse-ring 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 10px var(--accent-emerald); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.model-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.model-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-gold);
}

/* Header Navigation Tabs */
.header-nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  flex-shrink: 1;
  min-width: 0;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--accent-indigo);
  color: #ffffff;
  box-shadow: 0 0 14px var(--accent-indigo-glow);
}

.tab-icon {
  font-size: 13px;
}

.tab-badge {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.tab-badge-glow {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: #10b981;
  color: #064e3b;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  min-width: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.status-connected {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #86efac;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --------------------------------------------------------------------------
   4. BUTTONS & UI CONTROLS SYSTEM
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-glass:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-sm {
  height: var(--control-height-sm);
  padding: 0 10px;
  font-size: 11.5px;
}

.btn-micro {
  height: 24px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-micro:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn-icon-only {
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-icon-tiny {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.btn-icon-tiny:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger-tiny, .btn-danger-micro {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  font-size: 10px;
}
.btn-danger-tiny:hover, .btn-danger-micro:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

.btn-upload-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.hidden-file-input {
  display: none !important;
}

/* --------------------------------------------------------------------------
   5. STUDIO PAGES CONTAINER
   -------------------------------------------------------------------------- */
.studio-pages-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.studio-page {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.studio-page.active {
  display: flex;
  flex-direction: column;
}

/* Common Panel Frame */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.015);
  flex-shrink: 0;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel-icon {
  font-size: 14px;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Common Studio Card */
.studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}

.studio-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
  gap: 6px;
  flex-shrink: 0;
}

.header-left-flex {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.slot-number {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.card-caption {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.badge-mini {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge-gold {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-gold);
}

.pill-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.pill-purple {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
}

/* ==========================================================================
   6. PAGE 2: GENERATE WORKBENCH (EDITORIAL PRO 3-COLUMN SUITE)
   ========================================================================== */
.generate-page-layout {
  display: grid;
  grid-template-columns: minmax(290px, 320px) minmax(0, 1fr) minmax(310px, 340px);
  gap: var(--space-3);
  padding: var(--space-3);
  width: 100%;
  max-width: 100vw;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   6.1 COLUMN 1 (LEFT): DIRECTIVES, BIOMETRICS & PRESETS
   -------------------------------------------------------------------------- */
.generate-directives-col {
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.directives-content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Model Preset Cards */
.model-presets-section-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.model-presets-grid {
  display: flex;
  gap: 6px;
  overflow-x: hidden;
}

.model-avatar-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
}

.model-avatar-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: var(--bg-card-hover);
}

.model-avatar-card.active {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.model-avatar-img-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.model-avatar-title {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-quick-rename-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-model-name-tiny {
  flex: 1 1 0;
  min-width: 0;
  height: 26px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  padding: 0 7px;
  font-size: 11px;
  outline: none;
}
.input-model-name-tiny:focus {
  border-color: var(--accent-indigo);
}

/* Biometrics Sliders */
.biometrics-card {
  overflow: hidden;
}

.biometrics-sliders-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px;
}

.bio-slider-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bio-slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.bio-label {
  color: var(--text-secondary);
}

.bio-val-pill {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
}

.bio-range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.bio-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold-glow);
  cursor: pointer;
  transition: transform 0.1s;
}
.bio-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.bio-toggles-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 2px;
}

.bio-toggle-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bio-label-micro {
  font-size: 9.5px;
  color: var(--text-muted);
}

.bio-toggle-btn {
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bio-toggle-btn.active {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-gold);
}

/* Directives Feature Cards */
.directives-group-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.directive-feature-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 8px;
}

.directive-feature-header {
  width: 100%;
}

.target-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.target-chip:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.target-chip.active {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.14);
  color: #c7d2fe;
}

.chip-icon {
  margin-right: 4px;
}

.chip-status {
  font-weight: 700;
  font-size: 11px;
}

.alt-chips-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.alt-chip {
  padding: 3px 2px;
  font-size: 9.5px;
  font-weight: 500;
  text-align: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
}

.alt-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

.alt-chip.active {
  border-color: var(--accent-indigo);
  background: var(--accent-indigo);
  color: #ffffff;
  font-weight: 700;
}

.directive-snippet-box {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  font-size: 9px;
  font-family: var(--font-mono);
  overflow: hidden;
}

.snippet-label {
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 700;
}

.snippet-code {
  color: #38bdf8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.directive-toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

/* Body-Lock Card */
.body-lock-card {
  overflow: hidden;
}

.body-lock-toggles {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  max-height: 180px;
  overflow-y: auto;
}

.lock-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 7px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.lock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.lock-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 0;
}

.lock-label input[type="checkbox"] {
  accent-color: var(--accent-gold);
  cursor: pointer;
}

.lock-badge {
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-gold);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   6.2 COLUMN 2 (CENTER): STAGE, HUD & PROMPT DOCK
   -------------------------------------------------------------------------- */
.generate-stage-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Stage Topbar */
.stage-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
}

.aspect-ratio-selector-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 0;
}

.aspect-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.aspect-buttons-row {
  display: flex;
  gap: 4px;
}

.aspect-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.aspect-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.aspect-btn.active {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.18);
  color: #ffffff;
}

.aspect-sub {
  font-size: 8.5px;
  color: var(--text-muted);
}

.stage-floating-hud {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 1;
}

.hud-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.hud-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.hud-badge-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #86efac;
  white-space: nowrap;
}

.stage-model-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
}

/* Chat Viewport & Production Canvas */
.chat-viewport {
  flex: 1 1 0;
  min-height: 110px;
  overflow-y: auto;
  padding: var(--space-3);
  background: rgba(10, 13, 18, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  max-width: 85%;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble-user {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  align-self: flex-end;
  color: #e0e7ff;
}

.bubble-assistant {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  align-self: flex-start;
  color: var(--text-primary);
  width: 100%;
  max-width: 580px;
}

.chat-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chat-sender {
  font-weight: 700;
  color: var(--text-secondary);
}

.chat-media-wrap {
  width: 100%;
  max-height: 460px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  border: 1px solid var(--border-subtle);
}

.chat-media-wrap img {
  max-width: 100%;
  max-height: 460px;
  object-fit: contain;
}

.chat-img-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.btn-chat-action {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-chat-action:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* System Card in Chat */
.system-card {
  width: 100%;
  max-width: 100%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.07) 0%, rgba(139, 92, 246, 0.03) 100%);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: var(--radius-md);
  padding: 12px;
}

.system-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sys-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a5b4fc;
}

.sys-time {
  font-size: 10px;
  color: var(--text-muted);
}

.system-card-body h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.system-card-body p {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Progress Overlay Dock */
.generation-progress-dock {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.progress-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-spinner-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-indigo);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-meta {
  display: flex;
  flex-direction: column;
}

.progress-title {
  font-size: 12px;
  font-weight: 700;
  color: #c7d2fe;
}

.progress-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.progress-track-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}

.progress-bar-shimmer {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #818cf8, transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* Live Prompt Terminal */
.live-prompt-terminal {
  flex-shrink: 0;
  max-height: 230px;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.live-prompt-terminal.expanded {
  max-height: 400px;
}

.prompt-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}

.terminal-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 1;
}

.terminal-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.terminal-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-badge-auto {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
}

.terminal-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-chars {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.terminal-editor-wrap {
  flex: 1 1 auto;
  max-height: 110px;
  min-height: 52px;
  overflow: hidden;
}

.terminal-textarea {
  width: 100%;
  height: 100%;
  min-height: 52px;
  max-height: 110px;
  resize: none;
  background: #07090e;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  padding: 6px 10px;
  border: none;
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.terminal-reassurance-bar {
  flex-shrink: 0;
  max-height: 56px;
  overflow-y: auto;
  padding: 5px 10px;
  background: rgba(16, 185, 129, 0.06);
  border-top: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 10.5px;
  line-height: 1.35;
  color: #a7f3d0;
  word-break: break-word;
}

.reassurance-bar-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 9.5px;
  color: #6ee7b7;
  margin-bottom: 2px;
}

.reassurance-text {
  font-size: 10.5px;
  color: #d1fae5;
}

/* Prompt Action Bar */
.prompt-action-bar {
  flex-shrink: 0;
  min-height: 52px;
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: var(--bg-panel);
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.prompt-textarea-box {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  display: flex;
}

#prompt-textarea {
  width: 100%;
  height: 100%;
  min-height: 44px;
  max-height: 80px;
  resize: vertical;
  padding: 8px 12px;
  padding-right: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.4;
  outline: none;
}

#prompt-textarea:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 10px var(--accent-indigo-glow);
}

.kbd-hint {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 9.5px;
  color: var(--text-dim);
  pointer-events: none;
  user-select: none;
}

.prompt-side-buttons {
  display: flex;
  gap: 6px;
  align-items: stretch;
  flex-shrink: 0;
}

#btn-send-generation {
  min-height: 44px;
  padding: 0 18px;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transition: all 0.2s;
  white-space: nowrap;
}

#btn-send-generation:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

#btn-send-generation:active {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   6.3 COLUMN 3 (RIGHT): REFERENCE MEDIA BIN
   -------------------------------------------------------------------------- */
.generate-media-bin-col {
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.media-bin-content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Slot Cards Common Styling */
.slot-card {
  overflow: hidden;
}

.slot-display-box {
  position: relative;
  height: 120px;
  width: 100%;
  background: #07090e;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  border: 1.5px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.slot-empty-state:hover {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.05);
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 20px;
  opacity: 0.8;
}

.empty-text {
  font-size: 10.5px;
  font-weight: 600;
}

.empty-hint {
  font-size: 9px;
  color: var(--text-dim);
}

.slot-active-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

.slot-media-wrap {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-media-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-media-wrap.body-aspect img {
  object-fit: cover;
  object-position: top center;
}

.media-floating-tag {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
  white-space: nowrap;
}

.media-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 10px;
  flex-shrink: 0;
}

.meta-filename {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.meta-btn-group {
  display: flex;
  gap: 4px;
}

.btn-tiny-action {
  padding: 2px 6px;
  font-size: 9.5px;
  font-weight: 600;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-tiny-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.slot-thumbs-drawer {
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.18);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.slot-thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  max-height: 85px;
  overflow-y: auto;
}

.slot-thumb-item {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  border: 1.5px solid transparent;
  cursor: pointer;
  background: #050608;
  position: relative;
}

.slot-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-thumb-item:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.slot-thumb-item.active {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold-glow);
}

/* Slot 3: Target Dock Box */
.target-dock-box {
  background: var(--bg-card);
  border: 1.5px dashed rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dock-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid var(--border-subtle);
}

.dock-title {
  font-size: 11px;
  font-weight: 700;
  color: #c7d2fe;
}

.dock-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.target-dropzone {
  min-height: 85px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.target-dropzone.drag-over {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-indigo);
}

.target-empty-state {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px;
}

.drop-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-indigo);
  flex-shrink: 0;
}

.drop-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.primary-text {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.primary-text kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 9px;
  font-family: var(--font-mono);
}

.secondary-text {
  font-size: 9px;
  color: var(--text-muted);
}

.target-filled-state {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.target-thumb-box {
  width: 50px;
  height: 65px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #000000;
  border: 1px solid var(--border-subtle);
}

.target-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.target-details {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tag-target-active {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  display: inline-block;
  white-space: nowrap;
}

.target-name-text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-btn-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

/* Switch Controls (Wardrobe & Anchor Toggles) */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 17px;
  cursor: pointer;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  transition: 0.25s;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 11px;
  width: 11px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.25s;
}

.switch-control input:checked + .switch-slider {
  background-color: var(--accent-indigo);
}

.switch-control input:checked + .switch-slider::before {
  transform: translateX(13px);
}

.switch-status-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
}
.switch-status-label.is-active {
  color: var(--accent-emerald);
}

/* Slot 4: Clothing */
.slot-clothing-card.is-disabled .clothing-body-wrapper,
.slot-clothing-card.is-disabled .slot-display-box,
.slot-clothing-card.is-disabled .slot-thumbs-drawer {
  opacity: 0.4;
  pointer-events: none;
}

/* Slot 5: Anchor Box */
.anchor-slot-box {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.anchor-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
}

.anchor-title-flex {
  display: flex;
  align-items: center;
  gap: 6px;
}

.anchor-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.anchor-display-area {
  padding: 7px;
  background: #07090e;
}

.anchor-empty-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: var(--text-dim);
  padding: 3px;
}

.anchor-active-view {
  display: flex;
  align-items: center;
  gap: 8px;
}

.anchor-thumb-box {
  width: 42px;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.anchor-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.anchor-details {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-anchor-active {
  font-size: 8px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: inline-block;
  white-space: nowrap;
}

.anchor-filename {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anchor-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

/* Slot 6: Live Generation Gallery */
.gallery-bin-card {
  overflow: hidden;
}

.bin-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 7px;
  max-height: 150px;
  overflow-y: auto;
}

.bin-thumb {
  aspect-ratio: 9/16;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #000000;
  border: 1px solid var(--border-subtle);
}

.bin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bin-thumb:hover {
  border-color: var(--accent-indigo);
}

/* ==========================================================================
   7. PAGE 1: MODEL MANAGEMENT & DNA SLOTS
   ========================================================================== */
.model-page-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  width: 100%;
  height: 100%;
  overflow-y: auto;
}

.model-page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  flex-shrink: 0;
}

.page-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-badge-icon {
  font-size: 24px;
}

.model-title-presets-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.model-presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.presets-row-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.model-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.model-name-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-model-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  height: 30px;
}

.input-prefix-label {
  font-size: 11px;
  color: var(--text-muted);
}

.input-model-name {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  outline: none;
}

.ref-mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-mode-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.ref-mode-label {
  color: var(--text-muted);
}

.ref-mode-status {
  font-weight: 700;
  color: var(--accent-gold);
}

.ref-mode-toggle-group {
  display: flex;
  gap: 6px;
}

.ref-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ref-mode-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.ref-mode-btn.active {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.15);
  color: #ffffff;
}

.ref-mode-badge {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.model-slots-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.split-slots-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

.traits-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.traits-content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.traits-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  outline: none;
  resize: vertical;
}

.form-group textarea:focus {
  border-color: var(--accent-indigo);
}

.btn-full {
  width: 100%;
}

/* ==========================================================================
   8. PAGE 3: VAULT & FORENSIC COMPARE
   ========================================================================== */
.vault-page-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-3);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.vault-compare-panel, .vault-galleries-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compare-box {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  gap: 10px;
}

.compare-frame {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  min-height: 240px;
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.compare-img-before, .compare-img-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-img-after {
  clip-path: inset(0 0 0 50%);
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 10;
}

.compare-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.vault-tabs-header {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.vault-tab-btn {
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.vault-tab-btn.active {
  background: var(--accent-indigo);
  color: white;
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  flex: 1 1 0;
}

/* ==========================================================================
   9. MODALS, LIGHTBOX & TOASTS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 85vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

/* Lightbox Modal */
.lightbox-box {
  max-width: 90vw;
  max-height: 92vh;
  width: auto;
  background: #000000;
  border: 1px solid var(--border-subtle);
}

.lightbox-media-box {
  max-width: 85vw;
  max-height: 75vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-media-box img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

.lightbox-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(14, 18, 26, 0.95);
  border-top: 1px solid var(--border-subtle);
}

/* Toast Notifications - Top Right */
#toast-container {
  position: fixed;
  top: 66px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(14, 18, 26, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slide-toast 0.25s ease;
  pointer-events: auto;
  max-width: 340px;
  word-break: break-word;
}

@keyframes slide-toast {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   10. SYSTEMATIC RESPONSIVE ARCHITECTURE
   ========================================================================== */

/* 1440px Laptop Standard */
@media (max-width: 1440px) {
  .brand-sub {
    display: none;
  }
  .nav-tab-btn {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }
  .tab-badge {
    display: none;
  }
  .aspect-sub {
    display: none;
  }
  .stage-model-status {
    display: none;
  }
  .generate-page-layout {
    grid-template-columns: 270px minmax(0, 1fr) 285px;
    gap: 8px;
    padding: 8px;
  }
  #btn-launch-browser span:not(.btn-icon),
  #btn-inject-bridge span:not(.btn-icon) {
    display: none;
  }
  .status-pill {
    padding: 4px 7px;
    font-size: 10px;
  }
}

/* 1280px Compact Screen */
@media (max-width: 1280px) {
  .generate-page-layout {
    grid-template-columns: 255px minmax(0, 1fr) 270px;
    gap: 6px;
    padding: 6px;
  }
  .stage-topbar {
    padding: 5px 8px;
    gap: 6px;
  }
  .aspect-btn {
    padding: 2px 5px;
    font-size: 10px;
  }
  .hud-btn span:not(.hud-icon) {
    display: none;
  }
  .hud-badge-pill {
    font-size: 9.5px;
    padding: 2px 5px;
  }
  .terminal-title {
    max-width: 180px;
  }
}

/* 1024px Tablet Landscape / Narrow Window */
@media (max-width: 1024px) {
  .generate-page-layout {
    grid-template-columns: 240px minmax(0, 1fr) 250px;
    gap: 5px;
    padding: 5px;
  }
  .vault-page-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .hud-badge-pill {
    display: none;
  }
}

/* 768px Mobile / Narrow Viewport */
@media (max-width: 768px) {
  .app-layout {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
  }
  .app-header {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header-nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .generate-page-layout {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .generate-directives-col,
  .generate-stage-col,
  .generate-media-bin-col {
    min-height: auto;
  }
}

/* ===========================================================================
   11. LAYOUT STABILITY & RESPONSIVE REFINEMENT
   A final, component-scoped layer: no application behaviour depends on it.
   =========================================================================== */
:root {
  --sidebar-width: 292px;
  --media-bin-width: 304px;
  --panel-padding: var(--space-3);
}

/* Flex and grid descendants must be allowed to shrink before their content. */
.app-layout,
.studio-pages-container,
.studio-page,
.generate-page-layout,
.generate-page-layout > *,
.generate-stage-col > *,
.panel,
.panel-header,
.panel-title-group,
.directives-content,
.media-bin-content,
.chat-viewport,
.live-prompt-terminal,
.prompt-terminal-header,
.terminal-header-left,
.terminal-header-right,
.prompt-action-bar,
.prompt-side-buttons {
  min-width: 0;
}

.studio-pages-container,
.studio-page,
.generate-page-layout,
.generate-directives-col,
.generate-stage-col,
.generate-media-bin-col,
.directives-content,
.media-bin-content,
.chat-viewport {
  min-height: 0;
}

/* Keep page-level clipping at the shell only; content columns own their scroll. */
.generate-page-layout {
  grid-template-columns: minmax(250px, var(--sidebar-width)) minmax(360px, 1fr) minmax(270px, var(--media-bin-width));
  align-items: stretch;
  gap: var(--space-3);
  padding: var(--space-3);
  overflow: clip;
}

.generate-directives-col,
.generate-media-bin-col {
  overflow: hidden;
}

.directives-content,
.media-bin-content {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.generate-stage-col {
  overflow: hidden;
  gap: var(--space-3);
}

.chat-viewport {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* Headers can compress deliberately instead of cutting through controls. */
.app-header {
  overflow: visible;
}

.header-left,
.header-nav-tabs,
.header-right,
.stage-topbar,
.aspect-buttons-row,
.stage-floating-hud,
.model-presets-row,
.model-name-edit-row,
.model-page-topbar {
  min-width: 0;
}

.brand-title,
.panel-header h2,
.terminal-title,
.card-caption,
.meta-filename,
.target-name-text,
.anchor-filename,
.model-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-bubble,
.system-card,
.system-card-body p,
.terminal-reassurance-bar,
.reassurance-text,
.target-empty-state,
.anchor-empty-state,
.slot-empty-state {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* The final prompt remains an independent, bounded reading/editing surface. */
.live-prompt-terminal {
  flex: 0 1 248px;
  min-height: 150px;
  max-height: 260px;
}

.live-prompt-terminal.expanded,
.live-prompt-terminal.is-expanded {
  flex-basis: 400px;
  max-height: min(52vh, 430px);
}

.terminal-editor-wrap {
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.terminal-textarea {
  display: block;
  height: 100%;
  min-height: 94px;
  max-height: none;
  overflow: auto;
  overflow-wrap: anywhere;
}

.terminal-header-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.terminal-chars {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Generation controls use normal flow: the textarea gets remaining space. */
.prompt-action-bar {
  min-height: 0;
  flex: 0 0 auto;
  align-items: stretch;
  gap: var(--space-2);
}

.prompt-textarea-box {
  min-height: 72px;
}

#prompt-textarea {
  min-height: 72px;
  max-height: 160px;
  padding: 10px 12px;
  resize: vertical;
}

.kbd-hint {
  position: static;
  align-self: flex-end;
  margin: 0 10px 8px -150px;
  color: var(--text-muted);
  white-space: nowrap;
}

.prompt-side-buttons {
  flex: 0 0 auto;
}

#btn-send-generation {
  min-width: 188px;
  min-height: 72px;
  justify-content: center;
}

.btn,
.btn-micro,
.btn-tiny-action,
.bio-toggle-btn,
.target-chip,
.alt-chip,
.aspect-btn,
.hud-btn {
  max-width: 100%;
}

/* Preserve click targets while avoiding accidental non-wrapping overflow. */
.btn-micro,
.btn-tiny-action,
.bio-toggle-btn,
.target-chip,
.alt-chip {
  min-height: 28px;
}

.btn-icon-only,
.btn-icon-tiny {
  flex: 0 0 auto;
}

@media (max-width: 1440px) {
  .generate-page-layout {
    grid-template-columns: minmax(240px, 270px) minmax(340px, 1fr) minmax(250px, 285px);
    gap: var(--space-2);
    padding: var(--space-2);
  }
}

/* At laptop widths the media library moves below the working pair instead of
   crushing the centre prompt and controls into an unusable third column. */
@media (max-width: 1120px) {
  .app-header {
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
  }

  .header-nav-tabs {
    order: 3;
    flex: 1 1 100%;
    justify-content: center;
  }

  .header-right {
    margin-left: auto;
  }

  .status-pill {
    display: none;
  }

  .generate-page-layout {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(210px, 34vh);
  }

  .generate-media-bin-col {
    grid-column: 1 / -1;
  }

  .media-bin-content {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
    gap: var(--space-2);
  }

  .media-bin-content > * {
    min-width: 0;
  }

  .gallery-bin-card,
  .anchor-dock-box {
    grid-column: span 1;
  }
}

@media (max-width: 900px) {
  .app-header {
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
  }

  .header-nav-tabs {
    order: 3;
    flex: 1 1 100%;
    justify-content: center;
  }

  .header-right {
    margin-left: auto;
  }

  .generate-page-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(340px, auto) minmax(400px, 1fr) minmax(230px, auto);
    overflow: auto;
  }

  .generate-directives-col,
  .generate-stage-col,
  .generate-media-bin-col {
    grid-column: 1;
    min-height: 0;
  }

  .generate-directives-col,
  .generate-media-bin-col {
    max-height: 420px;
  }

  .media-bin-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  html, body,
  .app-layout {
    min-height: 100dvh;
    height: auto;
    overflow: auto;
  }

  .app-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .studio-pages-container,
  .studio-page,
  .studio-page.active {
    height: auto;
    overflow: visible;
  }

  .header-left {
    flex: 1 1 auto;
  }

  .brand-text,
  .model-badge-pill,
  .status-pill,
  .tab-badge-glow {
    display: none;
  }

  .header-right {
    gap: 4px;
  }

  .header-nav-tabs {
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .generate-page-layout {
    display: flex;
    flex-direction: column;
    padding: var(--space-2);
    overflow: visible;
  }

  .generate-directives-col,
  .generate-stage-col,
  .generate-media-bin-col {
    width: 100%;
    max-height: none;
  }

  .generate-stage-col {
    min-height: 620px;
  }

  .stage-topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .aspect-ratio-selector-group,
  .stage-floating-hud {
    flex-wrap: wrap;
  }

  .prompt-terminal-header {
    align-items: flex-start;
  }

  .terminal-header-right {
    width: 100%;
    justify-content: flex-start;
  }

  .prompt-action-bar,
  .prompt-side-buttons {
    flex-direction: column;
  }

  .prompt-side-buttons {
    width: 100%;
  }

  #btn-copy-prompt,
  #btn-send-generation {
    width: 100%;
    min-height: 48px;
  }

  .kbd-hint {
    display: none;
  }

  .media-bin-content {
    display: flex;
    flex-direction: column;
  }

  .model-page-topbar,
  .model-presets-row,
  .model-name-edit-row,
  .vault-page-layout {
    flex-direction: column;
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===========================================================================
   14. MODEL REFERENCE GRID — stable card geometry for any image ratio
   =========================================================================== */
.model-slots-grid {
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

/* Master mode gets a generous two-column preview; clothing stays useful at
   the right instead of claiming an entire row. */
#pane-ref-master {
  grid-column: span 2;
}

/* Split mode puts Face + Body together in the first two grid columns. */
#pane-ref-split {
  grid-column: span 2;
}

#pane-ref-split .split-slots-container {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  height: 100%;
}

.model-slots-grid > .slot-clothing-card {
  grid-column: 3;
}

.model-slots-grid > .traits-card {
  grid-column: 1 / -1;
}

/* Every source gets exactly the same visual footprint. The image may be
   portrait, landscape or a contact sheet; it no longer changes card height. */
#pane-ref-master > .slot-card,
#pane-ref-split .slot-card,
.model-slots-grid > .slot-clothing-card {
  height: 528px;
  min-height: 0;
}

#pane-ref-split .slot-card,
.model-slots-grid > .slot-clothing-card {
  display: flex;
  flex-direction: column;
}

.model-page-layout .slot-display-box {
  flex: 0 0 296px;
  height: 296px;
}

.model-page-layout .slot-active-view,
.model-page-layout .slot-media-wrap {
  min-height: 0;
}

.model-page-layout .slot-thumbs-drawer,
.model-page-layout .clothing-body-wrapper {
  min-height: 0;
}

.model-page-layout .slot-thumbs-drawer {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.model-page-layout .clothing-body-wrapper {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.model-page-layout .clothing-body-wrapper .slot-thumbs-drawer {
  flex: 1 1 auto;
}

.model-page-layout .slot-thumb-grid {
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  grid-auto-rows: 100px;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.model-page-layout .slot-thumb-item {
  aspect-ratio: auto;
  min-height: 0;
}

@media (max-width: 1240px) {
  .model-slots-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #pane-ref-master,
  #pane-ref-split,
  .model-slots-grid > .traits-card {
    grid-column: 1 / -1;
  }

  .model-slots-grid > .slot-clothing-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  #pane-ref-split .split-slots-container {
    grid-template-columns: minmax(0, 1fr);
  }

  #pane-ref-master > .slot-card,
  #pane-ref-split .slot-card,
  .model-slots-grid > .slot-clothing-card {
    height: 468px;
  }

  .model-page-layout .slot-display-box {
    flex-basis: 240px;
    height: 240px;
  }
}

/* ===========================================================================
   13. DIRECTOR USABILITY PASS — focused workspace and legible media
   =========================================================================== */

/* Reference management belongs to Model Library. Removing the permanent
   duplicate drawer gives the Director one clear primary work surface. */
.generate-page-layout {
  grid-template-columns: minmax(290px, 336px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.generate-media-bin-col {
  display: none;
}

.generate-directives-col {
  border-radius: 16px;
}

.generate-directives-col .directives-content {
  padding: 16px;
  gap: 16px;
}

/* The rail presents choices, not raw prompt implementation details. */
.generate-directives-col .directive-snippet-box {
  display: none;
}

.generate-directives-col .directive-feature-card {
  gap: 10px;
  padding: 12px;
}

.generate-directives-col .alt-chips-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.generate-directives-col .alt-chip {
  min-height: 34px;
  padding: 6px 7px;
  font-size: 10.5px;
}

.generate-directives-col .directive-toggles-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.generate-directives-col .target-chip {
  min-height: 38px;
  padding: 8px 10px;
}

.generate-directives-col .body-lock-card {
  flex: 0 0 auto;
}

.generate-directives-col .body-lock-toggles {
  max-height: 268px;
  overflow: auto;
  padding: 10px;
}

.generate-directives-col .lock-label {
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.generate-stage-col {
  border-radius: 16px;
  padding: 16px;
}

.stage-topbar {
  min-height: 56px;
}

/* Make the reference action explicit now that its full library is a tab. */
.stage-model-status {
  display: flex;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid rgba(143, 130, 255, 0.3);
  color: #c7c5ff;
}

.stage-model-status::before {
  content: "Референсы";
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.chat-viewport {
  min-height: 110px;
  padding: 18px;
}

.live-prompt-terminal {
  flex: 0 0 204px;
  min-height: 0;
  max-height: 204px;
}

.live-prompt-terminal.expanded,
.live-prompt-terminal.is-expanded {
  flex-basis: min(430px, 58vh);
  max-height: min(430px, 58vh);
}

.terminal-editor-wrap,
.terminal-textarea {
  min-height: 0;
}

.terminal-textarea {
  overflow: auto;
  scrollbar-gutter: stable;
}

/* Model Library previews always show the whole selected source, never a
   narrow cropped strip. Thumbnails are a usable browsing grid. */
.model-page-layout {
  padding: 16px;
}

.model-page-layout .slot-display-box {
  height: clamp(220px, 24vw, 340px);
  padding: 10px;
  background:
    radial-gradient(circle at 50% 45%, rgba(99, 102, 241, 0.12), transparent 58%),
    #060912;
}

.model-page-layout .slot-active-view,
.model-page-layout .slot-media-wrap {
  border-radius: 9px;
}

.model-page-layout .slot-media-wrap {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0)),
    #03050a;
}

.model-page-layout .slot-media-wrap img {
  /* Selected sources are shown in full. The preview stage has a stable,
     generous height below, so portrait, landscape and contact-sheet images
     are readable without being cropped. */
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.model-page-layout .slot-thumbs-drawer {
  padding: 10px 12px 12px;
}

.model-page-layout .slot-thumb-grid {
  grid-template-columns: repeat(auto-fill, minmax(112px, 140px));
  justify-content: start;
  gap: 8px;
  max-height: 184px;
  padding-bottom: 2px;
}

.model-page-layout .slot-thumb-item {
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  background: #05070d;
}

.model-page-layout .slot-thumb-item img {
  object-fit: contain;
  background: #05070d;
}

.model-page-layout .media-meta-row {
  gap: 10px;
  padding: 8px 10px;
}

.model-page-layout .meta-filename {
  flex: 1 1 auto;
  max-width: none;
  min-width: 0;
}

.model-page-layout .meta-btn-group {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Long model descriptions remain readable in their own fields. */
.traits-form-grid {
  align-items: start;
}

.form-group textarea {
  min-height: 108px;
  max-height: 170px;
  overflow: auto;
  resize: vertical;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .generate-page-layout {
    grid-template-columns: minmax(270px, 310px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .generate-media-bin-col {
    display: none;
  }

  .live-prompt-terminal {
    flex-basis: 188px;
    max-height: 188px;
  }
}

@media (max-width: 900px) {
  .generate-page-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(480px, 1fr);
  }

  .generate-directives-col {
    max-height: 480px;
  }
}

@media (max-width: 760px) {
  .generate-page-layout {
    padding: 10px;
  }

  .generate-directives-col .alt-chips-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-page-layout .slot-display-box {
    height: 230px;
  }

  .model-page-layout .slot-thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===========================================================================
   12. SH0X LIQUID GLASS WORKSPACES
   Shared visual language for Model, Director and Vault. Existing IDs and
   event bindings remain intentionally untouched.
   =========================================================================== */
:root {
  --glass-surface: linear-gradient(145deg, rgba(29, 37, 54, 0.84), rgba(11, 15, 24, 0.9));
  --glass-surface-strong: linear-gradient(145deg, rgba(37, 46, 67, 0.88), rgba(12, 16, 26, 0.94));
  --glass-border: rgba(173, 192, 255, 0.15);
  --glass-highlight: rgba(151, 135, 255, 0.25);
}

.app-layout {
  background:
    radial-gradient(circle at 54% -20%, rgba(99, 102, 241, 0.14), transparent 34%),
    radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.06), transparent 30%),
    var(--bg-app);
}

.app-header {
  background: rgba(10, 14, 23, 0.82);
  border-bottom-color: var(--glass-border);
  backdrop-filter: blur(22px) saturate(125%);
}

.header-nav-tabs {
  padding: 4px;
  background: rgba(7, 10, 17, 0.48);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav-tab-btn {
  min-height: 34px;
  padding-inline: 14px;
}

.nav-tab-btn.active {
  background: linear-gradient(135deg, #6156df, #875ce9);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.panel,
.studio-card,
.model-page-topbar,
.vault-compare-panel,
.vault-galleries-panel {
  background: var(--glass-surface);
  border-color: var(--glass-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(16px) saturate(115%);
}

.panel-header,
.studio-card-header {
  min-height: 48px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.018);
  border-bottom-color: rgba(173, 192, 255, 0.11);
}

.panel-header h2,
.card-caption {
  letter-spacing: 0.01em;
}

/* Director: the rail contains only usable selection controls, not fake knobs. */
.generate-directives-col .biometrics-card {
  display: none;
}

.generate-directives-col .directives-content {
  padding: 14px;
  gap: 14px;
}

.model-presets-section-wrap,
.directive-feature-card,
.body-lock-card,
.target-dock-box,
.anchor-slot-box {
  background: rgba(7, 10, 17, 0.38);
  border-color: rgba(173, 192, 255, 0.12);
}

.directive-feature-card {
  padding: 10px;
  gap: 8px;
}

.target-chip {
  min-height: 34px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.035);
}

.target-chip.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(122, 92, 222, 0.16));
  border-color: rgba(143, 130, 255, 0.58);
}

.alt-chips-grid {
  gap: 5px;
}

.alt-chip {
  min-height: 30px;
  padding: 4px 5px;
  border-radius: 7px;
}

.directive-snippet-box {
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(1, 4, 10, 0.36);
}

.body-lock-toggles {
  max-height: none;
  gap: 6px;
  padding: 10px;
}

.lock-toggle-item {
  min-height: 34px;
  border-color: rgba(173, 192, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
}

/* Generate workspace: a quiet canvas with a visible prompt-to-action flow. */
.generate-stage-col {
  padding: 12px;
  gap: 12px;
  background: var(--glass-surface);
  border-color: var(--glass-border);
}

.stage-topbar,
.live-prompt-terminal,
.prompt-action-bar,
.generation-progress-dock {
  background: rgba(8, 12, 21, 0.54);
  border-color: rgba(173, 192, 255, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.stage-topbar {
  min-height: 52px;
  padding: 8px 12px;
}

.chat-viewport {
  background:
    linear-gradient(180deg, rgba(11, 16, 28, 0.38), rgba(4, 7, 13, 0.58)),
    radial-gradient(circle at 50% 0%, rgba(92, 101, 210, 0.08), transparent 55%);
  border-color: rgba(173, 192, 255, 0.13);
  padding: 14px;
}

.system-card,
.chat-bubble {
  background: linear-gradient(145deg, rgba(47, 55, 88, 0.3), rgba(16, 20, 33, 0.5));
  border-color: rgba(143, 130, 255, 0.22);
}

.live-prompt-terminal {
  border-radius: 14px;
}

.prompt-terminal-header {
  min-height: 50px;
  padding: 8px 12px;
}

.terminal-textarea {
  padding: 12px;
  background: rgba(3, 7, 13, 0.7);
  color: #b9d7ff;
}

.terminal-reassurance-bar {
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.075);
}

.prompt-action-bar {
  padding: 10px;
  border-radius: 14px;
}

#prompt-textarea {
  background: rgba(4, 8, 15, 0.62);
  border-color: rgba(173, 192, 255, 0.14);
}

#btn-send-generation {
  min-width: 198px;
  background: linear-gradient(135deg, #5b59ed 0%, #7b60ee 53%, #4596f6 100%);
  box-shadow: 0 10px 24px rgba(85, 100, 237, 0.33), inset 0 1px 0 rgba(255,255,255,0.24);
}

/* Reference drawer: all current slots remain available, arranged like a utility panel. */
.generate-media-bin-col .media-bin-content {
  padding: 14px;
  gap: 12px;
}

.generate-media-bin-col .slot-display-box {
  height: 128px;
  background: rgba(2, 5, 10, 0.48);
}

.generate-media-bin-col .slot-empty-state {
  border-color: rgba(173, 192, 255, 0.17);
  background: rgba(255, 255, 255, 0.012);
}

/* Model Library: presets first, references grouped into flexible work cards. */
.model-page-layout {
  padding: 18px;
  gap: 16px;
  overflow: auto;
  background:
    radial-gradient(circle at 0 0, rgba(99, 102, 241, 0.08), transparent 32%),
    transparent;
}

.model-page-topbar {
  min-height: 112px;
  padding: 18px 20px;
  border-radius: 16px;
}

.model-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.model-slots-grid > *,
.model-slots-grid .studio-card {
  min-width: 0;
}

#pane-ref-master,
#pane-ref-split,
.model-slots-grid > .slot-clothing-card,
.model-slots-grid > .traits-card {
  grid-column: 1 / -1;
}

#pane-ref-master .slot-card,
.model-slots-grid > .slot-card {
  min-height: 250px;
}

#pane-ref-master > .slot-card {
  width: 100%;
}

.split-slots-container {
  gap: 16px;
}

.traits-content {
  padding: 16px;
}

.traits-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-group textarea {
  min-height: 78px;
  background: rgba(4, 8, 15, 0.58);
  border-color: rgba(173, 192, 255, 0.13);
}

/* Vault: comparison has visual priority, both galleries are independently scrollable. */
.vault-page-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.82fr);
  gap: 16px;
  padding: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 25% 0%, rgba(99, 102, 241, 0.08), transparent 34%),
    transparent;
}

.vault-compare-panel,
.vault-galleries-panel {
  border-radius: 16px;
}

.vault-compare-panel {
  min-width: 0;
}

.compare-card-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.compare-stage {
  flex: 1 1 auto;
  min-height: 300px;
  display: flex;
}

.compare-frame {
  min-height: 0;
  border-radius: 12px;
  background: #05070d;
  border-color: rgba(173, 192, 255, 0.16);
}

.compare-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vault-galleries-panel {
  min-height: 0;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
}

.vault-card {
  flex: 1 1 0;
  min-height: 0;
}

.vault-card .results-grid {
  min-height: 0;
  overflow: auto;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 8px;
  padding: 10px;
}

@media (max-width: 1120px) {
  .vault-page-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(360px, 1fr) minmax(280px, 0.72fr);
  }

  .vault-galleries-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .model-page-layout,
  .vault-page-layout {
    padding: 10px;
    overflow: visible;
  }

  .model-slots-grid,
  .traits-form-grid,
  .vault-galleries-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .model-page-topbar {
    align-items: stretch;
    padding: 14px;
  }

  .ref-mode-toggle-group,
  .model-name-edit-row {
    flex-wrap: wrap;
  }

  .ref-mode-btn,
  .input-model-wrap {
    flex: 1 1 100%;
  }

  .vault-page-layout {
    display: flex;
    flex-direction: column;
  }

  .compare-stage {
    min-height: 240px;
  }

  .vault-galleries-panel {
    display: flex;
    min-height: 520px;
  }
}

/* ===========================================================================
   15. MODEL REFERENCES — one stable desktop row
   The source image must never decide the dimensions of its card. Face + body
   share two cells; clothing occupies the third, then the profile follows.
   =========================================================================== */
@media (min-width: 981px) {
  .model-page-layout .model-slots-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .model-page-layout #pane-ref-master,
  .model-page-layout #pane-ref-split {
    grid-column: span 2;
  }

  .model-page-layout #pane-ref-split .split-slots-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    height: 100%;
    width: 100%;
    flex: 1 1 auto;
  }

  .model-page-layout .model-slots-grid > .slot-clothing-card {
    grid-column: 3;
  }

  .model-page-layout .model-slots-grid > .traits-card {
    grid-column: 1 / -1;
  }
}

/* Photo actions live below the preview; source labels do not compete with it. */
.model-page-layout .media-floating-tag {
  display: none;
}

.model-page-layout .media-meta-row {
  min-height: 44px;
  padding: 7px 10px;
}

.model-page-layout .media-meta-row .meta-filename {
  display: none;
}

.model-page-layout .slot-photo-actions {
  width: 100%;
  justify-content: stretch;
  gap: 7px;
}

.model-page-layout .slot-photo-actions .btn-tiny-action {
  flex: 1 1 0;
  min-width: 0;
  min-height: 28px;
  padding: 5px 8px;
  color: var(--text-secondary);
  border-color: rgba(173, 192, 255, 0.15);
  background: rgba(255, 255, 255, 0.055);
}

.model-page-layout .slot-photo-actions .btn-favorite-slot.is-favorite {
  color: #f6c75e;
  border-color: rgba(246, 199, 94, 0.52);
  background: rgba(246, 199, 94, 0.12);
}

.model-page-layout .slot-photo-actions .btn-unpin-slot {
  color: #ffaaa9;
  border-color: rgba(255, 113, 113, 0.25);
  background: rgba(255, 82, 82, 0.08);
}

.model-page-layout .slot-thumb-item {
  position: relative;
}

.model-page-layout .slot-thumb-item.is-favorite {
  border-color: #f6c75e;
  box-shadow: 0 0 0 1px rgba(246, 199, 94, 0.55), 0 5px 14px rgba(246, 199, 94, 0.16);
}

.model-page-layout .slot-favorite-star {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 3;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #1c1504;
  background: #f6c75e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.48);
  font-size: 12px;
  line-height: 1;
}

.slot-thumb-del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.88);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: all 0.15s ease;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.slot-thumb-item:hover .slot-thumb-del-btn {
  display: flex;
}

.slot-thumb-del-btn:hover {
  background: #ef4444;
  transform: scale(1.15);
}

@media (max-width: 760px) {
  .model-page-layout .slot-photo-actions {
    flex-wrap: wrap;
  }

  .model-page-layout .slot-photo-actions .btn-tiny-action {
    flex-basis: calc(50% - 4px);
  }
}

.model-page-layout #pane-ref-master > .slot-card,
.model-page-layout #pane-ref-split .slot-card,
.model-page-layout .model-slots-grid > .slot-clothing-card {
  height: 620px;
  min-height: 0;
}

.model-page-layout #pane-ref-split .slot-card,
.model-page-layout .model-slots-grid > .slot-clothing-card {
  display: flex;
  flex-direction: column;
}

.model-page-layout .slot-display-box {
  flex: 0 0 400px;
  height: 400px;
}

/* A full-size preview without distorting or cropping the selected source.
   Its own blurred image fills the wide stage behind the intact foreground. */
.model-page-layout .slot-media-wrap {
  isolation: isolate;
  background: #05070d;
}

.model-page-layout .slot-media-wrap::before {
  content: "";
  position: absolute;
  inset: -18px;
  z-index: -1;
  background: var(--slot-preview-image) center / cover no-repeat;
  filter: blur(22px) saturate(0.86);
  opacity: 0.52;
  transform: scale(1.08);
}

.model-page-layout .slot-media-wrap img {
  position: relative;
  z-index: 1;
}

.model-page-layout .slot-media-wrap .media-floating-tag {
  z-index: 2;
}

.model-page-layout .slot-thumbs-drawer,
.model-page-layout .clothing-body-wrapper {
  min-height: 0;
}

.model-page-layout .slot-thumbs-drawer,
.model-page-layout .clothing-body-wrapper {
  flex: 1 1 auto;
}

.model-page-layout .slot-thumbs-drawer,
.model-page-layout .clothing-body-wrapper {
  display: flex;
  flex-direction: column;
}

.model-page-layout .slot-thumb-grid {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  grid-auto-rows: 88px;
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
}

.model-page-layout .slot-thumb-item {
  aspect-ratio: auto;
  min-height: 0;
}

@media (max-width: 980px) {
  .model-page-layout .model-slots-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-page-layout #pane-ref-master,
  .model-page-layout #pane-ref-split,
  .model-page-layout .model-slots-grid > .slot-clothing-card,
  .model-page-layout .model-slots-grid > .traits-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .model-page-layout #pane-ref-split .split-slots-container {
    grid-template-columns: minmax(0, 1fr);
  }

  .model-page-layout #pane-ref-master > .slot-card,
  .model-page-layout #pane-ref-split .slot-card,
  .model-page-layout .model-slots-grid > .slot-clothing-card {
    height: 438px;
  }

  .model-page-layout .slot-display-box {
    flex-basis: 224px;
    height: 224px;
  }
}

/* Desktop reference stages follow the stable aspect ratio of their slot,
   rather than forcing every source into a shallow landscape strip. */
@media (min-width: 981px) {
  .model-page-layout #pane-ref-master > .slot-card,
  .model-page-layout #pane-ref-split .slot-card,
  .model-page-layout .model-slots-grid > .slot-clothing-card {
    height: auto;
  }

  .model-page-layout #master_card-display-box,
  .model-page-layout #face-display-box,
  .model-page-layout #body-display-box {
    flex: 0 0 auto;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .model-page-layout #clothing-display-box {
    flex: 0 0 auto;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .model-page-layout .slot-thumbs-drawer,
  .model-page-layout .clothing-body-wrapper {
    flex: 0 0 auto;
  }
}

/* Workspace controls: one compact visual language for the model page and
   the final send decision. The active choice is the same in both locations. */
.model-page-layout .model-page-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  align-items: center;
  gap: 24px;
  min-height: 128px;
  padding: 20px 24px;
  background:
    radial-gradient(circle at 8% 0, rgba(111, 115, 255, 0.13), transparent 42%),
    rgba(17, 24, 39, 0.76);
}

.model-page-layout .page-title-block,
.model-page-layout .model-title-presets-col {
  width: 100%;
}

.model-page-layout .model-title-presets-col {
  gap: 13px;
}

.model-page-layout .model-presets-row {
  gap: 12px;
}

.model-page-layout .presets-row-label {
  flex: 0 0 auto;
  color: #9aa8c5;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.model-page-layout .model-chips-row {
  min-width: 0;
  gap: 8px;
  padding: 2px;
  scroll-padding-inline: 2px;
}

.model-page-layout .model-avatar-card {
  flex: 0 0 64px;
  min-width: 64px;
  min-height: 62px;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  border-color: rgba(173, 192, 255, 0.14);
  border-radius: 11px;
  background: rgba(7, 12, 24, 0.56);
}

.model-page-layout .model-avatar-img-wrap {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(177, 190, 255, 0.2);
  border-radius: 8px;
  color: #e8ebff;
  background: linear-gradient(135deg, rgba(115, 105, 246, 0.42), rgba(54, 143, 246, 0.24));
  font-size: 10px;
  font-weight: 800;
}

.model-page-layout .model-avatar-title {
  display: block;
  width: 100%;
  overflow: hidden;
  color: #b9c4df;
  font-size: 9px;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-page-layout .model-avatar-card.active {
  border-color: rgba(133, 119, 255, 0.9);
  background: linear-gradient(145deg, rgba(102, 89, 237, 0.3), rgba(43, 85, 174, 0.18));
  box-shadow: 0 0 0 1px rgba(132, 119, 255, 0.24), 0 10px 22px rgba(56, 53, 151, 0.2);
}

.model-page-layout .model-avatar-card.active .model-avatar-title {
  color: #ffffff;
}

.model-page-layout .model-name-edit-row {
  gap: 9px;
}

.model-page-layout .input-model-wrap {
  height: 34px;
  flex: 1 1 300px;
  max-width: 430px;
  border-color: rgba(173, 192, 255, 0.18);
  border-radius: 9px;
  background: rgba(4, 8, 16, 0.58);
}

.model-page-layout .model-page-ref-card {
  width: 100%;
  justify-self: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(163, 177, 255, 0.18);
  border-radius: 13px;
  background: rgba(7, 12, 24, 0.62);
}

.model-page-layout .ref-mode-header {
  justify-content: space-between;
  padding: 0 3px;
}

.model-page-layout .ref-mode-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model-page-layout .ref-mode-status {
  color: #b7b3ff;
}

.model-page-layout .ref-mode-toggle-group,
.send-ref-mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(173, 192, 255, 0.12);
  border-radius: 10px;
  background: rgba(2, 5, 12, 0.56);
}

.model-page-layout .ref-mode-btn,
.send-ref-mode-option {
  justify-content: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #9eabc6;
  background: transparent;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.model-page-layout .ref-mode-btn:hover,
.send-ref-mode-option:hover {
  color: #edf1ff;
  background: rgba(255, 255, 255, 0.06);
}

.model-page-layout .ref-mode-btn.active,
.send-ref-mode-option.active {
  border-color: rgba(130, 115, 255, 0.66);
  color: #ffffff;
  background: linear-gradient(135deg, rgba(95, 84, 235, 0.78), rgba(86, 138, 239, 0.6));
  box-shadow: 0 4px 14px rgba(87, 82, 226, 0.26);
}

.model-page-layout .ref-mode-badge {
  display: none;
}

.send-ref-mode-picker {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  justify-content: center;
  min-width: 208px;
  gap: 4px;
}

.send-ref-mode-label {
  padding-left: 3px;
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.send-ref-mode-option {
  min-height: 30px;
  font-size: 10px;
}

@media (min-width: 981px) {
  /* Master mode shows exactly two equal cards: master card and clothing. */
  .model-page-layout .model-slots-grid.is-master-mode {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-page-layout .model-slots-grid.is-master-mode #pane-ref-master {
    grid-column: 1;
  }

  .model-page-layout .model-slots-grid.is-master-mode > .slot-clothing-card {
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  .model-page-layout .model-page-topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 15px;
  }

  .model-page-layout .model-presets-row,
  .model-page-layout .model-name-edit-row {
    flex-wrap: wrap;
  }

  .model-page-layout .model-chips-row {
    width: 100%;
    order: 3;
  }

  .model-page-layout .input-model-wrap {
    flex-basis: 100%;
  }

  .send-ref-mode-picker {
    flex: 1 1 100%;
    min-width: 0;
  }
}

/* ==========================================================================
   11. HELP MODAL, BOOKMARKLET & EASY BRIDGE STYLES
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-glass-window {
  background: #0d121c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.05);
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 88vh;
  animation: modal-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.help-methods-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.help-method-card {
  background: rgba(22, 27, 34, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 18px;
  transition: all 0.2s ease;
}
.help-method-card:hover {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(22, 27, 34, 0.9);
}
.help-method-card.featured {
  background: linear-gradient(145deg, rgba(30, 58, 138, 0.2), rgba(15, 23, 42, 0.7));
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 24px rgba(30, 58, 138, 0.2);
}
.help-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.help-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #f0f6fc;
}
.help-badge-speed {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(35, 134, 54, 0.25);
  border: 1px solid rgba(35, 134, 54, 0.5);
  color: #3fb950;
  font-weight: 600;
}
.help-badge-auto {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  font-weight: 600;
}
.help-card-desc {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 12px;
}
.bookmarklet-drag-container {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(13, 17, 23, 0.95);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px dashed rgba(59, 130, 246, 0.5);
  margin-bottom: 12px;
}
.bookmarklet-drag-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none !important;
  cursor: grab;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: all;
  white-space: nowrap;
}
.bookmarklet-drag-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.6);
}
.bookmarklet-drag-pill:active {
  cursor: grabbing;
}
.bookmarklet-hint {
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.4;
}
.bookmarklet-hint strong {
  color: #60a5fa;
}
.btn-copy-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy-action:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn-download-extension {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #238636, #1f7730);
  color: #ffffff !important;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none !important;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(35, 134, 54, 0.35);
}
.btn-download-extension:hover {
  background: linear-gradient(135deg, #2ea043, #238636);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(35, 134, 54, 0.5);
}
.ext-steps-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ext-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: #94a3b8;
}
.ext-step-item strong {
  color: #f0f6fc;
}
.ext-step-badge {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.details-dev-console {
  margin-top: 10px;
  background: rgba(13, 17, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 14px;
}
.details-dev-console summary {
  font-size: 12.5px;
  color: #8b949e;
  cursor: pointer;
  outline: none;
  user-select: none;
}
.details-dev-console summary:hover {
  color: #c9d1d9;
}

/* ==========================================================================
   12. STAGE WORKSPACE SPLIT (TARGET PANEL + CONVERSATION CHAT STREAM)
   ========================================================================== */
.stage-workspace-split {
  display: flex;
  gap: 12px;
  flex: 1 1 0;
  min-height: 240px;
  max-height: calc(100vh - 280px);
  overflow: hidden;
  margin-bottom: 8px;
}

/* --- LEFT: TARGET PHOTO DOCK PANEL --- */
.stage-target-panel {
  width: 250px;
  flex-shrink: 0;
  background: rgba(13, 17, 24, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stage-target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stage-target-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #f0f6fc;
}

.stage-target-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stage-target-dropzone {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: 320px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.stage-target-dropzone:hover {
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(15, 23, 42, 0.5);
}

.stage-target-dropzone.drag-over {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.18) !important;
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.3) !important;
}

.stage-target-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 10px;
  gap: 6px;
  user-select: none;
}

.drop-icon-pulse {
  color: #3b82f6;
  margin-bottom: 2px;
  animation: pulse-slow 2.4s infinite ease-in-out;
}

@keyframes pulse-slow {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}

.drop-text-primary {
  font-size: 11.5px;
  font-weight: 700;
  color: #e2e8f0;
}

.drop-text-sub {
  font-size: 10px;
  color: #94a3b8;
}

.drop-text-sub kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 9.5px;
  color: #60a5fa;
}

.drop-hint-pill {
  font-size: 9px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  margin-top: 4px;
}

.stage-target-filled {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.stage-target-img-wrap {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 140px;
  max-height: 240px;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stage-target-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.stage-target-img-wrap:hover img {
  transform: scale(1.03);
}

.target-status-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(59, 130, 246, 0.5);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #60a5fa;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stage-target-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 4px;
}

.stage-target-name {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.stage-target-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.stage-target-directives-summary {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 9.5px;
  font-weight: 700;
  color: #8b949e;
  letter-spacing: 0.05em;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.micro-chip {
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b949e;
  transition: all 0.15s;
}

.micro-chip.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

/* --- RIGHT: CHAT CONSOLE PANEL --- */
.stage-chat-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(13, 17, 24, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stage-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(22, 27, 34, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.chat-header-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #cbd5e1;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-counter-badge {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 10px;
}

/* --- CONVERSATION BUBBLES --- */
.chat-bubble.user-bubble {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.25) 0%, rgba(15, 23, 42, 0.6) 100%);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
  align-self: stretch;
  max-width: 100%;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.bubble-meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 4px;
}

.bubble-user-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #60a5fa;
}

.bubble-model-badge {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  font-weight: 700;
}

.bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 2px 6px 2px 2px;
  font-size: 10px;
  font-weight: 600;
  color: #cbd5e1;
}

.attachment-thumb {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}

.attachment-label {
  font-size: 9.5px;
  color: #94a3b8;
}

.user-bubble-text {
  font-size: 11.5px;
  color: #e2e8f0;
  line-height: 1.45;
  margin: 0;
}

/* Prompt Preview Details Box inside User Bubble */
.user-bubble-prompt-preview {
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 10px;
}

.user-bubble-prompt-preview summary {
  font-size: 10.5px;
  color: #60a5fa;
  cursor: pointer;
  outline: none;
  user-select: none;
  font-weight: 600;
}

.user-bubble-prompt-preview pre {
  margin-top: 6px;
  font-size: 10px;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', Consolas, monospace;
}

/* ASSISTANT BUBBLE (GENERATION RESULT) */
.chat-bubble.assistant-bubble {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  align-self: stretch;
  max-width: 100%;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.gen-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
}

.gen-model-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #cbd5e1;
}

.gen-model-tag strong {
  color: #38bdf8;
}

.gen-time {
  font-size: 10px;
  color: #94a3b8;
}

.generated-photo-stage {
  position: relative;
  width: 100%;
  max-height: 480px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.generated-photo-stage:hover {
  border-color: rgba(59, 130, 246, 0.5);
}

.generated-photo-stage img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 6px;
}

/* Photo Action Toolbar */
.stage-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(13, 17, 24, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.btn-action-regen {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.3), rgba(29, 78, 216, 0.4)) !important;
  border: 1px solid rgba(59, 130, 246, 0.5) !important;
  color: #93c5fd !important;
  font-weight: 700 !important;
}

.btn-action-regen:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.5), rgba(29, 78, 216, 0.6)) !important;
  color: #ffffff !important;
  border-color: #60a5fa !important;
}

.btn-action-refine {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(126, 34, 206, 0.35)) !important;
  border: 1px solid rgba(168, 85, 247, 0.45) !important;
  color: #d8b4fe !important;
  font-weight: 700 !important;
}

.btn-action-refine:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.45), rgba(126, 34, 206, 0.55)) !important;
  color: #ffffff !important;
  border-color: #c084fc !important;
}

.btn-action-star {
  color: #fbbf24 !important;
}

/* Inline Refinement Input Box */
.chat-refine-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 8px;
  animation: slide-toast 0.2s ease;
}

.chat-refine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-refine-title {
  font-size: 11px;
  font-weight: 700;
  color: #c084fc;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-refine-input-row {
  display: flex;
  gap: 6px;
}

.chat-refine-input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 11.5px;
  outline: none;
}

.chat-refine-input:focus {
  border-color: #a855f7;
}

.chat-refine-submit-btn {
  padding: 6px 12px;
  background: #7c3aed;
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.chat-refine-submit-btn:hover {
  background: #6d28d9;
}

.chat-refine-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.refine-quick-tag {
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s;
}

.refine-quick-tag:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
}

@media (max-width: 1200px) {
  .stage-workspace-split {
    flex-direction: column;
  }
  .stage-target-panel {
    width: 100%;
    max-height: 200px;
  }
}

/* ==========================================================================
   MODULES 1-5: WARDROBE, BATCH, INPAINTING, HISTORY, TARGET MODES
   ========================================================================== */

/* Target Transfer Mode Chips */
.target-mode-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
  border-radius: 8px;
}
.target-mode-chip:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}
.target-mode-chip.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(168, 85, 247, 0.25)) !important;
  border-color: #818cf8 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

/* Batch Count Options */
#batch-selector-box .send-ref-mode-options {
  display: flex;
  gap: 2px;
}
#batch-selector-box .send-ref-mode-option {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
#batch-selector-box .send-ref-mode-option:hover {
  color: #f1f5f9;
}
#batch-selector-box .send-ref-mode-option.active {
  background: #3b82f6;
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

/* Wardrobe Page Layout */
.wardrobe-page-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  padding: 24px;
  gap: 18px;
  box-sizing: border-box;
}
.wardrobe-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px 20px;
  backdrop-filter: blur(12px);
}
.wardrobe-title-block {
  display: flex;
  align-items: center;
  gap: 14px;
}
.wardrobe-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wardrobe-chip {
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
}
.wardrobe-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}
.wardrobe-chip.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  color: #ffffff !important;
  border-color: #a78bfa !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
}

.wardrobe-content-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.wardrobe-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}
.wardrobe-card:hover {
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.wardrobe-card-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #020617;
  overflow: hidden;
}
.wardrobe-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.wardrobe-card:hover .wardrobe-card-img {
  transform: scale(1.03);
}
.wardrobe-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(6px);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
}
.wardrobe-card-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.wardrobe-card:hover .wardrobe-card-delete-btn {
  opacity: 1;
}
.wardrobe-card-delete-btn:hover {
  background: #ef4444;
  color: #fff;
}
.wardrobe-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.wardrobe-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.3;
}
.wardrobe-card-prompt-snippet {
  font-size: 11px;
  color: #94a3b8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}
.wardrobe-card-actions {
  margin-top: auto;
}
.btn-equip-outfit {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-equip-outfit:hover {
  background: linear-gradient(135deg, #4338ca, #6d28d9);
  box-shadow: 0 0 12px rgba(79, 70, 229, 0.4);
}

/* History Journal Cards */
.history-card {
  display: flex;
  gap: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px;
  transition: all 0.2s ease;
}
.history-card:hover {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(255, 255, 255, 0.12);
}
.history-card-thumb-link {
  width: 72px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #020617;
  display: block;
}
.history-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.history-card:hover .history-card-thumb {
  transform: scale(1.05);
}
.history-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-card-model-badge {
  font-size: 10px;
  font-weight: 700;
  color: #818cf8;
  background: rgba(99, 102, 241, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}
.history-card-time {
  font-size: 10px;
  color: #64748b;
}
.history-card-prompt {
  font-size: 11px;
  color: #cbd5e1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.history-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

/* Inpainting UI */
.inpaint-preset-chip {
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.inpaint-preset-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f1f5f9;
}
.inpaint-preset-chip.active {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(168, 85, 247, 0.2)) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}



/* ==========================================================================
   SH0X AI MODEL STUDIO - COMMERCIAL MASTER DESIGN SYSTEM & LAYOUT OVERHAUL
   Enterprise-grade density, responsive flow, compact UI tokens & accessibility
   ========================================================================== */

:root {
  --header-h: 46px;
  --bg-app: #07090e;
  --bg-header: rgba(9, 13, 20, 0.96);
  --bg-panel: #0d1119;
  --bg-card: #121722;
  --bg-card-hover: #182030;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.12);
  --border-active: #6366f1;
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.3);
}

/* 1. APP HEADER & NAVIGATION BAR */
.app-header {
  height: var(--header-h) !important;
  min-height: var(--header-h) !important;
  padding: 0 16px !important;
  background: var(--bg-header) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  z-index: 100 !important;
}

.brand-gem {
  width: 24px !important;
  height: 24px !important;
}
.brand-gem svg {
  width: 100% !important;
  height: 100% !important;
}
.brand-title {
  font-size: 13px !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px !important;
}
.brand-sub {
  font-size: 9px !important;
  color: #64748b !important;
  font-weight: 600 !important;
}
.model-badge-pill {
  padding: 3px 8px !important;
  height: 24px !important;
  font-size: 11px !important;
  border-radius: 9999px !important;
}

.header-nav-tabs {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  background: rgba(10, 15, 26, 0.65) !important;
  padding: 4px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
}
.nav-tab-btn {
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #94a3b8 !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  transition: all 0.18s ease !important;
  cursor: pointer !important;
  white-space: nowrap !important;
}
.nav-tab-btn:hover {
  color: #f1f5f9 !important;
  background: rgba(255, 255, 255, 0.04) !important;
}
.nav-tab-btn.active {
  color: #ffffff !important;
  background: rgba(99, 102, 241, 0.18) !important;
  border-color: rgba(99, 102, 241, 0.45) !important;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.25) !important;
}
.nav-tab-btn .tab-badge,
.nav-tab-btn .tab-badge-glow {
  font-size: 10px !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
}

/* 2. GENERATOR PAGE WORKSPACE (PAGE 2) */
.generate-page-layout {
  display: grid !important;
  grid-template-columns: 270px minmax(0, 1fr) !important;
  gap: 12px !important;
  padding: 12px !important;
  height: calc(100vh - var(--header-h)) !important;
  max-height: calc(100vh - var(--header-h)) !important;
  overflow: hidden !important;
}

/* LEFT SIDEBAR: DIRECTIVES & PRESETS */
.generate-directives-col {
  width: 270px !important;
  max-width: 270px !important;
  overflow-y: auto !important;
  border-radius: 12px !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  display: flex !important;
  flex-direction: column !important;
}
.generate-directives-col .panel-header {
  padding: 10px 12px !important;
  min-height: 40px !important;
}
.generate-directives-col .panel-header h2 {
  font-size: 13px !important;
  font-weight: 700 !important;
}
.directives-content {
  padding: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

/* Hide verbose snippet debug boxes in sidebar */
.directive-snippet-box {
  display: none !important;
}

/* Compact Target Transfer Mode Chips */
.target-transfer-mode-box {
  padding: 10px !important;
  margin-bottom: 10px !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-sizing: border-box !important;
  width: 100% !important;
  overflow: hidden !important;
}
.target-transfer-chips {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
.target-mode-chip {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  padding: 4px 8px !important;
  font-size: 11px !important;
  height: 30px !important;
  min-width: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  border-radius: 8px !important;
}
.target-mode-chip .mode-icon {
  margin-right: 4px !important;
  flex-shrink: 0 !important;
}
.target-mode-chip .mode-text,
.target-mode-chip span:last-child {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Compact Directive Cards */
.directive-feature-card {
  padding: 6px !important;
  margin-bottom: 6px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 8px !important;
}
.target-chip {
  padding: 4px 8px !important;
  height: 26px !important;
  font-size: 11px !important;
}
.alt-chips-grid {
  gap: 4px !important;
  margin-top: 6px !important;
}
.alt-chip {
  padding: 3px 6px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
}

/* MAIN STAGE (CENTER/RIGHT) */
.generate-stage-col {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  gap: 8px !important;
}

/* Stage Top Bar */
.stage-topbar {
  flex-shrink: 0 !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 10px !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
.aspect-selector {
  gap: 4px !important;
}
.aspect-btn {
  height: 26px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
}
.stage-floating-hud {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.hud-btn, .hud-badge-pill {
  height: 26px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
}

/* Split Area: Target Dock (Left) + Chat Stream (Right) */
.stage-workspace-split {
  display: flex !important;
  gap: 10px !important;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
}

/* Target Panel (Compact Portrait Dock) */
.stage-target-panel {
  width: 215px !important;
  flex-shrink: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}
.stage-target-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 8px 10px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  gap: 6px !important;
  min-width: 0 !important;
}
.stage-target-title {
  display: flex !important;
  align-items: center !important;
  gap: 5px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: #f0f6fc !important;
  white-space: nowrap !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
.stage-target-title-text {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.stage-target-actions {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}
.stage-target-actions .btn-micro,
.stage-target-actions .btn-upload-label {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 24px !important;
  padding: 0 7px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  color: #c7d2fe !important;
  background: rgba(99, 102, 241, 0.12) !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  transition: all 0.15s ease !important;
}
.stage-target-actions .btn-folder-pick {
  color: #94a3b8 !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
}
.stage-target-actions .upload-btn-text {
  white-space: nowrap !important;
  display: inline-block !important;
}
.stage-target-dropzone {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  padding: 8px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}
.stage-target-img-wrap {
  width: 100% !important;
  aspect-ratio: 3/4 !important;
  max-height: 220px !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  position: relative !important;
  background: #03060c !important;
  margin: 0 auto !important;
}
.stage-target-img-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}
.stage-target-directives-summary {
  background: rgba(0, 0, 0, 0.35) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
  padding: 8px 10px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  box-sizing: border-box !important;
  width: 100% !important;
}
.stage-target-directives-summary .summary-label {
  font-size: 9.5px !important;
  font-weight: 700 !important;
  color: #8b949e !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
}
.stage-target-directives-summary .summary-chips {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 5px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
.stage-target-directives-summary .micro-chip {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 3px 6px !important;
  height: 24px !important;
  font-size: 10.5px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #94a3b8 !important;
  white-space: nowrap !important;
  transition: all 0.15s ease !important;
}
.stage-target-directives-summary .micro-chip.active {
  background: rgba(59, 130, 246, 0.18) !important;
  border-color: rgba(59, 130, 246, 0.45) !important;
  color: #93c5fd !important;
}

/* Chat Stream & Stage Console */
.stage-chat-panel {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}
.stage-chat-header {
  padding: 6px 12px !important;
  min-height: 34px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}
.chat-viewport {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 14px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

/* Generated Image in Bubble */
.chat-bubble {
  max-width: 90% !important;
}
.chat-bubble img,
.chat-bubble .generated-preview-image {
  max-height: 460px !important;
  width: auto !important;
  max-width: 100% !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  display: block !important;
  margin: 6px 0 !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5) !important;
}

/* LIVE PROMPT TERMINAL: COMPACT SLICK DRAWER */
.live-prompt-terminal {
  flex: 0 0 auto !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  overflow: hidden !important;
  background: rgba(10, 14, 22, 0.9) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 10px !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.prompt-terminal-header {
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: transparent !important;
  border-bottom: none !important;
}
.terminal-title {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: #cbd5e1 !important;
}
.terminal-chars {
  font-size: 10px !important;
  color: #64748b !important;
}

/* Collapsed by default: hide inner content */
.live-prompt-terminal:not(.is-expanded):not(.expanded) .terminal-editor-wrap,
.live-prompt-terminal:not(.is-expanded):not(.expanded) .terminal-reassurance-bar {
  display: none !important;
}

/* Expanded state */
.live-prompt-terminal.is-expanded,
.live-prompt-terminal.expanded {
  height: 220px !important;
  max-height: 220px !important;
}
.live-prompt-terminal.is-expanded .prompt-terminal-header,
.live-prompt-terminal.expanded .prompt-terminal-header {
  border-bottom: 1px solid var(--border-subtle) !important;
}
.live-prompt-terminal.is-expanded .terminal-editor-wrap,
.live-prompt-terminal.expanded .terminal-editor-wrap {
  display: block !important;
  height: 120px !important;
  overflow: auto !important;
}
.live-prompt-terminal.is-expanded .terminal-reassurance-bar,
.live-prompt-terminal.expanded .terminal-reassurance-bar {
  display: block !important;
}

/* ACTION CONSOLE (SEND ROW) */
.prompt-action-bar {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 10px !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
}
.prompt-textarea-box {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.prompt-textarea-box textarea {
  width: 100% !important;
  height: 38px !important;
  min-height: 38px !important;
  max-height: 38px !important;
  resize: none !important;
  padding: 8px 10px !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
  border-radius: 8px !important;
  background: rgba(3, 6, 12, 0.8) !important;
  border: 1px solid var(--border-subtle) !important;
  color: #f8fafc !important;
}
.prompt-side-buttons {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
}
.send-ref-mode-picker {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  background: rgba(255, 255, 255, 0.03) !important;
  padding: 3px 6px !important;
  border-radius: 8px !important;
  border: 1px solid var(--border-subtle) !important;
}
.send-ref-mode-label {
  font-size: 10px !important;
  font-weight: 700 !important;
  color: #64748b !important;
  text-transform: uppercase !important;
}
.send-ref-mode-option {
  height: 24px !important;
  padding: 0 6px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 5px !important;
}
#btn-send-prompt {
  height: 38px !important;
  padding: 0 16px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35) !important;
  border: none !important;
  cursor: pointer !important;
  white-space: nowrap !important;
}

/* 3. MODEL PAGE WORKSPACE (PAGE 1) */
.model-page-layout {
  padding: 14px 18px !important;
  gap: 12px !important;
  max-width: 1400px !important;
  margin: 0 auto !important;
  width: 100% !important;
  height: calc(100vh - var(--header-h)) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
.model-page-topbar {
  flex-shrink: 0 !important;
  padding: 10px 14px !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
}
.model-slots-grid {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
.model-slots-grid.is-master-mode {
  display: grid !important;
  grid-template-columns: minmax(0, 380px) minmax(0, 380px) !important;
  justify-content: center !important;
  gap: 20px !important;
  padding: 10px 0 !important;
}
.model-page-layout .slot-card {
  height: 100% !important;
  max-height: calc(100vh - 190px) !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
}
.model-page-layout .slot-media-wrap {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 3/4 !important;
}
.model-page-layout .slot-media-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* 4. WARDROBE PAGE WORKSPACE (PAGE 3) */
.wardrobe-page-layout {
  padding: 14px 20px !important;
  gap: 12px !important;
  max-width: 1360px !important;
  margin: 0 auto !important;
  width: 100% !important;
  height: calc(100vh - var(--header-h)) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
.wardrobe-topbar {
  flex-shrink: 0 !important;
  padding: 10px 16px !important;
  background: var(--bg-panel) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
}
.wardrobe-filter-bar {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}
.wardrobe-chip {
  height: 28px !important;
  padding: 0 10px !important;
  font-size: 11px !important;
}
.wardrobe-content-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
.wardrobe-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)) !important;
  gap: 14px !important;
  padding-bottom: 20px !important;
}
.wardrobe-card {
  border-radius: 12px !important;
  background: rgba(15, 23, 42, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
  transition: transform 0.2s ease, border-color 0.2s ease !important;
}
.wardrobe-card:hover {
  border-color: rgba(99, 102, 241, 0.5) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}
.wardrobe-card-thumb-wrap,
.wardrobe-card-img-wrap {
  position: relative !important;
  width: 100% !important;
  aspect-ratio: 3/4 !important;
  background: #020617 !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
}
.wardrobe-card-thumb-wrap img,
.wardrobe-card-img,
.wardrobe-card-img-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  transition: transform 0.3s ease !important;
}
.wardrobe-card:hover .wardrobe-card-img {
  transform: scale(1.03) !important;
}
.wardrobe-card-badge {
  position: absolute !important;
  top: 8px !important;
  left: 8px !important;
  background: rgba(0, 0, 0, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(6px) !important;
  padding: 3px 8px !important;
  border-radius: 6px !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  color: #e2e8f0 !important;
  z-index: 2 !important;
}
.wardrobe-card-delete-btn {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  width: 26px !important;
  height: 26px !important;
  border-radius: 6px !important;
  background: rgba(0, 0, 0, 0.75) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  color: #ef4444 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 2 !important;
}
.wardrobe-card-body {
  padding: 10px 12px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  flex: 1 1 auto !important;
  background: rgba(13, 17, 24, 0.75) !important;
}
.wardrobe-card-title {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #f1f5f9 !important;
}
.wardrobe-card-prompt-snippet {
  font-size: 11px !important;
  color: #94a3b8 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  line-height: 1.4 !important;
}
.btn-equip-outfit {
  width: 100% !important;
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
  color: #ffffff !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
}
.btn-equip-outfit:hover {
  background: linear-gradient(135deg, #4338ca, #6d28d9) !important;
  box-shadow: 0 0 12px rgba(79, 70, 229, 0.4) !important;
}

/* 5. VAULT & GALLERY (PAGE 4) */
.vault-page-layout {
  padding: 14px 20px !important;
  gap: 14px !important;
  max-width: 1440px !important;
  margin: 0 auto !important;
  width: 100% !important;
  height: calc(100vh - var(--header-h)) !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) !important;
  overflow: hidden !important;
}
.compare-stage {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #020408 !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  position: relative !important;
  padding: 12px !important;
}
.compare-frame {
  width: 100% !important;
  height: 100% !important;
  max-width: 860px !important;
  max-height: calc(100vh - 220px) !important;
  aspect-ratio: 3/4 !important;
  position: relative !important;
  overflow: hidden !important;
  background: #000000 !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7) !important;
  --compare-pos: 50%;
}
.compare-layer {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  pointer-events: none !important;
  user-select: none !important;
}
.compare-layer-before {
  z-index: 2 !important;
  clip-path: polygon(0 0, var(--compare-pos, 50%) 0, var(--compare-pos, 50%) 100%, 0 100%) !important;
}
.compare-layer-after {
  z-index: 1 !important;
}
.compare-divider {
  position: absolute !important;
  top: 0 !important;
  bottom: 0 !important;
  left: var(--compare-pos, 50%) !important;
  width: 2px !important;
  background: #6366f1 !important;
  transform: translateX(-50%) !important;
  z-index: 10 !important;
  pointer-events: none !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.9), 0 0 2px #ffffff !important;
}
.compare-knob {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  background: #6366f1 !important;
  border: 2px solid #ffffff !important;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.95), 0 4px 10px rgba(0, 0, 0, 0.6) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #ffffff !important;
  pointer-events: none !important;
}
.compare-knob svg {
  width: 12px !important;
  height: 12px !important;
  fill: currentColor !important;
}
.compare-range-input {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  cursor: ew-resize !important;
  z-index: 20 !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.compare-pill-tag {
  position: absolute !important;
  top: 14px !important;
  z-index: 15 !important;
  padding: 5px 12px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.3px !important;
  border-radius: 20px !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5) !important;
  pointer-events: none !important;
  user-select: none !important;
}
.compare-pill-tag.tag-left {
  left: 14px !important;
  background: rgba(10, 15, 26, 0.85) !important;
  color: #f8fafc !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}
.compare-pill-tag.tag-right {
  right: 14px !important;
  background: rgba(10, 15, 26, 0.85) !important;
  color: #38bdf8 !important;
  border-color: rgba(56, 189, 248, 0.5) !important;
}
/* Suppress broken image markers */
img[src=""], img:not([src]) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.wardrobe-card.wardrobe-card-add {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px dashed rgba(99, 102, 241, 0.35) !important;
  background: rgba(99, 102, 241, 0.04) !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  min-height: 280px !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.wardrobe-card.wardrobe-card-add:hover {
  background: rgba(99, 102, 241, 0.09) !important;
  border-color: rgba(99, 102, 241, 0.7) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15) !important;
}
.wardrobe-add-inner {
  text-align: center;
  padding: 24px 16px;
}
.wardrobe-add-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.wardrobe-add-title {
  font-size: 13px;
  font-weight: 700;
  color: #c7d2fe;
  margin-bottom: 4px;
}
.wardrobe-add-desc {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* 6. UNIVERSAL RESPONSIVE BREAKPOINTS */
@media (max-width: 1024px) and (min-width: 769px) {
  .generate-page-layout {
    grid-template-columns: 240px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 8px !important;
  }
  .stage-target-panel {
    width: 170px !important;
  }
  .stage-target-img-wrap {
    max-height: 180px !important;
  }
  .vault-page-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
  }
  .app-layout {
    height: auto !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
  .studio-pages-container, .studio-page {
    height: auto !important;
    min-height: calc(100vh - 56px) !important;
    overflow-y: visible !important;
  }
  .app-header {
    height: auto !important;
    padding: 8px 10px 6px 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .header-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
  }
  .brand-gem {
    width: 28px !important;
    height: 28px !important;
  }
  .brand-text {
    display: flex !important;
    flex-direction: column !important;
  }
  .brand-title {
    font-size: 13px !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
  }
  .brand-sub {
    display: none !important;
  }
  .model-badge-pill {
    display: inline-flex !important;
    height: 22px !important;
    padding: 0 6px !important;
    font-size: 10px !important;
  }
  .header-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 0 0 auto !important;
  }
  .header-nav-tabs {
    order: 3 !important;
    width: 100% !important;
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding: 2px 0 4px 0 !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .header-nav-tabs::-webkit-scrollbar {
    display: none !important;
  }
  .nav-tab-btn {
    flex-shrink: 0 !important;
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 11px !important;
  }
  
  /* GENERATOR MOBILE FLOW */
  .generate-page-layout {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 8px !important;
    gap: 12px !important;
  }
  .generate-stage-col {
    order: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
    gap: 10px !important;
  }
  .stage-topbar {
    height: auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 8px 10px !important;
  }
  .aspect-buttons-row {
    justify-content: center !important;
  }
  .stage-floating-hud {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }
  
  /* WORKSPACE SPLIT: STACK ON MOBILE WITH EXPLICIT HEIGHT */
  .stage-workspace-split {
    display: flex !important;
    flex-direction: column !important;
    flex: none !important;
    height: auto !important;
    min-height: unset !important;
    max-height: none !important;
    overflow: visible !important;
    gap: 12px !important;
  }
  .stage-target-panel {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    flex: none !important;
    overflow: visible !important;
  }
  .stage-target-dropzone {
    min-height: 110px !important;
    padding: 10px !important;
  }
  .stage-target-filled {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    align-items: center !important;
    padding: 6px !important;
  }
  .stage-target-img-wrap {
    flex: 0 0 84px !important;
    width: 84px !important;
    min-width: 84px !important;
    max-width: 84px !important;
    height: 112px !important;
    max-height: 112px !important;
    aspect-ratio: 3/4 !important;
    margin: 0 !important;
  }
  .stage-target-meta {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  .stage-chat-panel {
    width: 100% !important;
    max-width: 100% !important;
    height: 420px !important;
    min-height: 360px !important;
    flex: none !important;
    overflow: hidden !important;
  }
  .chat-viewport {
    height: 350px !important;
    min-height: 300px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
  }
  
  /* PROMPT TERMINAL ON MOBILE */
  .live-prompt-terminal {
    width: 100% !important;
    max-width: 100% !important;
  }
  .prompt-terminal-header {
    flex-wrap: wrap !important;
    height: auto !important;
    min-height: 36px !important;
    padding: 6px 10px !important;
    gap: 6px !important;
  }
  .terminal-header-right {
    display: flex !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
  }
  
  /* ACTION BAR ON MOBILE */
  .prompt-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px !important;
  }
  .prompt-textarea-box {
    width: 100% !important;
  }
  .prompt-textarea-box textarea {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
  }
  .prompt-side-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }
  .send-ref-mode-picker {
    flex: 1 1 auto !important;
    justify-content: center !important;
  }
  .btn-send {
    width: 100% !important;
    height: 44px !important;
    font-size: 13px !important;
    margin-top: 4px !important;
  }

  /* DIRECTIVES SIDEBAR: BELOW STAGE ON MOBILE */
  .generate-directives-col {
    order: 2 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
  }
  
  /* MODEL PAGE ON MOBILE */
  .model-page-layout {
    height: auto !important;
    overflow: visible !important;
    padding: 10px !important;
    gap: 12px !important;
  }
  .model-slots-grid.is-master-mode,
  .model-slots-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  
  /* WARDROBE ON MOBILE */
  .wardrobe-page-layout {
    height: auto !important;
    overflow: visible !important;
    padding: 10px !important;
    gap: 12px !important;
  }
  .wardrobe-topbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .wardrobe-actions-top button {
    width: 100% !important;
  }
  .wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 10px !important;
  }

  /* VAULT ON MOBILE */
  .vault-page-layout {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
    padding: 10px !important;
    gap: 12px !important;
  }
  .vault-compare-panel {
    min-height: 420px !important;
  }
}

/* ==========================================================================
   7. 2K QHD (2560x1440) & ULTRAWIDE (3440x1440) OPTIMIZATIONS
   ========================================================================== */
@media (min-width: 1800px) {
  :root {
    --header-h: 52px;
  }

  /* Header */
  .app-header {
    height: 52px !important;
    padding: 0 24px !important;
  }
  .brand-gem {
    width: 32px !important;
    height: 32px !important;
  }
  .brand-title {
    font-size: 15px !important;
    letter-spacing: 0.8px !important;
  }
  .brand-sub {
    font-size: 9px !important;
  }
  .model-badge-pill {
    height: 28px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
  }
  .nav-tab-btn {
    height: 36px !important;
    padding: 0 16px !important;
    font-size: 12.5px !important;
    gap: 8px !important;
  }
  .status-pill {
    height: 28px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
  }
  .header-btn {
    width: 34px !important;
    height: 34px !important;
  }

  /* PAGE 2: GENERATOR ON 2K / ULTRAWIDE */
  .generate-page-layout {
    grid-template-columns: 320px minmax(0, 1fr) !important;
    gap: 16px !important;
    padding: 16px 20px !important;
    height: calc(100vh - 52px) !important;
  }

  /* Left Directives Column: Generous & Readable */
  .generate-directives-col {
    width: 320px !important;
    max-width: 320px !important;
  }
  .generate-directives-col .panel-header h2 {
    font-size: 14px !important;
  }
  .target-mode-chip {
    height: 30px !important;
    font-size: 11.5px !important;
  }
  .target-chip {
    height: 28px !important;
    font-size: 11.5px !important;
    padding: 4px 10px !important;
  }
  .alt-chip {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }

  /* Center Stage */
  .generate-stage-col {
    gap: 10px !important;
  }
  .stage-topbar {
    height: 42px !important;
    padding: 0 14px !important;
  }
  .aspect-btn {
    height: 28px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
  }
  .hud-btn, .hud-badge-pill {
    height: 28px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
  }

  /* Target Panel: Substantial High-Res Inspection Dock */
  .stage-target-panel {
    width: 300px !important;
    flex-shrink: 0 !important;
    padding: 12px !important;
  }
  .stage-target-header {
    padding: 8px 12px !important;
    font-size: 12px !important;
  }
  .stage-target-img-wrap {
    width: 100% !important;
    aspect-ratio: 3/4 !important;
    max-height: 380px !important;
    border-radius: 10px !important;
  }
  .stage-target-meta {
    padding: 8px 4px 4px 4px !important;
  }
  .stage-target-name {
    font-size: 12px !important;
  }
  .stage-target-btns button {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
  }
  .stage-target-directives-summary {
    padding: 8px 10px !important;
    font-size: 11px !important;
  }
  .stage-target-directives-summary .micro-chip {
    padding: 4px 8px !important;
    font-size: 11px !important;
    width: 100% !important;
    justify-content: center !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  /* Stage Chat Panel & High-Res Previews */
  .stage-chat-header {
    padding: 8px 16px !important;
    min-height: 38px !important;
  }
  .chat-header-title {
    font-size: 12.5px !important;
  }
  .chat-viewport {
    padding: 20px !important;
    gap: 16px !important;
  }
  .chat-bubble {
    max-width: 960px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  .chat-bubble-content {
    font-size: 13.5px !important;
    line-height: 1.6 !important;
  }
  .chat-bubble img,
  .chat-bubble .generated-preview-image {
    max-height: 600px !important;
    border-radius: 12px !important;
  }

  /* Live Prompt Terminal Drawer */
  .live-prompt-terminal {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    border-radius: 10px !important;
  }
  .prompt-terminal-header {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 14px !important;
  }
  .terminal-title {
    font-size: 12px !important;
  }
  .terminal-chars {
    font-size: 11px !important;
  }
  .live-prompt-terminal.is-expanded,
  .live-prompt-terminal.expanded {
    height: 260px !important;
    max-height: 260px !important;
  }
  .live-prompt-terminal.is-expanded .terminal-editor-wrap,
  .live-prompt-terminal.expanded .terminal-editor-wrap {
    height: 150px !important;
  }

  /* Action Console (Send Bar) */
  .prompt-action-bar {
    padding: 10px 14px !important;
    border-radius: 14px !important;
    gap: 12px !important;
  }
  .prompt-textarea-box textarea {
    height: 44px !important;
    min-height: 44px !important;
    font-size: 13.5px !important;
  }
  .btn-send {
    height: 44px !important;
    padding: 0 24px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
  }
  .send-ref-mode-option {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 12px !important;
  }

  /* PAGE 1: MODEL PAGE ON 2K */
  .model-page-layout {
    max-width: 2000px !important;
    padding: 20px 24px !important;
    gap: 18px !important;
    height: calc(100vh - 52px) !important;
  }
  .model-topbar {
    padding: 12px 18px !important;
  }
  .model-preset-name-input {
    height: 36px !important;
    font-size: 13px !important;
  }
  .model-slots-grid.is-master-mode {
    grid-template-columns: minmax(0, 520px) minmax(0, 520px) !important;
    gap: 24px !important;
  }
  .model-page-layout #pane-ref-master > .slot-card,
  .model-page-layout .model-slots-grid > .slot-clothing-card {
    max-height: calc(100vh - 170px) !important;
  }
  .model-page-layout .slot-media-wrap {
    height: 480px !important;
    max-height: 520px !important;
  }
  .slot-thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)) !important;
    gap: 8px !important;
  }
  .slot-thumb {
    height: 95px !important;
  }

  /* PAGE 3: WARDROBE ON 2K */
  .wardrobe-page-layout {
    max-width: 2200px !important;
    padding: 18px 24px !important;
    gap: 16px !important;
    height: calc(100vh - 52px) !important;
  }
  .wardrobe-topbar {
    padding: 14px 20px !important;
  }
  .wardrobe-chip {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 12px !important;
  }
  .wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 320px)) !important;
    gap: 20px !important;
  }
  .wardrobe-card.wardrobe-card-add {
    min-height: 340px !important;
  }

  /* PAGE 4: VAULT & FORENSIC COMPARE ON 2K */
  .vault-page-layout {
    max-width: 2200px !important;
    padding: 18px 24px !important;
    gap: 18px !important;
    height: calc(100vh - 52px) !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) !important;
  }
  .compare-stage {
    border-radius: 12px !important;
  }
  .compare-frame {
    max-width: 740px !important;
  }
  .compare-controls-row button {
    height: 34px !important;
    font-size: 12.5px !important;
    padding: 0 16px !important;
  }
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 10px !important;
  }
}

/* ==========================================================================
   8. ULTRAWIDE (3440x1440, 5120x1440, 21:9 & 32:9) OPTIMIZATIONS
   ========================================================================== */
@media (min-width: 3000px) and (max-height: 1600px) {
  .generate-page-layout {
    grid-template-columns: 340px minmax(0, 1fr) !important;
    gap: 20px !important;
    padding: 16px 32px !important;
  }
  .generate-directives-col {
    width: 340px !important;
    max-width: 340px !important;
  }
  .stage-target-panel {
    width: 340px !important;
  }
  .stage-target-img-wrap {
    max-height: 420px !important;
  }
  .chat-bubble {
    max-width: 1050px !important;
    margin: 0 auto !important;
  }
  .prompt-action-bar {
    max-width: 1600px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  .live-prompt-terminal {
    max-width: 1600px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
}

/* ==========================================================================
   9. 4K UHD (3840x2160) EXTRA-LARGE RESOLUTION OPTIMIZATIONS
   ========================================================================== */
@media (min-width: 2800px) and (min-height: 1601px) {
  :root {
    --header-h: 64px;
  }

  /* Header */
  .app-header {
    height: 64px !important;
    padding: 0 36px !important;
  }
  .brand-gem {
    width: 38px !important;
    height: 38px !important;
  }
  .brand-title {
    font-size: 18px !important;
    letter-spacing: 1px !important;
  }
  .brand-sub {
    font-size: 10px !important;
  }
  .model-badge-pill {
    height: 34px !important;
    padding: 0 16px !important;
    font-size: 13.5px !important;
  }
  .nav-tab-btn {
    height: 42px !important;
    padding: 0 20px !important;
    font-size: 14px !important;
    gap: 10px !important;
  }
  .status-pill {
    height: 34px !important;
    padding: 0 16px !important;
    font-size: 13.5px !important;
  }
  .header-btn {
    width: 40px !important;
    height: 40px !important;
  }

  /* PAGE 2: GENERATOR ON 4K */
  .generate-page-layout {
    grid-template-columns: 380px minmax(0, 1fr) !important;
    gap: 20px !important;
    padding: 20px 28px !important;
    height: calc(100vh - 64px) !important;
  }

  .generate-directives-col {
    width: 380px !important;
    max-width: 380px !important;
  }
  .generate-directives-col .panel-header h2 {
    font-size: 16px !important;
  }
  .target-mode-chip {
    height: 34px !important;
    font-size: 13px !important;
  }
  .target-chip {
    height: 32px !important;
    font-size: 12.5px !important;
    padding: 5px 12px !important;
  }
  .alt-chip {
    font-size: 12px !important;
    padding: 5px 10px !important;
  }

  .stage-topbar {
    height: 48px !important;
    padding: 0 18px !important;
  }
  .aspect-btn {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
  }
  .hud-btn, .hud-badge-pill {
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
  }

  /* Target Panel on 4K */
  .stage-target-panel {
    width: 380px !important;
    padding: 16px !important;
  }
  .stage-target-header {
    padding: 10px 14px !important;
    font-size: 14px !important;
  }
  .stage-target-img-wrap {
    max-height: 480px !important;
  }
  .stage-target-name {
    font-size: 13.5px !important;
  }
  .stage-target-btns button {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;
  }
  .stage-target-directives-summary {
    font-size: 12.5px !important;
  }
  .stage-target-directives-summary .micro-chip {
    padding: 5px 10px !important;
    font-size: 12px !important;
    width: 100% !important;
    justify-content: center !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  /* Chat viewport on 4K */
  .chat-viewport {
    padding: 24px !important;
    gap: 20px !important;
  }
  .chat-bubble {
    max-width: 1200px !important;
    margin: 0 auto !important;
  }
  .chat-bubble-content {
    font-size: 15px !important;
    line-height: 1.7 !important;
  }
  .chat-bubble img,
  .chat-bubble .generated-preview-image {
    max-height: 750px !important;
  }

  /* Prompt Terminal on 4K */
  .live-prompt-terminal {
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;
    max-width: 1800px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  .prompt-terminal-header {
    height: 46px !important;
    min-height: 46px !important;
    padding: 0 18px !important;
  }
  .terminal-title {
    font-size: 13.5px !important;
  }
  .terminal-chars {
    font-size: 12px !important;
  }
  .live-prompt-terminal.is-expanded,
  .live-prompt-terminal.expanded {
    height: 320px !important;
    max-height: 320px !important;
  }
  .live-prompt-terminal.is-expanded .terminal-editor-wrap,
  .live-prompt-terminal.expanded .terminal-editor-wrap {
    height: 190px !important;
  }

  /* Action Console on 4K */
  .prompt-action-bar {
    padding: 14px 18px !important;
    gap: 16px !important;
    border-radius: 16px !important;
    max-width: 1800px !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  .prompt-textarea-box textarea {
    height: 52px !important;
    min-height: 52px !important;
    font-size: 14.5px !important;
  }
  .btn-send {
    height: 52px !important;
    padding: 0 32px !important;
    font-size: 14.5px !important;
  }
  .send-ref-mode-option {
    height: 38px !important;
    padding: 0 18px !important;
    font-size: 13.5px !important;
  }

  /* Model page on 4K */
  .model-page-layout {
    max-width: 2800px !important;
    padding: 24px 36px !important;
    gap: 24px !important;
    height: calc(100vh - 64px) !important;
  }
  .model-slots-grid.is-master-mode {
    grid-template-columns: minmax(0, 680px) minmax(0, 680px) !important;
    gap: 32px !important;
  }
  .model-page-layout #pane-ref-master > .slot-card,
  .model-page-layout .model-slots-grid > .slot-clothing-card {
    max-height: calc(100vh - 200px) !important;
  }
  .model-page-layout .slot-media-wrap {
    height: 640px !important;
    max-height: 680px !important;
  }
  .slot-thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)) !important;
    gap: 10px !important;
  }
  .slot-thumb {
    height: 115px !important;
  }

  /* Wardrobe on 4K */
  .wardrobe-page-layout {
    max-width: 3000px !important;
    padding: 24px 36px !important;
    gap: 20px !important;
    height: calc(100vh - 64px) !important;
  }
  .wardrobe-chip {
    height: 36px !important;
    padding: 0 16px !important;
    font-size: 13.5px !important;
  }
  .wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 400px)) !important;
    gap: 24px !important;
  }

  /* Vault on 4K */
  .vault-page-layout {
    max-width: 3000px !important;
    padding: 24px 36px !important;
    gap: 24px !important;
    height: calc(100vh - 64px) !important;
  }
  .compare-frame {
    max-width: 950px !important;
  }
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    gap: 12px !important;
  }
}
