/* ==============================================================================
   [NAESSE ATELIER] STUDIO PARTICLE LAB - WORKSTATION DESIGN SYSTEM (V3.2)
   Palette: Dark Studio Slate (#090b0e), Brushed Needle Gold (#D8CA8E), Cyan (#3cc8f0)
   1024x768 (4:3) Native Viewport • High-Density Prim Touch Console
   ============================================================================== */

:root {
  --bg-core: #090b0e;
  --bg-panel: #10141b;
  --bg-card: #161b24;
  --bg-input: #0b0e13;
  --bg-hover: #1e2430;
  
  --gold-needle: #D8CA8E;
  --gold-soft: #c4b67b;
  --gold-faint: rgba(216, 202, 142, 0.14);
  --cyan-neon: #3cc8f0;
  --cyan-glow: rgba(60, 200, 240, 0.25);
  
  --border-subtle: #202632;
  --border-focus: #374254;
  --border-gold: rgba(216, 202, 142, 0.45);
  
  --text-primary: #f5f7fa;
  --text-secondary: #a8b2c4;
  --text-muted: #667287;
  
  --status-active: #30d158;
  --status-stop: #ff453a;
  
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Hide all scrollbars in viewer CEF */
::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden !important;
  background-color: var(--bg-core);
  color: var(--text-primary);
  font-family: var(--font-ui);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(216, 202, 142, 0.08) 0%, transparent 70%),
    linear-gradient(rgba(26, 32, 42, 0.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 32, 42, 0.45) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
}

/* Fullscreen 4:3 Frame with Inset Safe Area and Gold Border */
.workstation-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 28px 10px 28px; /* Safe padding prevents any mesh frame bevel cutoff */
  gap: 8px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 24px rgba(216, 202, 142, 0.06), 0 0 20px rgba(0, 0, 0, 0.85);
}

/* HEADER */
.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  flex-shrink: 0;
  height: 44px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(216, 202, 142, 0.4));
}

.brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gold-needle);
  font-weight: 700;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
  line-height: 1.1;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.connection-pill.connected {
  border-color: rgba(48, 209, 88, 0.45);
  background: rgba(48, 209, 88, 0.08);
  color: #c9f7d2;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-needle);
  box-shadow: 0 0 6px var(--gold-needle);
}

.status-dot.online {
  background: var(--status-active);
  box-shadow: 0 0 8px var(--status-active);
}

/* 2-ROW PRESETS SHELF (12 SIGNATURE PRESETS) */
.presets-shelf {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  flex-shrink: 0;
}

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

.shelf-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold-needle);
}

.shelf-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.preset-cards-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.preset-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  justify-content: center;
}

.preset-btn .p-icon {
  font-size: 14px;
}

.preset-btn:hover {
  border-color: var(--gold-soft);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.preset-btn.active {
  border-color: var(--gold-needle);
  color: var(--gold-needle);
  background: var(--gold-faint);
  box-shadow: 0 0 10px rgba(216, 202, 142, 0.25);
}

/* MAIN CONSOLE GRID */
.console-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr 1.05fr;
  gap: 12px;
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  flex-shrink: 0;
}

.panel-header.subheader {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  border-bottom: none;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-needle);
  background: var(--gold-faint);
  padding: 1px 6px;
  border-radius: 3px;
}

.panel-header h2 {
  font-size: 14px;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-top: 8px;
  min-height: 0;
}

/* CONTROL GROUPS (SLIDERS) */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.val-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan-neon);
  background: rgba(60, 200, 240, 0.12);
  border: 1px solid rgba(60, 200, 240, 0.25);
  padding: 1px 7px;
  border-radius: 4px;
}

/* SLIDERS */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  background: var(--bg-input);
  border: 1px solid #2a3342;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cyan-neon);
  box-shadow: 0 0 10px rgba(60, 200, 240, 0.8);
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 14px rgba(60, 200, 240, 1);
}

/* PATTERN BUTTONS */
.pattern-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pattern-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
  min-height: 56px;
}

.pattern-btn:hover {
  border-color: var(--border-focus);
  background: var(--bg-hover);
}

.pattern-btn.active {
  border-color: var(--cyan-neon);
  background: var(--cyan-glow);
  box-shadow: 0 0 10px rgba(60, 200, 240, 0.25);
}

.pat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  margin-top: 3px;
  flex-shrink: 0;
}

.pattern-btn.active .pat-dot {
  background: var(--cyan-neon);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 6px var(--cyan-neon);
}

.pat-info strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
}

.pat-info span {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.15;
}

/* SYSTEM BEHAVIOR FLAGS */
.flags-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.flag-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  min-height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}

.flag-toggle:hover {
  border-color: var(--border-focus);
  background: var(--bg-hover);
}

