/* ═══════════════════════════════════════════════════════════════════
   Western Blot — Dark theme matching mimowb.html mockup
   Scoped under #wb-workspace to avoid leaking into Agora sidebar.
   CSP: style-src 'self', font-src 'self' — system font stack, no CDN.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Page-level overrides for WB full-viewport layout ────────── */
body.agora-body[data-page="biovision-wb"] {
  overflow: hidden;
  height: 100vh;
}
body.agora-body[data-page="biovision-wb"] .agora {
  height: 100vh;
  overflow: hidden;
}
body.agora-body[data-page="biovision-wb"] .ag-workspace,
body.agora-body[data-page="biovision-wb"] .agora .ag-workspace {
  padding: 0;
  overflow: hidden;
  height: 100%;
}

/* ── Design Tokens (scoped to WB workspace) ───────────────────── */
#wb-workspace {
  --bg-0: oklch(0.165 0.012 250);
  --bg-1: oklch(0.205 0.012 250);
  --bg-2: oklch(0.245 0.014 250);
  --bg-3: oklch(0.295 0.014 250);
  --border: oklch(0.32 0.012 250);
  --border-soft: oklch(0.27 0.012 250);
  --text: oklch(0.965 0.005 250);
  --text-2: oklch(0.82 0.008 250);
  --muted: oklch(0.62 0.012 250);
  --dim: oklch(0.48 0.012 250);
  --accent: oklch(0.80 0.13 195);
  --accent-strong: oklch(0.86 0.16 195);
  --accent-dim: oklch(0.45 0.07 195);
  --warn: oklch(0.82 0.15 78);
  --bad: oklch(0.70 0.19 25);
  --sel: oklch(0.74 0.18 320);
  --topbar-height: 40px;
  --inspector-width: 320px;

  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
}

/* ── Reset inside workspace ───────────────────────────────────── */
#wb-workspace *,
#wb-workspace *::before,
#wb-workspace *::after {
  box-sizing: border-box;
}

/* ── CSP utility: hidden ──────────────────────────────────────── */
.is-hidden { display: none !important; }

/* ── Presentational classes (moved from inline style=) ────────── */
/* Image info chip (topbar crumb) */
.wb-img-chip {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
}

/* Help button (topbar — replaces avatar) */
.wb-help-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: help;
  font-family: inherit;
  transition: all 0.15s;
}

.wb-help-btn:hover {
  background: var(--bg-3);
  color: var(--text-2);
  border-color: var(--accent-dim);
}

/* Flex spacer */
.wb-spacer { flex: 1; }

/* Lane info text (toolbar) */
.wb-lane-info-text {
  color: var(--muted);
  font-size: 11px;
}

/* Drop zone emoji */
.wb-drop-emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

/* AI confidence label (AI card header) */
.wb-ai-conf {
  font-size: 10px;
  color: var(--muted);
}

/* kDa input label */
.wb-kda-label {
  font-size: 12px;
  color: var(--muted);
}

/* Lane count badge */
.wb-lane-count-badge {
  font-size: 10px;
}

/* Expert detail row */
.wb-expert-row {
  margin-bottom: 6px;
}

/* Expert divider row (scene type) */
.wb-expert-divider {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

/* Chat toggle layout/look lives in the "Aspis Helper Chat — v3" block below. */

/* Chat AI tag */
.wb-chat-ai-tag {
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .06em;
  color: var(--wbc-quiet, var(--muted));
}

/* Chat toggle caret icon */
.wb-chat-toggle-icon {
  width: 12px;
  height: 12px;
  color: var(--wbc-quiet, var(--muted));
  transition: transform 0.2s;
}

/* Band hint extras (margin) — combined with .is-hidden when hidden */
.wb-band-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* Lane hint extras (margin) — combined with .is-hidden when hidden */
.wb-lane-hint {
  margin-top: 8px;
}


/* Chat suggestions row (built in JS, was inline cssText) */
.wb-chat-suggest-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* AI summary warning text (was inline color in innerHTML) */
.wb-warn-text {
  color: var(--warn);
}

/* AI summary error text (was inline color in innerHTML) */
.wb-error-text {
  color: var(--bad);
}

/* ── Mono font stack ──────────────────────────────────────────── */
#wb-workspace .mono {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', 'JetBrains Mono', SFMono-Regular, Consolas, monospace;
  font-feature-settings: 'zero', 'ss01';
}

