/* quick_studio.css */

/* Variables and Reset */
.qs-overlay {
  --qs-bg: #fdfcff;
  --qs-fg: #1e1338;
  --qs-border: #ede8f5;
  --qs-border-hover: #d8cfea;
  --qs-primary: #4e2a84;
  --qs-primary-hover: #371a62;
  --qs-accent: #efbf04;
  --qs-danger: #dc2626;
  --qs-danger-hover: #b91c1c;
  --qs-muted: #796d94;
  --qs-bg-card: #ffffff;
  --qs-shadow: 0 4px 12px rgba(78, 42, 132, 0.1);
  --qs-split: 50%;

  position: fixed;
  inset: 0;
  z-index: 100000;
  background: var(--qs-bg);
  color: var(--qs-fg);
  font-family: "Inter", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.qs-overlay * {
  box-sizing: border-box;
}

/* Header - Streamlined for maximum graph viewport height */
.qs-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  min-height: 40px;
  background: linear-gradient(135deg, #371a62 0%, #4e2a84 55%, #593098 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(55, 26, 98, 0.2);
  color: #ffffff;
  flex-shrink: 0;
}

.qs-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qs-brand .larvol-logo-mark {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  user-select: none;
}

.qs-brand .larvol-logo-text {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #ffffff;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

.qs-brand .larvol-logo-sub {
  font-size: 0.46rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #efbf04;
  margin-top: 1px;
}

.qs-brand-divider {
  height: 20px;
  width: 1px;
  background: rgba(255, 255, 255, 0.25);
}

.qs-brand-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qs-brand-app-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
}

.qs-badge-manual {
  font-size: 0.62rem;
  font-weight: 800;
  background: rgba(239, 191, 4, 0.22);
  color: #efbf04;
  border: 1px solid rgba(239, 191, 4, 0.6);
  padding: 1.5px 6px;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.qs-meta {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.76rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 10px;
}

.qs-layout-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  gap: 2px;
}

.qs-layout-switch button {
  background: transparent;
  border: none;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  transition: all 0.15s;
}

.qs-layout-switch button.active {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.qs-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qs-btn-fullscreen {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.qs-btn-fullscreen:hover {
  background: rgba(255, 255, 255, 0.25);
}

.qs-done {
  background: #10b981;
  color: white;
  border: none;
  padding: 4px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  transition: background 0.15s;
}

.qs-done:hover {
  background: #059669;
}

.qs-close {
  background: transparent;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0 4px;
}

.qs-close:hover {
  color: #ffffff;
}

/* Toolbar - Compact, Left-aligned, Purple themed */
.qs-tools {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 3px 14px;
  background: #fbf9fe;
  border-bottom: 1px solid #ede8f5;
  gap: 4px;
  min-height: 32px;
  flex-shrink: 0;
}

.qs-tool {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b3e66;
  transition: all 0.15s;
}

.qs-tool:hover {
  background: #f0eaf9;
  border-color: #d8cfea;
  color: #4e2a84;
}

.qs-tool.active {
  background: #ede9fe;
  border: 1.5px solid #7c3aed;
  color: #4e2a84;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.15);
}

.qs-tool-auto {
  background: linear-gradient(135deg, #4e2a84, #6b21a8);
  color: white;
  border: none;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(78, 42, 132, 0.2);
}

.qs-tool-auto:hover {
  background: linear-gradient(135deg, #371a62, #581c87);
  color: #ffffff;
}

.qs-tool-auto.loading {
  opacity: 0.7;
  pointer-events: none;
}

.qs-tool:disabled,
.qs-tool.disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.qs-tool-reset {
  color: var(--qs-danger);
}
.qs-tool-reset:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: var(--qs-danger-hover);
}

.qs-sep {
  width: 1px;
  height: 18px;
  background: var(--qs-border);
  margin: 0 4px;
}

/* Hints - Compact info card with rounded corners, lighter violet background, and theme border */
.qs-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 3px 12px;
  padding: 3px 14px;
  background: #f8f5fd;
  border: 1px solid #6b3ba6;
  border-radius: 8px;
  font-size: 0.76rem;
  color: #371a62;
  min-height: 28px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(78, 42, 132, 0.05);
}

.qs-hint-text b {
  color: #210d3d;
  font-weight: 700;
}

.qs-hint-text u {
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  color: #210d3d;
}

.qs-hint-keys {
  color: #55338a;
  font-weight: 500;
}

.qs-tilt-ctrl {
  display: none;
}

/* Redundant top bar controls inside qs-hint are hidden in favor of floating panel */
.qs-bar-ctrl {
  display: none !important;
}

.qs-bar-badge {
  font-weight: 700;
  color: #4e2a84;
  font-size: 0.8rem;
  background: #ede9fe;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #c4b5fd;
  white-space: nowrap;
}

.qs-bar-field {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: #4b3e66;
  font-size: 0.78rem;
  margin: 0;
  white-space: nowrap;
}

.qs-bar-field span {
  color: #796d94;
  font-size: 0.75rem;
}

.qs-bar-input {
  width: 58px;
  padding: 2px 6px;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace, monospace;
  font-weight: 600;
  color: #1e1338;
  background: #ffffff;
  border: 1px solid #c4b5fd;
  border-radius: 4px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.qs-bar-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.qs-bar-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  font-size: 0.8rem;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-bar-del-btn:hover {
  background: #fecaca;
  color: #991b1b;
}

.qs-bar-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4e2a84;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-bar-close-btn:hover {
  background: #ddd6fe;
  color: #371a62;
}

/* Floating bar inspector at top-left of graph container */
.qs-bar-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 45;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
  gap: 6px;
  row-gap: 5px;
  pointer-events: auto;
  font-size: 11px;
  color: #1e293b;
  animation: qsFadeIn 0.15s ease-out;
}

@keyframes qsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.qs-bar-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  color: #1e293b;
  font-size: 0.82rem;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
}

.qs-label-edit-icon {
  font-size: 10px;
  opacity: 0.6;
  cursor: pointer;
  line-height: 1;
}

.qs-bar-panel-title:hover .qs-label-edit-icon {
  opacity: 1;
}

.qs-bar-panel-label-input {
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: #0f172a;
  outline: none;
  width: 72px;
  padding: 1px 3px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.qs-bar-panel-label-input:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: #cbd5e1;
}

.qs-bar-panel-label-input:focus {
  background: #ffffff;
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.qs-bar-panel-field {
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  color: #475569;
  font-size: 0.78rem;
  margin: 0;
  white-space: nowrap;
}

.qs-bar-panel-field span {
  color: #64748b;
}

.qs-bar-panel-input {
  width: 56px;
  padding: 2px 5px;
  font-size: 0.8rem;
  font-family: monospace, monospace;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.qs-bar-panel-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.qs-bar-panel-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  font-size: 0.8rem;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-bar-panel-del:hover {
  background: #fecaca;
  color: #991b1b;
}

.qs-bar-panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-bar-panel-close:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* Floating tilt control panel at top-left of graph container (same location as bar panel) */
.qs-tilt-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 45;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  font-size: 12px;
  color: #1e293b;
  animation: qsFadeIn 0.15s ease-out;
}

.qs-tilt-badge {
  font-weight: 700;
  color: #4e2a84;
  font-size: 0.8rem;
  background: #ede9fe;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #c4b5fd;
  white-space: nowrap;
}

.qs-tilt-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qs-tilt-nudge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}

.qs-tilt-nudge:hover {
  background: #ede9fe;
  color: #4e2a84;
  border-color: #c4b5fd;
}

.qs-tilt-val {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  color: #4e2a84;
  min-width: 48px;
  text-align: right;
  font-size: 0.85rem;
}

.qs-tilt-zero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}

.qs-tilt-zero:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* Scroll Area that holds Main split layout and the Result Table */
.qs-scroll-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
  background: #fbf9fe;
  min-height: 0;
}

