/* ======================================================
   Interactive Components for Distributed Training Article
   Inspired by ciechanow.ski interactive visualizations
   ====================================================== */

/* ---- Shared Widget Shell ---- */
.dt-widget {
  margin: 2rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: var(--bg-color, #fff);
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  overflow: hidden;
}
[data-theme="dark"] .dt-widget {
  border-color: #2e3a4a;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}
.dt-widget-header {
  background: var(--accent-color, #20B2AA);
  padding: 16px 20px;
}
h3.dt-widget-title {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}
.dt-widget-body {
  padding: 20px;
}
.dt-widget-footer {
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #888;
  text-align: center;
}
[data-theme="dark"] .dt-widget-footer {
  border-top-color: #2e3a4a;
  color: #888;
}

/* ---- Controls ---- */
.dt-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.dt-control-group:last-child {
  margin-bottom: 0;
}
.dt-label-text {
  flex: 0 0 80px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--font-color, #333);
  white-space: nowrap;
}
.dt-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--font-color, #333);
  margin-bottom: 6px;
}
.dt-label-value {
  font-weight: 600;
  font-size: 0.85rem;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
  flex-shrink: 0;
}
.dt-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  transition: background 0.15s;
}
[data-theme="dark"] .dt-slider {
  background: #2e3a4a;
}
.dt-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #20B2AA;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s;
}
.dt-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.dt-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #20B2AA;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.dt-select {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg-color, #fff);
  color: var(--font-color, #333);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
[data-theme="dark"] .dt-select {
  border-color: #2e3a4a;
  background: #1a1a2e;
  color: #ccc;
}
.dt-select:focus {
  border-color: #20B2AA;
}

/* ---- Memory Calculator ---- */
.mem-calc-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.mem-calc-stat {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
[data-theme="dark"] .mem-calc-stat {
  background: #111827;
}
.mem-calc-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #20B2AA;
}
.mem-calc-stat-label {
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
}
.mem-calc-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.mem-calc-bar-label {
  width: 140px;
  font-size: 0.82rem;
  color: var(--font-color, #555);
  flex-shrink: 0;
  text-align: right;
}
.mem-calc-bar-track {
  flex: 1;
  height: 22px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .mem-calc-bar-track {
  background: #1e293b;
}
.mem-calc-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
  display: block;
  min-width: 2px;
  position: relative;
}
.mem-calc-bar-fill.params { background: #10b981; }
.mem-calc-bar-fill.grads { background: #8b5cf6; }
.mem-calc-bar-fill.opt  { background: #ec4899; }
.mem-calc-bar-fill.master { background: #f59e0b; }
.mem-calc-bar-fill.act  { background: #06b6d4; }
.mem-calc-bar-fill.temp { background: #d946ef; }

.mem-calc-bar-val {
  width: 70px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--font-color, #555);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
#mem-calc .dt-label-text {
  flex: 0 0 115px;
}
.mem-calc-total {
  margin-top: 12px;
  padding: 12px;
  background: #f0fdf4;
  border-radius: 8px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--font-color, #333);
}
[data-theme="dark"] .mem-calc-total {
  background: #0a1f14;
}
.mem-calc-total span {
  color: #16a34a;
  font-size: 1.15rem;
}

/* ---- Pipeline Visualizer ---- */
.pipeline-controls {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pipeline-control-group {
  flex: 1;
  min-width: 140px;
}
.pipeline-grid-wrapper {
  overflow-x: auto;
  margin-bottom: 12px;
}
.pipeline-grid {
  display: inline-grid;
  gap: 2px;
  min-width: 100%;
}
.pipeline-cell {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  transition: all 0.15s;
}
.pipeline-cell.fwd {
  background: #22c55e;
}
.pipeline-cell.bwd {
  background: #3b82f6;
}
.pipeline-cell.idle {
  background: #e2e8f0;
}
[data-theme="dark"] .pipeline-cell.idle {
  background: #1e293b;
}
.pipeline-cell.empty {
  background: transparent;
}
.pipeline-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--font-color, #666);
}
.pipeline-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pipeline-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.pipeline-legend-swatch.fwd { background: #22c55e; }
.pipeline-legend-swatch.bwd { background: #3b82f6; }
.pipeline-legend-swatch.idle { background: #e2e8f0; }
[data-theme="dark"] .pipeline-legend-swatch.idle { background: #1e293b; }

.pipeline-bubble-stat {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .pipeline-bubble-stat {
  background: #111827;
}
.pipeline-bubble-stat-item {
  text-align: center;
}
.pipeline-bubble-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #20B2AA;
}
.pipeline-bubble-stat-label {
  font-size: 0.75rem;
  color: #888;
}
.pipeline-bubble-stat-value.danger {
  color: #ef4444;
}
.pipeline-bubble-stat-value.warning {
  color: #f59e0b;
}
.pipeline-bubble-stat-value.success {
  color: #22c55e;
}

/* ---- ZeRO Comparison ---- */
.zero-controls {
  margin-bottom: 16px;
}
.zero-stage-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
}
[data-theme="dark"] .zero-stage-tabs {
  background: #1e293b;
}
.zero-stage-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #888;
  transition: all 0.2s;
  text-align: center;
}
.zero-stage-tab:hover {
  color: var(--font-color, #333);
}
.zero-stage-tab.active {
  background: #fff;
  color: #20B2AA;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
[data-theme="dark"] .zero-stage-tab.active {
  background: #1a1a2e;
  color: #20B2AA;
}

.zero-chart {
  position: relative;
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 10px;
  margin-bottom: 8px;
}
.zero-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.zero-bar-stack {
  width: 100%;
  max-width: 60px;
  border-radius: 4px 4px 0 0;
  display: flex;
  flex-direction: column;
  height: 0;
  transition: height 0.4s ease;
  position: relative;
}
.zero-bar-segment {
  transition: height 0.4s ease;
  position: relative;
}
.zero-bar-segment.param { background: #10b981; }
.zero-bar-segment.grad { background: #8b5cf6; }
.zero-bar-segment.opt  { background: #ec4899; }
.zero-bar-segment.master { background: #f59e0b; }
.zero-bar-segment.act  { background: #06b6d4; }

.zero-bar-seg-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  white-space: nowrap;
  pointer-events: none;
}

.zero-bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--font-color, #555);
  margin-top: 6px;
  text-align: center;
}
.zero-bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: #20B2AA;
  text-align: center;
}
.zero-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
  font-size: 0.8rem;
  color: var(--font-color, #666);
}
.zero-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.zero-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.zero-savings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.zero-savings-item {
  text-align: center;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .zero-savings-item {
  background: #111827;
}
.zero-savings-label {
  font-size: 0.75rem;
  color: #888;
}
.zero-savings-value {
  font-size: 1rem;
  font-weight: 700;
  color: #20B2AA;
}

/* ---- ZeRO Communication Volume ---- */
.zero-comm-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}
[data-theme="dark"] .zero-comm-section {
  border-top-color: #2e3a4a;
}
.zero-comm-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--font-color, #555);
  margin-bottom: 10px;
}
.zero-comm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.zero-comm-label {
  width: 130px;
  font-size: 0.78rem;
  color: var(--font-color, #666);
  flex-shrink: 0;
  text-align: right;
}
.zero-comm-track {
  flex: 1;
  height: 16px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}
[data-theme="dark"] .zero-comm-track {
  background: #1e293b;
}
.zero-comm-fill {
  height: 100%;
  background: linear-gradient(90deg, #20B2AA, #06b6d4);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.zero-comm-ratio {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.zero-comm-value {
  width: 60px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #20B2AA;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.zero-comm-ratio-value {
  width: 60px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f59e0b;
  flex-shrink: 0;
}

/* ---- Ring AllReduce (slot-based vector display) ---- */
.ar-container {
  position: relative;
  width: 100%;
  min-height: 220px;
  overflow: visible;
  background: #f8fafc;
  border-radius: 8px;
  padding: 20px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px 40px;
  justify-items: center;
  align-items: center;
}
[data-theme="dark"] .ar-container {
  background: #0f172a;
}

.ar-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px 8px;
  position: relative;
  z-index: 2;
  width: fit-content;
  min-width: 140px;
  text-align: center;
}
[data-theme="dark"] .ar-card {
  background: #1e293b;
  border-color: #334155;
}
.ar-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--font-color, #333);
  margin-bottom: 5px;
}
[data-theme="dark"] .ar-card-title {
  color: #ccc;
}

.ar-slots {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.ar-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 28px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: #fff;
  transition: background 0.3s, transform 0.2s, box-shadow 0.2s;
}
.ar-slot-sending {
  animation: ar-slot-pulse 0.7s ease-in-out infinite;
  box-shadow: 0 0 0 2px rgba(32,178,170,0.7);
  z-index: 6;
}
.ar-slot-receiving {
  box-shadow: 0 0 0 2px rgba(251,191,36,0.7);
}
@keyframes ar-slot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); box-shadow: 0 0 10px rgba(32,178,170,0.5); }
}

/* SVG overlay lines */
.ar-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}
.ar-lines line {
  animation: ar-dash 0.7s linear infinite;
}
@keyframes ar-dash {
  to { stroke-dashoffset: -18; }
}

/* Step progress bar */
.ar-step-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 8px;
}
.ar-step-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: background 0.3s, transform 0.3s;
}
[data-theme="dark"] .ar-step-dot {
  background: #2e3a4a;
}
.ar-step-dot.done {
  background: #20B2AA;
}
.ar-step-dot.current {
  background: #20B2AA;
  transform: scale(1.5);
  box-shadow: 0 0 5px rgba(32,178,170,0.5);
}

/* Controls */
.ar-controls {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  justify-content: center;
}
.ar-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.ar-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.ar-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.ar-btn-primary {
  background: #20B2AA;
  color: #fff;
}
.ar-btn-primary:hover:not(:disabled) {
  background: #178f8c;
}
.ar-btn-secondary {
  background: transparent;
  border: 1.5px solid #e2e8f0;
  color: var(--font-color, #333);
}
[data-theme="dark"] .ar-btn-secondary {
  border-color: #2e3a4a;
  color: #ccc;
}
.ar-btn-secondary:hover:not(:disabled) {
  border-color: #20B2AA;
  color: #20B2AA;
}

.ar-step-label {
  text-align: center;
  font-size: 0.82rem;
  color: var(--font-color, #555);
  margin-top: 8px;
  font-family: 'Courier New', monospace;
  line-height: 1.35;
}

/* ---- Perplexity Explorer ---- */
.ppl-chart {
  margin-bottom: 16px;
}
.ppl-bars-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  justify-content: center;
  padding: 20px 0 10px;
}
.ppl-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 70px;
}
.ppl-bar-track {
  width: 100%;
  height: 120px;
  background: #f1f5f9;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
[data-theme="dark"] .ppl-bar-track {
  background: #1e293b;
}
.ppl-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, #20B2AA, #06b6d4);
  border-radius: 4px 4px 0 0;
  transition: height 0.15s ease;
  min-height: 2px;
}
.ppl-prob-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
  height: 1em;
}
.ppl-token-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--font-color, #555);
}
.ppl-slider {
  width: 100% !important;
}
.ppl-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}
[data-theme="dark"] .ppl-stats {
  border-top-color: #2e3a4a;
}
.ppl-stat-item {
  text-align: center;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .ppl-stat-item {
  background: #111827;
}
.ppl-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #20B2AA;
}
.ppl-stat-label {
  font-size: 0.72rem;
  color: #888;
  margin-top: 2px;
}
.ppl-intuition {
  color: #0891b2;
}

/* ---- BLEU Score Calculator ---- */
.bleu-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.bleu-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bleu-input-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--font-color, #555);
}
.bleu-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Courier New', monospace;
  background: var(--bg-color, #fff);
  color: var(--font-color, #333);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
[data-theme="dark"] .bleu-input {
  border-color: #2e3a4a;
  background: #1a1a2e;
  color: #ccc;
}
.bleu-input:focus {
  border-color: #20B2AA;
}
.bleu-results {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}
.bleu-precisions {
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .bleu-precisions {
  background: #111827;
}
.bleu-precision-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--font-color, #555);
  margin-bottom: 10px;
}
.bleu-precision-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.bleu-precision-row:last-child {
  margin-bottom: 0;
}
.bleu-precision-lbl {
  width: 110px;
  font-size: 0.78rem;
  color: var(--font-color, #666);
  flex-shrink: 0;
}
.bleu-precision-track {
  flex: 1;
  height: 18px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
[data-theme="dark"] .bleu-precision-track {
  background: #1e293b;
}
.bleu-precision-fill {
  height: 100%;
  transition: width 0.2s ease;
  background: linear-gradient(90deg, #20B2AA, #06b6d4);
}
.bleu-precision-val {
  width: 160px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #20B2AA;
  flex-shrink: 0;
  flex-grow: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.bleu-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  min-width: 140px;
}
[data-theme="dark"] .bleu-meta {
  background: #111827;
}
.bleu-meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.bleu-meta-lbl {
  font-size: 0.72rem;
  color: #888;
}
.bleu-meta-val {
  font-size: 1rem;
  font-weight: 700;
  color: #20B2AA;
}
.bleu-score {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border-radius: 10px;
  margin-top: 4px;
}
[data-theme="dark"] .bleu-score {
  background: linear-gradient(135deg, #0a1f14, #0d2818);
}
.bleu-score-lbl {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.bleu-score-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
}

/* ---- MCP Architecture Explorer ---- */
.mcp-arch-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 10px;
  flex-wrap: wrap;
}
.mcp-arch-component {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mcp-arch-card {
  background: var(--bg-color, #fff);
  border: 2px solid var(--mcp-color, #6366f1);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-width: 120px;
  user-select: none;
}
.mcp-arch-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
[data-theme="dark"] .mcp-arch-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.mcp-arch-card.active {
  background: var(--mcp-color, #6366f1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.mcp-arch-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mcp-color, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  margin: 0 auto 6px;
}
.mcp-arch-card.active .mcp-arch-card-icon {
  background: rgba(255,255,255,0.25);
}
.mcp-arch-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--font-color, #333);
}
.mcp-arch-card.active .mcp-arch-card-title,
.mcp-arch-card.active .mcp-arch-card-sub {
  color: #fff;
}
.mcp-arch-card-sub {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}
.mcp-arch-arrow {
  font-size: 1.4rem;
  color: var(--mcp-color, #888);
  font-weight: 300;
  line-height: 1;
}
.mcp-arch-arrow-right { margin-left: 4px; }
.mcp-arch-arrow-left { margin-right: 4px; }
.mcp-arch-detail {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
  background: #f8fafc;
}
[data-theme="dark"] .mcp-arch-detail {
  border-color: #2e3a4a;
  background: #111827;
}
.mcp-arch-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 6px;
}
.mcp-arch-detail-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--font-color, #333);
}
.mcp-arch-detail-role {
  font-size: 0.8rem;
  font-weight: 500;
  color: #20B2AA;
}
.mcp-arch-detail-section {
  margin-bottom: 10px;
}
.mcp-arch-detail-section:last-child {
  margin-bottom: 0;
}
.mcp-arch-detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mcp-arch-detail-desc,
.mcp-arch-detail-prims {
  font-size: 0.85rem;
  color: var(--font-color, #555);
  line-height: 1.5;
}
.mcp-arch-detail-json {
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: 'Courier New', monospace;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.4;
  margin: 0;
}

/* ---- MCP Handshake Simulator ---- */
.mcp-hs-phases {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 18px;
  padding: 10px 0;
}
.mcp-hs-phase {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #888;
  transition: all 0.2s;
}
.mcp-hs-phase.active {
  background: #20B2AA;
  color: #fff;
}
[data-theme="dark"] .mcp-hs-phase.active {
  background: #178f8c;
}
.mcp-hs-phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e2e8f0;
}
.mcp-hs-phase.active .mcp-hs-phase-dot {
  background: #fff;
}
.mcp-hs-connector {
  width: 24px;
  height: 2px;
  background: #e2e8f0;
}
[data-theme="dark"] .mcp-hs-connector {
  background: #2e3a4a;
}
.mcp-hs-flow {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
}
.mcp-hs-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mcp-hs-column-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--font-color, #555);
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  background: #f1f5f9;
}
[data-theme="dark"] .mcp-hs-column-label {
  background: #1e293b;
}
.mcp-hs-msg {
  flex: 1;
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: 'Courier New', monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.4;
  margin: 0;
  min-height: 60px;
  transition: all 0.3s;
}
.mcp-hs-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5568;
  font-family: sans-serif;
  font-size: 0.8rem;
}
.mcp-hs-arrows {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  width: 20px;
}
.mcp-hs-arrow-down,
.mcp-hs-arrow-up {
  font-size: 1rem;
  color: #20B2AA;
  opacity: 0.5;
}
.mcp-hs-desc {
  text-align: center;
  font-size: 0.85rem;
  color: var(--font-color, #555);
  margin: 8px 0 10px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .mcp-hs-desc {
  background: #111827;
}
.mcp-hs-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}
.mcp-hs-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: background 0.3s, transform 0.3s;
}
[data-theme="dark"] .mcp-hs-dot {
  background: #2e3a4a;
}
.mcp-hs-dot.done {
  background: #20B2AA;
}
.mcp-hs-dot.current {
  background: #20B2AA;
  transform: scale(1.5);
  box-shadow: 0 0 5px rgba(32,178,170,0.5);
}


/* ---- MCP Tool Call Flow ---- */
.mcp-tf-flow {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 20px 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.mcp-tf-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: var(--bg-color, #fff);
  transition: all 0.3s;
  min-width: 80px;
  flex-shrink: 0;
}
[data-theme="dark"] .mcp-tf-node {
  border-color: #2e3a4a;
}
.mcp-tf-node.active {
  border-color: #20B2AA;
  background: #f0fdfa;
  box-shadow: 0 0 0 3px rgba(32,178,170,0.2);
  transform: scale(1.05);
}
[data-theme="dark"] .mcp-tf-node.active {
  background: #0a1f14;
}
.mcp-tf-node.done {
  border-color: #10b981;
  background: #f0fdf4;
  opacity: 0.7;
}
[data-theme="dark"] .mcp-tf-node.done {
  background: #0a1f14;
  opacity: 0.6;
}
.mcp-tf-node-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.mcp-tf-node-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--font-color, #555);
  text-align: center;
  white-space: nowrap;
}
.mcp-tf-connector {
  width: 24px;
  height: 2px;
  background: #e2e8f0;
  flex-shrink: 0;
  transition: background 0.3s;
}
[data-theme="dark"] .mcp-tf-connector {
  background: #2e3a4a;
}
.mcp-tf-connector.done {
  background: #10b981;
}
.mcp-tf-detail {
  padding: 14px;
  background: #f8fafc;
  border-radius: 8px;
  margin: 8px 0;
}
[data-theme="dark"] .mcp-tf-detail {
  background: #111827;
}
.mcp-tf-stage {
  font-size: 0.85rem;
  color: var(--font-color, #555);
  line-height: 1.5;
  margin-bottom: 6px;
}
.mcp-tf-stage-query { border-left: 3px solid #6366f1; padding-left: 10px; }
.mcp-tf-stage-reason { border-left: 3px solid #8b5cf6; padding-left: 10px; }
.mcp-tf-stage-call { border-left: 3px solid #f59e0b; padding-left: 10px; }
.mcp-tf-stage-route { border-left: 3px solid #20B2AA; padding-left: 10px; }
.mcp-tf-stage-execute { border-left: 3px solid #10b981; padding-left: 10px; }
.mcp-tf-stage-response { border-left: 3px solid #22c55e; padding-left: 10px; }
.mcp-tf-desc {
  font-size: 0.85rem;
  font-weight: 600;
  color: #20B2AA;
}
.mcp-tf-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
}
.mcp-tf-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: background 0.3s, transform 0.3s;
}
[data-theme="dark"] .mcp-tf-dot {
  background: #2e3a4a;
}
.mcp-tf-dot.done {
  background: #20B2AA;
}
.mcp-tf-dot.current {
  background: #20B2AA;
  transform: scale(1.5);
  box-shadow: 0 0 5px rgba(32,178,170,0.5);
}

@media (max-width: 640px) {
  .bleu-inputs { grid-template-columns: 1fr; }
  .bleu-results { grid-template-columns: 1fr; }
  .ppl-stats { grid-template-columns: 1fr; }
  .ppl-bar-track { height: 80px; }
  .ppl-bar-group { max-width: 44px; }
  .ppl-intuition { font-size: 0.85rem; }
  .bleu-precision-lbl { width: 80px; font-size: 0.7rem; }
  .mcp-arch-diagram { flex-direction: column; gap: 8px; }
  .mcp-arch-arrow { transform: rotate(90deg); }
  .mcp-arch-arrow-right, .mcp-arch-arrow-left { margin: 0; }
  .mcp-hs-flow { flex-direction: column; }
  .mcp-hs-arrows { flex-direction: row; width: auto; }
  .mcp-hs-arrow-down, .mcp-hs-arrow-up { transform: rotate(90deg); }
  .mcp-tf-flow { flex-wrap: wrap; gap: 4px; }
  .mcp-tf-node { min-width: 60px; padding: 6px 8px; }
  .mcp-tf-node-label { font-size: 0.6rem; }
  .mcp-tf-connector { width: 12px; }
}

/* ---- RGB Color Mixer ---- */
.rgb-layout {
  display: flex;
  gap: 24px;
  align-items: stretch;
}
.rgb-controls {
  flex: 1;
  min-width: 0;
}
.rgb-swatch-area {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.rgb-swatch {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  transition: background 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
[data-theme="dark"] .rgb-swatch {
  border-color: #2e3a4a;
}
.rgb-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 12px;
}
.rgb-value-item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
[data-theme="dark"] .rgb-value-item {
  background: #111827;
}
.rgb-value-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rgb-value-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.rgb-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rgb-preset-label {
  font-size: 0.78rem;
  color: #888;
  margin-right: 4px;
}
.rgb-preset-btn {
  width: 28px;
  height: 28px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
  padding: 0;
}
[data-theme="dark"] .rgb-preset-btn {
  border-color: #2e3a4a;
}
.rgb-preset-btn:hover {
  transform: scale(1.15);
  border-color: #20B2AA;
}

/* ---- HSV/HSL Explorer ---- */
.hsv-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.hsv-controls {
  flex: 1;
  min-width: 0;
}
.hsv-mode-tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 16px;
}
[data-theme="dark"] .hsv-mode-tabs {
  background: #1e293b;
}
.hsv-mode-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #888;
  transition: all 0.2s;
  text-align: center;
}
.hsv-mode-tab:hover {
  color: var(--font-color, #333);
}
.hsv-mode-tab.active {
  background: #fff;
  color: #20B2AA;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
[data-theme="dark"] .hsv-mode-tab.active {
  background: #1a1a2e;
  color: #20B2AA;
}
.hsv-rgb-display {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--font-color, #555);
  text-align: center;
}
[data-theme="dark"] .hsv-rgb-display {
  background: #111827;
}
.hsv-rgb-val {
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
}
.hsv-controls-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.hsv-sliders {
  flex: 1;
  min-width: 0;
}
.hsv-swatch-area {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.hsv-swatch {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  transition: background 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
[data-theme="dark"] .hsv-swatch {
  border-color: #2e3a4a;
}
.hsv-shapes-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  margin-top: 14px;
}
.hsv-plane-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hsv-shape-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hsv-shape-canvas {
  width: 260px;
  height: 260px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}
[data-theme="dark"] .hsv-shape-canvas {
  border-color: #2e3a4a;
}
.hsv-shape-label {
  font-size: 0.75rem;
  color: #888;
  margin-top: 6px;
}
.hsv-plane {
  width: 100%;
  max-width: 260px;
  height: 260px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}
[data-theme="dark"] .hsv-plane {
  border-color: #2e3a4a;
}
.hsv-plane-label {
  font-size: 0.75rem;
  color: #888;
  margin-top: 6px;
}

/* ---- Delta E Color Comparator ---- */
.de-layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
}
.de-color-a, .de-color-b {
  flex: 1;
  max-width: 280px;
}
.de-side-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--font-color, #555);
  margin-bottom: 8px;
  text-align: center;
}
.de-swatch {
  width: 100%;
  height: 80px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  transition: background 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 12px;
}
[data-theme="dark"] .de-swatch {
  border-color: #2e3a4a;
}
.de-side-controls {
  padding: 0 4px;
}
.de-side-group {
  margin-bottom: 6px !important;
}
.de-hex-label {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #20B2AA;
  font-family: 'Courier New', monospace;
  margin-top: 4px;
}
.de-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  flex-shrink: 0;
}
.de-vs-text {
  font-size: 1rem;
  font-weight: 700;
  color: #888;
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 20px;
}
[data-theme="dark"] .de-vs-text {
  background: #1e293b;
}
.de-results {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
  margin: 18px 0 14px;
}
.de-result-card {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}
[data-theme="dark"] .de-result-card {
  background: #111827;
}
.de-result-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.de-result-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
}
.de-result-perception .de-result-value {
  font-size: 0.85rem;
  color: #0891b2;
}
.de-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.de-preset-label {
  font-size: 0.78rem;
  color: #888;
  margin-right: 4px;
}
.de-preset-btn {
  padding: 5px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-color, #fff);
  color: var(--font-color, #333);
  transition: all 0.15s;
}
[data-theme="dark"] .de-preset-btn {
  border-color: #2e3a4a;
  background: #1a1a2e;
  color: #ccc;
}
.de-preset-btn:hover {
  border-color: #20B2AA;
  color: #20B2AA;
}

/* ---- Visible Spectrum Explorer ---- */
.spec-layout {
  display: flex;
  gap: 24px;
  align-items: stretch;
}
.spec-controls {
  flex: 1;
  min-width: 0;
}
.spec-info {
  margin-top: 12px;
}
.spec-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.spec-info-label {
  width: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--font-color, #555);
  flex-shrink: 0;
}
.spec-info-val {
  width: 40px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  text-align: right;
}
.spec-info-bar {
  flex: 1;
  height: 10px;
  background: #f1f5f9;
  border-radius: 5px;
  overflow: hidden;
}
[data-theme="dark"] .spec-info-bar {
  background: #1e293b;
}
.spec-info-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.1s;
}
.spec-s-fill { background: #3b82f6; }
.spec-m-fill { background: #22c55e; }
.spec-l-fill { background: #ef4444; }
.spec-dominant {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--font-color, #555);
  text-align: center;
  padding: 8px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .spec-dominant {
  background: #111827;
}
.spec-dom-val {
  color: #20B2AA;
}
.spec-visuals {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.spec-swatch {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  transition: background 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
[data-theme="dark"] .spec-swatch {
  border-color: #2e3a4a;
}
.spec-wavelength-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
}
.spec-chart-container {
  margin-top: 16px;
}
.spec-chart {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}
[data-theme="dark"] .spec-chart {
  border-color: #2e3a4a;
}

/* ---- Chromaticity Explorer ---- */
.chroma-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.chroma-diagram-container {
  position: relative;
  flex-shrink: 0;
}
.chroma-canvas {
  width: 300px;
  height: 300px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: block;
}
[data-theme="dark"] .chroma-canvas {
  border-color: #2e3a4a;
}
.chroma-axis-label {
  font-size: 0.7rem;
  color: #888;
  position: absolute;
}
.chroma-x-label {
  bottom: -18px;
  right: 10px;
}
.chroma-y-label {
  top: 5px;
  left: -8px;
  transform: rotate(-90deg);
}
.chroma-controls {
  flex: 1;
  min-width: 0;
}
.chroma-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
}
[data-theme="dark"] .chroma-preview {
  background: #111827;
}
.chroma-preview-swatch {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  transition: background 0.1s;
  flex-shrink: 0;
}
[data-theme="dark"] .chroma-preview-swatch {
  border-color: #2e3a4a;
}
.chroma-preview-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chroma-preview-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chroma-preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
  width: 20px;
}
.chroma-preview-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #20B2AA;
  font-variant-numeric: tabular-nums;
}
.chroma-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chroma-note {
  font-size: 0.75rem;
  color: #888;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
}
[data-theme="dark"] .chroma-note {
  background: #1e293b;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .mem-calc-bar-label { width: 90px; font-size: 0.75rem; }
  .mem-calc-bar-val { width: 55px; font-size: 0.75rem; }
  .pipeline-cell { width: 24px; height: 24px; font-size: 0.55rem; }
  .zero-chart { height: 160px; }
  .ar-container { gap: 8px 14px; padding: 10px; min-height: auto; }
  .ar-card { min-width: 90px; padding: 4px 6px; }
  .ar-card-title { font-size: 0.6rem; }
  .ar-slot { width: 28px; height: 22px; font-size: 0.6rem; }
  .ar-step-label { font-size: 0.7rem; }
  .ar-lines { display: none; }
  .rgb-layout { flex-direction: column; align-items: center; }
  .rgb-swatch { width: 80px; height: 80px; }
  .rgb-values { grid-template-columns: 1fr 1fr; }
  .rgb-value-val { font-size: 0.8rem; }
  .hsv-layout { flex-direction: column; align-items: center; }
  .hsv-swatch { width: 80px; height: 80px; }
  .hsv-controls-row { flex-direction: column; align-items: center; }
  .hsv-plane { max-width: 200px; height: 200px; }
  .hsv-shapes-row { flex-direction: column; align-items: center; }
  .hsv-shape-canvas { width: 200px; height: 200px; }
  .de-layout { flex-direction: column; align-items: center; }
  .de-color-a, .de-color-b { max-width: 100%; width: 100%; }
  .de-vs { padding: 8px 0; }
  .de-results { grid-template-columns: 1fr 1fr; }
  .de-result-value { font-size: 1rem; }
  .spec-layout { flex-direction: column; align-items: center; }
  .spec-swatch { width: 80px; height: 80px; }
  .spec-chart { height: 160px; }
  .spec-info-label { width: 80px; font-size: 0.7rem; }
  .chroma-layout { flex-direction: column; align-items: center; }
  .chroma-canvas { width: 240px; height: 240px; }
}

/* ---- Chunk Explorer ---- */
.chunk-text-display {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.chunk-text-display::-webkit-scrollbar { width: 6px; }
.chunk-text-display::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
[data-theme="dark"] .chunk-text-display {
  background: #111827 !important;
  border-color: #2e3a4a !important;
}
[data-theme="dark"] .chunk-text-display::-webkit-scrollbar-thumb { background: #334155; }

/* ---- Vector Search Simulator ---- */
.vecsearch-plot {
  max-width: 100%;
}
.vecsearch-query:focus {
  border-color: #20B2AA !important;
}
.vecsearch-btn:hover {
  background: #178f8c !important;
}
.vecsearch-btn:active {
  transform: scale(0.97);
}
.vecsearch-random-btn:hover {
  border-color: #20B2AA !important;
  color: #20B2AA !important;
}
.vecsearch-random-btn:active {
  transform: scale(0.97);
}
.vecsearch-results {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.vecsearch-results::-webkit-scrollbar { width: 5px; }
.vecsearch-results::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
[data-theme="dark"] .vecsearch-results {
  scrollbar-color: #334155 transparent;
}
[data-theme="dark"] .vecsearch-results::-webkit-scrollbar-thumb { background: #334155; }

[data-theme="dark"] .vecsearch-query {
  background: #1a1a2e !important;
  color: #ccc !important;
  border-color: #2e3a4a !important;
}

@media (max-width: 640px) {
  .vecsearch-plot { width: 100%; }
  .vecsearch-plot svg { width: 100%; height: auto; }
}

/* ---- Temp Explorer ---- */
[data-theme="dark"] .temp-orig-chart,
[data-theme="dark"] .temp-mod-chart {
  background: #111827 !important;
  border-color: #2e3a4a !important;
}

/* ---- Masking Viz ---- */
[data-theme="dark"] .masking-image-grid > div {
  border-color: #2e3a4a !important;
}
[data-theme="dark"] .masking-text-tokens {
  background: #111827 !important;
  border-color: #2e3a4a !important;
}
[data-theme="dark"] .masking-description {
  background: #111827 !important;
  border-color: #2e3a4a !important;
}

/* ---- Arch Compare ---- */
[data-theme="dark"] .arch-diagram svg {
  background: #111827 !important;
}
[data-theme="dark"] .arch-diagram svg rect[fill*="var"] {
  fill: #111827 !important;
}
[data-theme="dark"] .arch-diagram svg text {
  fill: #e2e8f0 !important;
}
[data-theme="dark"] .arch-details {
  background: #111827 !important;
  border-color: #2e3a4a !important;
}

/* ---- Quant Sim ---- */
.quant-table thead th { color: var(--font-color,#555); border-color: #e2e8f0; }
[data-theme="dark"] .quant-table thead th { border-color: #2e3a4a; }
[data-theme="dark"] .quant-input,
[data-theme="dark"] .quant-mode { background: #111827 !important; color: #e2e8f0 !important; border-color: #2e3a4a !important; }
[data-theme="dark"] .quant-table tbody tr {
  background: #1a1a2e !important;
  border-color: #2e3a4a !important;
}
[data-theme="dark"] .quant-table tbody td { border-color: #2e3a4a; }

/* ---- CUDA Thread Block Mapper ---- */
[data-theme="dark"] .cbm-grid-svg { background: #111827; }
[data-theme="dark"] .cbm-block-x, [data-theme="dark"] .cbm-block-y { background: #1a1a2e !important; color: #ccc !important; border-color: #2e3a4a !important; }
[data-theme="dark"] .cbm-thread-info { background: #111827 !important; border-color: #2e3a4a !important; }

/* ---- CUDA Tiled Matmul Animator ---- */
[data-theme="dark"] .cta-matrix-a svg, [data-theme="dark"] .cta-matrix-b svg,
[data-theme="dark"] .cta-matrix-c svg, [data-theme="dark"] .cta-shared-a svg,
[data-theme="dark"] .cta-shared-b svg { background: #111827; }
[data-theme="dark"] .cta-phase { background: #0a1f14 !important; border-color: #178f8c !important; }