/* ── Layout ───────────────────────────────────────────────────── */
#wb-workspace {
  display: grid !important;
  grid-template-rows: var(--topbar-height) 1fr;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
}

#wb-workspace .wb-main-area {
  display: grid;
  grid-template-columns: 1fr var(--inspector-width);
  min-height: 0;
}

/* ── Top Bar ──────────────────────────────────────────────────── */
.wb-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-soft);
  height: var(--topbar-height);
  font-size: 12.5px;
  flex-shrink: 0;
}

.wb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wb-brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-strong), transparent 50%),
    radial-gradient(circle at 70% 70%, var(--sel), transparent 55%),
    var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--border);
  flex-shrink: 0;
}

.wb-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.wb-crumb b {
  color: var(--text);
  font-weight: 500;
}

.wb-crumb .sep {
  opacity: .4;
}

/* Editable project name */
#wbProjectName[contenteditable="true"] {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s;
}

#wbProjectName[contenteditable="true"]:hover {
  background: var(--bg-2);
}

#wbProjectName[contenteditable="true"]:focus {
  outline: none;
  background: var(--bg-0);
  border: 1px solid var(--accent-dim);
  cursor: text;
}

.wb-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Mode-specific styling ────────────────────────────────────── */
#wb-workspace.mode-guided .wb-canvas-toolbar {
  border-left: 3px solid var(--accent);
}

#wb-workspace.mode-expert .wb-canvas-toolbar {
  border-left: 3px solid var(--sel);
}

/* Expert badge */
.wb-expert-badge {
  display: inline-block;
  background: var(--sel);
  color: oklch(0.165 0.012 250);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 8px;
  flex-shrink: 0;
  align-self: center;
}

/* ── Segmented Control ────────────────────────────────────────── */
.wb-segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 11.5px;
}

.wb-segmented button {
  padding: 4px 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
  border-radius: 6px;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wb-segmented button.on {
  background: var(--bg-0);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.wb-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: inherit;
}

.wb-btn:hover {
  background: var(--bg-3);
}

.wb-btn.primary {
  background: var(--accent);
  color: oklch(0.165 0.012 250);
  border-color: transparent;
}

.wb-btn.primary:hover {
  background: var(--accent-strong);
}

.wb-btn.warn {
  background: var(--warn);
  color: oklch(0.165 0.012 250);
  border-color: transparent;
}

.wb-btn.warn:hover {
  opacity: 0.9;
}

.wb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── AI CTA button ────────────────────────────────────────────── */
.wb-ai-cta {
  background: linear-gradient(135deg, var(--accent), var(--sel));
  color: oklch(0.165 0.012 250);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.wb-ai-cta:hover {
  opacity: 0.9;
}

.wb-ai-cta:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Mini segmented ───────────────────────────────────────────── */
.wb-seg-mini {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 11px;
}

.wb-seg-mini button {
  padding: 4px 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
  border-radius: 4px;
  font: inherit;
}

.wb-seg-mini button.on {
  background: var(--bg-0);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ── Canvas Area ──────────────────────────────────────────────── */
.wb-canvas-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  min-width: 0;
  min-height: 0;
}

.wb-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.wb-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 0;
  min-width: 0;
}

.wb-blot-canvas {
  width: 100%;
  height: 100%;
  max-width: 800px;
  max-height: 600px;
  background: var(--bg-1);
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  position: relative;
  overflow: hidden;
}

.wb-blot-canvas img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.wb-blot-canvas.dragover {
  border-color: var(--accent);
  background: var(--bg-2);
}

/* Drop zone */
.wb-drop-zone {
  text-align: center;
  padding: 40px;
  cursor: pointer;
}

.wb-drop-zone:hover {
  color: var(--text-2);
}

.wb-drop-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Band overlay ─────────────────────────────────────────────── */
.wb-band-overlay {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(128, 200, 255, 0.1);
  cursor: pointer;
  pointer-events: auto;
  border-radius: 2px;
  /* FIX H1: touch-action must be unconditional so a touch tap on the overlay
     fires a pointer/click instead of being swallowed by scroll/zoom gestures.
     Selection (Pick mode) needs this just as much as ROI drag. */
  touch-action: none;
}

.wb-band-overlay.ladder {
  border-color: var(--warn);
  background: rgba(240, 136, 62, 0.15);
}

.wb-band-overlay.selected {
  border-color: var(--sel);
  background: rgba(200, 100, 200, 0.2);
}

.wb-band-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text);
  background: var(--bg-0);
  padding: 1px 3px;
  border-radius: 2px;
  white-space: nowrap;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', 'JetBrains Mono', monospace;
}