.qs-scroll-container::-webkit-scrollbar {
  width: 8px;
}
.qs-scroll-container::-webkit-scrollbar-track {
  background: #f1ecf9;
}
.qs-scroll-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.qs-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--qs-primary);
}

/* Main Layout - Maximizes the viewport area for both HTML and Actual graphs */
.qs-main {
  height: calc(100vh - 104px);
  min-height: calc(100vh - 104px);
  flex-shrink: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

@media (max-height: 600px) {
  .qs-main {
    min-height: 480px;
  }
}

.qs-overlay.qs-fullscreen-mode .qs-hint {
  display: none !important;
}

.qs-overlay.qs-fullscreen-mode .qs-main {
  height: calc(100vh - 72px);
  min-height: calc(100vh - 72px);
}

.qs-pane {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  min-width: 0;
}

.qs-divider {
  background: var(--qs-border);
  z-index: 10;
  transition: background 0.15s;
}

.qs-divider:hover {
  background: #7c3aed;
}

/* Side-by-side */
.qs-layout-side {
  flex-direction: row;
}
.qs-layout-side .qs-image-pane {
  width: var(--qs-split);
  min-width: 0;
  min-height: 0;
}
.qs-layout-side .qs-chart-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.qs-layout-side .qs-divider {
  width: 4px;
  cursor: col-resize;
}

/* Stacked */
.qs-layout-stack {
  flex-direction: column;
}
.qs-layout-stack .qs-image-pane {
  height: var(--qs-split);
  min-height: 0;
}
.qs-layout-stack .qs-chart-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.qs-layout-stack .qs-divider {
  height: 4px;
  cursor: row-resize;
}

/* Fullscreen Pane Modes */
.qs-main.qs-fullscreen-image .qs-image-pane {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  flex: 1 1 100% !important;
}
.qs-main.qs-fullscreen-image .qs-chart-pane,
.qs-main.qs-fullscreen-image .qs-divider {
  display: none !important;
}

.qs-main.qs-fullscreen-chart .qs-chart-pane {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  flex: 1 1 100% !important;
}
.qs-main.qs-fullscreen-chart .qs-image-pane,
.qs-main.qs-fullscreen-chart .qs-divider {
  display: none !important;
}

/* Canvas Area */
.qs-canvas-wrap {
  flex: 1;
  position: relative;
  background: #e9e5f0;
  overflow: hidden;
}

#qsCanvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none; /* Prevent scroll on canvas */
}

