/* ══════════════════════════════════════════════════════════════
   nterm.css — v0.6.0
   
   Changes from v0.5:
   - --ui-scale custom property for font scaling
   - Contrast-improved default colors (text-dim, text-muted lifted)
   - All font sizes use calc() with --ui-scale multiplier
   - Minimum font sizes bumped: 10px→11px, 9px→10px base
   - Enhanced/high contrast mode via CSS class on <html>
   - Zoom indicator in status bar
   ══════════════════════════════════════════════════════════════ */

:root {
    /* ── Scale factor (set by JS/desktop) ─────────────── */
    --ui-scale: 1;

    /* ── Base colors ──────────────────────────────────── */
    --bg:          #0a0e14;
    --bg-panel:    #0d1117;
    --bg-surface:  #131820;
    --bg-elevated: #1a2030;
    --bg-hover:    #1c2333;
    --bg-active:   #21293a;

    /* ── Borders (improved from #1e2736) ─────────────── */
    --border:      #222d3d;
    --border-light: #2e3d50;

    /* ── Text (contrast-improved defaults) ────────────── 
         Old: text #d4dce8, muted #6b7d96, dim #3d4f65
         New: dim raised ~40%, muted raised ~15%          */
    --text:        #d4dce8;
    --text-muted:  #7d92ab;
    --text-dim:    #536b84;

    /* ── Accent colors (unchanged) ───────────────────── */
    --cyan:        #00d4aa;
    --cyan-dim:    rgba(0,212,170,0.12);
    --red:         #f85149;
    --red-dim:     rgba(248,81,73,0.12);
    --green:       #3fb950;
    --green-dim:   rgba(63,185,80,0.12);
    --yellow:      #e3b341;
    --yellow-dim:  rgba(227,179,65,0.12);
    --blue:        #58a6ff;
    --orange:      #d29922;
    --magenta:     #e872b0;

    /* ── Font size tokens (scaled) ───────────────────── */
    --fs-xs:    calc(10px * var(--ui-scale));   /* was 9px  — badges, meta */
    --fs-sm:    calc(11px * var(--ui-scale));   /* was 10px — labels, status */
    --fs-base:  calc(12px * var(--ui-scale));   /* was 11px — tab labels, body */
    --fs-md:    calc(13px * var(--ui-scale));   /* was 12px — inputs, sidebar */
    --fs-lg:    calc(14px * var(--ui-scale));   /* buttons, headings */
    --fs-mono:  calc(11px * var(--ui-scale));   /* monospace body text */
  }

  /* ── Enhanced contrast mode ─────────────────────────── */
  html.contrast-enhanced {
    --text:        #e2e8f0;
    --text-muted:  #8da2b8;
    --text-dim:    #5a7a96;
    --border:      #263040;
    --border-light: #344455;
  }
  html.contrast-high {
    --text:        #f1f5f9;
    --text-muted:  #a8bdd0;
    --text-dim:    #7094b4;
    --border:      #2d4050;
    --border-light: #3d5565;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html {
    height: 100%;
    overflow: hidden;
  }
  body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    font-size: var(--fs-md);
  }