/* ── ROI editing (Phase 3): drag + resize handles ─────────────── */
/* Handles + move cursor are only active when the canvas is .is-editable
   (currentTool === "roi" AND a densitometry plane exists). */
.wb-blot-canvas.is-editable .wb-band-overlay {
  cursor: move; /* touch-action is now unconditional on .wb-band-overlay (FIX H1) */
}

.wb-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--accent-strong);
  border: 1px solid var(--bg-0);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  display: none; /* shown only when the canvas is editable */
  touch-action: none;
  z-index: 2;
}

.wb-blot-canvas.is-editable .wb-handle {
  display: block;
}

.wb-band-overlay.ladder .wb-handle {
  background: var(--warn);
}

.wb-band-overlay.selected .wb-handle {
  background: var(--sel);
}

/* Corner + edge placement. Each handle is centered on its anchor point via a
   -5px offset (≈ half the 9px box + 1px border). */
.wb-handle-nw { top: -5px;  left: -5px;  cursor: nwse-resize; }
.wb-handle-n  { top: -5px;  left: 50%; margin-left: -5px; cursor: ns-resize; }
.wb-handle-ne { top: -5px;  right: -5px; cursor: nesw-resize; }
.wb-handle-e  { top: 50%; margin-top: -5px; right: -5px; cursor: ew-resize; }
.wb-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.wb-handle-s  { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.wb-handle-sw { bottom: -5px; left: -5px;  cursor: nesw-resize; }
.wb-handle-w  { top: 50%; margin-top: -5px; left: -5px;  cursor: ew-resize; }

/* ── Inspector Panel ──────────────────────────────────────────── */
.wb-inspector {
  background: var(--bg-1);
  border-left: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wb-inspector-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

.wb-inspector-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.wb-inspector-content::-webkit-scrollbar {
  width: 8px;
}

.wb-inspector-content::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 4px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.wb-card {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.wb-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

/* Section label */
.wb-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 12px;
}

.wb-section-label .grow {
  flex: 1;
}

/* ── Band Card ────────────────────────────────────────────────── */
.wb-band-card {
  border-left: 3px solid var(--accent);
}

.wb-band-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.wb-band-role {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: oklch(0.165 0.012 250);
  text-transform: uppercase;
}

.wb-band-name {
  font-weight: 500;
}

/* Editable role select (Phase 5) — styled like the static .wb-band-role badge */
.wb-band-role-select {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent);
  color: oklch(0.165 0.012 250);
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.wb-band-role-select:focus {
  outline: 1px solid var(--accent-strong);
}

.wb-band-role-select option {
  background: var(--bg-2);
  color: var(--text);
}

/* Implicit LADDER role badge (Phase 5) — shown instead of the select for
   bands in the ladder lane (not editable as target/HK). */
.wb-band-role-ladder {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--warn);
  color: oklch(0.165 0.012 250);
  text-transform: uppercase;
}

/* Editable band name input (Phase 5) */
.wb-band-name-input {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: 12px;
  background: var(--bg-0);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text);
  padding: 3px 6px;
  font-family: inherit;
}

.wb-band-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.wb-band-name-input::placeholder {
  color: var(--muted);
}

.wb-band-meta {
  color: var(--muted);
  font-size: 12px;
}

.wb-band-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.wb-readout-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wb-readout-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wb-readout-value {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
}

.wb-readout-value.accent {
  color: var(--accent);
}

.wb-readout-value.warn {
  color: var(--warn);
}

/* kDa input for ladder bands */
.wb-kda-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.wb-kda-input {
  width: 80px;
  padding: 4px 8px;
  background: var(--bg-0);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text);
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', 'JetBrains Mono', monospace;
  font-size: 12px;
}

.wb-kda-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Flag ─────────────────────────────────────────────────────── */
.wb-flag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 8px;
}

.wb-flag.warn {
  background: oklch(0.25 0.05 78 / 0.3);
  color: var(--warn);
}

/* ── AI Card ──────────────────────────────────────────────────── */
.wb-ai-card {
  background: linear-gradient(135deg, oklch(0.2 0.02 250), oklch(0.22 0.03 250));
  border: 1px solid var(--accent-dim);
}

.wb-ai-card .wb-card-header {
  color: var(--accent);
}

.wb-ai-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

.wb-ai-body b {
  color: var(--text);
}

/* Linearity / gamma caveat (Phase 4): small chip in the AI summary header.
   .is-ok variant for linear TIFFs; .is-warn for display-gamma JPEG/PNG. */
.wb-linearity-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  cursor: help;
  color: var(--muted);
  border: 1px solid var(--border-soft);
  background: oklch(0.22 0.008 250 / 0.4);
}

.wb-linearity-chip.is-ok {
  color: var(--text-2);
  border-color: var(--border-soft);
  background: oklch(0.24 0.02 195 / 0.35);
}

.wb-linearity-chip.is-warn {
  color: var(--warn);
  border-color: var(--warn);
  background: oklch(0.25 0.05 78 / 0.3);
}

.wb-ai-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.wb-ai-mini-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}

.wb-ai-mini-btn:hover {
  background: var(--bg-0);
}

/* ── Lane List ────────────────────────────────────────────────── */
.wb-lane-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wb-lane-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.wb-lane-item:hover {
  background: var(--bg-3);
}

.wb-lane-item.selected {
  background: oklch(0.25 0.02 250);
  border: 1px solid var(--accent-dim);
}

.wb-lane-item.ladder {
  background: oklch(0.25 0.05 78 / 0.2);
}

.wb-lane-item.ladder.selected {
  background: oklch(0.25 0.05 78 / 0.3);
}

.wb-lane-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.wb-lane-name {
  flex: 1;
}

.wb-lane-count {
  color: var(--muted);
  font-size: 11px;
}

.wb-ladder-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--warn);
  color: oklch(0.165 0.012 250);
  text-transform: uppercase;
}

.wb-set-ladder-btn,
.wb-set-control-btn {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}

.wb-set-ladder-btn:hover,
.wb-set-control-btn:hover {
  background: var(--bg-3);
}

/* Control-lane designation (Phase 5) */
.wb-set-control-btn.is-active {
  background: var(--sel);
  color: oklch(0.165 0.012 250);
  border-color: transparent;
}

.wb-control-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--sel);
  color: oklch(0.165 0.012 250);
  text-transform: uppercase;
}

.wb-lane-item.control {
  background: oklch(0.25 0.05 320 / 0.2);
}

.wb-lane-item.control.selected {
  background: oklch(0.25 0.05 320 / 0.3);
}

/* Control-lane bar marker in the fold-change chart (Phase 5) */
.wb-chart-bar.control {
  box-shadow: inset 0 0 0 2px var(--sel);
}

/* ── Slot switcher (Phase 6: dual-image) ──────────────────────── */
/* A subtle dot on a slot button that already holds an image, so the user can
   see at a glance whether the housekeeping slot is loaded. */