/* Chips (Scale Editing) */
.qs-chips {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none; /* children enable pointer-events */
}

.qs-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--qs-primary);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: auto;
  cursor: text;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  user-select: none;
  transition:
    box-shadow 0.15s,
    outline 0.15s;
}
.qs-chip.selected {
  outline: 2px solid #ffffff;
  box-shadow:
    0 0 0 3px #9333ea,
    0 2px 8px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.qs-chip.qs-chip-zero {
  background: var(--qs-accent);
  color: #5c4700;
}
.qs-chip.qs-chip-zero.selected {
  outline: 2px solid #ffffff;
  box-shadow:
    0 0 0 3px #ca8a04,
    0 2px 8px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.qs-chip-input {
  top: 50%;
  left: 50%;
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11px;
  padding: 2px 6px;
  text-align: center;
  border-radius: 4px;
  border: 2px solid var(--qs-primary);
  outline: none;
  pointer-events: auto;
  width: 60px;
}

/* Zoom & Fit controls at bottom of source and manual graph */
.qs-zoom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(78, 42, 132, 0.18);
  overflow: hidden;
  z-index: 25;
  user-select: none;
}

.qs-zoom button {
  background: transparent;
  border: none;
  padding: 5px 11px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: #475569;
  border-right: 1px solid rgba(78, 42, 132, 0.12);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.qs-zoom button:last-child {
  border-right: none;
}

.qs-zoom button:hover {
  background: rgba(78, 42, 132, 0.08);
  color: var(--qs-primary, #4e2a84);
}

.qs-zoom button:active {
  background: rgba(78, 42, 132, 0.16);
}

/* Busy overlay */
.qs-busy {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  font-weight: 600;
  color: var(--qs-primary);
  gap: 16px;
}

.qs-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(78, 42, 132, 0.2);
  border-top-color: var(--qs-primary);
  border-radius: 50%;
  animation: qs-spin 1s linear infinite;
}

@keyframes qs-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Toast */
.qs-toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e1338;
  color: white;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  z-index: 150;
}

.qs-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Loupe Magnifier (supports dual magnification at zero line and graph end) */
.qs-loupe {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2.5px solid #4e2a84;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  background: white;
  transform: translate(-50%, -50%);
  z-index: 50;
  overflow: hidden;
  transition: opacity 0.1s ease;
}

.qs-loupe.qs-loupe-secondary {
  border-color: #2563eb;
}

.qs-loupe.qs-loupe-secondary .qs-loupe-val {
  background: rgba(37, 99, 235, 0.9);
}

.qs-loupe-val {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(78, 42, 132, 0.9);
  color: white;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

#qsCanvas:focus {
  outline: none;
}

/* Chart Pane - Maximized height for live HTML chart */
.qs-chart-pane {
  background: var(--qs-bg-card);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.qs-chart-pane::-webkit-scrollbar,
.qs-legend-list::-webkit-scrollbar,
.qs-legend-preview-bar::-webkit-scrollbar,
.qs-preview-chips-wrap::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.qs-chart-pane::-webkit-scrollbar-thumb,
.qs-legend-list::-webkit-scrollbar-thumb,
.qs-legend-preview-bar::-webkit-scrollbar-thumb,
.qs-preview-chips-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.qs-chart-pane::-webkit-scrollbar-thumb:hover,
.qs-legend-list::-webkit-scrollbar-thumb:hover,
.qs-legend-preview-bar::-webkit-scrollbar-thumb:hover,
.qs-preview-chips-wrap::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.qs-image-head,
.qs-chart-head {
  padding: 4px 12px;
  border-bottom: 1px solid var(--qs-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  flex-shrink: 0;
  background: #ffffff;
  min-height: 30px;
}

.qs-image-head-left,
.qs-chart-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qs-image-head-right,
.qs-chart-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qs-pane-fullscreen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid var(--qs-border);
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.qs-pane-fullscreen-btn:hover {
  background: #f8f6fc;
  color: var(--qs-primary);
  border-color: #c4b5fd;
  transform: scale(1.04);
}

.qs-pane-fullscreen-btn.active {
  background: #ede9fe;
  color: #6d28d9;
  border-color: #8b5cf6;
}

.qs-pane-fullscreen-btn .qs-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qs-pane-fullscreen-btn .qs-ic svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
}

.qs-image-badge {
  font-size: 0.70rem;
  color: var(--qs-muted);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: #f8f6fc;
  padding: 1.5px 6px;
  border-radius: 9999px;
  border: 1px solid var(--qs-border);
}

.qs-legend-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qs-legend-toggle-btn:hover {
  background: #ddd6fe;
  color: #5b21b6;
  border-color: #a78bfa;
}

.qs-legend-toggle-btn.qs-edit-active {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
}

.qs-legend-toggle-btn.qs-edit-active:hover {
  background: #059669;
  border-color: #047857;
}

.qs-legend-count-pill {
  background: #6d28d9;
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1.1;
}

.qs-count {
  background: var(--qs-border);
  padding: 1.5px 7px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--qs-muted);
}

.qs-plot {
  flex: 1;
  height: 100%;
  min-height: 0;
  width: 100%;
}

/* Popover */
.qs-pop {
  position: absolute;
  background: white;
  border: 1px solid var(--qs-border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 5px 8px;
  font-size: 12px;
  z-index: 40;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}

.qs-pop::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0;
  border-style: solid;
  border-color: white transparent transparent transparent;
  display: block;
  width: 0;
}
.qs-pop::before {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: var(--qs-border) transparent transparent transparent;
  display: block;
  width: 0;
}

.qs-pop-label {
  font-weight: 700;
  color: #1e293b;
  font-size: 11px;
}

.qs-pop-field {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  margin: 0;
}

.qs-pop-in {
  width: 58px;
  padding: 2px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace, monospace;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  outline: none;
}

.qs-pop-in:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.qs-pop-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  border: 1px solid #fca5a5;
  background: #fee2e2;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.qs-pop-del:hover {
  background: #fecaca;
}