.flag-toggle input {
  display: none;
}

.flag-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 3px;
  position: relative;
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.flag-toggle input:checked + .flag-box {
  background: var(--gold-needle);
  border-color: var(--gold-needle);
  box-shadow: 0 0 6px rgba(216, 202, 142, 0.5);
}

.flag-toggle input:checked + .flag-box::after {
  content: '✓';
  position: absolute;
  top: -3px;
  left: 2px;
  font-size: 11px;
  color: #0c0f14;
  font-weight: 900;
}

.flag-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.flag-toggle input:checked ~ .flag-text {
  color: var(--text-primary);
}

/* COLOR STUDIO */
.color-pairing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-picker-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.color-picker-box label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.picker-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.picker-inner:hover {
  border-color: var(--gold-soft);
  background: var(--bg-hover);
}

.color-swatch-display {
  width: 44px;
  height: 38px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.color-swatch-display:hover {
  transform: scale(1.06);
  border-color: var(--gold-needle);
  box-shadow: 0 0 10px rgba(216, 202, 142, 0.4);
}

.hex-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-needle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* GRADIENT PREVIEW */
.gradient-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gradient-bar {
  height: 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(90deg, #ffd866, #ff4d0d);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.4);
}

.gradient-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* DEDICATED TEXTURE ASSET CARD */
.texture-asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.card-header-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-needle);
  letter-spacing: 0.5px;
}

.tex-status-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
}

.tex-input-wrap {
  display: flex;
  gap: 6px;
}

.tex-input-wrap input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  outline: none;
}

.tex-input-wrap input:focus {
  border-color: var(--gold-soft);
}

.btn-sm {
  background: var(--gold-needle);
  color: #10141b;
  border: none;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-sm.secondary {
  background: #202632;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-sm:hover {
  filter: brightness(1.1);
}

/* BOTTOM ACTION DOCK */
.action-dock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
  flex-shrink: 0;
  height: 54px;
}

.dock-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.power-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--status-active);
  color: var(--status-active);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0 12px rgba(48, 209, 88, 0.25);
}

.power-btn.stopped {
  border-color: var(--status-stop);
  color: var(--status-stop);
  box-shadow: 0 0 12px rgba(255, 69, 58, 0.25);
}

.power-glow {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.dock-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.export-btn {
  background: linear-gradient(135deg, var(--gold-needle), #baab6e);
  color: #0e1218;
  border: none;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(216, 202, 142, 0.35);
  transition: all 0.15s ease;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(216, 202, 142, 0.6);
}

.export-btn.copied {
  background: var(--status-active);
  color: #ffffff;
}

/* ==============================================================================
   ATELIER IN-DOM LUXURY COLOR STUDIO MODAL
   Zero OS Popups • Explicit Close & Apply • Fast Touch Operation
   ============================================================================== */
.color-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 6, 10, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-modal-window {
  width: 500px;
  background: #11151e;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.95), 0 0 25px rgba(216, 202, 142, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmFadeIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cmFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1.0); }
}

.color-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #151a24;
  border-bottom: 1px solid var(--border-subtle);
}

.cm-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-needle);
  background: var(--gold-faint);
  padding: 2px 6px;
  border-radius: 3px;
}

.color-modal-header h3 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-primary);
}

.cm-close-btn {
  background: #1e2432;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 700;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cm-close-btn:hover {
  background: #ff453a;
  border-color: #ff453a;
  color: #ffffff;
}

.color-modal-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Live Preview Strip */
.cm-preview-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.cm-swatch-large {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.cm-preview-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cm-vec-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.cm-vec-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan-neon);
}

.cm-hex-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-needle);
}

.cm-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold-needle);
}

/* Palettes Grid */
.cm-palette-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.cm-palette-swatch {
  height: 28px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.cm-palette-swatch:hover {
  transform: scale(1.15);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  z-index: 2;
}

/* RGB Fine-Tuning Controls */
.cm-rgb-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.cm-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-rgb-channel {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  width: 16px;
}
.cm-rgb-channel.red { color: #ff5252; }
.cm-rgb-channel.green { color: #69f0ae; }
.cm-rgb-channel.blue { color: #448aff; }

.cm-slider-row input[type="range"] {
  flex: 1;
}

.cm-slider-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  width: 36px;
  text-align: right;
}

/* Modal Footer */
.color-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px;
  background: #151a24;
  border-top: 1px solid var(--border-subtle);
}

.btn-cm-cancel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-cm-cancel:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.btn-cm-apply {
  background: linear-gradient(135deg, var(--gold-needle), #baab6e);
  border: none;
  color: #10141b;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(216, 202, 142, 0.3);
  transition: all 0.12s ease;
}

.btn-cm-apply:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 16px rgba(216, 202, 142, 0.5);
}