#wbSlotToggle button.wb-slot-has-image::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  vertical-align: middle;
}

/* Per-target-lane housekeeping-lane mapping select (Phase 6). Shown in the lane
   row only when dual-image + viewing the target slot. */
.wb-lane-map-select {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--bg-0);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}

.wb-lane-map-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Lane-count mismatch note under the lane list (Phase 6). */
.wb-lane-map-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
}

/* ── Chart ────────────────────────────────────────────────────── */
.wb-chart-container {
  height: 120px;
  background: var(--bg-0);
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: flex-end;
  padding: 8px;
  gap: 4px;
}

.wb-chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  position: relative;
  cursor: pointer;
  transition: filter 0.15s;
}

.wb-chart-bar:hover {
  filter: brightness(1.1);
}

.wb-chart-bar .label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Statistics ───────────────────────────────────────────────── */
.wb-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
}

/* ── Expert details ───────────────────────────────────────────── */
.wb-expert-details {
  font-size: 11px;
  line-height: 1.6;
}

/* ── Chat bottom-pinned section ──────────────────────────────── */
.wb-chat-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--border-soft);
  padding: 12px;
}

/* ── Ctrl+Alt Explain Mode ──────────────────────────────────── */
#wb-explain-tip {
  position: fixed;
  z-index: 9999;
  max-width: 280px;
  padding: 10px 14px;
  background: oklch(0.18 0.014 250);
  color: var(--text);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.12s;
}

#wb-explain-tip.is-visible {
  opacity: 1;
}

.wb-explain-mode {
  cursor: help !important;
}

.wb-explain-mode [data-explain] {
  outline: 1px dashed var(--accent-dim);
  outline-offset: 2px;
  cursor: help;
}

/* ── Calibration ──────────────────────────────────────────────── */
.wb-calibration-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--bg-0);
  border-radius: 4px;
}

.wb-calibration-result {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-0);
  border-radius: 4px;
  font-size: 11px;
}

.wb-calibration-result .r2 {
  color: var(--accent);
  font-weight: 600;
}

/* ── Loading overlay ──────────────────────────────────────────── */
.wb-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: oklch(0.165 0.012 250 / 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.wb-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: wb-spin 1s linear infinite;
}

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

/* ── Step indicator ───────────────────────────────────────────── */
.wb-step-indicator {
  padding: 6px 8px;
  background: var(--bg-2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  margin-top: 8px;
}

.wb-step-number {
  font-weight: 700;
  color: var(--accent);
}

/* ── Hidden file input ────────────────────────────────────────── */
#wbFileInput {
  display: none;
}

/* ── Icon sizing ──────────────────────────────────────────────── */
.wb-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Hint visibility (Guided mode) ────────────────────────────── */
/* Base display is block; toggled via .is-hidden so removing it restores block. */
.wb-hint {
  display: block;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ── Smooth transitions ───────────────────────────────────────── */
.wb-canvas-toolbar,
.wb-inspector-content,
.wb-band-card,
.wb-lane-list {
  transition: all 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   Aspis Helper Chat — v3 warm-dark design
   ═══════════════════════════════════════════════════════════════════ */

/* v3 look from ai-scientist-chat-mockup.html (the .drawer aside), adapted to
   the INLINE WB inspector panel. Warm-dark tokens are scoped LOCALLY to the
   chat (header + card) so the rest of the page theme is untouched.
   Visual only — chat logic / IDs / SSE wiring unchanged. */
.wb-chat-toggle,
#wbChatCard {
  --wbc-text: #f8f0e6;
  --wbc-muted: #c7b7a7;
  --wbc-quiet: #8c8178;
  --wbc-line: rgba(255, 255, 255, .12);
  --wbc-line-soft: rgba(255, 255, 255, .075);
  --wbc-amber: #f4d19a;
  --wbc-rose: #d4a9a0;
  --wbc-cyan: #87d8f7;
}

/* Header (the section-label toggle) — brand-mark globe + name + sub */
.wb-chat-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  cursor: pointer;
}

/* 34px globe disc — header brand-mark */
.wb-chat-brand {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .54));
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .8);
  overflow: hidden;
}

.wb-chat-brand img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: .96;
}

.wb-chat-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.wb-chat-identity-name {
  font-size: 18px;
  font-weight: 780;
  line-height: 1.1;
  color: var(--wbc-text);
  letter-spacing: 0;
  text-transform: none;
}

.wb-chat-identity-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--wbc-quiet);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The chat card itself — warm-dark inline panel */
#wbChatCard {
  color: var(--wbc-text);
}

.wb-chat-container {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 2px;
  margin-bottom: 14px;
}

.wb-chat-container::-webkit-scrollbar {
  width: 6px;
}

.wb-chat-container::-webkit-scrollbar-thumb {
  background: var(--wbc-line);
  border-radius: 3px;
}

/* Message = uppercase label ABOVE a bubble. No per-message avatar. */
.wb-chat-message {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.wb-chat-message.user {
  padding-left: 62px;
}

.wb-chat-message.assistant {
  padding-right: 12px;
}

.wb-chat-name {
  display: block;
  font-size: 11px;
  font-weight: 760;
  color: var(--wbc-quiet);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 0;
}

.wb-chat-bubble {
  min-width: 0;
  border: 1px solid var(--wbc-line-soft);
  border-radius: 24px;
  padding: 15px 16px;
  font-size: 13px;
  line-height: 1.54;
  color: var(--wbc-text);
}

.wb-chat-message.user .wb-chat-bubble {
  border-top-right-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025)),
    rgba(35, 36, 42, .82);
}

.wb-chat-message.assistant .wb-chat-bubble {
  border-top-left-radius: 10px;
  background:
    linear-gradient(155deg, rgba(248, 226, 201, .09), rgba(255, 255, 255, .03) 46%, rgba(135, 216, 247, .045)),
    rgba(16, 17, 20, .92);
  box-shadow: 0 22px 48px rgba(0, 0, 0, .22);
}

.wb-chat-text {
  margin-top: 0;
  font-size: 13px;
  line-height: 1.54;
  color: var(--wbc-text);
}

/* Typing indicator — 3 dots inside the assistant bubble */
.wb-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 2px 0;
}

.wb-typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--wbc-muted);
  border-radius: 50%;
  animation: wb-typing 1.4s infinite ease-in-out;
}

.wb-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.wb-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.wb-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wb-typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Composer — pill input + amber→rose round send */
.wb-chat-input-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--wbc-line);
}

.wb-chat-input {
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--wbc-line);
  border-radius: 999px;
  color: var(--wbc-text);
  font-size: 13px;
  font-family: inherit;
}

.wb-chat-input:focus {
  outline: none;
  border-color: rgba(244, 209, 154, .5);
}

.wb-chat-input::placeholder {
  color: var(--wbc-quiet);
}

.wb-chat-send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: linear-gradient(145deg, #f8e2c9, #d4a9a0);
  border-radius: 999px;
  cursor: pointer;
  color: #14100b;
  font-weight: 800;
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 14px 30px rgba(212, 169, 160, .22);
}

.wb-chat-send:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

/* Suggestion chips */
.wb-chat-suggestions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--wbc-line);
}

.wb-chat-suggestion {
  border: 1px solid var(--wbc-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .055);
  color: var(--wbc-text);
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}

.wb-chat-suggestion:hover {
  background: rgba(255, 255, 255, .1);
}

/* ── Save-to-Vault inline form (CSP-safe; toggled by JS) ───────── */
.wb-vault-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}

.wb-vault-form.is-hidden {
  display: none;
}

.wb-vault-form-label {
  color: var(--muted);
  white-space: nowrap;
}

.wb-vault-form-input {
  flex: 0 1 280px;
  min-width: 0;
  padding: 6px 10px;
  background: var(--bg-0);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
}

.wb-vault-form-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #wb-workspace .wb-main-area {
    grid-template-columns: 1fr;
  }
  #wb-workspace .wb-inspector {
    display: none;
  }
}