/* Auto-Detect Recalibrate Axis Modal */
.qs-dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: qsFadeIn 0.15s ease-out;
}

.qs-dialog-card {
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.25),
    0 10px 10px -5px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  border: 1px solid #e2e8f0;
  animation: qsScaleUp 0.15s ease-out;
}

@keyframes qsFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.qs-dialog-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  gap: 10px;
}

.qs-dialog-icon {
  font-size: 20px;
}

.qs-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
}

.qs-dialog-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}
.qs-dialog-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.qs-dialog-body {
  padding: 20px;
}

.qs-dialog-msg {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
}

.qs-dialog-sub {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.qs-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.qs-dialog-btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s ease;
}

.qs-dialog-btn-keep {
  background: #4e2a84;
  color: #ffffff;
  border-color: #4e2a84;
}
.qs-dialog-btn-keep:hover {
  background: #3b1f66;
}

.qs-dialog-btn-recal {
  background: #ffffff;
  color: #475569;
  border-color: #cbd5e1;
}
.qs-dialog-btn-recal:hover {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #94a3b8;
}

.qs-dialog-btn-cancel {
  background: transparent;
  color: #64748b;
  border-color: transparent;
}
.qs-dialog-btn-cancel:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ==========================================================================
   Legend / Series Strip (Detected Colors)
   ========================================================================== */
.qs-legend-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 14px;
  background: #f8f6fc;
  border-bottom: 1px solid var(--qs-border);
  box-shadow: 0 1px 3px rgba(78, 42, 132, 0.04);
  flex-shrink: 0;
}

.qs-legend-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--qs-muted);
}

.qs-legend-strip-title {
  font-weight: 700;
  color: var(--qs-primary);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.qs-legend-strip-sub {
  font-size: 0.74rem;
  color: var(--qs-muted);
}

.qs-legend-add-btn {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.qs-legend-add-btn:hover {
  background: #ddd6fe;
  color: #5b21b6;
  border-color: #a78bfa;
}

.qs-legend-close-btn {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-legend-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ── Compact & Neat Legend Strip ── */
.qs-legend-panel {
  padding: 4px 12px;
  background: #faf8fc;
  border-bottom: 1px solid var(--qs-border);
  display: flex;
  align-items: center;
  overflow: visible; /* NO scrollbars */
  flex-shrink: 0;
  min-height: 32px;
}

.qs-legend-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  overflow: visible;
}

/* Compact Legend Chip (Normal Mode) */
.qs-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #dcd5eb;
  border-radius: 14px;
  padding: 2px 8px 2px 6px;
  height: 24px;
  cursor: pointer;
  user-select: none;
  font-size: 0.74rem;
  font-weight: 500;
  color: #1e1338;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(78, 42, 132, 0.04);
  white-space: nowrap;
}

.qs-legend-chip:hover {
  border-color: #7c3aed;
  background: #faf7fd;
  color: #5b21b6;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.12);
}

.qs-legend-chip.paint-active {
  border-color: #7c3aed;
  background: #ede9fe;
  color: #4e2a84;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.22);
  transform: translateY(-1px);
}

.qs-chip-dot {
  width: 14px;
  height: 10px;
  border-radius: 2px !important;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s;
}

.qs-chip-name {
  font-size: 0.74rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qs-chip-count {
  font-size: 0.66rem;
  font-weight: 700;
  color: #64748b;
  background: #f1ecf9;
  padding: 0 5px;
  border-radius: 8px;
  height: 16px;
  line-height: 16px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.qs-legend-chip.paint-active .qs-chip-count {
  background: #c4b5fd;
  color: #3b0764;
}

/* Legend Panel in Table Edit Mode */
.qs-legend-panel.qs-legend-panel-table-mode {
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 2px solid #ddd6fe;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.08);
  max-height: 220px;
  overflow-y: auto;
  display: block;
}

.qs-legend-panel.qs-legend-panel-table-mode .qs-legend-grid {
  display: block;
  width: 100%;
}

/* Small Grid-like Table for Legends */
.qs-legend-table-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qs-legend-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 6px;
  border-bottom: 1px solid #ede9fe;
}

.qs-legend-table-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #4e2a84;
  display: flex;
  align-items: center;
  gap: 6px;
}

.qs-legend-table-title-count {
  background: #ede9fe;
  color: #6d28d9;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.qs-legend-table-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qs-legend-tbl-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #c4b5fd;
  background: #fbf9ff;
  color: #5b21b6;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qs-legend-tbl-action-btn:hover {
  background: #ede9fe;
  border-color: #7c3aed;
}

.qs-legend-tbl-done-btn {
  background: #7c3aed;
  color: #ffffff;
  border-color: #6d28d9;
  font-weight: 700;
}

.qs-legend-tbl-done-btn:hover {
  background: #6d28d9;
}

.qs-legend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.qs-legend-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 0.70rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 8px;
  border-bottom: 1px solid #cbd5e1;
  text-align: left;
}

.qs-legend-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #1e293b;
}

.qs-legend-table tr:last-child td {
  border-bottom: none;
}

.qs-legend-table tr:hover td {
  background: #faf5ff;
}

.qs-legend-table tr.paint-active td {
  background: #ede9fe;
}

.qs-legend-tbl-swatch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.qs-legend-tbl-swatch-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