/* ── Scrollbars (Chromium / QWebEngineView) ─────── */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: var(--bg-panel);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
  }
  ::-webkit-scrollbar-corner {
    background: var(--bg-panel);
  }

  /* ── Layout ───────────────────────────────────────── */
  .app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .title-bar {
    height: 36px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 12px;
    flex-shrink: 0;
  }
  .title-bar .brand {
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--cyan);
    letter-spacing: 1px;
  }
  .title-bar .title-controls {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .title-bar .title-controls button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    padding: 2px 8px;
    border-radius: 3px;
    font-family: inherit;
    transition: all 0.15s;
  }
  .title-bar .title-controls button:hover {
    border-color: var(--cyan);
    color: var(--cyan);
  }
  .title-bar .title-controls button.active {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
  }
  .title-bar .status-text {
    font-size: var(--fs-sm);
    color: var(--text-dim);
    margin-left: auto;
  }
  .main-area {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* ── Sidebar ──────────────────────────────────────── */
  .sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 0;
    overflow-y: auto;
    transition: width 0.15s ease;
  }
  .sidebar.collapsed { width: 0; overflow: hidden; }
  .sidebar-section {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-section h3 {
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
  }
  .form-group { margin-bottom: 8px; }
  .form-group label {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: 3px;
    letter-spacing: 0.3px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: var(--fs-md);
    color: var(--text);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    outline: none;
    transition: border-color 0.15s;
  }
  .form-group input:focus,
  .form-group textarea:focus {
    border-color: var(--cyan);
  }
  .form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-size: var(--fs-sm);
  }
  .form-row {
    display: flex;
    gap: 8px;
  }
  .form-row .form-group { flex: 1; }
  .checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
  }
  .checkbox-group input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--cyan);
  }
  .checkbox-group label {
    font-size: var(--fs-base);
    color: var(--text-muted);
    margin: 0;
  }
  .auth-method-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
    background: var(--bg);
    border-radius: 4px;
    padding: 2px;
  }
  .auth-method-tabs button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 5px 4px;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
    font-family: inherit;
  }
  .auth-method-tabs button.active {
    background: var(--bg-elevated);
    color: var(--cyan);
  }
  .auth-fields { display: none; }
  .auth-fields.active { display: block; }
  .btn-connect {
    width: 100%;
    padding: 8px;
    background: var(--cyan-dim);
    border: 1px solid var(--cyan);
    border-radius: 4px;
    color: var(--cyan);
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.15s;
    font-family: inherit;
    margin-top: 4px;
  }
  .btn-connect:hover { background: rgba(0,212,170,0.2); }
  .btn-connect:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .btn-connect.connecting {
    color: var(--yellow);
    border-color: var(--yellow);
    background: var(--yellow-dim);
  }

  /* ── Terminal area ────────────────────────────────── */
  .terminal-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
  }
  .tab-bar {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    height: 32px;
    flex-shrink: 0;
    overflow-x: auto;
    padding: 0 4px;
    gap: 2px;
  }
  .tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px 4px 0 0;
    font-size: var(--fs-base);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.15s;
  }
  .tab-btn:hover { background: var(--bg-hover); }
  .tab-btn.active {
    background: var(--bg);
    color: var(--text);
  }
  .tab-btn .status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
  }
  .tab-btn .status-dot.connected { background: var(--green); }
  .tab-btn .status-dot.error { background: var(--red); }
  .tab-btn .status-dot.connecting {
    background: var(--yellow);
    animation: pulse 1s ease-in-out infinite;
  }
  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }
  .tab-btn .close-tab {
    font-size: var(--fs-lg);
    color: var(--text-dim);
    margin-left: 2px;
    line-height: 1;
  }
  .tab-btn .close-tab:hover { color: var(--red); }
  .terminal-panels {
    flex: 1;
    position: relative;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .terminal-pane {
    position: absolute;
    inset: 0;
    display: none;
    padding: 4px;
  }
  .terminal-pane.active { display: block; }
  /* When diag panel is open, terminal panes need room */
  .terminal-panels.diag-open .terminal-pane {
    bottom: 180px;
  }
  .terminal-pane .xterm { height: 100%; }
  .empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-dim);
  }
  .empty-state .logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--cyan);
    letter-spacing: 2px;
    opacity: 0.3;
  }
  .empty-state .hint { font-size: var(--fs-md); }

  /* ── Gutter bar (block indicators) ─────────────── */
  .terminal-pane-inner {
    display: flex;
    height: 100%;
  }
  .block-gutter {
    width: 14px;
    background: transparent;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 2;
  }
  .gutter-mark {
    position: absolute;
    left: 3px;
    width: 8px;
    border-radius: 2px;
    cursor: pointer;
    transition: opacity 0.15s, box-shadow 0.15s;
  }
  .gutter-mark.gutter-normal {
    background: #ff9d2e;
    opacity: 0.7;
    box-shadow: 0 0 4px rgba(255,157,46,0.3);
    border: 1px solid rgba(255,180,80,0.25);
  }
  .gutter-mark.gutter-normal:hover {
    opacity: 1;
    background: #ffb347;
    box-shadow: 0 0 10px rgba(255,157,46,0.6), 0 0 20px rgba(255,130,0,0.2);
  }
  .gutter-mark.gutter-interrupted {
    background: #f85149;
    opacity: 0.7;
    box-shadow: 0 0 4px rgba(248,81,73,0.3);
    border: 1px solid rgba(248,100,90,0.25);
  }
  .gutter-mark.gutter-interrupted:hover {
    opacity: 1;
    box-shadow: 0 0 10px rgba(248,81,73,0.6), 0 0 20px rgba(248,50,40,0.2);
  }
  .gutter-mark.gutter-active {
    opacity: 1;
    background: #ffb347;
    box-shadow: 0 0 12px rgba(255,157,46,0.7), 0 0 24px rgba(255,130,0,0.3);
  }

  /* ── Block context menu ────────────────────────── */
  .block-ctx-menu {
    position: fixed;
    z-index: 1000;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 220px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    font-family: 'Segoe UI', -apple-system, sans-serif;
    font-size: var(--fs-md);
  }
  .block-ctx-menu .ctx-header {
    padding: 6px 14px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
  }
  .block-ctx-menu .ctx-cmd {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }
  .block-ctx-menu .ctx-meta {
    font-size: var(--fs-xs);
    color: var(--text-dim);
    margin-top: 2px;
  }
  .block-ctx-menu .ctx-item {
    padding: 7px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    transition: background 0.1s;
  }
  .block-ctx-menu .ctx-item:hover {
    background: var(--bg-hover);
  }
  .block-ctx-menu .ctx-item .ctx-icon {
    width: 16px;
    text-align: center;
    font-size: var(--fs-lg);
    flex-shrink: 0;
  }
  .block-ctx-menu .ctx-item .ctx-badge {
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--text-dim);
    background: var(--bg-panel);
    padding: 2px 6px;
    border-radius: 3px;
  }
  .block-ctx-menu .ctx-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
  }
  .block-ctx-menu .ctx-item.ctx-cyan  { color: var(--cyan); }
  .block-ctx-menu .ctx-item.ctx-yellow { color: var(--yellow); }
  .block-ctx-menu .ctx-item.ctx-blue  { color: var(--blue); }
  .block-ctx-menu .ctx-item.ctx-disabled {
    color: var(--text-dim);
    cursor: default;
    opacity: 0.5;
  }
  .block-ctx-menu .ctx-item.ctx-disabled:hover {
    background: transparent;
  }
  .ctx-toast {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--cyan);
    padding: 6px 16px;
    border-radius: 4px;
    font-size: var(--fs-base);
    font-family: 'Segoe UI', -apple-system, sans-serif;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
  }
  .ctx-toast.show { opacity: 1; }

  /* ── Diagnostics panel ────────────────────────────── */
  .diag-panel {
    height: 180px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }
  .diag-panel.open { display: flex; }
  .diag-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
  }
  .diag-header .diag-tabs {
    display: flex;
    gap: 12px;
  }
  .diag-header .diag-tab {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 0;
    border-bottom: 1px solid transparent;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
  }
  .diag-header .diag-tab.active {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
  }
  .diag-body {
    flex: 1;
    overflow: auto;
    padding: 6px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-sm);
    line-height: 1.6;
  }
  .diag-body .log-line {
    display: flex;
    gap: 8px;
    color: var(--text-muted);
  }
  .diag-body .log-time {
    color: var(--text-dim);
    flex-shrink: 0;
    width: 70px;
  }
  .diag-body .log-tag {
    padding: 0 4px;
    border-radius: 2px;
    font-size: var(--fs-xs);
    flex-shrink: 0;
  }
  .diag-body .tag-recv { background: var(--cyan-dim); color: var(--cyan); }
  .diag-body .tag-send { background: var(--yellow-dim); color: var(--yellow); }
  .diag-body .tag-event { background: var(--blue); color: #fff; }
  .diag-body .tag-sniff { background: var(--magenta); color: #fff; }
  .diag-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    padding: 4px 0;
  }
  .diag-stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
  }
  .diag-stat-card .stat-host {
    font-size: var(--fs-base);
    color: var(--text);
    margin-bottom: 4px;
  }
  .diag-stat-card .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.8;
  }
  .diag-stat-card .stat-val { color: var(--cyan); }

  /* ── Sniffer lines (Milestone 1) ───────────────── */
  .sniffer-line {
    display: flex;
    gap: 10px;
    line-height: 1.5;
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-sm);
  }
  .sniffer-num {
    color: var(--text-dim);
    flex-shrink: 0;
    user-select: none;
    width: 32px;
    text-align: right;
  }
  .sniffer-text {
    color: var(--text-muted);
    white-space: pre;
    overflow-x: hidden;
    text-overflow: ellipsis;
  }
  .sniffer-pending .sniffer-num { color: var(--cyan); }
  .sniffer-pending .sniffer-text { color: var(--cyan); }
  .sniffer-cursor {
    color: var(--cyan);
    animation: pulse 1s ease-in-out infinite;
  }
  .sniffer-badge {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 0 4px;
    border-radius: 2px;
    flex-shrink: 0;
    text-transform: uppercase;
  }
  .sniffer-badge.badge-pagination { background: var(--yellow-dim); color: var(--yellow); }
  .sniffer-badge.badge-confirm    { background: var(--red-dim);    color: var(--red); }
  .sniffer-badge.badge-continue   { background: var(--yellow-dim); color: var(--orange); }
  .sniffer-badge.badge-auth       { background: var(--red-dim);    color: var(--magenta); }

  /* ── Prompt detector (Milestone 3) ───────────────── */
  .prompt-status {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 6px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
  }
  .prompt-state-badge {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
  }
  .prompt-state-badge.state-learning  { background: var(--yellow-dim); color: var(--yellow); }
  .prompt-state-badge.state-candidate { background: var(--blue);       color: #fff; opacity: 0.85; }
  .prompt-state-badge.state-locked    { background: var(--green-dim);  color: var(--green); }
  .prompt-info {
    display: flex;
    gap: 16px;
    font-size: var(--fs-sm);
  }
  .prompt-info-label { color: var(--text-dim); }
  .prompt-info-val   { color: var(--cyan); font-family: 'JetBrains Mono', monospace; }
  .prompt-events {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-sm);
    line-height: 1.6;
  }
  .prompt-event {
    display: flex;
    gap: 8px;
    color: var(--text-muted);
  }
  .prompt-event-time {
    color: var(--text-dim);
    flex-shrink: 0;
    width: 70px;
  }
  .prompt-event-type {
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 0 4px;
    border-radius: 2px;
    flex-shrink: 0;
    min-width: 60px;
    text-align: center;
    text-transform: uppercase;
  }
  .prompt-event-type.evt-candidate { background: var(--blue); color: #fff; opacity: 0.8; }
  .prompt-event-type.evt-confirmed { background: var(--green-dim); color: var(--green); }
  .prompt-event-type.evt-matched   { background: var(--cyan-dim); color: var(--cyan); }
  .prompt-event-type.evt-variant   { background: var(--yellow-dim); color: var(--yellow); }
  .prompt-event-type.evt-rejected  { background: var(--red-dim); color: var(--red); }
  .prompt-event-line {
    color: var(--text-muted);
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
  }
  .prompt-event-detail {
    color: var(--text-dim);
    font-size: var(--fs-xs);
  }

  /* ── Block extractor (Milestone 4) ───────────────── */
  .block-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-sm);
  }
  .block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
  }
  .block-header:hover { background: var(--bg-hover); }
  .block-command {
    color: var(--cyan);
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .block-meta {
    display: flex;
    gap: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
    font-size: var(--fs-xs);
  }
  .block-meta .interrupted-badge {
    background: var(--yellow-dim);
    color: var(--yellow);
    font-size: calc(var(--fs-xs) - 1px);
    font-weight: 600;
    padding: 0 4px;
    border-radius: 2px;
    text-transform: uppercase;
  }
  .block-preview {
    display: none;
    padding: 4px 10px 8px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    white-space: pre;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
  }
  .block-card.expanded .block-preview { display: block; }
  .block-expand-hint {
    color: var(--text-dim);
    font-size: var(--fs-xs);
  }
  .block-empty {
    color: var(--text-dim);
    padding: 12px;
    font-size: var(--fs-sm);
  }

  /* ── Status bar ───────────────────────────────────── */
  .status-bar {
    height: 24px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    justify-content: space-between;
    flex-shrink: 0;
    font-size: var(--fs-sm);
    color: var(--text-dim);
  }
  .status-bar .zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
  }
  .status-bar .zoom-controls button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    padding: 0 6px;
    border-radius: 2px;
    font-family: inherit;
    line-height: 18px;
    transition: all 0.15s;
  }
  .status-bar .zoom-controls button:hover {
    border-color: var(--cyan);
    color: var(--cyan);
  }
  .status-bar .zoom-indicator {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
    cursor: pointer;
    user-select: none;
  }
  .status-bar .zoom-indicator:hover { color: var(--cyan); }
  .status-bar .contrast-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--fs-xs);
    padding: 0 6px;
    border-radius: 2px;
    font-family: inherit;
    line-height: 18px;
    margin-left: 8px;
    transition: all 0.15s;
  }
  .status-bar .contrast-toggle:hover {
    border-color: var(--cyan);
    color: var(--cyan);
  }

  /* ── Visualizer overlay ──────────────────────────── */
  .viz-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
  }
  .viz-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    width: min(90vw, 860px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
    overflow: hidden;
  }
  .viz-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .viz-header .viz-cmd {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--cyan);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .viz-header .viz-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
  }
  .viz-header .viz-close:hover { color: var(--text); }
  .viz-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
    flex-shrink: 0;
    flex-wrap: wrap;
  }
  .viz-confidence {
    font-weight: 700;
    font-size: var(--fs-xs);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 3px;
  }
  .viz-confidence.conf-high    { background: var(--green-dim); color: var(--green); }
  .viz-confidence.conf-partial { background: var(--yellow-dim); color: var(--yellow); }
  .viz-confidence.conf-low     { background: var(--red-dim); color: var(--red); }
  .viz-confidence.conf-llm     { background: rgba(88,166,255,0.12); color: var(--blue); }
  .viz-confidence.conf-none    { background: var(--bg-surface); color: var(--text-dim); }
  .viz-meta-item {
    color: var(--text-dim);
  }
  .viz-meta-item span { color: var(--text-muted); }
  .viz-body {
    flex: 1;
    overflow: auto;
    padding: 0;
  }
  .viz-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--fs-base);
  }
  .viz-table th {
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    color: var(--cyan);
    font-weight: 600;
    font-size: var(--fs-sm);
    letter-spacing: 0.3px;
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
  }
  .viz-table td {
    padding: 5px 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .viz-table tr:hover td {
    background: var(--bg-hover);
  }
  .viz-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  .viz-footer button {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
  }
  .viz-footer button:hover {
    border-color: var(--cyan);
    color: var(--cyan);
  }
  .viz-footer .viz-spacer { flex: 1; }
  .viz-footer .viz-stats {
    font-size: var(--fs-xs);
    color: var(--text-dim);
  }
  .viz-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: var(--fs-md);
  }
  .viz-loading {
    padding: 32px 16px;
    text-align: center;
    color: var(--cyan);
    font-size: var(--fs-md);
  }
  .viz-loading .viz-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }