/* css/theme-studio.css */
/* Internode Theme Studio Pro - Ported from Theme Designer Pro v1.6.8 */

:root {
  --ts-accent: #3b82f6;
  --ts-bg-deep: #09090b;
  --ts-bg-surface: #18181b;
  --ts-bg-elevated: #27272a;
  --ts-border: #3f3f46;
  --ts-text-main: #f4f4f5;
  --ts-text-muted: #a1a1aa;
  --ts-slider-track: #242c3d;
  --ts-radius-lg: 16px;
  --ts-radius-md: 12px;
}

/* Modal Overlay: 100% sharp background, NO blur so player colors are visible in real time */
#modal-theme-studio {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  border: none;
  margin: 0;
  padding: 0;
  max-width: none;
  max-height: none;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  user-select: none;
  pointer-events: none;
}

#modal-theme-studio.visible {
  display: flex !important;
}

/* Exactly 720px wide by 720px high */
.theme-studio-modal {
  width: 720px !important;
  height: 720px !important;
  max-width: 95vw !important;
  max-height: 95vh !important;
  background: var(--ts-bg-surface, #18181b);
  border: 1px solid var(--ts-border, rgba(255, 255, 255, 0.16));
  border-radius: var(--ts-radius-lg, 16px);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: relative !important;
  animation: tsModalSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--ts-text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: auto;
  pointer-events: auto;
}

@keyframes tsModalSlideIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Draggable Header Bar */
.ts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--ts-bg-deep, #09090b);
  border-bottom: 1px solid var(--ts-border, #3f3f46);
  position: relative;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background-color 0.15s ease;
}

.ts-header:hover {
  background: color-mix(in srgb, var(--ts-bg-deep, #09090b) 92%, #ffffff 8%);
}

.ts-header:active,
.ts-header.dragging {
  cursor: grabbing;
}

.ts-header-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-drag-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ts-text-muted, #a1a1aa);
  opacity: 0.55;
  cursor: grab;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.ts-header:hover .ts-drag-indicator {
  opacity: 0.95;
  color: var(--accent, var(--ts-accent, #3b82f6));
}

body.ts-is-dragging {
  cursor: grabbing !important;
  user-select: none !important;
}

body.ts-is-dragging * {
  user-select: none !important;
}

.ts-header h1 {
  font-size: 0.92rem;
  margin: 0;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ts-text-main, #f4f4f5);
  letter-spacing: -0.01em;
}

.ts-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-header-btn {
  background: transparent;
  border: 1px solid var(--ts-border, #3f3f46);
  color: var(--ts-text-muted, #a1a1aa);
  font-family: monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ts-header-btn:hover {
  border-color: var(--ts-accent, #3b82f6);
  color: var(--ts-accent, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
}

.ts-close-btn {
  background: transparent;
  border: none;
  color: var(--ts-text-muted, #a1a1aa);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.ts-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Tabs */
.ts-tabs {
  display: flex;
  background: var(--ts-bg-deep, #09090b);
  padding: 4px;
  border-radius: 12px;
  margin: 14px 20px 0;
  border: 1px solid var(--ts-border, #3f3f46);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.ts-tabs::-webkit-scrollbar { display: none; }

.ts-tab {
  flex: 1;
  padding: 7px 8px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
  color: var(--ts-text-muted, #a1a1aa);
  transition: 0.18s ease;
  white-space: nowrap;
}

.ts-tab:hover {
  color: var(--ts-text-main, #f4f4f5);
}

.ts-tab.active {
  background: var(--ts-bg-elevated, #27272a);
  color: var(--ts-text-main, #ffffff);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Mode Switcher */
.ts-mode-toggle {
  display: flex;
  background: var(--ts-bg-deep, #09090b);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--ts-border, #3f3f46);
  gap: 4px;
  margin-bottom: 12px;
}

.ts-mode-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ts-text-muted, #a1a1aa);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ts-mode-btn:hover {
  color: #ffffff;
}

.ts-mode-btn.active {
  background: var(--ts-bg-elevated, #27272a);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Content Area */
.ts-content-area {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.ts-section-title {
  font-size: 0.65rem;
  color: var(--ts-text-muted, #a1a1aa);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 800;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ts-control-group {
  background: var(--ts-bg-deep, #09090b);
  border: 1px solid var(--ts-border, #3f3f46);
  padding: 16px;
  border-radius: var(--ts-radius-md, 12px);
  margin-bottom: 14px;
}

.ts-slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.ts-slider-row:last-child { margin-bottom: 0; }

.ts-slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--ts-text-muted, #a1a1aa);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.ts-slider-val {
  color: var(--ts-accent, #3b82f6);
  font-family: monospace;
  font-weight: 700;
}

.ts-color-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.ts-color-preview {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.ts-sliders-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Range input */
.theme-studio-modal input[type="range"],
.ts-slider-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--ts-slider-track, #242c3d) !important;
  border: 1px solid var(--ts-border, rgba(255, 255, 255, 0.18)) !important;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-studio-modal input[type="range"]:hover,
.ts-slider-row input[type="range"]:hover {
  border-color: var(--ts-accent, rgba(255, 255, 255, 0.35)) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 6px var(--ts-accent, rgba(59, 130, 246, 0.25));
}

.theme-studio-modal input[type="range"]::-webkit-slider-thumb,
.ts-slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  border: 2.5px solid var(--ts-accent, #3b82f6);
  box-shadow: 0 0 10px var(--ts-accent, rgba(59, 130, 246, 0.5)), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-studio-modal input[type="range"]::-webkit-slider-thumb:hover,
.ts-slider-row input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 14px var(--ts-accent, rgba(59, 130, 246, 0.75)), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.theme-studio-modal input[type="range"]::-moz-range-track,
.ts-slider-row input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--ts-slider-track, #242c3d) !important;
  border: 1px solid var(--ts-border, rgba(255, 255, 255, 0.18)) !important;
  border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.theme-studio-modal input[type="range"]::-moz-range-thumb,
.ts-slider-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  border: 2.5px solid var(--ts-accent, #3b82f6);
  box-shadow: 0 0 10px var(--ts-accent, rgba(59, 130, 246, 0.5)), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-studio-modal input[type="range"]::-moz-range-thumb:hover,
.ts-slider-row input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 14px var(--ts-accent, rgba(59, 130, 246, 0.75)), 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* OKLCH Tonal Ramp */
.ts-ramp {
  display: flex;
  height: 32px;
  gap: 2px;
  margin-bottom: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--ts-border, #3f3f46);
}

.ts-ramp-block {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 800;
  font-family: monospace;
  cursor: pointer;
  transition: transform 0.15s ease;
  position: relative;
  user-select: none;
}
.ts-ramp-block:hover {
  transform: scaleY(1.12);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Curated Presets Grid */
.ts-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.ts-preset-chip {
  background: var(--ts-bg-deep, #09090b);
  border: 1px solid var(--ts-border, #3f3f46);
  padding: 10px 8px;
  border-radius: 12px;
  font-size: 0.68rem;
  color: var(--ts-text-muted, #a1a1aa);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
  position: relative;
}
.ts-preset-chip:hover {
  border-color: var(--ts-accent, #3b82f6);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}
.ts-preset-chip.active-theme {
  border-color: var(--ts-accent, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
  color: #ffffff;
}

.ts-preset-dots {
  display: flex;
  gap: 1px;
  width: 100%;
  height: 16px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

/* Color Variables Tab */
.ts-var-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.ts-var-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--ts-bg-deep, #09090b);
  border-radius: 10px;
  border: 1px solid var(--ts-border, #3f3f46);
  transition: border-color 0.15s;
}
.ts-var-item.is-locked {
  border-color: var(--ts-accent, #3b82f6);
  background: rgba(59, 130, 246, 0.06);
}

.ts-var-name {
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--ts-text-muted, #a1a1aa);
  cursor: pointer;
}
.ts-var-name:hover {
  color: var(--ts-accent, #3b82f6);
}

.ts-var-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ts-var-lock {
  cursor: pointer;
  font-size: 13px;
  opacity: 0.4;
  transition: opacity 0.15s;
  padding: 2px;
}
.ts-var-lock:hover,
.ts-var-item.is-locked .ts-var-lock {
  opacity: 1;
  color: var(--ts-accent, #3b82f6);
}

.ts-var-picker-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ts-var-picker {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border: none;
  cursor: pointer;
  background: none;
  padding: 0;
}

.ts-var-aa {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  pointer-events: none;
  z-index: 1;
}

/* Code block & Textarea */
.ts-code-block {
  display: flex;
  flex-direction: column;
  background: #000000;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-top: 8px;
}

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

.ts-code-lang {
  font-size: 0.72rem;
  color: var(--ts-text-muted, #a1a1aa);
  font-family: monospace;
}

.ts-code-actions {
  display: flex;
  gap: 4px;
}

.ts-code-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e4e4e7;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ts-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.ts-code-block textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: #e4e4e7;
  font-family: monospace;
  font-size: 0.74rem;
  resize: vertical;
  outline: none;
  padding: 12px;
  line-height: 1.5;
  box-sizing: border-box;
}

/* Gradient Builder */
.ts-gradient-type-pills {
  display: flex;
  gap: 4px;
  background: var(--ts-bg-deep, #09090b);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--ts-border, #3f3f46);
  margin-bottom: 12px;
}

.ts-gradient-pill {
  flex: 1;
  padding: 6px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ts-text-muted, #a1a1aa);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
  text-align: center;
}
.ts-gradient-pill.active {
  background: var(--ts-bg-elevated, #27272a);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.ts-gradient-preview {
  width: 100%;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--ts-border, #3f3f46);
  margin-bottom: 12px;
}

.ts-gradient-stops-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 160px;
  overflow-y: auto;
}

.ts-gradient-stop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--ts-bg-deep, #09090b);
  border: 1px solid var(--ts-border, #3f3f46);
  border-radius: 8px;
}

.ts-gradient-swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.ts-gradient-swatch input[type="color"] {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border: none;
  cursor: pointer;
  background: none;
  padding: 0;
}

/* Radial XY Pad */
.ts-radial-xy-pad {
  position: relative;
  width: 110px;
  height: 110px;
  background: var(--ts-bg-deep, #09090b);
  border: 1px solid var(--ts-border, #3f3f46);
  border-radius: 10px;
  cursor: crosshair;
  overflow: hidden;
  touch-action: none;
}
.ts-radial-xy-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ts-accent, #3b82f6);
  border: 2px solid #ffffff;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Mesh Pad */
.ts-mesh-pad {
  position: relative;
  width: 100%;
  height: 130px;
  background: var(--ts-bg-deep, #09090b);
  border: 1px solid var(--ts-border, #3f3f46);
  border-radius: 10px;
  cursor: crosshair;
  overflow: hidden;
  touch-action: none;
  margin-bottom: 8px;
}
.ts-mesh-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  cursor: grab;
}

/* Docs Accordions */
.ts-doc-accordion {
  border-bottom: 1px solid var(--ts-border, #3f3f46);
}
.ts-doc-accordion summary {
  padding: 12px 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--ts-text-main, #f4f4f5);
  font-size: 0.8rem;
  list-style: none;
}
.ts-doc-accordion summary::-webkit-details-marker { display: none; }
.ts-doc-accordion summary:hover { color: var(--ts-accent, #3b82f6); }
.ts-doc-inner {
  padding: 0 0 14px;
  color: var(--ts-text-muted, #a1a1aa);
  font-size: 0.74rem;
  line-height: 1.6;
}

/* Footer Toolbar */
.ts-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--ts-border, #3f3f46);
  background: var(--ts-bg-deep, #09090b);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.ts-footer-left,
.ts-footer-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ts-btn {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--ts-border, #3f3f46);
  background: var(--ts-bg-deep, #09090b);
  color: var(--ts-text-main, #f4f4f5);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ts-btn:hover {
  border-color: var(--ts-text-muted, #a1a1aa);
  transform: translateY(-1px);
}
.ts-btn-danger {
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, 0.3) !important;
}
.ts-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444 !important;
}
.ts-btn-primary {
  background: var(--ts-accent, #3b82f6) !important;
  border-color: var(--ts-accent, #3b82f6) !important;
  color: #ffffff !important;
}
.ts-btn-primary:hover {
  filter: brightness(1.1);
}

.ts-btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast */
.ts-toast {
  position: absolute;
  top: 14px;
  right: 60px;
  background: var(--ts-accent, #3b82f6);
  color: white;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
  transform: translateY(-4px);
}
.ts-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Visual Color Selection Elements (Hue Ribbon, 2D Canvas, Accent Gems) --- */
.ts-hue-ribbon-wrap {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ts-hue-track {
  width: 100%;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(to right,
    #ef4444 0%, #f97316 11%, #f59e0b 22%, #84cc16 33%,
    #10b981 44%, #06b6d4 55%, #3b82f6 66%, #8b5cf6 77%,
    #d946ef 88%, #ef4444 100%
  );
  position: relative;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.ts-hue-thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--ts-bg-deep, #000);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.05s ease;
}
.ts-snap-dots {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.ts-snap-dot {
  flex: 1;
  background: var(--ts-bg-elevated, #27272a);
  border: 1px solid var(--ts-border, #3f3f46);
  border-radius: 6px;
  padding: 3px 2px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ts-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.ts-snap-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-color, #fff);
  flex-shrink: 0;
}
.ts-snap-dot:hover {
  background: var(--ts-bg-surface);
  color: var(--ts-text-main);
  border-color: var(--dot-color, var(--ts-accent));
  transform: translateY(-1px);
}

/* 2D OKLCH Chroma-Lightness Visual Pad */
.ts-2d-wrap {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--ts-border, #3f3f46);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  cursor: crosshair;
  margin-bottom: 14px;
}
.ts-2d-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.ts-2d-reticle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.9), inset 0 0 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: transform 0.05s ease;
}

/* Quick Accent Gems */
.ts-gem-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ts-gem-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.ts-gem-chip:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}
.ts-gem-chip.active {
  border-color: #ffffff;
  box-shadow: 0 0 10px var(--ts-accent, #3b82f6), 0 0 0 2px rgba(255, 255, 255, 0.8);
  transform: scale(1.15);
}

/* Color Harmonies */
.ts-harmonics-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.ts-harmonic-chip {
  flex: 1;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.65rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0 8px;
}
.ts-harmonic-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.ts-harmonic-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.ts-harmonic-name {
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Preset Category Filter Tabs */
.ts-preset-tabs {
  display: flex;
  gap: 4px;
}
.ts-preset-tab {
  background: var(--ts-bg-elevated, #27272a);
  border: 1px solid var(--ts-border, #3f3f46);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ts-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.ts-preset-tab.active {
  background: var(--ts-accent, #3b82f6);
  border-color: var(--ts-accent, #3b82f6);
  color: #ffffff;
}

/* Self-Theming Modal Transitions */
.theme-studio-modal,
.theme-studio-modal *,
.ts-header,
.ts-tabs,
.ts-tab,
.ts-control-group,
.ts-mode-toggle,
.ts-mode-btn,
.ts-footer,
.ts-btn,
.ts-preset-chip,
.ts-var-item,
.ts-code-block {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

/* Light Mode Theme Studio Modal Overrides (Refined Luxury Off-White & Soft Greys Aesthetic) */
body.light-mode .theme-studio-modal,
html[data-theme="light"] .theme-studio-modal,
#modal-theme-studio.light-mode .theme-studio-modal,
.theme-studio-modal.light-mode {
  background: #f0f2f5 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
  color: #1e293b !important;
}

body.light-mode .ts-header,
html[data-theme="light"] .ts-header,
#modal-theme-studio.light-mode .ts-header {
  background: #e5e8ed !important;
  border-bottom: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

body.light-mode .ts-header h1,
html[data-theme="light"] .ts-header h1,
#modal-theme-studio.light-mode .ts-header h1 {
  color: #1e293b !important;
}

body.light-mode .ts-header-btn,
html[data-theme="light"] .ts-header-btn,
#modal-theme-studio.light-mode .ts-header-btn {
  border-color: #cbd5e1 !important;
  color: #475569 !important;
  background: #f0f2f5 !important;
}

body.light-mode .ts-close-btn,
html[data-theme="light"] .ts-close-btn,
#modal-theme-studio.light-mode .ts-close-btn {
  color: #475569 !important;
}

body.light-mode .ts-close-btn:hover,
html[data-theme="light"] .ts-close-btn:hover,
#modal-theme-studio.light-mode .ts-close-btn:hover {
  color: #1e293b !important;
  background: rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .ts-tabs,
html[data-theme="light"] .ts-tabs,
#modal-theme-studio.light-mode .ts-tabs {
  background: #e5e8ed !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

body.light-mode .ts-tab,
html[data-theme="light"] .ts-tab,
#modal-theme-studio.light-mode .ts-tab {
  color: #475569 !important;
}

body.light-mode .ts-tab:hover,
html[data-theme="light"] .ts-tab:hover,
#modal-theme-studio.light-mode .ts-tab:hover {
  color: #1e293b !important;
  background: rgba(0, 0, 0, 0.04) !important;
}

body.light-mode .ts-tab.active,
html[data-theme="light"] .ts-tab.active,
#modal-theme-studio.light-mode .ts-tab.active {
  background: #f8fafc !important;
  color: var(--accent, #2563eb) !important;
  border-bottom: 2px solid var(--accent, #2563eb) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
}

body.light-mode .ts-mode-toggle,
html[data-theme="light"] .ts-mode-toggle,
#modal-theme-studio.light-mode .ts-mode-toggle {
  background: #dde1e7 !important;
  border: 1px solid #cbd5e1 !important;
}

body.light-mode .ts-mode-btn,
html[data-theme="light"] .ts-mode-btn,
#modal-theme-studio.light-mode .ts-mode-btn {
  color: #475569 !important;
}

body.light-mode .ts-mode-btn:hover,
html[data-theme="light"] .ts-mode-btn:hover,
#modal-theme-studio.light-mode .ts-mode-btn:hover {
  color: #1e293b !important;
}

body.light-mode .ts-mode-btn.active,
html[data-theme="light"] .ts-mode-btn.active,
#modal-theme-studio.light-mode .ts-mode-btn.active {
  background: #f8fafc !important;
  color: var(--accent, #2563eb) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid #cbd5e1 !important;
}

body.light-mode .ts-control-group,
html[data-theme="light"] .ts-control-group,
#modal-theme-studio.light-mode .ts-control-group {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.light-mode .ts-section-title,
html[data-theme="light"] .ts-section-title,
#modal-theme-studio.light-mode .ts-section-title {
  color: #64748b !important;
}

body.light-mode .ts-slider-row label,
html[data-theme="light"] .ts-slider-row label,
#modal-theme-studio.light-mode .ts-slider-row label {
  color: #334155 !important;
}

body.light-mode .ts-slider,
body.light-mode .theme-studio-modal input[type="range"],
body.light-mode .ts-slider-row input[type="range"],
html[data-theme="light"] .ts-slider,
#modal-theme-studio.light-mode .ts-slider,
#modal-theme-studio.light-mode input[type="range"] {
  background: #cbd5e1 !important;
  border: 1px solid #94a3b8 !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12) !important;
}

body.light-mode .ts-btn,
html[data-theme="light"] .ts-btn,
#modal-theme-studio.light-mode .ts-btn {
  background: #f4f6f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

body.light-mode .ts-btn:hover,
html[data-theme="light"] .ts-btn:hover,
#modal-theme-studio.light-mode .ts-btn:hover {
  background: #e5e8ed !important;
  border-color: #94a3b8 !important;
}

body.light-mode .ts-select,
html[data-theme="light"] .ts-select,
#modal-theme-studio.light-mode .ts-select {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

body.light-mode .ts-textarea,
html[data-theme="light"] .ts-textarea,
#modal-theme-studio.light-mode .ts-textarea {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}

body.light-mode .ts-footer,
html[data-theme="light"] .ts-footer,
#modal-theme-studio.light-mode .ts-footer {
  background: #e5e8ed !important;
  border-top: 1px solid #cbd5e1 !important;
}

body.light-mode .ts-var-item,
html[data-theme="light"] .ts-var-item,
#modal-theme-studio.light-mode .ts-var-item {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

body.light-mode .ts-preset-chip,
html[data-theme="light"] .ts-preset-chip,
#modal-theme-studio.light-mode .ts-preset-chip {
  background: #f4f6f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

body.light-mode .ts-preset-chip:hover,
html[data-theme="light"] .ts-preset-chip:hover,
#modal-theme-studio.light-mode .ts-preset-chip:hover {
  border-color: var(--ts-accent) !important;
  background: #e5e8ed !important;
  color: #1e293b !important;
}

body.light-mode .ts-harmonic-chip,
html[data-theme="light"] .ts-harmonic-chip,
#modal-theme-studio.light-mode .ts-harmonic-chip {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

body.light-mode .ts-preset-tab,
html[data-theme="light"] .ts-preset-tab,
#modal-theme-studio.light-mode .ts-preset-tab {
  background: #dde1e7 !important;
  border: 1px solid #cbd5e1 !important;
  color: #475569 !important;
}

body.light-mode .ts-preset-tab.active,
html[data-theme="light"] .ts-preset-tab.active,
#modal-theme-studio.light-mode .ts-preset-tab.active {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: var(--accent, #2563eb) !important;
}

body.light-mode .ts-ramp-block,
html[data-theme="light"] .ts-ramp-block,
#modal-theme-studio.light-mode .ts-ramp-block {
  border: 1px solid #cbd5e1 !important;
}

body.light-mode .ts-color-preview,
html[data-theme="light"] .ts-color-preview,
#modal-theme-studio.light-mode .ts-color-preview {
  border: 2px solid #ffffff !important;
  box-shadow: 0 0 0 1px #cbd5e1, 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .ts-hue-track,
html[data-theme="light"] .ts-hue-track,
#modal-theme-studio.light-mode .ts-hue-track {
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

body.light-mode .ts-snap-dot,
html[data-theme="light"] .ts-snap-dot,
#modal-theme-studio.light-mode .ts-snap-dot {
  border: 1.5px solid #ffffff !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) !important;
}

body.light-mode .ts-gem-chip,
html[data-theme="light"] .ts-gem-chip,
#modal-theme-studio.light-mode .ts-gem-chip {
  border: 2px solid #ffffff !important;
  box-shadow: 0 0 0 1px #cbd5e1, 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

body.light-mode .ts-gem-chip.active,
html[data-theme="light"] .ts-gem-chip.active,
#modal-theme-studio.light-mode .ts-gem-chip.active {
  box-shadow: 0 0 0 2px var(--ts-accent), 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* OLED Mode Explicit High-Contrast Styling */
body.oled-mode .theme-studio-modal,
html[data-theme="oled"] .theme-studio-modal,
#modal-theme-studio.oled-mode .theme-studio-modal {
  background: #000000 !important;
  border: 1px solid #27272a !important;
  box-shadow: 0 0 0 1px #18181b, 0 16px 48px rgba(0, 0, 0, 0.95) !important;
}

body.oled-mode .ts-header,
html[data-theme="oled"] .ts-header,
#modal-theme-studio.oled-mode .ts-header {
  background: #09090b !important;
  border-bottom: 1px solid #27272a !important;
}

body.oled-mode .ts-footer,
html[data-theme="oled"] .ts-footer,
#modal-theme-studio.oled-mode .ts-footer {
  background: #09090b !important;
  border-top: 1px solid #27272a !important;
}

body.oled-mode .ts-tab.active,
html[data-theme="oled"] .ts-tab.active,
#modal-theme-studio.oled-mode .ts-tab.active {
  border-bottom-color: var(--ts-accent, #38bdf8) !important;
  color: #ffffff !important;
}

body.oled-mode .ts-mode-btn.active,
html[data-theme="oled"] .ts-mode-btn.active,
#modal-theme-studio.oled-mode .ts-mode-btn.active {
  background: #18181b !important;
  border: 1px solid var(--ts-accent, #38bdf8) !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25) !important;
}

body.oled-mode .ts-preset-chip,
html[data-theme="oled"] .ts-preset-chip,
#modal-theme-studio.oled-mode .ts-preset-chip {
  background: #0c0c0e !important;
  border: 1px solid #27272a !important;
}

body.oled-mode .ts-harmonic-chip,
html[data-theme="oled"] .ts-harmonic-chip,
#modal-theme-studio.oled-mode .ts-harmonic-chip {
  background: #0c0c0e !important;
  border: 1px solid #27272a !important;
}

body.oled-mode .ts-control-group,
html[data-theme="oled"] .ts-control-group,
#modal-theme-studio.oled-mode .ts-control-group {
  background: #050506 !important;
  border: 1px solid #27272a !important;
}

body.oled-mode .theme-studio-modal input[type="range"],
body.oled-mode .ts-slider-row input[type="range"],
html[data-theme="oled"] .theme-studio-modal input[type="range"],
#modal-theme-studio.oled-mode input[type="range"] {
  background: #1e1f26 !important;
  border: 1px solid #33333d !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8) !important;
}

/* --- Speed Dropdown Integration for Theme Studio Modes --- */
body.light-mode .speed-select-wrapper select,
body.light-mode #playback-rate {
  background-color: #f4f6f9 !important;
  border-color: #cbd2db !important;
  color: #1e293b !important;
  color-scheme: light !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}
body.light-mode .speed-select-wrapper select:hover,
body.light-mode #playback-rate:hover {
  background-color: #e5e8ed !important;
  border-color: var(--accent, #2563eb) !important;
  color: #0f172a !important;
}
body.light-mode .speed-select-wrapper select:focus,
body.light-mode #playback-rate:focus {
  border-color: var(--accent, #2563eb) !important;
  box-shadow: 0 0 0 2px var(--accent-glow, rgba(37, 99, 235, 0.25)) !important;
}
body.light-mode .speed-select-wrapper select option,
body.light-mode #playback-rate option {
  background: #f4f6f9 !important;
  color: #1e293b !important;
}
body.light-mode .speed-select-wrapper select option:checked,
body.light-mode #playback-rate option:checked {
  background-color: var(--accent, #2563eb) !important;
  color: #ffffff !important;
}

body.oled-mode .speed-select-wrapper select,
body.oled-mode #playback-rate {
  background-color: #000000 !important;
  border-color: #222222 !important;
  color: #ffffff !important;
  color-scheme: dark !important;
  box-shadow: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}
body.oled-mode .speed-select-wrapper select:hover,
body.oled-mode #playback-rate:hover {
  background-color: #0a0a0a !important;
  border-color: var(--accent, #ffffff) !important;
  color: #ffffff !important;
}
body.oled-mode .speed-select-wrapper select:focus,
body.oled-mode #playback-rate:focus {
  border-color: var(--accent, #ffffff) !important;
  box-shadow: 0 0 0 2px var(--accent-glow, rgba(255, 255, 255, 0.4)) !important;
}
body.oled-mode .speed-select-wrapper select option,
body.oled-mode #playback-rate option {
  background: #000000 !important;
  color: #ffffff !important;
}
body.oled-mode .speed-select-wrapper select option:checked,
body.oled-mode #playback-rate option:checked {
  background-color: var(--accent, #ffffff) !important;
  color: #000000 !important;
}