.qs-legend-tbl-swatch {
  width: 18px;
  height: 12px;
  border-radius: 2px !important;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  display: inline-block;
  transition: transform 0.15s, box-shadow 0.15s;
}

.qs-legend-tbl-swatch-wrap:hover .qs-legend-tbl-swatch {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.qs-legend-tbl-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: #1e1338;
  padding: 2px 6px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.qs-legend-tbl-input:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.qs-legend-tbl-input:focus {
  border-color: #7c3aed;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.qs-legend-tbl-count {
  font-size: 0.70rem;
  font-weight: 700;
  color: #64748b;
  background: #f1ecf9;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-block;
}

.qs-legend-tbl-paint-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qs-legend-tbl-paint-btn:hover {
  border-color: #7c3aed;
  color: #7c3aed;
  background: #fdfaff;
}

.qs-legend-tbl-paint-btn.active {
  background: #7c3aed;
  color: #ffffff;
  border-color: #6d28d9;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.3);
}

.qs-legend-tbl-del-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.qs-legend-tbl-del-btn:hover {
  color: #dc2626;
  background: #fee2e2;
  transform: scale(1.1);
}

/* Compact Editable Legend Chip (Fallback) */
.qs-legend-chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  border: 1px solid #c4b5fd;
  border-radius: 14px;
  padding: 1px 6px 1px 5px;
  height: 24px;
  box-shadow: 0 1px 2px rgba(78, 42, 132, 0.05);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.qs-legend-chip-edit:hover,
.qs-legend-chip-edit:focus-within {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.qs-legend-chip-edit.paint-active {
  border-color: #7c3aed;
  background: #fdfaff;
}

.qs-chip-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.qs-chip-color-wrap .qs-legend-color-picker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

.qs-chip-color-wrap .qs-chip-dot {
  width: 16px;
  height: 11px;
  border-radius: 2px !important;
  cursor: pointer;
}

.qs-chip-color-wrap:hover .qs-chip-dot {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.3);
}

.qs-chip-edit-input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  color: #1e1338;
  padding: 0 2px;
  width: 76px;
  min-width: 44px;
  max-width: 160px;
  border-bottom: 1px dashed #cbd5e1;
  transition: border-color 0.15s, width 0.1s;
}

.qs-chip-edit-input:hover {
  border-bottom-color: #94a3b8;
}

.qs-chip-edit-input:focus {
  border-bottom: 1.5px solid #7c3aed;
  background: rgba(124, 58, 237, 0.04);
  border-radius: 2px 2px 0 0;
}

.qs-chip-del-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.qs-chip-del-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  transform: scale(1.15);
}

.qs-legend-add-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #f1ecf9;
  border: 1px dashed #a78bfa;
  border-radius: 14px;
  padding: 2px 8px;
  height: 24px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #6d28d9;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.qs-legend-add-chip:hover {
  background: #ddd6fe;
  border-color: #7c3aed;
  color: #5b21b6;
  transform: translateY(-1px);
}

/* Paint Floating Badge over Canvas */
.qs-paint-floating-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  background: rgba(30, 19, 56, 0.94);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  pointer-events: auto;
  animation: qsFadeIn 0.15s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.qs-paint-dot {
  width: 14px;
  height: 10px;
  border-radius: 2px !important;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.qs-paint-info {
  white-space: nowrap;
}

.qs-paint-info b {
  color: #efbf04;
}

.qs-paint-done-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-paint-done-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Paint Indicator in Image Pane Header */
.qs-paint-mode-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-paint-mode-indicator:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.qs-paint-indicator-dot {
  width: 12px;
  height: 8px;
  border-radius: 2px !important;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.qs-paint-indicator-close {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Legacy selector compatibility */
.qs-legend-list {
  display: contents;
}
.qs-legend-card {
  display: contents;
}
.qs-legend-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  background: #f1ecf9;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.qs-bar-legend-input {
  width: 105px !important;
  font-family: inherit !important;
  padding: 2px 6px !important;
  font-size: 0.8rem !important;
}

.qs-panel-legend-custom-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.qs-legend-btn-confirm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: #10b981;
  border: 1px solid #059669;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.qs-legend-btn-confirm:hover {
  background: #059669;
}

.qs-legend-btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.qs-legend-btn-cancel:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.qs-legend-edit-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 11px;
  cursor: pointer;
  color: #475569;
  line-height: 1;
  transition: all 0.15s;
}

.qs-legend-edit-trigger:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: #6d28d9;
}

.qs-legend-del-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.qs-legend-del-btn:hover {
  color: #dc2626;
  background: #fee2e2;
}

.qs-bar-legend-select,
.qs-bar-panel-select {
  padding: 2px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1e1338;
  background: #ffffff;
  border: 1px solid #c4b5fd;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  max-width: 150px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.qs-bar-legend-select:focus,
.qs-bar-panel-select:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}




/* ── QuickStudio Result Table (Scrolling down) ── */
.table-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
}

.qs-results-card {
  margin: 20px 24px 36px 24px;
  background: #ffffff;
  border: 1px solid var(--qs-border);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(78, 42, 132, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.qs-results-header {
  background: #faf8fd;
  border-bottom: 1px solid var(--qs-border);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.qs-results-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--qs-fg);
  letter-spacing: -0.02em;
}

.qs-results-count-badge {
  font-size: 0.75rem;
  color: var(--qs-muted);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.qs-results-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qs-btn-scroll-top {
  background: #f1ecf9 !important;
  color: var(--qs-primary) !important;
  border-color: #dcd5eb !important;
}
.qs-btn-scroll-top:hover {
  background: var(--qs-primary) !important;
  color: #ffffff !important;
}

.qs-scroll-to-table-btn {
  margin-left: auto;
  background: #ffffff;
  border: 1px solid #4e2a84;
  color: #4e2a84;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2.5px 11px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(78, 42, 132, 0.08);
}
.qs-scroll-to-table-btn:hover {
  background: #4e2a84;
  color: #ffffff;
  border-color: #371a62;
  box-shadow: 0 2px 6px rgba(78, 42, 132, 0.25);
}

.larvol-data-table tbody tr.selected td {
  background: #f3e8ff !important;
}
.larvol-data-table tbody tr.selected {
  outline: 1.5px solid #7c3aed;
}



/* Standard Outline SVG Icon System */
.qs-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.qs-ic svg,
.qs-ic-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-layout-switch button svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-btn-fullscreen svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-done svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-scroll-to-table-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.qs-btn-scroll-top svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.qs-paint-info svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.qs-bar-panel-del svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-bar-panel-close svg,
.qs-dialog-close svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-label-edit-icon svg,
.qs-legend-edit-trigger svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-legend-btn-confirm svg,
.qs-legend-btn-cancel svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-tilt-badge svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.qs-tilt-nudge svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-chip-del-btn svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.qs-legend-add-chip svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.qs-empty-icon svg {
  width: 36px;
  height: 36px;
  stroke: #94a3b8;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin: 0 auto 6px;
  display: block;
}

/* Quick Bar Action Buttons: [+] on Left, [Del] on Right */
.qs-quick-btn {
  position: absolute;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  pointer-events: auto;
}

.qs-quick-btn-add {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #10b981;
  color: #10b981;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
  padding: 0;
}

.qs-quick-btn-add svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2.8;
  display: block;
}

.qs-quick-btn-add:hover {
  background: #10b981;
  color: #ffffff;
  transform: translate(-100%, -50%) scale(1.18) !important;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.45);
}

.qs-quick-btn-del {
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid #ef4444;
  color: #ef4444;
  font-size: 0.72rem;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.qs-quick-btn-del svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.2;
  display: block;
}

.qs-quick-btn-del:hover {
  background: #ef4444;
  color: #ffffff;
  transform: translate(0, -50%) scale(1.12) !important;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.45);
}

/* Selected Bar Outline in HTML Plot: Same crisp running dotted glow as canvas */
@keyframes qsRunningDottedBorder {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -30;
  }
}

#qsPlotSelectedBarOutline,
.qs-bar-selection-overlay {
  fill: none !important;
  stroke: #f97316 !important;
  stroke-width: 2.5px !important;
  stroke-dasharray: 6 4 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.9)) drop-shadow(0 0 8px rgba(234, 88, 12, 0.5)) !important;
  pointer-events: none !important;
  vector-effect: non-scaling-stroke !important;
  animation: qsRunningDottedBorder 0.9s linear infinite !important;
}

#qsPlotSelectedBarOutline.qs-outline-dark,
.qs-bar-selection-overlay.qs-outline-dark {
  stroke: #0f172a !important;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 6px rgba(15, 23, 42, 0.8)) !important;
}

