/* =============================================================================
   THEME TOKENS
   Two-tier system:
     Tier 1 (--palette-*) — raw color primitives. Single source of truth.
     Tier 2 (--color-*, --shadow-*) — function-named semantic tokens that
     reference primitives. ALL CSS rules below reference Tier 2 tokens (never
     raw hex / rgba and never primitives directly), so adding a Light theme
     later only requires re-mapping Tier 2 under :root[data-theme="light"].
   ============================================================================= */

:root,
:root[data-theme="dark"] {
    color-scheme: dark;

    /* ── Shape + type tokens (Style D · Rounded Pill, 2026-10-18). Theme-independent. ── */
    --r-sm:   8px;      /* small chrome: badges, swatches, tiny controls          */
    --r-md:   10px;     /* inputs, selects, menu items, hover pills               */
    --r-lg:   14px;     /* cards, panels, popovers                                */
    --r-xl:   16px;     /* modals, floating windows                               */
    --r-pill: 999px;    /* buttons, tabs, chips, counts                           */
    --font-ui: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', Consolas, 'SFMono-Regular', Menlo, monospace;
    accent-color: var(--color-accent);

    /* ── Tier 1: Palette primitives ───────────────────────────────────────── */

    /* Cyan accent family */
    --palette-cyan-300:       #a8ffe9;
    --palette-cyan-400:       #64ffda;
    --palette-cyan-500:       #00d4aa;

    /* Navy / blue family */
    --palette-navy-950:       #0d1625;
    --palette-navy-900:       #0a1628;
    --palette-navy-850:       #0d1b2e;
    --palette-navy-800:       #0d1b2a;
    --palette-navy-750:       #0d2137;
    --palette-navy-725:       #091523;
    --palette-navy-700:       #0f3460;
    --palette-navy-650:       #112240;
    --palette-navy-600:       #1e3a5f;
    --palette-navy-500:       #1e3050;
    --palette-navy-450:       #2a4a6a;
    --palette-navy-400:       #3d5a7a;
    --palette-navy-350:       #4a6080;
    --palette-navy-300:       #6baed6;

    /* Midnight (page / card chrome) family */
    --palette-midnight-900:   #1a1a2e;
    --palette-midnight-800:   #16213e;
    --palette-midnight-700:   #2a2a3a;

    /* Slate (text / muted) family */
    --palette-slate-700:      #4a5568;
    --palette-slate-600:      #6b7a99;
    --palette-slate-500:      #8892b0;
    --palette-slate-400:      #8892a4;
    --palette-slate-300:      #ccd6f6;
    --palette-slate-200:      #e6f1ff;
    --palette-slate-100:      #eaeaea;

    /* GitHub-style neutral grays (used in newer panels) */
    --palette-gh-bg-900:      #0d1117;
    --palette-gh-bg-800:      #161b22;
    --palette-gh-bg-700:      #21262d;
    --palette-gh-border-700:  #30363d;
    --palette-gh-text-500:    #8b949e;
    --palette-gh-text-300:    #c9d1d9;
    --palette-gh-text-200:    #e6edf3;

    /* Bootstrap-flavored grays (neutral status indicator) */
    --palette-gray-500:       #6c757d;
    --palette-gray-600:       #64748b;
    --palette-gray-700:       #4a5568;
    --palette-gray-800:       #2d3748;

    /* Amber / warm warning shades (earnings-soon) */
    --palette-amber-300:      #e6a817;
    --palette-amber-500:      #ffc107;
    --palette-amber-700:      #8a5c00;

    /* Deep red (earnings-today border) */
    --palette-red-900:        #8b1a1a;

    /* Status hues */
    --palette-red-400:        #ff6b6b;
    --palette-red-500:        #dc3545;
    --palette-red-600:        #ef4444;
    --palette-red-700:        #f87171;
    --palette-green-400:      #69db7c;
    --palette-green-500:      #4ade80;
    --palette-green-600:      #28a745;
    --palette-yellow-300:     #ffd43b;
    --palette-orange-400:     #ffa94d;
    --palette-orange-500:     #ff9f40;
    --palette-blue-400:       #74c0fc;
    --palette-blue-500:       #58a6ff;

    /* Absolutes */
    --palette-black:          #000000;
    --palette-white:          #ffffff;

    /* ── Tier 2: Semantic surface tokens ──────────────────────────────────── */
    --color-bg-page:                 var(--palette-midnight-900);
    /* Generic surface ramp (primary = base, secondary = raised, tertiary = hover).
       Referenced by the note-window database table/header/toolbars; must be opaque
       so sticky headers don't show scrolled rows through them. */
    --color-bg-primary:              var(--palette-midnight-900);
    --color-bg-secondary:            var(--palette-midnight-800);
    --color-bg-tertiary:             var(--palette-midnight-700);
    --color-bg-card:                 var(--palette-midnight-800);
    --color-bg-card-elevated:        var(--palette-midnight-700);
    --color-bg-input:                var(--palette-midnight-900);
    --color-bg-modal:                var(--palette-midnight-800);
    --color-bg-modal-overlay:        rgba(0, 0, 0, 0.6);
    --color-bg-tooltip:              var(--palette-midnight-800);
    --color-bg-table-header:         var(--palette-gh-bg-900);
    --color-bg-table-row-alt:        rgba(255, 255, 255, 0.04);
    --color-bg-row-hover:            rgba(255, 255, 255, 0.04);
    --color-bg-row-hover-accent:     rgba(100, 255, 218, 0.05);
    --color-bg-section-header:       var(--palette-midnight-900);
    --color-bg-section-header-hover: #1e2a4a;
    --color-bg-subtotal-row:         #1a2744;
    --color-bg-total-row:            var(--palette-navy-700);
    --color-bg-options-group-header: var(--palette-navy-900);
    --color-bg-toolbar:              var(--palette-navy-700);
    --color-bg-disabled:             #2a3a50;
    --color-bg-button-secondary:     #1e1e3a;
    --color-bg-button-secondary-hover: #2a2a4a;

    /* Ticker tape (bottom strip + editor window) */
    --color-bg-ticker-tape:          var(--palette-navy-900);
    --color-bg-ticker-editor:        var(--palette-navy-850);
    --color-bg-ticker-textarea:      #07111f;
    --color-border-ticker:           #0f2545;
    --color-border-ticker-section:   #1a2a4a;

    /* ── Tier 2: Semantic border tokens ───────────────────────────────────── */
    --color-border-default:          var(--palette-navy-700);
    --color-border-strong:           var(--palette-navy-600);
    --color-border-subtle:           rgba(255, 255, 255, 0.08);
    --color-border-input:            var(--palette-navy-600);
    --color-border-focus:            var(--palette-cyan-400);
    --color-border-card-accent:      var(--palette-cyan-400);
    --color-border-divider:          var(--palette-navy-700);

    /* Overlay borders/rings used on colored swatches and pickers */
    --color-overlay-ring-soft:       rgba(255, 255, 255, 0.18);
    --color-overlay-ring-medium:     rgba(255, 255, 255, 0.50);
    --color-overlay-ring-strong:     rgba(255, 255, 255, 0.70);
    --color-overlay-divider:         rgba(255, 255, 255, 0.08);
    --color-overlay-row-tint:        rgba(255, 255, 255, 0.04);

    /* Translucent navy hover/track tints (alternative dark-mode hover style) */
    --color-bg-card-hover-tint:      rgba(15, 52, 96, 0.25);
    --color-bg-card-hover-tint-strong: rgba(15, 52, 96, 0.45);
    --color-bg-track-tint:           rgba(15, 52, 96, 0.30);
    --color-bg-track-tint-strong:    rgba(15, 52, 96, 0.40);
    --color-bg-nested-panel:         rgba(15, 31, 61, 0.65);

    /* ── Tier 2: Semantic text tokens ─────────────────────────────────────── */
    --color-text-primary:            var(--palette-slate-100);
    --color-text-secondary:          var(--palette-slate-300);
    --color-text-muted:              var(--palette-slate-500);
    --color-text-faint:              #4a5580;
    --color-text-tiny-label:         var(--palette-gray-600);
    --color-text-disabled:           var(--palette-slate-700);
    --color-text-link:               var(--palette-cyan-400);
    --color-text-inverse:            var(--palette-navy-900);
    --color-text-on-accent:          var(--palette-navy-900);
    --color-text-placeholder:        var(--palette-slate-600);

    /* ── Tier 2: Brand / accent ───────────────────────────────────────────── */
    --color-accent:                  var(--palette-cyan-400);
    --color-accent-hover:            var(--palette-cyan-300);
    --color-accent-active:           var(--palette-cyan-500);
    --color-accent-tint-subtle:      rgba(100, 255, 218, 0.05);
    --color-accent-tint-soft:        rgba(100, 255, 218, 0.10);
    --color-accent-tint-medium:      rgba(100, 255, 218, 0.18);
    --color-accent-tint-strong:      rgba(100, 255, 218, 0.30);

    /* ── Tier 2: Status colors with parallel tint scales ──────────────────── */
    --color-status-success:               var(--palette-green-400);
    --color-status-success-tint-soft:     rgba(105, 219, 124, 0.10);
    --color-status-success-tint-medium:   rgba(105, 219, 124, 0.20);
    --color-status-success-tint-strong:   rgba(105, 219, 124, 0.40);

    --color-status-warning:               var(--palette-yellow-300);
    --color-status-warning-tint-soft:     rgba(255, 212, 59, 0.15);
    --color-status-warning-tint-strong:   rgba(255, 212, 59, 0.30);

    --color-status-caution:               var(--palette-orange-400);
    --color-status-caution-tint-soft:     rgba(255, 169, 77, 0.15);
    --color-status-caution-tint-strong:   rgba(255, 169, 77, 0.30);

    --color-status-danger:                var(--palette-red-400);
    --color-status-danger-tint-soft:      rgba(255, 107, 107, 0.10);
    --color-status-danger-tint-medium:    rgba(255, 107, 107, 0.20);
    --color-status-danger-tint-strong:    rgba(255, 107, 107, 0.40);

    --color-status-info:                  var(--palette-blue-500);
    --color-status-info-tint-soft:        rgba(88, 166, 255, 0.10);
    --color-status-info-tint-medium:      rgba(88, 166, 255, 0.20);
    --color-status-info-tint-strong:      rgba(88, 166, 255, 0.30);

    --color-state-neutral:                var(--palette-gray-500);

    /* Specialized state pills (dashboard pin / hide affordance) */
    --color-state-pin:                    #63b3ed;
    --color-state-pin-bg:                 rgba(99, 179, 237, 0.08);
    --color-state-pin-border:             rgba(99, 179, 237, 0.40);
    --color-state-hide:                   #f6ad55;
    --color-state-hide-bg:                rgba(246, 173, 85, 0.08);
    --color-state-hide-border:            rgba(246, 173, 85, 0.40);

    /* Earnings proximity badges (portfolio table) */
    --color-earnings-far:                 var(--palette-gray-700);
    --color-earnings-far-border:          var(--palette-gray-800);
    --color-earnings-near:                var(--palette-slate-500);
    --color-earnings-near-border:         var(--palette-gray-700);
    --color-earnings-near-bg:             rgba(100, 255, 218, 0.04);
    --color-earnings-soon:                var(--palette-amber-300);
    --color-earnings-soon-border:         var(--palette-amber-700);
    --color-earnings-soon-bg:             rgba(230, 168, 23, 0.08);
    --color-earnings-today:               var(--palette-red-400);
    --color-earnings-today-border:        var(--palette-red-900);
    --color-earnings-today-bg:            rgba(255, 107, 107, 0.12);

    /* Portfolio table chrome */
    --color-portfolio-th-bg:              var(--palette-navy-700);
    --color-portfolio-th-shadow:          #1a4a7a;
    --color-portfolio-greeks-row-bg:      rgba(15, 52, 96, 0.30);
    --color-portfolio-greeks-row-bg-hover: rgba(15, 52, 96, 0.40);

    /* Position-greek column band tints (Options table band striping) */
    --color-bg-table-band-market:         rgba(30, 58, 95, 0.12);
    --color-bg-table-band-position:       rgba(30, 74, 63, 0.12);

    /* Option-type accent borders (separating column groups) */
    --color-border-position-group:        #1e4a3f;

    /* ITM/OTM badges (option contracts) */
    --color-bg-itm-badge:                 rgba(105, 219, 124, 0.18);
    --color-border-itm-badge:             rgba(105, 219, 124, 0.35);
    --color-bg-otm-badge:                 rgba(136, 146, 176, 0.12);
    --color-border-otm-badge:             rgba(136, 146, 176, 0.25);

    /* Trade-type group label backgrounds (color-coded option strategies) */
    --color-trade-short-put-bg:           rgba(255, 107, 107, 0.12);
    --color-trade-short-put-border:       rgba(255, 107, 107, 0.30);
    --color-trade-long-put-bg:            rgba(116, 192, 252, 0.12);
    --color-trade-long-put-border:        rgba(116, 192, 252, 0.30);
    --color-trade-short-call-bg:          rgba(255, 169, 77, 0.12);
    --color-trade-short-call-border:      rgba(255, 169, 77, 0.30);
    --color-trade-long-call-bg:           rgba(105, 219, 124, 0.12);
    --color-trade-long-call-border:       rgba(105, 219, 124, 0.30);

    /* Option card chrome */
    --color-bg-opt-card-tabs:             #0d1b33;
    --color-border-opt-group-collapsed:   #0a1e3a;
    --color-opt-card-alert-dot:           var(--palette-navy-600);
    --color-opt-card-alert-dot-border:    #2a4a6f;
    --color-opt-card-pnl-zero-border:     var(--palette-navy-600);
    --color-opt-card-pnl-zero-bg:         rgba(255, 255, 255, 0.03);
    --color-opt-card-order-btn-bg:        rgba(100, 255, 218, 0.07);
    --color-opt-card-order-btn-border:    rgba(100, 255, 218, 0.30);
    --color-opt-card-order-btn-bg-hover:  rgba(100, 255, 218, 0.18);
    --color-opt-card-pnl-pos-border:      rgba(105, 219, 124, 0.35);
    --color-opt-card-pnl-pos-bg:          rgba(105, 219, 124, 0.07);
    --color-opt-card-pnl-neg-border:      rgba(255, 107, 107, 0.35);
    --color-opt-card-pnl-neg-bg:          rgba(255, 107, 107, 0.07);

    /* Active alerts banner */
    --color-bg-alert-banner:              rgba(220, 53, 69, 0.15);
    --color-bg-alert-banner-header:       rgba(220, 53, 69, 0.20);
    --color-bg-alert-banner-header-hover: rgba(220, 53, 69, 0.28);
    --color-border-alert-banner:          var(--palette-red-500);

    /* Risk Gates panel */
    --color-bg-rg-section-header:         #0a1929;
    --color-bg-rg-section-header-hover:   #0e2540;
    --color-bg-rg-section-body:           #060f1a;
    --color-bg-rg-add-btn:                #0d2137;
    --color-bg-rg-add-btn-hover:          var(--palette-navy-600);
    --color-border-rg-section-divider:    rgba(30, 58, 95, 0.50);
    --color-border-rg-row:                #0e2036;

    /* Generic dim slate variants */
    --color-text-dim:                     #5c6a7a;
    --color-text-very-faint:              #3a4560;

    /* Bright cornflower blue (ACP level badge) */
    --color-status-info-alt:              #6495ed;

    /* ACP (API Control Panel) — config tab */
    --color-bg-acp-card:                  #0d1b33;
    --color-border-acp-danger-idle:       #2a1a1a;
    --color-text-acp-danger-idle:         #6b3a3a;

    /* Generic ON/OFF/LEVEL/UNKNOWN badge tints */
    --color-bg-badge-level:               rgba(100, 149, 237, 0.15);
    --color-border-badge-level:           rgba(100, 149, 237, 0.25);
    --color-bg-badge-on:                  rgba(74, 222, 128, 0.12);
    --color-border-badge-on:              rgba(74, 222, 128, 0.25);
    --color-bg-badge-on-strong:           rgba(74, 222, 128, 0.18);
    --color-bg-badge-off:                 rgba(255, 107, 107, 0.12);
    --color-border-badge-off:             rgba(255, 107, 107, 0.25);
    --color-bg-badge-off-strong:          rgba(255, 107, 107, 0.18);
    --color-bg-badge-unknown:             rgba(136, 146, 164, 0.12);
    --color-border-badge-unknown:         rgba(136, 146, 164, 0.20);
    --color-text-badge-unknown:           var(--palette-slate-400);

    /* Primary button hover (lighter cyan) */
    --color-accent-hover-bright:          #4fd1b0;
    /* Danger button hover (darker red) */
    --color-status-danger-hover:          #c82333;

    /* Light slate variant for form-label-text */
    --color-text-form-label:              #b8c5d9;
    /* Lighter slate variant for window titles */
    --color-text-window-title:            #cdd6f4;

    /* Lighter slate for property cells (between secondary and primary) */
    --color-text-prop-cell:               #d7e3f4;
    --color-text-prop-cell-empty:         #556177;

    /* Disclosure (details/summary) hover & open border */
    --color-bg-disclosure-hover:          #10243e;
    --color-border-disclosure-open:       #1e4976;

    /* Detail panel deep navy background */
    --color-bg-detail-content:            #0d1a30;

    /* Hover border highlight (slightly brighter blue) */
    --color-border-strong-hover:          #2d5a8e;

    /* Mini chart inline controls (interval / days input) */
    --color-bg-mini-chart-ctrl:           #1e2d40;
    --color-border-mini-chart-ctrl:       #30465e;

    /* Slate-overlay tints (for disabled badges, archived rows) */
    --color-bg-slate-overlay-soft:        rgba(136, 146, 176, 0.05);
    --color-bg-slate-overlay-medium:      rgba(136, 146, 176, 0.20);

    /* Orange tint (matching --palette-orange-500 #ff9f40) */
    --color-status-orange-tint-soft:      rgba(255, 159, 64, 0.10);

    /* Triggered alert row tint (red) */
    --color-bg-alert-triggered:           rgba(255, 107, 107, 0.15);

    /* Paused/standby amber state (#ffc107) */
    --color-status-paused:                var(--palette-amber-500);
    --color-status-paused-tint-soft:      rgba(255, 193, 7, 0.15);
    --color-status-paused-tint-medium:    rgba(255, 193, 7, 0.20);
    --color-status-paused-border-medium:  rgba(255, 193, 7, 0.30);

    /* Notes accordion / detail panels */
    --color-bg-notes-accordion-header:        var(--palette-navy-850);
    --color-bg-notes-accordion-header-hover:  var(--palette-navy-650);
    --color-bg-notes-accordion-body:          var(--palette-navy-900);
    --color-border-notes-section:             var(--color-border-strong);

    /* Note card archived state */
    --color-bg-note-archived:                 var(--palette-navy-950);
    --color-bg-note-archived-badge:           var(--color-bg-slate-overlay-medium);

    /* TipTap editor surfaces */
    --color-bg-tiptap-toolbar:                var(--color-bg-page);
    --color-bg-tiptap-editor:                 var(--palette-navy-750);
    --color-bg-tiptap-pre:                    var(--palette-navy-725);
    --color-bg-tiptap-code:                   var(--palette-navy-650);
    --color-bg-tiptap-th:                     var(--palette-navy-650);
    --color-bg-tiptap-scrollbar-track:        #0a192f;
    --color-bg-tiptap-select:                 var(--palette-navy-650);

    /* Bright/light text variants used in editors and headings */
    --color-text-bright:                      #e6f1ff;
    --color-text-italic-soft:                 #a8b2c8;
    --color-text-code-light:                  #a8d8ff;
    --color-text-code-light-alt:              #a8b2d8;
    --color-text-link-blue:                   var(--palette-blue-400);
    --color-text-light-blue:                  var(--palette-navy-300);
    --color-text-deep-muted:                  var(--palette-navy-400);
    --color-text-deeper-muted:                var(--palette-navy-450);
    --color-text-form-placeholder:            var(--palette-navy-350);

    /* Accent tints (extra granularity for editor/border usage) */
    --color-accent-tint-faint:                rgba(100, 255, 218, 0.07);
    --color-accent-tint-stronger:             rgba(100, 255, 218, 0.30);
    --color-accent-border-soft:               rgba(100, 255, 218, 0.30);
    --color-accent-border-medium:             rgba(100, 255, 218, 0.40);
    --color-accent-border-strong:             rgba(100, 255, 218, 0.45);
    --color-accent-border-bright:             rgba(100, 255, 218, 0.50);
    --color-accent-tint-table-cell:           rgba(100, 255, 218, 0.12);

    /* Muted-slate tint (used by note function tag) */
    --color-bg-slate-overlay-faint:           rgba(136, 146, 176, 0.15);

    /* Red500 status (deprecated/error) — separate from --color-status-danger */
    --color-status-error:                     #ef4444;
    --color-status-error-tint-soft:           rgba(239, 68, 68, 0.15);
    --color-status-error-border:              rgba(239, 68, 68, 0.30);

    /* Blue tints for nested details inside notes */
    --color-bg-blue-tint-faint:               rgba(116, 192, 252, 0.05);

    /* Solid checkmark inverse (for note pill checkboxes) */
    --color-checkmark-on-accent:              #0a192f;

    /* Conversation drawer colors */
    --color-bg-conv-user-bubble:              #1a3a5c;
    --color-bg-conv-context-btn:              var(--palette-navy-900);
    --color-bg-conv-context-btn-hover:        var(--palette-navy-800);

    /* Status amber (in-flight request) */
    --color-status-amber:                     var(--palette-amber-300);

    /* Memory-source AI badge */
    --color-memory-ai-fg:                     var(--color-state-pin);
    --color-memory-ai-bg:                     rgba(99, 179, 237, 0.15);
    --color-memory-ai-border:                 rgba(99, 179, 237, 0.30);

    /* System-prompt name badge (purple) */
    --palette-purple-400:                     #9a75ea;
    --color-sysmsg-fg:                        var(--palette-purple-400);
    --color-sysmsg-bg:                        rgba(154, 117, 234, 0.15);
    --color-sysmsg-border:                    rgba(154, 117, 234, 0.30);

    /* Price source badges (portfolio table) */
    --color-ps-afterhours-fg:                 var(--palette-orange-400);
    --color-ps-afterhours-bg:                 rgba(255, 169, 77, 0.18);
    --color-ps-afterhours-border:             rgba(255, 169, 77, 0.35);
    --color-ps-premarket-fg:                  var(--palette-blue-400);
    --color-ps-premarket-bg:                  rgba(116, 192, 252, 0.18);
    --color-ps-premarket-border:              rgba(116, 192, 252, 0.35);
    --color-ps-close-fg:                      var(--palette-green-400);
    --color-ps-close-bg:                      rgba(105, 219, 124, 0.15);
    --color-ps-close-border:                  rgba(105, 219, 124, 0.30);
    --color-ps-prevclose-fg:                  var(--color-text-muted);
    --color-ps-prevclose-bg:                  rgba(138, 150, 180, 0.15);
    --color-ps-prevclose-border:              rgba(138, 150, 180, 0.30);

    /* Floating note window framework */
    --palette-deep-blue-900:                  #0a0f1e;
    --palette-deep-blue-850:                  #0d1a2e;
    --color-bg-note-window-base:              var(--palette-deep-blue-900);
    --color-bg-note-window-titlebar-base:     var(--palette-deep-blue-850);
    --color-border-note-window:               var(--color-portfolio-th-shadow);
    --color-overlay-ring-faint:               rgba(255, 255, 255, 0.25);
    --color-overlay-ring-medium-faint:        rgba(255, 255, 255, 0.18);
    /* Matches --shadow-sdw — note editing window should lift off the page with
       the same prominence as the Stock Detail Window (three-layer: edge halo +
       mid lift + wide outer pool). */
    --shadow-note-window:                     0 0 0 1px rgba(0, 0, 0, 0.55),
                                              0 8px 20px rgba(0, 0, 0, 0.85),
                                              0 36px 90px rgba(0, 0, 0, 0.95);
    --shadow-note-swatch:                     0 0 4px rgba(0, 0, 0, 0.4);
    --shadow-note-popover:                    0 8px 24px rgba(0, 0, 0, 0.6);

    /* Note window deeper surfaces */
    --color-bg-note-window-props:             #07090f;
    --color-bg-note-window-input:             #0a0e1a;

    /* Extra muted text/placeholder shades for note windows */
    --color-text-note-placeholder:            #3a4560;
    --color-text-note-tab-inactive:           #4a5570;

    /* Note window deep border + faint divider */
    --color-border-note-window-soft:          var(--palette-navy-500);
    --color-border-note-window-faint:         #0a1a2e;

    /* Conv code/pre block background */
    --color-bg-conv-pre:                      #0a0f1a;

    /* Note window: deepest base for conversation thread */
    --color-bg-note-window-conv-base:         #060c18;

    /* Order status badges (from various design eras) */
    --color-status-info-blue-alt:             rgba(74, 144, 226, 0.15);
    --color-status-info-blue-alt-border:      rgba(74, 192, 252, 0.30);
    --color-status-success-green-bg:          rgba(105, 219, 124, 0.15);
    --color-status-success-green-border:      rgba(105, 219, 124, 0.30);
    --color-text-pale-grey:                   #999999;
    --color-text-dim-grey:                    #666666;
    --color-border-deep-grey:                 #333333;
    --color-bg-cancelled-row:                 rgba(255, 107, 107, 0.10);
    --color-border-cancelled-row:             rgba(255, 107, 107, 0.20);
    --color-bg-inactive-row:                  rgba(136, 146, 176, 0.10);
    --color-border-inactive-row:              rgba(136, 146, 176, 0.20);

    /* Cornflower-blue / second-blue accent (option order status, trade preview) */
    --palette-cornflower-blue:                #6495ed;
    --color-status-info-cornflower:           var(--palette-cornflower-blue);
    --color-status-info-cornflower-bg:        rgba(100, 149, 237, 0.15);
    --color-status-info-cornflower-bg-hover:  rgba(100, 149, 237, 0.12);
    --color-status-info-cornflower-bg-active: rgba(100, 149, 237, 0.22);

    /* Trade card / margin / option detail surfaces */
    --color-bg-trade-card:                    #111e2e;
    --color-bg-trade-card-input:              var(--palette-navy-900);
    --color-bg-trade-card-price-btn:          #0d1e38;
    --color-bg-trade-card-margin:             #081220;
    --color-bg-trade-card-pop:                #0d1f30;
    --color-border-trade-card:                #2a3f5f;
    --color-border-trade-card-input:          #253555;
    --color-border-trade-card-section:        var(--palette-navy-500);
    --color-border-trade-card-row:            #1a2a3e;
    --color-border-trade-card-row-faint:      #12243a;
    --color-border-trade-card-row-fainter:    #0f1e30;

    /* Light/dim slate text shades used in trade card */
    --color-text-light-slate:                 #c8d8e8;
    --color-text-mid-slate:                   #a0b0c8;
    --color-text-faint-slate:                 #4a5a6a;
    --color-text-fainter-slate:               #556070;
    --color-text-trade-placeholder:           #3a4a5a;

    /* Modern green/red/orange accent shades for trade card */
    --palette-emerald-400:                    #4ade80;
    --palette-rose-400:                       #f87171;
    --palette-orange-amber-400:               #fb923c;
    --color-pnl-positive-alt:                 var(--palette-emerald-400);
    --color-pnl-negative-alt:                 var(--palette-rose-400);
    --color-pnl-warn-alt:                     var(--palette-orange-amber-400);
    --color-bg-pnl-positive-alt-tint:         rgba(74, 222, 128, 0.12);
    --color-border-pnl-positive-alt-tint:     rgba(74, 222, 128, 0.35);
    --color-bg-pnl-negative-alt-tint:         rgba(248, 113, 113, 0.12);
    --color-border-pnl-negative-alt-tint:     rgba(248, 113, 113, 0.35);
    --color-border-pnl-positive-alt-faint:    rgba(74, 222, 128, 0.30);
    --color-border-pnl-negative-alt-faint:    rgba(248, 113, 113, 0.30);
    --color-border-mid-slate-faint:           rgba(200, 216, 232, 0.20);
    --shadow-trade-card:                      0 16px 48px rgba(0, 0, 0, 0.55);

    /* Accent ghost button (orders header) */
    --color-accent-tint-ghost:                rgba(100, 255, 218, 0.06);
    --color-accent-border-vivid:              rgba(100, 255, 218, 0.45);
    --color-accent-tint-strong-alt:           rgba(100, 255, 218, 0.20);

    /* Focus ring for trade card inputs */
    --shadow-focus-ring-trade:                0 0 0 2px rgba(100, 255, 218, 0.12);

    /* Bracket order leg tints (preview header backgrounds) */
    --color-bg-bracket-tp-tint:               rgba(74, 222, 128, 0.10);
    --color-bg-bracket-sl-tint:               rgba(248, 113, 113, 0.10);

    /* Slate-400 tint at 15% (option order cancelled state) */
    --color-bg-slate-cancelled:               rgba(136, 146, 164, 0.15);

    /* Neutral mid-gray (empty PPS progress bar, generic empty/disabled fills) */
    --color-bg-progress-empty:                #444444;

    /* ── Chart.js theme tokens (read by chartThemeColors() in monitor.js) ── */
    --color-chart-line-default:               var(--color-accent);
    --color-chart-area-default:               var(--color-accent-tint-soft);
    --color-chart-yesterday-line:             rgba(138, 146, 176, 0.40);
    --color-chart-axis-text:                  var(--color-text-muted);
    --color-chart-overlay-default:            rgba(200, 200, 200, 0.60);
    --color-chart-overlay-buy:                rgba(40, 167, 69, 0.85);
    --color-chart-overlay-sell:               rgba(220, 53, 69, 0.85);
    --color-chart-overlay-long:               rgba(88, 166, 255, 0.85);
    --color-chart-overlay-short:              rgba(255, 140, 0, 0.85);

    /* Watchlist (daily) chart tooltip + grid */
    --color-chart-tooltip-bg-watchlist:       var(--palette-midnight-800);
    --color-chart-tooltip-title-watchlist:    var(--palette-slate-100);
    --color-chart-tooltip-body-watchlist:     var(--palette-gh-text-300);
    --color-chart-tooltip-border-watchlist:   var(--color-border-default);
    --color-chart-grid-watchlist:             rgba(15, 52, 96, 0.50);

    /* Minute chart tooltip + grid */
    --color-chart-tooltip-bg-minute:          rgba(15, 52, 96, 0.95);
    --color-chart-tooltip-title-minute:       var(--color-accent);
    --color-chart-tooltip-body-minute:        #e6e6e6;
    --color-chart-tooltip-border-minute:      var(--palette-navy-600);
    --color-chart-grid-minute:                rgba(30, 58, 95, 0.50);

    /* GitHub-style palette extensions for SDW/Strategies/Strategy Builder */
    --palette-gh-text-100:                    #cdd9e5;
    --palette-gh-text-400:                    #adbac7;
    --palette-gh-text-600:                    #6e7681;
    --palette-gh-blue-300:                    #79c0ff;
    --palette-gh-green-400:                   #56d364;
    --palette-gh-red-500:                     #f85149;
    --palette-gh-purple-400:                  #a371f7;
    --palette-gh-yellow-500:                  #e3b341;
    --palette-gh-tan-400:                     #d2a679;
    --palette-gh-bg-card:                     #1c2128;
    --palette-gh-bg-deepest:                  #080c10;
    --palette-gh-grey-300:                    #adb5bd;

    /* Symbol detail window (SDW) — uses GitHub palette */
    --color-bg-sdw:                           var(--palette-gh-bg-900);
    --color-bg-sdw-header:                    var(--palette-gh-bg-800);
    --color-border-sdw:                       var(--palette-gh-border-700);
    --color-text-sdw-title:                   var(--palette-gh-text-200);
    --color-text-sdw-subtitle:                var(--palette-gh-text-500);
    --color-text-sdw-strong:                  var(--palette-gh-text-200);
    --color-text-sdw-muted:                   var(--palette-gh-text-500);
    --color-border-sdw-divider:               var(--palette-gh-bg-700);
    --color-bg-sdw-row-hover:                 rgba(255, 255, 255, 0.03);
    --color-bg-sdw-section-band:              rgba(88, 166, 255, 0.04);
    --color-bg-sdw-link-tint:                 rgba(88, 166, 255, 0.06);
    --color-bg-sdw-badge:                     rgba(88, 166, 255, 0.08);
    --color-border-sdw-badge:                 rgba(88, 166, 255, 0.25);
    --color-text-sdw-link:                    var(--palette-blue-500);
    --color-text-sdw-link-light:              var(--palette-gh-blue-300);
    --color-bg-sdw-pill-tint:                 rgba(255, 255, 255, 0.05);
    /* Three-layer shadow: a tight 1px halo to harden the edge against the
       content beneath, a mid-distance "lift" layer, and a wide outer pool
       for depth. The combined effect clearly separates the window from
       whatever sits underneath it. */
    --shadow-sdw:                             0 0 0 1px rgba(0, 0, 0, 0.55),
                                              0 8px 20px rgba(0, 0, 0, 0.85),
                                              0 36px 90px rgba(0, 0, 0, 0.95);
    --shadow-sdw-close-hover:                 rgba(255, 255, 255, 0.1);
    /* Generic card drop shadow — used by .note-card, .opt-card, .wl-item-card
       and .wl-list-card so they visually separate from each other and the
       surrounding section background. Two-layer: a close 1-2px definer plus
       a softer lift. Lighter than --shadow-sdw because cards live in a grid
       (we don't want them to read as floating modals). */
    --shadow-card:                            0 1px 3px rgba(0, 0, 0, 0.45),
                                              0 6px 18px rgba(0, 0, 0, 0.55);
    /* Note card shadow — same family as --shadow-card but a touch deeper. Note
       cards layer a colored gradient + bright left border on top, both of which
       compete with the shadow visually; this bump brings them back to parity
       with watchlist/option cards. */
    --shadow-note-card:                       0 2px 4px rgba(0, 0, 0, 0.55),
                                              0 10px 28px rgba(0, 0, 0, 0.70);
    --color-border-sdw-trigger-dashed:        rgba(88, 166, 255, 0.5);

    /* Analyst rating badges (SDW) */
    --color-rating-buy-fg:                    var(--palette-green-400);
    --color-rating-buy-border:                rgba(105, 219, 124, 0.4);
    --color-rating-buy-bg:                    rgba(105, 219, 124, 0.10);
    --color-rating-hold-fg:                   var(--palette-gh-yellow-500);
    --color-rating-hold-border:               rgba(227, 179, 65, 0.4);
    --color-rating-hold-bg:                   rgba(227, 179, 65, 0.08);
    --color-rating-sell-fg:                   var(--palette-red-400);
    --color-rating-sell-border:               rgba(255, 107, 107, 0.4);
    --color-rating-sell-bg:                   rgba(255, 107, 107, 0.08);
    --color-rating-na-fg:                     var(--palette-gh-text-500);
    --color-rating-na-border:                 var(--palette-gh-border-700);
    --color-rating-na-bg:                     rgba(255, 255, 255, 0.03);

    /* Strategy badges */
    --color-strat-active-bg:                  rgba(40, 167, 69, 0.15);
    --color-strat-active-fg:                  var(--palette-green-600);
    --color-strat-active-border:              rgba(40, 167, 69, 0.30);
    --color-strat-paused-bg:                  rgba(255, 193, 7, 0.15);
    --color-strat-paused-fg:                  var(--palette-amber-500);
    --color-strat-paused-border:              rgba(255, 193, 7, 0.30);
    --color-strat-stopped-bg:                 rgba(108, 117, 125, 0.15);
    --color-strat-stopped-fg:                 var(--palette-gray-500);
    --color-strat-stopped-border:             rgba(108, 117, 125, 0.30);
    --color-strat-created-bg:                 rgba(88, 166, 255, 0.12);
    --color-strat-created-fg:                 var(--palette-blue-500);
    --color-strat-created-border:             rgba(88, 166, 255, 0.30);
    --color-strat-error-bg:                   rgba(220, 53, 69, 0.15);
    --color-strat-error-fg:                   var(--palette-red-500);
    --color-strat-error-border:               rgba(220, 53, 69, 0.30);
    --color-strat-flatten-bg:                 rgba(220, 53, 69, 0.25);
    --color-strat-flatten-fg:                 var(--palette-red-400);
    --color-strat-flatten-border:             rgba(220, 53, 69, 0.50);
    --color-strat-unknown-bg:                 rgba(108, 117, 125, 0.10);
    --color-strat-unknown-fg:                 var(--palette-gh-grey-300);
    --color-strat-unknown-border:             rgba(108, 117, 125, 0.20);

    /* Strategy P&L colors (uses Bootstrap green/red) */
    --color-strat-pnl-pos:                    var(--palette-green-600);
    --color-strat-pnl-neg:                    var(--palette-red-500);

    /* Strategy symbol/SDW badge */
    --color-bg-strat-badge:                   rgba(88, 166, 255, 0.12);
    --color-bg-strat-badge-hover:             rgba(88, 166, 255, 0.25);
    --color-fg-strat-badge:                   var(--palette-blue-500);
    --color-border-strat-badge:               rgba(88, 166, 255, 0.30);

    /* Strategy table — selected/expanded row */
    --color-bg-strat-row-selected:            var(--palette-gh-bg-900);
    --color-bg-strat-row-expanded:            var(--palette-gh-bg-800);
    --color-border-strat-row-selected:        var(--color-accent);
    --color-border-strat-row-divider:         var(--palette-gh-bg-700);

    /* Strategy expanded card */
    --color-bg-strat-detail-card:             var(--palette-gh-bg-800);
    --color-border-strat-detail-card:         var(--palette-gh-bg-700);
    --color-text-strat-label:                 var(--palette-gh-text-500);
    --color-text-strat-value:                 var(--palette-gh-text-200);
    --color-text-strat-value-emphasis:        var(--palette-gh-blue-300);
    --color-bg-strat-error-banner:            rgba(220, 53, 69, 0.10);
    --color-bg-strat-json-error:              rgba(220, 53, 69, 0.08);
    --color-border-strat-error-banner:        rgba(220, 53, 69, 0.30);
    --color-text-strat-error:                 var(--palette-red-400);

    /* Strategy event chips */
    --color-strat-ev-blue-bg:                 rgba(88, 166, 255, 0.12);
    --color-strat-ev-blue-fg:                 var(--palette-blue-500);
    --color-strat-ev-green-bg:                rgba(40, 167, 69, 0.12);
    --color-strat-ev-green-fg:                var(--palette-gh-green-400);
    --color-strat-ev-orange-bg:               rgba(255, 140, 0, 0.12);
    --color-strat-ev-orange-fg:               var(--palette-amber-300);
    --color-strat-ev-red-bg:                  rgba(220, 53, 69, 0.12);
    --color-strat-ev-red-fg:                  var(--palette-gh-red-500);
    --color-strat-ev-yellow-bg:               rgba(255, 193, 7, 0.12);
    --color-strat-ev-yellow-fg:               var(--palette-amber-500);
    --color-strat-ev-purple-bg:               rgba(163, 113, 247, 0.12);
    --color-strat-ev-purple-fg:               var(--palette-gh-purple-400);
    --color-strat-ev-gray-bg:                 rgba(108, 117, 125, 0.12);
    --color-strat-ev-gray-fg:                 var(--palette-gh-text-500);

    /* Strategy params — ok/err */
    --color-strat-param-ok:                   var(--palette-gh-green-400);
    --color-strat-param-err:                  var(--palette-gh-red-500);

    /* Strategy badges - tan / earnings text */
    --color-text-strat-tan:                   var(--palette-gh-tan-400);

    /* Strategy POP summary (light) */
    --color-text-strat-pop:                   var(--palette-gh-text-400);

    /* Strategy table - row select bg */
    --color-bg-strat-row-link-tint:           rgba(88, 166, 255, 0.08);
    --color-bg-strat-row-link-tint-hover:     rgba(88, 166, 255, 0.12);

    /* Strategy event POP banner */
    --color-bg-strat-pop-tint:                rgba(88, 166, 255, 0.10);
    --color-border-strat-pop-tint:            rgba(88, 166, 255, 0.25);

    /* Strategy section subhead */
    --color-bg-strat-subhead-tint:            rgba(88, 166, 255, 0.08);
    --color-fg-strat-subhead:                 var(--palette-gh-blue-300);

    /* Strategy footer date / preview text */
    --color-text-strat-emphasis:              var(--palette-gh-blue-300);

    /* Strategy builder modal */
    --color-bg-strat-builder:                 var(--palette-gh-bg-800);
    --color-border-strat-builder:             var(--palette-gh-border-700);
    --color-bg-strat-builder-card:            var(--palette-gh-bg-card);
    --color-bg-strat-builder-pre:             var(--palette-gh-bg-deepest);
    --shadow-strat-builder:                   0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-strat-builder-popup:             0 8px 24px rgba(0, 0, 0, 0.4);
    --color-text-strat-builder-dim:           var(--palette-gh-text-600);
    --color-bg-strat-builder-tab-active:      rgba(88, 166, 255, 0.15);
    --color-bg-strat-builder-tab-hover:       rgba(255, 255, 255, 0.04);
    --color-bg-strat-builder-input-active:    rgba(88, 166, 255, 0.10);
    --color-bg-strat-builder-input-pop:       rgba(88, 166, 255, 0.08);

    /* Symbol search dropdown (used in strategy builder) */
    --color-bg-symbol-search-input:           #0f1a2e;
    --color-bg-symbol-search-active:          #112338;
    --color-text-symbol-search:               var(--palette-slate-100);

    /* Hashtable browser (modal-based) */
    --color-bg-ht-card:                       #111827;
    --color-bg-ht-header:                     var(--palette-gh-bg-900);
    --color-text-ht-title:                    var(--palette-slate-100);
    --color-bg-ht-row-hover:                  rgba(100, 255, 218, 0.04);
    --shadow-ht-modal:                        0 8px 32px rgba(0, 0, 0, 0.6);
    --color-bg-ht-input:                      var(--palette-midnight-900);
    --color-border-ht-default:                var(--palette-midnight-700);
    --color-text-ht-primary:                  #e0e0e0;
    --color-text-ht-secondary:                var(--palette-slate-400);

    /* PPS / Risk Gauge */
    --color-bg-pps-track:                     rgba(255, 255, 255, 0.08);
    --color-border-pps-gear:                  rgba(136, 146, 176, 0.35);
    --color-border-pps-gear-hover:            rgba(100, 255, 218, 0.40);
    --color-text-pps-warning:                 #ff6d00;
    --color-bg-pps-doc:                       rgba(100, 255, 218, 0.06);
    --color-bg-pps-transparency:              rgba(10, 22, 40, 0.65);
    --color-border-pps-transparency-divider:  rgba(30, 58, 95, 0.7);
    --color-text-pps-trans-dd:                #e0e6f0;
    --color-text-pps-trans-dt:                var(--palette-slate-300);
    --color-text-pps-trans-symbol:            var(--palette-slate-300);
    --color-text-pps-trans-mono:              #a8b2d1;
    --color-text-pps-trans-yes:               #69f0ae;
    --color-text-pps-trans-no:                #ff8a65;

    /* Suspended/error states for builder & strategy lists */
    --color-bg-strat-suspended:               #2d1b00;
    --color-border-strat-suspended:           #7c4a00;
    --color-fg-strat-suspended:               var(--palette-amber-300);
    --color-bg-strat-suspended-pill:          #7c4a00;
    --color-bg-strat-killswitch:              #2d0d0d;
    --color-border-strat-killswitch:          #7c1e1e;
    --color-fg-strat-killswitch:              #e05555;
    --color-bg-strat-killswitch-pill:         #7c1e1e;

    /* ── Tier 2: Trading-domain semantics ─────────────────────────────────── */
    --color-pnl-positive:            var(--palette-green-400);
    --color-pnl-negative:            var(--palette-red-400);
    --color-position-long:           var(--palette-blue-500);
    --color-position-short:          var(--palette-orange-400);
    --color-itm:                     var(--palette-green-400);
    --color-otm:                     var(--palette-slate-500);

    /* ── Tier 2: Chart colors (Chart.js axes, grids, tooltips) ────────────── */
    --color-chart-grid:              rgba(15, 52, 96, 0.50);
    --color-chart-axis-text:         var(--palette-slate-500);
    --color-chart-tooltip-bg:        var(--palette-midnight-800);
    --color-chart-tooltip-bg-translucent: rgba(15, 52, 96, 0.95);
    --color-chart-tooltip-title:     var(--palette-slate-100);
    --color-chart-tooltip-body:      var(--palette-slate-300);
    --color-chart-tooltip-border:    var(--palette-navy-700);
    --color-chart-line-default:      var(--palette-cyan-400);
    --color-chart-area-default:      rgba(100, 255, 218, 0.10);

    /* ── Tier 2: Shadow tokens (full box-shadow values; theme-aware) ──────── */
    --shadow-card-soft:              0 3px 12px rgba(0, 0, 0, 0.5);
    --shadow-card-hover:             0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-dropdown:               0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-modal:                  0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-overlay-strong:         0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-focus-ring-accent:      0 0 0 2px rgba(100, 255, 218, 0.15);
    --shadow-glow-warn:              0 0 6px rgba(255, 212, 59, 0.25);
    --shadow-glow-caution:           0 0 6px rgba(255, 169, 77, 0.25);
    --shadow-glow-danger:            0 0 10px rgba(255, 107, 107, 0.35);
    --shadow-glow-danger-strong:     0 0 18px rgba(255, 107, 107, 0.65);
    --shadow-swatch-outer-ring:      0 0 0 1px rgba(0, 0, 0, 0.25);
    --shadow-swatch-selected-ring:   0 0 0 1px rgba(255, 255, 255, 0.50);
    --shadow-priority-dot-ring:      0 0 0 1px rgba(0, 0, 0, 0.3);
    --shadow-drawer:                 -6px 0 24px rgba(0, 0, 0, 0.5);
    --color-bg-code-translucent:     rgba(9, 21, 35, 0.85);
    --color-overlay-backdrop:        rgba(0, 0, 0, 0.4);
    --color-overlay-row-hover:       rgba(255, 255, 255, 0.07);
}

/* =============================================================================
   LIGHT THEME — semantic-token overrides only.
   The Tier 1 palette primitives are inherited from :root above. Only the Tier 2
   --color-* / --shadow-* tokens get re-mapped for light mode. Adding new
   palette entries below only when no dark-theme primitive matches the role.
   ============================================================================= */
:root[data-theme="light"] {
    color-scheme: light;

    /* ── New light-mode palette additions (only where dark palette has no match) ── */
    --palette-paper:                          #f5f7fa;   /* page background */
    --palette-paper-alt:                      #eef1f5;   /* subtle alt rows */
    --palette-paper-elevated:                 #e7eaf0;   /* elevated card / input bg-alt */
    --palette-card-light:                     #ffffff;   /* card surface */
    --palette-ink-900:                        #0a1628;   /* primary text (deep navy) */
    --palette-ink-700:                        #2a3955;   /* secondary text */
    --palette-ink-500:                        #4a5872;   /* muted */
    --palette-ink-400:                        #6b7a99;   /* placeholder / faint */
    --palette-ink-300:                        #98a2b8;   /* very faint */
    --palette-line-300:                       #d0d7de;   /* default border */
    --palette-line-400:                       #b8c0cc;   /* stronger border */
    --palette-line-200:                       #e3e7ed;   /* subtle divider */
    --palette-cyan-700:                       #0fa28c;   /* darker cyan for accent on light */
    --palette-cyan-800:                       #0a7d6c;   /* even deeper for active */
    --palette-blue-700:                       #1a6dc7;   /* link blue */

    /* ── Tier 2: Surfaces ─────────────────────────────────────────────────── */
    --color-bg-page:                 var(--palette-paper);
    /* Generic surface ramp — opaque so sticky note-window table headers are solid. */
    --color-bg-primary:              var(--palette-paper);
    --color-bg-secondary:            var(--palette-paper-alt);
    --color-bg-tertiary:             var(--palette-paper-elevated);
    --color-bg-card:                 var(--palette-card-light);
    --color-bg-card-elevated:        var(--palette-paper-elevated);
    --color-bg-input:                var(--palette-card-light);
    --color-bg-modal:                var(--palette-card-light);
    --color-bg-modal-overlay:        rgba(20, 30, 50, 0.40);
    --color-bg-tooltip:              var(--palette-ink-900);
    --color-bg-table-header:         var(--palette-paper-alt);
    --color-bg-table-row-alt:        rgba(0, 0, 0, 0.03);
    --color-bg-row-hover:            rgba(0, 0, 0, 0.04);
    --color-bg-row-hover-accent:     rgba(15, 162, 140, 0.06);
    --color-bg-section-header:       var(--palette-paper-alt);
    --color-bg-section-header-hover: var(--palette-paper-elevated);
    --color-bg-subtotal-row:         #eef4ff;
    --color-bg-total-row:            #dde5f0;
    --color-bg-options-group-header: var(--palette-paper-alt);
    --color-bg-toolbar:              var(--palette-paper-elevated);
    --color-bg-disabled:             #d8dde5;
    --color-bg-button-secondary:     var(--palette-paper-elevated);
    --color-bg-button-secondary-hover: #dde2eb;

    /* Ticker tape */
    --color-bg-ticker-tape:          var(--palette-paper-alt);
    --color-bg-ticker-editor:        var(--palette-card-light);
    --color-bg-ticker-textarea:      var(--palette-card-light);
    --color-border-ticker:           var(--palette-line-300);
    --color-border-ticker-section:   var(--palette-line-200);

    /* ── Tier 2: Borders ─────────────────────────────────────────────────── */
    --color-border-default:          var(--palette-line-300);
    --color-border-strong:           var(--palette-line-400);
    --color-border-subtle:           rgba(0, 0, 0, 0.08);
    --color-border-input:            var(--palette-line-300);
    --color-border-focus:            var(--palette-cyan-700);
    --color-border-card-accent:      var(--palette-cyan-700);
    --color-border-divider:          var(--palette-line-200);

    --color-overlay-ring-soft:       rgba(0, 0, 0, 0.10);
    --color-overlay-ring-medium:     rgba(0, 0, 0, 0.30);
    --color-overlay-ring-strong:     rgba(0, 0, 0, 0.50);
    --color-overlay-divider:         rgba(0, 0, 0, 0.08);
    --color-overlay-row-tint:        rgba(0, 0, 0, 0.03);

    --color-bg-card-hover-tint:        rgba(15, 162, 140, 0.06);
    --color-bg-card-hover-tint-strong: rgba(15, 162, 140, 0.12);
    --color-bg-track-tint:             rgba(0, 0, 0, 0.04);
    --color-bg-track-tint-strong:      rgba(0, 0, 0, 0.08);
    --color-bg-nested-panel:           var(--palette-paper-alt);

    /* ── Tier 2: Text ─────────────────────────────────────────────────────── */
    --color-text-primary:            var(--palette-ink-900);
    --color-text-secondary:          var(--palette-ink-700);
    --color-text-muted:              var(--palette-ink-500);
    --color-text-faint:              var(--palette-ink-400);
    --color-text-tiny-label:         var(--palette-ink-400);
    --color-text-disabled:           var(--palette-ink-300);
    --color-text-link:               var(--palette-cyan-700);
    --color-text-inverse:            var(--palette-card-light);
    --color-text-on-accent:          var(--palette-card-light);
    --color-text-placeholder:        var(--palette-ink-400);

    /* ── Tier 2: Brand / accent ───────────────────────────────────────────── */
    --color-accent:                  var(--palette-cyan-700);
    --color-accent-hover:            var(--palette-cyan-800);
    --color-accent-active:           var(--palette-cyan-800);
    --color-accent-tint-subtle:      rgba(15, 162, 140, 0.05);
    --color-accent-tint-soft:        rgba(15, 162, 140, 0.10);
    --color-accent-tint-medium:      rgba(15, 162, 140, 0.18);
    --color-accent-tint-strong:      rgba(15, 162, 140, 0.30);

    /* ── Tier 2: Status colors (kept hue-stable; only tints adjusted) ──── */
    --color-status-success:               #1a8a3a;
    --color-status-success-tint-soft:     rgba(40, 167, 69, 0.10);
    --color-status-success-tint-medium:   rgba(40, 167, 69, 0.18);
    --color-status-success-tint-strong:   rgba(40, 167, 69, 0.30);

    --color-status-warning:               #b08a00;
    --color-status-warning-tint-soft:     rgba(255, 212, 59, 0.20);
    --color-status-warning-tint-strong:   rgba(255, 212, 59, 0.40);

    --color-status-caution:               #cc7a00;
    --color-status-caution-tint-soft:     rgba(255, 169, 77, 0.20);
    --color-status-caution-tint-strong:   rgba(255, 169, 77, 0.40);

    --color-status-danger:                #c92a2a;
    --color-status-danger-tint-soft:      rgba(220, 53, 69, 0.10);
    --color-status-danger-tint-medium:    rgba(220, 53, 69, 0.18);
    --color-status-danger-tint-strong:    rgba(220, 53, 69, 0.30);

    --color-status-info:                  var(--palette-blue-700);
    --color-status-info-tint-soft:        rgba(26, 109, 199, 0.10);
    --color-status-info-tint-medium:      rgba(26, 109, 199, 0.18);
    --color-status-info-tint-strong:      rgba(26, 109, 199, 0.30);

    --color-state-neutral:                var(--palette-ink-500);

    /* Specialized state pills */
    --color-state-pin:                    #1a6dc7;
    --color-state-pin-bg:                 rgba(26, 109, 199, 0.08);
    --color-state-pin-border:             rgba(26, 109, 199, 0.40);
    --color-state-hide:                   #cc7a00;
    --color-state-hide-bg:                rgba(204, 122, 0, 0.08);
    --color-state-hide-border:            rgba(204, 122, 0, 0.40);

    /* Earnings */
    --color-earnings-far:                 var(--palette-ink-400);
    --color-earnings-far-border:          var(--palette-line-300);
    --color-earnings-near:                var(--palette-ink-500);
    --color-earnings-near-border:         var(--palette-line-300);
    --color-earnings-near-bg:             rgba(15, 162, 140, 0.04);
    --color-earnings-soon:                #b08a00;
    --color-earnings-soon-border:         rgba(176, 138, 0, 0.40);
    --color-earnings-soon-bg:             rgba(255, 212, 59, 0.10);
    --color-earnings-today:               #c92a2a;
    --color-earnings-today-border:        rgba(201, 42, 42, 0.40);
    --color-earnings-today-bg:            rgba(220, 53, 69, 0.08);

    /* Portfolio table chrome */
    --color-portfolio-th-bg:              var(--palette-paper-alt);
    --color-portfolio-th-shadow:          var(--palette-line-300);
    --color-portfolio-greeks-row-bg:      rgba(0, 0, 0, 0.03);
    --color-portfolio-greeks-row-bg-hover: rgba(0, 0, 0, 0.05);

    /* Position-greek band tints */
    --color-bg-table-band-market:         rgba(26, 109, 199, 0.05);
    --color-bg-table-band-position:       rgba(40, 167, 69, 0.05);

    --color-border-position-group:        rgba(40, 167, 69, 0.40);

    /* ITM/OTM badges */
    --color-bg-itm-badge:                 rgba(40, 167, 69, 0.12);
    --color-border-itm-badge:             rgba(40, 167, 69, 0.30);
    --color-bg-otm-badge:                 rgba(0, 0, 0, 0.06);
    --color-border-otm-badge:             rgba(0, 0, 0, 0.15);

    /* Trade-type group label backgrounds */
    --color-trade-short-put-bg:           rgba(220, 53, 69, 0.10);
    --color-trade-short-put-border:       rgba(220, 53, 69, 0.30);
    --color-trade-long-put-bg:            rgba(26, 109, 199, 0.10);
    --color-trade-long-put-border:        rgba(26, 109, 199, 0.30);
    --color-trade-short-call-bg:          rgba(204, 122, 0, 0.10);
    --color-trade-short-call-border:      rgba(204, 122, 0, 0.30);
    --color-trade-long-call-bg:           rgba(40, 167, 69, 0.10);
    --color-trade-long-call-border:       rgba(40, 167, 69, 0.30);

    /* Option card chrome */
    --color-bg-opt-card-tabs:             var(--palette-paper-alt);
    --color-border-opt-group-collapsed:   var(--palette-line-200);
    --color-opt-card-alert-dot:           var(--palette-line-400);
    --color-opt-card-alert-dot-border:    var(--palette-line-300);
    --color-opt-card-pnl-zero-border:     var(--palette-line-300);
    --color-opt-card-pnl-zero-bg:         rgba(0, 0, 0, 0.02);
    --color-opt-card-order-btn-bg:        rgba(15, 162, 140, 0.06);
    --color-opt-card-order-btn-border:    rgba(15, 162, 140, 0.30);
    --color-opt-card-order-btn-bg-hover:  rgba(15, 162, 140, 0.16);
    --color-opt-card-pnl-pos-border:      rgba(40, 167, 69, 0.35);
    --color-opt-card-pnl-pos-bg:          rgba(40, 167, 69, 0.07);
    --color-opt-card-pnl-neg-border:      rgba(220, 53, 69, 0.35);
    --color-opt-card-pnl-neg-bg:          rgba(220, 53, 69, 0.06);

    /* Active alerts banner */
    --color-bg-alert-banner:              rgba(220, 53, 69, 0.10);
    --color-bg-alert-banner-header:       rgba(220, 53, 69, 0.16);
    --color-bg-alert-banner-header-hover: rgba(220, 53, 69, 0.22);
    --color-border-alert-banner:          #c92a2a;

    /* Risk Gates panel */
    --color-bg-rg-section-header:         var(--palette-paper-alt);
    --color-bg-rg-section-header-hover:   var(--palette-paper-elevated);
    --color-bg-rg-section-body:           var(--palette-paper);
    --color-bg-rg-add-btn:                var(--palette-paper-alt);
    --color-bg-rg-add-btn-hover:          var(--palette-paper-elevated);
    --color-border-rg-section-divider:    var(--palette-line-200);
    --color-border-rg-row:                var(--palette-line-200);

    /* Generic dim slate variants */
    --color-text-dim:                     var(--palette-ink-500);
    --color-text-very-faint:              var(--palette-ink-400);

    /* Bright cornflower blue */
    --color-status-info-alt:              var(--palette-blue-700);

    /* ACP card */
    --color-bg-acp-card:                  var(--palette-card-light);
    --color-border-acp-danger-idle:       rgba(220, 53, 69, 0.20);
    --color-text-acp-danger-idle:         rgba(220, 53, 69, 0.55);

    /* Generic ON/OFF/LEVEL/UNKNOWN badge tints */
    --color-bg-badge-level:               rgba(26, 109, 199, 0.12);
    --color-border-badge-level:           rgba(26, 109, 199, 0.25);
    --color-bg-badge-on:                  rgba(40, 167, 69, 0.12);
    --color-border-badge-on:              rgba(40, 167, 69, 0.25);
    --color-bg-badge-on-strong:           rgba(40, 167, 69, 0.20);
    --color-bg-badge-off:                 rgba(220, 53, 69, 0.10);
    --color-border-badge-off:             rgba(220, 53, 69, 0.25);
    --color-bg-badge-off-strong:          rgba(220, 53, 69, 0.18);
    --color-bg-badge-unknown:             rgba(0, 0, 0, 0.06);
    --color-border-badge-unknown:         rgba(0, 0, 0, 0.15);
    --color-text-badge-unknown:           var(--palette-ink-500);

    /* Buttons */
    --color-accent-hover-bright:          var(--palette-cyan-800);
    --color-status-danger-hover:          #a31e1e;

    /* Form & window labels */
    --color-text-form-label:              var(--palette-ink-700);
    --color-text-window-title:            var(--palette-ink-900);

    /* Property cells */
    --color-text-prop-cell:               var(--palette-ink-700);
    --color-text-prop-cell-empty:         var(--palette-ink-400);

    /* Disclosure */
    --color-bg-disclosure-hover:          var(--palette-paper-alt);
    --color-border-disclosure-open:       var(--palette-line-400);

    /* Detail panel */
    --color-bg-detail-content:            var(--palette-paper-alt);

    /* Hover border */
    --color-border-strong-hover:          var(--palette-line-400);

    /* Mini chart inline controls */
    --color-bg-mini-chart-ctrl:           var(--palette-paper-elevated);
    --color-border-mini-chart-ctrl:       var(--palette-line-300);

    /* Slate-overlay tints */
    --color-bg-slate-overlay-soft:        rgba(0, 0, 0, 0.03);
    --color-bg-slate-overlay-medium:      rgba(0, 0, 0, 0.10);

    /* Orange tint */
    --color-status-orange-tint-soft:      rgba(204, 122, 0, 0.10);

    /* Triggered alert row */
    --color-bg-alert-triggered:           rgba(220, 53, 69, 0.10);

    /* Paused/standby amber */
    --color-status-paused:                #b08a00;
    --color-status-paused-tint-soft:      rgba(255, 193, 7, 0.18);
    --color-status-paused-tint-medium:    rgba(255, 193, 7, 0.25);
    --color-status-paused-border-medium:  rgba(176, 138, 0, 0.40);

    /* Notes accordion */
    --color-bg-notes-accordion-header:        var(--palette-paper-alt);
    --color-bg-notes-accordion-header-hover:  var(--palette-paper-elevated);
    --color-bg-notes-accordion-body:          var(--palette-card-light);
    --color-border-notes-section:             var(--color-border-strong);

    /* Note card archived */
    --color-bg-note-archived:                 var(--palette-paper-elevated);
    --color-bg-note-archived-badge:           rgba(0, 0, 0, 0.10);

    /* TipTap surfaces */
    --color-bg-tiptap-toolbar:                var(--palette-paper-alt);
    --color-bg-tiptap-editor:                 var(--palette-card-light);
    --color-bg-tiptap-pre:                    var(--palette-paper-alt);
    --color-bg-tiptap-code:                   var(--palette-paper-alt);
    --color-bg-tiptap-th:                     var(--palette-paper-alt);
    --color-bg-tiptap-scrollbar-track:        var(--palette-paper-alt);
    --color-bg-tiptap-select:                 var(--palette-card-light);

    /* Bright/light text variants */
    --color-text-bright:                      var(--palette-ink-900);
    --color-text-italic-soft:                 var(--palette-ink-700);
    --color-text-code-light:                  var(--palette-blue-700);
    --color-text-code-light-alt:              var(--palette-ink-700);
    --color-text-link-blue:                   var(--palette-blue-700);
    --color-text-light-blue:                  var(--palette-blue-700);
    --color-text-deep-muted:                  var(--palette-ink-400);
    --color-text-deeper-muted:                var(--palette-ink-300);
    --color-text-form-placeholder:            var(--palette-ink-400);

    /* Accent tints (extra granularity) */
    --color-accent-tint-faint:                rgba(15, 162, 140, 0.05);
    --color-accent-tint-stronger:             rgba(15, 162, 140, 0.25);
    --color-accent-border-soft:               rgba(15, 162, 140, 0.30);
    --color-accent-border-medium:             rgba(15, 162, 140, 0.40);
    --color-accent-border-strong:             rgba(15, 162, 140, 0.50);
    --color-accent-border-bright:             rgba(15, 162, 140, 0.55);
    --color-accent-tint-table-cell:           rgba(15, 162, 140, 0.10);

    --color-bg-slate-overlay-faint:           rgba(0, 0, 0, 0.04);

    /* Red500 status (deprecated/error) */
    --color-status-error:                     #c92a2a;
    --color-status-error-tint-soft:           rgba(201, 42, 42, 0.10);
    --color-status-error-border:              rgba(201, 42, 42, 0.30);

    /* Blue tints for nested details */
    --color-bg-blue-tint-faint:               rgba(26, 109, 199, 0.06);

    /* Solid checkmark inverse */
    --color-checkmark-on-accent:              var(--palette-card-light);

    /* Conversation drawer */
    --color-bg-conv-user-bubble:              #d8e7f7;
    --color-bg-conv-context-btn:              var(--palette-paper-alt);
    --color-bg-conv-context-btn-hover:        var(--palette-paper-elevated);

    /* Status amber */
    --color-status-amber:                     #b08a00;

    /* Memory-source AI badge */
    --color-memory-ai-fg:                     var(--palette-blue-700);
    --color-memory-ai-bg:                     rgba(26, 109, 199, 0.10);
    --color-memory-ai-border:                 rgba(26, 109, 199, 0.30);

    /* System-prompt name badge */
    --color-sysmsg-fg:                        #6f42c1;
    --color-sysmsg-bg:                        rgba(111, 66, 193, 0.10);
    --color-sysmsg-border:                    rgba(111, 66, 193, 0.30);

    /* Price source badges */
    --color-ps-afterhours-fg:                 #cc7a00;
    --color-ps-afterhours-bg:                 rgba(204, 122, 0, 0.10);
    --color-ps-afterhours-border:             rgba(204, 122, 0, 0.30);
    --color-ps-premarket-fg:                  var(--palette-blue-700);
    --color-ps-premarket-bg:                  rgba(26, 109, 199, 0.10);
    --color-ps-premarket-border:              rgba(26, 109, 199, 0.30);
    --color-ps-close-fg:                      #1a8a3a;
    --color-ps-close-bg:                      rgba(40, 167, 69, 0.10);
    --color-ps-close-border:                  rgba(40, 167, 69, 0.30);
    --color-ps-prevclose-fg:                  var(--palette-ink-500);
    --color-ps-prevclose-bg:                  rgba(0, 0, 0, 0.05);
    --color-ps-prevclose-border:              rgba(0, 0, 0, 0.15);

    /* Floating note window framework */
    --color-bg-note-window-base:              var(--palette-card-light);
    --color-bg-note-window-titlebar-base:     var(--palette-paper-alt);
    --color-border-note-window:               var(--palette-line-300);
    --color-overlay-ring-faint:               rgba(0, 0, 0, 0.10);
    --color-overlay-ring-medium-faint:        rgba(0, 0, 0, 0.15);
    /* Light-mode equivalent of the SDW shadow — matches --shadow-sdw light. */
    --shadow-note-window:                     0 0 0 1px rgba(20, 30, 50, 0.20),
                                              0 8px 20px rgba(20, 30, 50, 0.40),
                                              0 36px 90px rgba(20, 30, 50, 0.55);
    --shadow-note-swatch:                     0 0 4px rgba(0, 0, 0, 0.15);
    --shadow-note-popover:                    0 8px 24px rgba(20, 30, 50, 0.20);

    /* Note window deeper surfaces */
    --color-bg-note-window-props:             var(--palette-paper-alt);
    --color-bg-note-window-input:             var(--palette-card-light);

    /* Note window placeholder text */
    --color-text-note-placeholder:            var(--palette-ink-400);
    --color-text-note-tab-inactive:           var(--palette-ink-400);

    /* Note window borders */
    --color-border-note-window-soft:          var(--palette-line-300);
    --color-border-note-window-faint:         var(--palette-line-200);

    /* Conv code/pre block */
    --color-bg-conv-pre:                      var(--palette-paper-alt);

    /* Note window conv base */
    --color-bg-note-window-conv-base:         var(--palette-paper);

    /* Order status badges */
    --color-status-info-blue-alt:             rgba(26, 109, 199, 0.10);
    --color-status-info-blue-alt-border:      rgba(26, 109, 199, 0.30);
    --color-status-success-green-bg:          rgba(40, 167, 69, 0.10);
    --color-status-success-green-border:      rgba(40, 167, 69, 0.30);
    --color-text-pale-grey:                   var(--palette-ink-400);
    --color-text-dim-grey:                    var(--palette-ink-500);
    --color-border-deep-grey:                 var(--palette-line-400);
    --color-bg-cancelled-row:                 rgba(220, 53, 69, 0.07);
    --color-border-cancelled-row:             rgba(220, 53, 69, 0.20);
    --color-bg-inactive-row:                  rgba(0, 0, 0, 0.05);
    --color-border-inactive-row:              rgba(0, 0, 0, 0.12);

    /* Cornflower blue */
    --color-status-info-cornflower:           var(--palette-blue-700);
    --color-status-info-cornflower-bg:        rgba(26, 109, 199, 0.10);
    --color-status-info-cornflower-bg-hover:  rgba(26, 109, 199, 0.08);
    --color-status-info-cornflower-bg-active: rgba(26, 109, 199, 0.18);

    /* Trade card surfaces */
    --color-bg-trade-card:                    var(--palette-card-light);
    --color-bg-trade-card-input:              var(--palette-paper);
    --color-bg-trade-card-price-btn:          var(--palette-paper-alt);
    --color-bg-trade-card-margin:             var(--palette-paper-alt);
    --color-bg-trade-card-pop:                var(--palette-paper-alt);
    --color-border-trade-card:                var(--palette-line-300);
    --color-border-trade-card-input:          var(--palette-line-300);
    --color-border-trade-card-section:        var(--palette-line-300);
    --color-border-trade-card-row:            var(--palette-line-200);
    --color-border-trade-card-row-faint:      var(--palette-line-200);
    --color-border-trade-card-row-fainter:    var(--palette-line-200);

    /* Trade card text */
    --color-text-light-slate:                 var(--palette-ink-700);
    --color-text-mid-slate:                   var(--palette-ink-500);
    --color-text-faint-slate:                 var(--palette-ink-400);
    --color-text-fainter-slate:               var(--palette-ink-400);
    --color-text-trade-placeholder:           var(--palette-ink-400);

    /* Modern PnL alt shades */
    --color-pnl-positive-alt:                 #1a8a3a;
    --color-pnl-negative-alt:                 #c92a2a;
    --color-pnl-warn-alt:                     #cc7a00;
    --color-bg-pnl-positive-alt-tint:         rgba(40, 167, 69, 0.10);
    --color-border-pnl-positive-alt-tint:     rgba(40, 167, 69, 0.30);
    --color-bg-pnl-negative-alt-tint:         rgba(220, 53, 69, 0.10);
    --color-border-pnl-negative-alt-tint:     rgba(220, 53, 69, 0.30);
    --color-border-pnl-positive-alt-faint:    rgba(40, 167, 69, 0.25);
    --color-border-pnl-negative-alt-faint:    rgba(220, 53, 69, 0.25);
    --color-border-mid-slate-faint:           rgba(0, 0, 0, 0.10);
    --shadow-trade-card:                      0 16px 48px rgba(20, 30, 50, 0.20);

    /* Accent ghost button */
    --color-accent-tint-ghost:                rgba(15, 162, 140, 0.05);
    --color-accent-border-vivid:              rgba(15, 162, 140, 0.45);
    --color-accent-tint-strong-alt:           rgba(15, 162, 140, 0.20);

    /* Focus ring */
    --shadow-focus-ring-trade:                0 0 0 2px rgba(15, 162, 140, 0.20);

    /* Bracket order leg tints */
    --color-bg-bracket-tp-tint:               rgba(40, 167, 69, 0.08);
    --color-bg-bracket-sl-tint:               rgba(220, 53, 69, 0.08);

    /* Slate-400 cancelled tint */
    --color-bg-slate-cancelled:               rgba(0, 0, 0, 0.08);

    /* Empty progress */
    --color-bg-progress-empty:                #d0d7de;

    /* ── Chart.js theme tokens ─────────────────────────────────────────── */
    --color-chart-line-default:               var(--color-accent);
    --color-chart-area-default:               var(--color-accent-tint-soft);
    --color-chart-yesterday-line:             rgba(74, 88, 114, 0.40);
    --color-chart-axis-text:                  var(--palette-ink-500);
    --color-chart-overlay-default:            rgba(74, 88, 114, 0.50);
    --color-chart-overlay-buy:                rgba(40, 167, 69, 0.85);
    --color-chart-overlay-sell:               rgba(220, 53, 69, 0.85);
    --color-chart-overlay-long:               rgba(26, 109, 199, 0.85);
    --color-chart-overlay-short:              rgba(204, 122, 0, 0.85);

    /* Watchlist (daily) chart tooltip + grid */
    --color-chart-tooltip-bg-watchlist:       var(--palette-card-light);
    --color-chart-tooltip-title-watchlist:    var(--palette-ink-900);
    --color-chart-tooltip-body-watchlist:     var(--palette-ink-700);
    --color-chart-tooltip-border-watchlist:   var(--palette-line-300);
    --color-chart-grid-watchlist:             rgba(0, 0, 0, 0.06);

    /* Minute chart tooltip + grid */
    --color-chart-tooltip-bg-minute:          rgba(255, 255, 255, 0.96);
    --color-chart-tooltip-title-minute:       var(--color-accent);
    --color-chart-tooltip-body-minute:        var(--palette-ink-700);
    --color-chart-tooltip-border-minute:      var(--palette-line-300);
    --color-chart-grid-minute:                rgba(0, 0, 0, 0.05);

    /* SDW (light) */
    --color-bg-sdw:                           var(--palette-card-light);
    --color-bg-sdw-header:                    var(--palette-paper-alt);
    --color-border-sdw:                       var(--palette-line-300);
    --color-text-sdw-title:                   var(--palette-ink-900);
    --color-text-sdw-subtitle:                var(--palette-ink-500);
    --color-text-sdw-strong:                  var(--palette-ink-900);
    --color-text-sdw-muted:                   var(--palette-ink-500);
    --color-border-sdw-divider:               var(--palette-line-200);
    --color-bg-sdw-row-hover:                 rgba(0, 0, 0, 0.03);
    --color-bg-sdw-section-band:              rgba(26, 109, 199, 0.04);
    --color-bg-sdw-link-tint:                 rgba(26, 109, 199, 0.06);
    --color-bg-sdw-badge:                     rgba(26, 109, 199, 0.08);
    --color-border-sdw-badge:                 rgba(26, 109, 199, 0.25);
    --color-text-sdw-link:                    var(--palette-blue-700);
    --color-text-sdw-link-light:              var(--palette-blue-700);
    --color-bg-sdw-pill-tint:                 rgba(0, 0, 0, 0.04);
    /* Light-mode equivalent — same three-layer approach (edge halo + lift +
       depth) as dark mode, but with lower opacities since the contrast
       against a light surface is naturally higher than against a dark one. */
    --shadow-sdw:                             0 0 0 1px rgba(20, 30, 50, 0.20),
                                              0 8px 20px rgba(20, 30, 50, 0.40),
                                              0 36px 90px rgba(20, 30, 50, 0.55);
    --shadow-sdw-close-hover:                 rgba(0, 0, 0, 0.08);
    /* Light-mode card shadow — matches the dark-mode two-layer pattern with
       opacities tuned for a light background. */
    --shadow-card:                            0 1px 3px rgba(20, 30, 50, 0.15),
                                              0 6px 18px rgba(20, 30, 50, 0.22);
    /* Light-mode equivalent of --shadow-note-card. */
    --shadow-note-card:                       0 2px 4px rgba(20, 30, 50, 0.22),
                                              0 10px 28px rgba(20, 30, 50, 0.32);
    --color-border-sdw-trigger-dashed:        rgba(26, 109, 199, 0.50);

    /* Analyst rating badges */
    --color-rating-buy-fg:                    #1a8a3a;
    --color-rating-buy-border:                rgba(40, 167, 69, 0.40);
    --color-rating-buy-bg:                    rgba(40, 167, 69, 0.10);
    --color-rating-hold-fg:                   #b08a00;
    --color-rating-hold-border:               rgba(176, 138, 0, 0.40);
    --color-rating-hold-bg:                   rgba(255, 212, 59, 0.10);
    --color-rating-sell-fg:                   #c92a2a;
    --color-rating-sell-border:               rgba(201, 42, 42, 0.40);
    --color-rating-sell-bg:                   rgba(220, 53, 69, 0.08);
    --color-rating-na-fg:                     var(--palette-ink-500);
    --color-rating-na-border:                 var(--palette-line-300);
    --color-rating-na-bg:                     rgba(0, 0, 0, 0.03);

    /* Strategy badges */
    --color-strat-active-bg:                  rgba(40, 167, 69, 0.12);
    --color-strat-active-fg:                  #1a8a3a;
    --color-strat-active-border:              rgba(40, 167, 69, 0.30);
    --color-strat-paused-bg:                  rgba(255, 193, 7, 0.18);
    --color-strat-paused-fg:                  #b08a00;
    --color-strat-paused-border:              rgba(176, 138, 0, 0.30);
    --color-strat-stopped-bg:                 rgba(0, 0, 0, 0.06);
    --color-strat-stopped-fg:                 var(--palette-ink-500);
    --color-strat-stopped-border:             rgba(0, 0, 0, 0.15);
    --color-strat-created-bg:                 rgba(26, 109, 199, 0.10);
    --color-strat-created-fg:                 var(--palette-blue-700);
    --color-strat-created-border:             rgba(26, 109, 199, 0.30);
    --color-strat-error-bg:                   rgba(220, 53, 69, 0.10);
    --color-strat-error-fg:                   #c92a2a;
    --color-strat-error-border:               rgba(220, 53, 69, 0.30);
    --color-strat-flatten-bg:                 rgba(220, 53, 69, 0.20);
    --color-strat-flatten-fg:                 #c92a2a;
    --color-strat-flatten-border:             rgba(220, 53, 69, 0.50);
    --color-strat-unknown-bg:                 rgba(0, 0, 0, 0.04);
    --color-strat-unknown-fg:                 var(--palette-ink-500);
    --color-strat-unknown-border:             rgba(0, 0, 0, 0.12);

    /* Strategy P&L */
    --color-strat-pnl-pos:                    #1a8a3a;
    --color-strat-pnl-neg:                    #c92a2a;

    /* Strategy badge */
    --color-bg-strat-badge:                   rgba(26, 109, 199, 0.10);
    --color-bg-strat-badge-hover:             rgba(26, 109, 199, 0.20);
    --color-fg-strat-badge:                   var(--palette-blue-700);
    --color-border-strat-badge:               rgba(26, 109, 199, 0.30);

    /* Strategy table rows */
    --color-bg-strat-row-selected:            var(--palette-paper-alt);
    --color-bg-strat-row-expanded:            var(--palette-paper-elevated);
    --color-border-strat-row-selected:        var(--color-accent);
    --color-border-strat-row-divider:         var(--palette-line-200);

    /* Strategy expanded card */
    --color-bg-strat-detail-card:             var(--palette-paper-alt);
    --color-border-strat-detail-card:         var(--palette-line-300);
    --color-text-strat-label:                 var(--palette-ink-500);
    --color-text-strat-value:                 var(--palette-ink-900);
    --color-text-strat-value-emphasis:        var(--palette-blue-700);
    --color-bg-strat-error-banner:            rgba(220, 53, 69, 0.08);
    --color-bg-strat-json-error:              rgba(220, 53, 69, 0.06);
    --color-border-strat-error-banner:        rgba(220, 53, 69, 0.30);
    --color-text-strat-error:                 #c92a2a;

    /* Strategy event chips */
    --color-strat-ev-blue-bg:                 rgba(26, 109, 199, 0.10);
    --color-strat-ev-blue-fg:                 var(--palette-blue-700);
    --color-strat-ev-green-bg:                rgba(40, 167, 69, 0.10);
    --color-strat-ev-green-fg:                #1a8a3a;
    --color-strat-ev-orange-bg:               rgba(204, 122, 0, 0.10);
    --color-strat-ev-orange-fg:               #cc7a00;
    --color-strat-ev-red-bg:                  rgba(220, 53, 69, 0.10);
    --color-strat-ev-red-fg:                  #c92a2a;
    --color-strat-ev-yellow-bg:               rgba(255, 193, 7, 0.16);
    --color-strat-ev-yellow-fg:               #b08a00;
    --color-strat-ev-purple-bg:               rgba(111, 66, 193, 0.10);
    --color-strat-ev-purple-fg:               #6f42c1;
    --color-strat-ev-gray-bg:                 rgba(0, 0, 0, 0.05);
    --color-strat-ev-gray-fg:                 var(--palette-ink-500);

    /* Strategy params ok/err */
    --color-strat-param-ok:                   #1a8a3a;
    --color-strat-param-err:                  #c92a2a;

    --color-text-strat-tan:                   #8a6a3a;
    --color-text-strat-pop:                   var(--palette-ink-500);

    --color-bg-strat-row-link-tint:           rgba(26, 109, 199, 0.06);
    --color-bg-strat-row-link-tint-hover:     rgba(26, 109, 199, 0.10);

    --color-bg-strat-pop-tint:                rgba(26, 109, 199, 0.08);
    --color-border-strat-pop-tint:            rgba(26, 109, 199, 0.25);

    --color-bg-strat-subhead-tint:            rgba(26, 109, 199, 0.06);
    --color-fg-strat-subhead:                 var(--palette-blue-700);

    --color-text-strat-emphasis:              var(--palette-blue-700);

    /* Strategy builder modal */
    --color-bg-strat-builder:                 var(--palette-card-light);
    --color-border-strat-builder:             var(--palette-line-300);
    --color-bg-strat-builder-card:            var(--palette-paper-alt);
    --color-bg-strat-builder-pre:             var(--palette-paper);
    --shadow-strat-builder:                   0 20px 60px rgba(20, 30, 50, 0.25);
    --shadow-strat-builder-popup:             0 8px 24px rgba(20, 30, 50, 0.18);
    --color-text-strat-builder-dim:           var(--palette-ink-500);
    --color-bg-strat-builder-tab-active:      rgba(26, 109, 199, 0.12);
    --color-bg-strat-builder-tab-hover:       rgba(0, 0, 0, 0.04);
    --color-bg-strat-builder-input-active:    rgba(26, 109, 199, 0.08);
    --color-bg-strat-builder-input-pop:       rgba(26, 109, 199, 0.06);

    /* Symbol search */
    --color-bg-symbol-search-input:           var(--palette-card-light);
    --color-bg-symbol-search-active:          var(--palette-paper-alt);
    --color-text-symbol-search:               var(--palette-ink-900);

    /* Hashtable browser */
    --color-bg-ht-card:                       var(--palette-card-light);
    --color-bg-ht-header:                     var(--palette-paper-alt);
    --color-text-ht-title:                    var(--palette-ink-900);
    --color-bg-ht-row-hover:                  rgba(15, 162, 140, 0.06);
    --shadow-ht-modal:                        0 8px 32px rgba(20, 30, 50, 0.25);
    --color-bg-ht-input:                      var(--palette-card-light);
    --color-border-ht-default:                var(--palette-line-300);
    --color-text-ht-primary:                  var(--palette-ink-900);
    --color-text-ht-secondary:                var(--palette-ink-500);

    /* PPS / Risk Gauge */
    --color-bg-pps-track:                     rgba(0, 0, 0, 0.06);
    --color-border-pps-gear:                  rgba(0, 0, 0, 0.20);
    --color-border-pps-gear-hover:            rgba(15, 162, 140, 0.50);
    --color-text-pps-warning:                 #cc4400;
    --color-bg-pps-doc:                       rgba(15, 162, 140, 0.06);
    --color-bg-pps-transparency:              rgba(245, 247, 250, 0.85);
    --color-border-pps-transparency-divider:  var(--palette-line-200);
    --color-text-pps-trans-dd:                var(--palette-ink-900);
    --color-text-pps-trans-dt:                var(--palette-ink-700);
    --color-text-pps-trans-symbol:            var(--palette-ink-700);
    --color-text-pps-trans-mono:              var(--palette-ink-500);
    --color-text-pps-trans-yes:               #1a8a3a;
    --color-text-pps-trans-no:                #c92a2a;

    /* Suspended/error states for builder */
    --color-bg-strat-suspended:               rgba(255, 212, 59, 0.18);
    --color-border-strat-suspended:           rgba(176, 138, 0, 0.40);
    --color-fg-strat-suspended:               #b08a00;
    --color-bg-strat-suspended-pill:          rgba(176, 138, 0, 0.18);
    --color-bg-strat-killswitch:              rgba(220, 53, 69, 0.10);
    --color-border-strat-killswitch:          rgba(201, 42, 42, 0.40);
    --color-fg-strat-killswitch:              #c92a2a;
    --color-bg-strat-killswitch-pill:         rgba(201, 42, 42, 0.18);

    /* ── Trading-domain semantics ─────────────────────────────────────────── */
    --color-pnl-positive:            #1a8a3a;
    --color-pnl-negative:            #c92a2a;
    --color-position-long:           var(--palette-blue-700);
    --color-position-short:          #cc7a00;
    --color-itm:                     #1a8a3a;
    --color-otm:                     var(--palette-ink-500);

    /* ── Chart colors (legacy aliases) ───────────────────────────────────── */
    --color-chart-grid:              rgba(0, 0, 0, 0.06);
    --color-chart-tooltip-bg:        var(--palette-card-light);
    --color-chart-tooltip-bg-translucent: rgba(255, 255, 255, 0.96);
    --color-chart-tooltip-title:     var(--palette-ink-900);
    --color-chart-tooltip-body:      var(--palette-ink-700);
    --color-chart-tooltip-border:    var(--palette-line-300);

    /* ── Shadow tokens (light theme is much softer) ──────────────────────── */
    --shadow-card-soft:              0 3px 12px rgba(20, 30, 50, 0.10);
    --shadow-card-hover:             0 4px 16px rgba(20, 30, 50, 0.12);
    --shadow-dropdown:               0 4px 12px rgba(20, 30, 50, 0.15);
    --shadow-modal:                  0 20px 60px rgba(20, 30, 50, 0.20);
    --shadow-overlay-strong:         0 16px 48px rgba(20, 30, 50, 0.20);
    --shadow-focus-ring-accent:      0 0 0 2px rgba(15, 162, 140, 0.20);
    --shadow-glow-warn:              0 0 6px rgba(255, 212, 59, 0.45);
    --shadow-glow-caution:           0 0 6px rgba(255, 169, 77, 0.45);
    --shadow-glow-danger:            0 0 10px rgba(220, 53, 69, 0.35);
    --shadow-glow-danger-strong:     0 0 18px rgba(220, 53, 69, 0.55);
    --shadow-swatch-outer-ring:      0 0 0 1px rgba(0, 0, 0, 0.20);
    --shadow-swatch-selected-ring:   0 0 0 1px rgba(0, 0, 0, 0.50);
    --shadow-priority-dot-ring:      0 0 0 1px rgba(0, 0, 0, 0.20);
    --shadow-drawer:                 -6px 0 24px rgba(20, 30, 50, 0.18);

    --color-bg-code-translucent:     rgba(245, 247, 250, 0.92);
    --color-overlay-backdrop:        rgba(20, 30, 50, 0.30);
    --color-overlay-row-hover:       rgba(0, 0, 0, 0.04);
}

/* =============================================================================
   END THEME TOKENS
   ============================================================================= */

/* =============================================================================
   COLOR UTILITY CLASSES (used by JS template literals)
   ============================================================================= */
.u-text-accent { color: var(--color-accent); }
.u-text-muted  { color: var(--color-text-muted); }
.u-text-muted-light { color: var(--color-text-sdw-muted); }

/* Status message colors (used by JS class toggles) */
.u-status-success { color: var(--color-status-success); }
.u-status-error   { color: var(--color-status-danger); }

/* Empty/inactive progress fill */
.u-progress-empty { background: var(--color-bg-progress-empty); }

/* Centered empty-state message (small, muted) */
.u-empty-state {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--color-text-sdw-muted);
}

.u-empty-state--lg {
    text-align: center;
    padding: 20px;
    color: var(--color-text-muted);
}

/* TipTap AI block button — accent text */
.tt-btn--ai {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--color-accent);
}

/* =============================================================================
   END COLOR UTILITY CLASSES
   ============================================================================= */

/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.4;
    background-color: var(--color-bg-page);
    color: var(--color-text-primary);
    display: flex;
    flex-direction: column;
}

/* Main content area */
#main-content {
    flex: 1;
    overflow: auto;
    padding: 0 16px 16px 16px;
    display: flex;
    flex-direction: column;
}

/* =============================================================================
   RESPONSIVE SECTIONS GRID
   At ~1200px+: Portfolio and Watchlist Alerts appear side-by-side.
   Watchlist spans all columns (full width); list cards stack vertically.
   Configuration fills remaining columns.
   ============================================================================= */

.sections-grid {
    display: grid;
    grid-template-columns: 1fr;   /* single column on narrow screens */
    gap: 0 20px;
    align-items: start;
}
@media (min-width: 1600px) {
    .sections-grid {
        grid-template-columns: repeat(2, 1fr);   /* exactly 2 columns, never more */
    }
}

/* Prevent any section from blowing out of its grid cell */
.sections-grid > section {
    min-width: 0;
    overflow: hidden;
}
/* Every section in the grid spans the full width anyway, so the wrapper adds nothing to layout. With
   display:contents its sections become flex items of #main-content like Notes and Dashboard, and the
   per-tab section order (Configuration → Tabs) is a plain CSS `order` on each of them. */
.sections-grid { display: contents; }
/* As flex items of #main-content these sections must not shrink: with overflow:hidden their automatic
   minimum height is 0, so they would squeeze to the viewport and clip instead of letting the page scroll. */
.sections-grid > section { flex-shrink: 0; }

/* These sections always span the full width regardless of column count */
#orders,
#stocks,
#options,
#portfolio,
#watchlist-alerts,
#watchlist,
#transactions,
#tasks,
#files,
#databases,
#channels,
#hashtable-browser,
#strategies,
#configuration {
    grid-column: 1 / -1;
}

/* Default styling for every top-level section inside .sections-grid.
   This is the canonical look (cyan accent title, 16px/600, 24/16 vertical
   spacing, 12px header→content gap). Many individual sections still have
   per-ID rules below (e.g. `#portfolio h2 { ... }`) that repeat these exact
   declarations — those are harmless duplicates and ID-specificity simply wins.
   The advantage of this default rule is that any NEW section added later
   (e.g. #orders, #stocks, #options) inherits the correct section-header look
   without anyone having to remember to add a matching per-ID block. */
.sections-grid > section {
    margin-top: 24px;
    margin-bottom: 16px;
}
.sections-grid > section > h2.collapsible-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}
.sections-grid > section > .collapsible-content {
    padding-top: 12px;
}

/* Single-column stack for per-list cards (no side-by-side wrapping) */
.watchlist-lists-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual watchlist list card */
.wl-list-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* Color accent: listDef.color bleeds into the left-edge bar and tints the
   header bottom border. --wl-list-color is set per-card inline by
   renderWatchlist when the list has a color assigned. */
.wl-list-card-colored::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--wl-list-color, transparent);
    pointer-events: none;
}
.wl-list-card-colored .wl-list-card-header {
    border-bottom: 1px solid color-mix(in srgb, var(--wl-list-color, transparent) 45%, transparent);
}

/* Round swatch dot rendered inline next to the list's name in the header. */
.wl-list-card-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--color-overlay-ring-soft);
    box-shadow: var(--shadow-swatch-outer-ring);
}

.wl-list-card-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    background: var(--color-bg-card-hover-tint);
    border-bottom: 1px solid var(--color-border-default);
}
.wl-list-card-header:hover { background: var(--color-bg-card-hover-tint-strong); }

.wl-list-card-header .collapse-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.wl-list-card.collapsed .wl-list-card-header .collapse-icon {
    transform: rotate(-90deg);
}

.wl-list-count {
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-muted);
    margin-left: 2px;
}

.wl-list-header-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.wl-list-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.wl-list-card-header:hover .wl-list-header-btn {
    opacity: 1;
}
.wl-list-header-btn:hover:not(:disabled) {
    color: var(--color-accent);
    background: var(--color-accent-tint-soft);
    opacity: 1;
}
.wl-list-header-btn:focus-visible {
    opacity: 1;
    outline: 1px solid var(--color-accent);
    outline-offset: 1px;
}
.wl-list-header-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}
.wl-list-card-header:hover .wl-list-header-btn:disabled {
    opacity: 0.25;
}

.wl-list-card-body {
    overflow: hidden;
    max-height: 4000px;
    transition: max-height 0.3s ease;
}
.wl-list-card.collapsed .wl-list-card-body {
    max-height: 0;
}

/* ── Watchlist symbol cards (per-list card layout vs table) ───────────── */
.wl-item-card {
    width: 340px;
    flex-shrink: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wl-item-card-top {
    padding: 8px 10px 8px;
    border-bottom: 1px solid var(--color-border-default);
}

.wl-item-card-symbol-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 35px;
}

.wl-item-card-symbol-left {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.wl-item-card-symbol-row .wl-item-card-symbol {
    flex: 0 1 auto;
    min-width: 0;
}

.wl-item-card-symbol {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
}

.wl-item-card-symbol.sdw-trigger {
    border-bottom: none;
}

.wl-item-card-symbol:hover,
.wl-item-card-symbol.sdw-trigger:hover {
    color: var(--color-accent);
    text-decoration: underline;
    border-bottom: none;
}

.wl-item-card-longname {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 4px 0 0;
    line-height: 1.35;
    word-break: break-word;
    max-height: 2.8em;
    overflow: hidden;
}

.wl-item-card-chart-inline {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.wl-item-card-chart-inline .mini-chart-canvas {
    width: 80px;
    height: 35px;
    display: block;
}

.wl-item-card-actions-inline {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.wl-item-shares-table {
    font-size: 10px;
    width: 100%;
}

.wl-item-shares-table th,
.wl-item-shares-table td {
    padding: 3px 4px !important;
    white-space: nowrap;
}

.wl-item-opt-leg-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wl-item-opt-leg {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    padding: 6px 8px;
    background: var(--color-bg-nested-panel);
}

.wl-item-opt-leg-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.wl-item-opt-ls {
    font-family: ui-monospace, monospace;
    font-size: 10px;
    word-break: break-all;
}

.wl-item-opt-qty {
    font-size: 10px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.wl-item-opt-leg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.wl-item-opt-leg-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
    margin-top: 5px;
    color: var(--color-text-secondary);
}

.wl-item-opt-daily {
    color: var(--color-text-muted);
    font-size: 9px;
}

/* Table inside each list card – flush, no outer border radius */
.wl-list-table {
    border-radius: 0;
    border: none;
}

/* =============================================================================
   END RESPONSIVE SECTIONS GRID
   ============================================================================= */

/* Status bar */
#status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
    padding: 8px 16px;
    background-color: var(--color-bg-card);
    border-top: 1px solid var(--color-border-default);
    font-size: 13px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label {
    color: var(--color-text-muted);
    font-weight: 500;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--color-state-neutral);
    transition: background-color 0.3s ease;
}

.status-indicator.connected {
    background-color: var(--color-status-success);
    box-shadow: 0 0 6px var(--color-status-success);
}

.status-indicator.disconnected {
    background-color: var(--color-status-danger);
    box-shadow: 0 0 6px var(--color-status-danger);
}

#market-close-countdown {
    font-weight: 500;
    color: var(--color-accent);
}

#market-close-countdown.market-regular {
    color: var(--color-status-success);
}

#market-close-countdown.market-prepost {
    color: var(--color-status-warning);
}

#market-close-countdown.market-closed {
    color: var(--color-text-muted);
}

#market-status-dot.market-open {
    background-color: var(--color-status-success);
    box-shadow: 0 0 6px var(--color-status-success);
}

#market-status-dot.market-closed {
    background-color: var(--color-status-danger);
    box-shadow: 0 0 6px var(--color-status-danger);
}

/* Data binding elements */
[data-bind] {
    transition: color 0.2s ease;
}

[data-bind].updated {
    color: var(--color-accent);
}

/* Dashboard */
#dashboard {
    margin-top: 16px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

#dashboard.dashboard-pinned {
    position: sticky;
    top: var(--tabs-bar-height, 36px);
    z-index: 200;
    margin-top: 0;
    background: var(--color-bg-page);
    box-shadow: var(--shadow-card-soft);
    border-bottom: 1px solid var(--color-border-strong);
}

/* Collapsible body — slides up when hidden.
   max-height is the EXPANDED cap and must clear the tallest the card grid can get.
   It has to be a concrete length because the collapse animates max-height (you cannot
   transition to `none`). Raised from 600px to 2000px on 2026-08-19: the dashboard went
   from one row of two cards to two rows of four, and 600px was silently clipping the
   Protection Cost and Exposure & Survival cards. Anything comfortably above the real
   content height works — the transition simply finishes early. */
.dashboard-body {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
    opacity: 1;
    padding-top: 10px;
}
#dashboard.dashboard-hidden .dashboard-body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
}

/* ── Ticker Tape ──────────────────────────────────────────────────────────── */
.ticker-tape-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-ticker-tape);
    border-top: 1px solid var(--color-border-ticker);
    border-bottom: 1px solid var(--color-border-ticker);
    overflow: hidden;
    flex-shrink: 0;
}

.ticker-tapes { display: flex; flex-direction: column; width: 100%; }

.ticker-tape-row {
    display: flex;
    align-items: center;
    height: 28px;
    width: 100%;
}
.ticker-tape-row + .ticker-tape-row { border-top: 1px solid var(--color-border-ticker-section); }

/* Control cluster overlays the top-right of the bar so it stays put regardless of tape count */
.ticker-controls {
    position: absolute;
    top: 0;
    right: 0;
    height: 28px;
    display: flex;
    align-items: center;
    background: var(--color-bg-ticker-tape);
    z-index: 3;
    box-shadow: -8px 0 8px -6px var(--color-bg-ticker-tape);
}

.ticker-tape-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.ticker-tape-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    height: 100%;
    will-change: transform;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 10px;
    font-size: var(--ticker-fs, 12px);
    font-weight: 500;
    white-space: nowrap;
}

.ticker-sym {
    color: var(--color-text-secondary);
    letter-spacing: 0.03em;
}

.ticker-pct {
    font-size: 0.9em;
    font-weight: 600;
}

.ticker-item.ticker-up .ticker-pct { color: var(--color-pnl-positive); }
.ticker-item.ticker-dn .ticker-pct { color: var(--color-pnl-negative); }
.ticker-item .ticker-pct           { color: var(--color-text-muted); } /* neutral / no data */

.ticker-section-label {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-faint);
    padding: 0 6px;
    border-right: 1px solid var(--color-border-ticker-section);
    margin-right: 4px;
    line-height: 1;
}

.ticker-sep {
    color: var(--color-border-strong);
    padding: 0 2px;
    font-size: 16px;
    line-height: 1;
}

.ticker-loading {
    font-size: 11px;
    color: var(--color-text-faint);
    padding: 0 12px;
}

.ticker-size-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    border-left: 1px solid var(--color-border-ticker);
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0 8px;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
    user-select: none;
}
.ticker-size-btn:hover {
    color: var(--color-accent);
    background: var(--color-accent-tint-subtle);
}

.ticker-edit-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    border-left: 1px solid var(--color-border-ticker);
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.ticker-edit-btn:hover {
    color: var(--color-accent);
    background: var(--color-accent-tint-subtle);
}

.ticker-logout-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    border-left: 1px solid var(--color-border-ticker);
    color: var(--color-text-faint);
    cursor: pointer;
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.ticker-logout-btn:hover {
    color: var(--color-status-danger);
    background: var(--color-status-danger-tint-soft);
}

/* ── Ticker Editor Window ─────────────────────────────────────────────────── */
.ticker-editor-win {
    position: fixed;
    z-index: 9100;
    display: flex;
    flex-direction: column;
    width: 520px;
    height: 460px;
    min-width: 340px;
    min-height: 280px;
    background: var(--color-bg-ticker-editor);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-overlay-strong);
    resize: both;
    overflow: hidden;
}

.ticker-editor-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--color-bg-ticker-tape);
    border-bottom: 1px solid var(--color-border-strong);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}
.ticker-editor-titlebar:active { cursor: grabbing; }

.ticker-editor-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.ticker-editor-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    line-height: 1;
}
.ticker-editor-close:hover { color: var(--color-status-danger); background: var(--color-status-danger-tint-soft); }

.ticker-editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 6px;
    min-height: 0;
    gap: 6px;
}

.ticker-editor-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 0;
    flex-shrink: 0;
}
.ticker-editor-hint code {
    color: var(--color-accent);
    background: var(--color-accent-tint-soft);
    padding: 0 3px;
    border-radius: var(--r-sm);
}

.ticker-editor-textarea {
    flex: 1;
    min-height: 0;
    background: var(--color-bg-ticker-textarea);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    padding: 8px 10px;
    resize: none;
    outline: none;
    line-height: 1.5;
}
.ticker-editor-textarea:focus { border-color: var(--color-border-focus); }

.ticker-editor-error {
    font-size: 11px;
    color: var(--color-status-danger);
    min-height: 16px;
    flex-shrink: 0;
}

.ticker-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--color-border-strong);
    flex-shrink: 0;
}

/* Structured ticker-tape maintenance editor */
.ticker-editor-win-wide { width: 660px; height: 560px; }

.ticker-editor-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
}

.tk-tape {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
    padding: 8px;
    background: var(--color-bg-ticker-textarea);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tk-tape-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-lbl { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--color-text-muted); }
.tk-tape-actions, .tk-entry-actions { display: inline-flex; gap: 2px; margin-left: auto; }

.tk-entries { display: flex; flex-direction: column; gap: 4px; }
.tk-entry { display: flex; align-items: center; gap: 6px; }
.tk-empty { font-size: 11px; color: var(--color-text-faint); padding: 2px 0; }

.tk-in {
    background: var(--color-bg-ticker-editor);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 3px 6px;
    outline: none;
}
.tk-in:focus { border-color: var(--color-border-focus); }
.tk-in-type { flex: 0 0 92px; }
.tk-in-num  { width: 52px; }
.tk-in-sm   { flex: 0 0 130px; }
.tk-tape-name { flex: 0 0 150px; font-weight: 600; }
.tk-entry .tk-in:not(.tk-in-type):not(.tk-in-sm) { flex: 1; min-width: 80px; }

.tk-mini {
    background: none;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    padding: 3px 5px;
}
.tk-mini:hover { color: var(--color-accent); border-color: var(--color-border-focus); }
.tk-mini.tk-del:hover { color: var(--color-status-danger); border-color: var(--color-status-danger); }

.tk-add {
    align-self: flex-start;
    background: none;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 4px 10px;
}
.tk-add:hover { color: var(--color-accent); border-color: var(--color-accent); }
.tk-add-tape { align-self: stretch; text-align: center; padding: 6px; }

/* Controls strip — always visible at the bottom */
.dashboard-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    padding: 2px 4px 3px;
}

.dashboard-ctrl-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 2px 7px 2px 5px;
    font-size: 11px;
    opacity: 0.35;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
    user-select: none;
    line-height: 1;
}
.dashboard-ctrl-btn:hover {
    opacity: 1;
    border-color: var(--color-border-strong);
    color: var(--color-text-secondary);
}
#dashboard.dashboard-pinned #dashboard-pin-btn {
    opacity: 1;
    color: var(--color-state-pin);
    border-color: var(--color-state-pin-border);
    background: var(--color-state-pin-bg);
}
#dashboard.dashboard-hidden #dashboard-hide-btn {
    opacity: 1;
    color: var(--color-state-hide);
    border-color: var(--color-state-hide-border);
    background: var(--color-state-hide-bg);
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* Responsive: stack cards on smaller screens */
@media (max-width: 600px) {
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 10px 16px;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--color-border-default);
}

.card-row:last-child {
    border-bottom: none;
}

.card-label {
    color: var(--color-text-muted);
    font-size: 13px;
}

.card-value {
    text-align: right;
    font-weight: 500;
    font-size: 14px;
}

.card-currency {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-left: 4px;
}

/* Daily Gain Card */
.card-daily-gain {
    border-left: 4px solid var(--color-state-neutral);
    transition: border-color 0.3s ease;
}

.card-daily-gain.gain-positive {
    border-left-color: var(--color-status-success);
}

.card-daily-gain.gain-negative {
    border-left-color: var(--color-status-danger);
}

.daily-gain-header {
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--color-border-default);
}

.card-header-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-tiny-label);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.daily-gain-primary .gain-value {
    font-size: 26px;
    font-weight: 700;
}

.daily-gain-primary .card-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Inline refresh icon next to Today's Gain (using span to avoid button styling) */
.btn-refresh-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh-inline:hover {
    background-color: var(--color-border-strong);
    color: var(--color-accent);
}

.btn-refresh-inline:active {
    background-color: var(--color-border-default);
}

.btn-refresh-inline svg {
    display: block;
}

.daily-gain-secondary .gain-value {
    font-size: 20px;
    font-weight: 600;
}

/* Stocks / Options / Futures breakdown under Today's Gain */
.daily-gain-breakdown { margin: -2px 0 2px; }
.daily-gain-breakdown .card-row.daily-gain-sub { padding-top: 1px; padding-bottom: 1px; }
.daily-gain-sub .card-label { font-size: 11px; color: var(--color-text-muted); padding-left: 12px; }
.daily-gain-sub .gain-value { font-size: 13px; font-weight: 600; }

.gain-value.positive {
    color: var(--color-status-success);
}

.gain-value.negative {
    color: var(--color-status-danger);
}

.daily-gain-meta {
    margin-top: 10px;
    padding-top: 6px;
}

.daily-gain-meta .card-label {
    font-size: 12px;
}

.daily-gain-meta .card-value {
    font-size: 12px;
    color: var(--color-text-muted);
}

.card-row-indent {
    padding-left: 16px;
    margin-top: -4px;
    padding-top: 4px;
    border-bottom: none;
}

.card-label-small {
    font-size: 11px;
}

.card-value-small {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* Time rows in first card */
.card-time-row {
    margin-top: 4px;
}

/* First time row (Current Time) - has separator line like Yesterday's Net Liq */
.card-time-row:first-of-type {
    border-top: 1px solid var(--color-border-default);
    margin-top: 10px;
    padding-top: 6px;
}

.card-time-row .card-label {
    font-size: 12px;
}

.card-time-row .card-value {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Accrued cash with projected value */
.accrued-cash-values {
    display: flex;
    gap: 8px;
    align-items: center;
}

.accrued-cash-projected {
    font-size: 11px;
    color: var(--color-accent);
    opacity: 0.8;
}

.accrued-cash-projected::before {
    content: "→ ";
    color: var(--color-text-muted);
}

.card-value.negative,
.card-value .negative {
    color: var(--color-pnl-negative);
}

.card-value.positive,
.card-value .positive {
    color: var(--color-pnl-positive);
}

.card-row-bold .card-label,
.card-row-bold .card-value {
    font-weight: 700;
}

.card-row-spacer {
    margin-top: 14px;
    padding-top: 8px;
}

/* Status Monitoring Badges */
.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    white-space: nowrap;
    vertical-align: middle;
}

.status-badge.phase {
    font-size: 10px;
    padding: 3px 8px;
}

.status-badge.deterioration {
    font-size: 9px;
    padding: 2px 6px;
    opacity: 0.9;
}

.status-badge.leverage {
    font-size: 9px;
}

.status-badge.cushion {
    font-size: 9px;
}

/* Portfolio section */
#portfolio {
    margin-top: 24px;
    margin-bottom: 16px;
}

#portfolio h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#portfolio .collapsible-content {
    padding-top: 12px;
}

#portfolio-container {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    overflow-x: auto;   /* scroll horizontally if table is wider than the grid cell */
}

.loading-text {
    padding: 16px;
    color: var(--color-text-muted);
    text-align: center;
}

.portfolio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.portfolio-table th,
.portfolio-table td {
    padding: 4px 10px;
    text-align: right;
    border-bottom: 1px solid var(--color-border-default);
}

.portfolio-table th {
    background-color: var(--color-portfolio-th-bg);
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 var(--color-portfolio-th-shadow);
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
    text-align: left;
}

/* Earnings column — second column, left-aligned */
.portfolio-table th:nth-child(2),
.portfolio-table td:nth-child(2) {
    text-align: left;
    white-space: nowrap;
}
.earnings-cell {
    min-width: 110px;
}

/* Earnings badge */
.earnings-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    border: 1px solid;
    white-space: nowrap;
    cursor: default;
    letter-spacing: 0.2px;
}
.earnings-far {
    color: var(--color-earnings-far);
    border-color: var(--color-earnings-far-border);
    background: transparent;
}
.earnings-near {
    color: var(--color-earnings-near);
    border-color: var(--color-earnings-near-border);
    background: var(--color-earnings-near-bg);
}
.earnings-soon {
    color: var(--color-earnings-soon);
    border-color: var(--color-earnings-soon-border);
    background: var(--color-earnings-soon-bg);
}
.earnings-today {
    color: var(--color-earnings-today);
    border-color: var(--color-earnings-today-border);
    background: var(--color-earnings-today-bg);
    font-weight: 700;
    animation: earnings-pulse 1.6s ease-in-out infinite;
}
@keyframes earnings-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

/* Left-align Symbol, Name, Industry columns in watchlist */
#watchlist-table th:nth-child(2),
#watchlist-table th:nth-child(3),
#watchlist-table th:nth-child(4),
#watchlist-table td:nth-child(2),
#watchlist-table td:nth-child(3),
#watchlist-table td:nth-child(4) {
    text-align: left !important;
}

.portfolio-table tbody tr:hover {
    background-color: var(--color-bg-row-hover-accent);
}

.portfolio-table .group-header {
    background-color: var(--color-bg-page);
    font-weight: 600;
    color: var(--color-accent);
}

.portfolio-table .group-header td {
    padding: 8px 10px;
    border-bottom: 2px solid var(--color-border-default);
}

.portfolio-table .subtotal-row {
    background-color: var(--color-bg-subtotal-row);
    font-weight: 500;
}

.portfolio-table .subtotal-row td {
    border-top: 1px solid var(--color-border-default);
    padding-top: 6px;
    padding-bottom: 6px;
}

.portfolio-table .total-row {
    background-color: var(--color-bg-total-row);
    font-weight: 600;
}

.portfolio-table .total-row td {
    border-top: 2px solid var(--color-accent);
    padding-top: 6px;
    padding-bottom: 6px;
}

.portfolio-table .positive {
    color: var(--color-pnl-positive);
}

.portfolio-table .negative {
    color: var(--color-pnl-negative);
}

/* Legacy standalone column - kept for any remaining references */
.portfolio-table .option-details {
    color: var(--color-text-muted);
    font-size: 11px;
}

/* Option symbol cell: spans Symbol + Earnings columns, shows contract details below */
.portfolio-table td.opt-symbol-cell {
    vertical-align: top;
    white-space: nowrap;
}
.opt-details-inline {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Position column — always right-aligned regardless of nth-child override */
.portfolio-table td.position-cell {
    text-align: right;
}

.portfolio-table .symbol-cell {
    font-weight: 500;
}

/* Option Greeks Row */
.portfolio-table .option-greeks-row {
    background-color: var(--color-portfolio-greeks-row-bg);
    border-bottom: 1px solid var(--color-border-default);
}

.portfolio-table .option-greeks-row:hover {
    background-color: var(--color-portfolio-greeks-row-bg-hover);
}

.portfolio-table .option-greeks-row td {
    padding: 6px 10px;
    border-bottom: none;
}

.portfolio-table .greeks-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    padding: 2px 0;
}

.portfolio-table .greeks-label {
    color: var(--color-text-muted);
    font-weight: 500;
}

.portfolio-table .greeks-value {
    color: var(--color-text-secondary);
    font-weight: 400;
}

.portfolio-table .greeks-value.positive {
    color: var(--color-pnl-positive);
    font-weight: 500;
}

.portfolio-table .greeks-value.negative {
    color: var(--color-pnl-negative);
    font-weight: 500;
}

.portfolio-table .greeks-separator {
    color: var(--color-border-default);
    margin: 0 4px;
}

.portfolio-table .actions-cell {
    text-align: center;
    white-space: nowrap;
}

/* ── Portfolio Section Headers (Stocks / Options separators) ──────────────── */
.portfolio-section {
    margin-bottom: 4px;
}

.portfolio-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background-color: var(--color-bg-section-header);
    border-top: 2px solid var(--color-border-default);
    border-bottom: 2px solid var(--color-border-default);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.portfolio-section-header:hover {
    background-color: var(--color-bg-section-header-hover);
}

.portfolio-section-header .collapse-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.portfolio-section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.portfolio-section-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-border-default);
    padding: 1px 6px;
    border-radius: var(--r-lg);
}

/* Scrollable wrapper for wide Options table */
.portfolio-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Options-specific table tweaks */
.portfolio-table-options th,
.portfolio-table-options td {
    padding: 4px 8px;
    white-space: nowrap;
}

/* Column group header row */
.portfolio-table-options tr.opt-thead-group th {
    background-color: var(--color-bg-options-group-header);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-bottom: none;
}

.portfolio-table-options .opt-col-group-market {
    color: var(--color-status-info);
    border-left: 2px solid var(--color-border-strong);
    border-right: 2px solid var(--color-border-strong);
    text-align: center;
}

.portfolio-table-options .opt-col-group-position {
    color: var(--color-accent);
    border-left: 2px solid var(--color-border-position-group);
    border-right: 2px solid var(--color-border-position-group);
    text-align: center;
}

/* Highlight market-data and position-greek column bands */
.portfolio-table-options td:nth-child(n+8):nth-child(-n+19) {
    background-color: var(--color-bg-table-band-market);
}
.portfolio-table-options td:nth-child(n+20):nth-child(-n+22) {
    background-color: var(--color-bg-table-band-position);
}

/* Type cell (LONG CALL / SHORT PUT etc.) */
.portfolio-table .opt-type-cell {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    text-align: left;
}

.portfolio-table .opt-long  { color: var(--color-pnl-positive); }
.portfolio-table .opt-short { color: var(--color-pnl-negative); }

/* Greeks / market data columns */
.portfolio-table .greeks-col {
    color: var(--color-text-secondary);
    font-size: 12px;
    text-align: right;
}

/* ITM / OTM badges */
.opt-itm-cell { text-align: center !important; }

.opt-itm-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    font-size: 10px;
    font-weight: 700;
    background-color: var(--color-bg-itm-badge);
    color: var(--color-itm);
    border: 1px solid var(--color-border-itm-badge);
    letter-spacing: 0.04em;
}

.opt-otm-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    font-size: 10px;
    font-weight: 700;
    background-color: var(--color-bg-otm-badge);
    color: var(--color-otm);
    border: 1px solid var(--color-border-otm-badge);
    letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════════════════════════════════
   OPTION CARDS
   Cards are grouped by trade type: Short Put | Long Put | Short Call | Long Call
   Each card has 4 tabs: Overview | P&L | Greeks | Market
   Alert state is driven by classes: .alert-warn .alert-caution .alert-critical
   ══════════════════════════════════════════════════════════════════════════════ */

.opt-cards-wrapper {
    padding: 10px 0 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Trade-type group ───────────────────────────────────────── */
.opt-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 6px;
    border-bottom: 1px solid var(--color-border-default);
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.opt-group-header:hover { opacity: 0.85; }

.opt-group-header .collapse-icon {
    color: var(--color-text-faint);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.opt-group-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.opt-group-header.collapsed { margin-bottom: 0; border-bottom-color: var(--color-border-opt-group-collapsed); }

.opt-group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 2px 8px;
    border-radius: var(--r-sm);
}

.opt-group-label.short-put  { color: var(--color-pnl-negative); background: var(--color-trade-short-put-bg); border: 1px solid var(--color-trade-short-put-border); }
.opt-group-label.long-put   { color: var(--palette-blue-400); background: var(--color-trade-long-put-bg); border: 1px solid var(--color-trade-long-put-border); }
.opt-group-label.short-call { color: var(--color-status-caution); background: var(--color-trade-short-call-bg); border: 1px solid var(--color-trade-short-call-border); }
.opt-group-label.long-call  { color: var(--color-pnl-positive); background: var(--color-trade-long-call-bg); border: 1px solid var(--color-trade-long-call-border); }

.opt-group-count {
    font-size: 11px;
    color: var(--color-text-muted);
    background: var(--color-border-default);
    padding: 1px 6px;
    border-radius: var(--r-lg);
}

.opt-group-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ── Individual card ────────────────────────────────────────── */
.opt-card {
    --card-accent: var(--color-border-default);   /* overridden by alert classes */
    width: 340px;
    flex-shrink: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-top: 3px solid var(--card-accent);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s, box-shadow 0.3s;
    position: relative;
}

.opt-card:hover {
    box-shadow: var(--shadow-card-hover);
}

/* Alert states — apply these classes via JS to change card accent */
.opt-card.alert-warn     { --card-accent: var(--color-status-warning); box-shadow: var(--shadow-glow-warn);  }
.opt-card.alert-caution  { --card-accent: var(--color-status-caution); box-shadow: var(--shadow-glow-caution);  }
.opt-card.alert-critical {
    --card-accent: var(--color-status-danger);
    box-shadow: var(--shadow-glow-danger);
    animation: opt-card-pulse 2s ease-in-out infinite;
}
.opt-card.alert-good     { --card-accent: var(--color-status-success); }

@keyframes opt-card-pulse {
    0%, 100% { box-shadow: var(--shadow-glow-danger); }
    50%       { box-shadow: var(--shadow-glow-danger-strong); }
}

/* ── Card header (always visible) ──────────────────────────── */
.opt-card-header {
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--color-border-default);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.opt-card-title-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.opt-card-symbol {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;
}

.opt-card-badges {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
}

.opt-card-alert-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-opt-card-alert-dot);
    border: 1px solid var(--color-opt-card-alert-dot-border);
    flex-shrink: 0;
    /* JS sets background/border to indicate alert level */
}

.opt-card-alert-btn {
    background: transparent;
    border: none;
    font-size: 12px;
    line-height: 1;
    padding: 1px 3px;
    border-radius: var(--r-sm);
    cursor: pointer;
    opacity: 0.55;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}
.opt-card-alert-btn:hover { opacity: 1; transform: scale(1.15); }

.opt-card-order-btn {
    margin-left: auto;
    background: var(--color-opt-card-order-btn-bg);
    border: 1px solid var(--color-opt-card-order-btn-border);
    color: var(--color-accent);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--r-sm);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}
.opt-card-order-btn:hover {
    background: var(--color-opt-card-order-btn-bg-hover);
}
.opt-card.alert-warn     .opt-card-alert-dot { background: var(--color-status-warning); border-color: var(--color-status-warning); }
.opt-card.alert-caution  .opt-card-alert-dot { background: var(--color-status-caution); border-color: var(--color-status-caution); }
.opt-card.alert-critical .opt-card-alert-dot {
    background: var(--color-status-danger); border-color: var(--color-status-danger);
    animation: dot-blink 1s step-start infinite;
}
.opt-card.alert-good .opt-card-alert-dot { background: var(--color-status-success); border-color: var(--color-status-success); }

@keyframes dot-blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

.opt-card-contract-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.opt-card-expiry { color: var(--color-text-muted); }
.opt-card-strike { color: var(--color-text-secondary); font-weight: 500; }
.opt-card-right  { font-weight: 700; font-size: 11px; }
.opt-card-right.opt-long  { color: var(--color-pnl-positive); }
.opt-card-right.opt-short { color: var(--color-pnl-negative); }
.opt-card-qty    { color: var(--color-text-muted); font-size: 11px; margin-left: auto; }

.opt-card-snapshot-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    margin-top: 1px;
}

.opt-card-price { color: var(--color-text-secondary); font-weight: 600; }
.opt-card-chg   { font-size: 11px; }
.opt-card-pnl {
    font-size: 11px;
    font-weight: 700;
    margin-left: auto;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    border: 1px solid;
    /* default (zero / unknown) */
    color: var(--color-text-muted);
    border-color: var(--color-opt-card-pnl-zero-border);
    background: var(--color-opt-card-pnl-zero-bg);
}
.opt-card-pnl.positive {
    color: var(--color-pnl-positive);
    border-color: var(--color-opt-card-pnl-pos-border);
    background: var(--color-opt-card-pnl-pos-bg);
}
.opt-card-pnl.negative {
    color: var(--color-pnl-negative);
    border-color: var(--color-opt-card-pnl-neg-border);
    background: var(--color-opt-card-pnl-neg-bg);
}
.opt-card-dte   { font-size: 10px; color: var(--color-text-muted); background: var(--color-border-default); padding: 1px 5px; border-radius: var(--r-sm); }

/* ── Tab navigation ─────────────────────────────────────────── */
.opt-card-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-opt-card-tabs);
}

.opt-tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 5px 1px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.opt-tab-btn:hover   { color: var(--color-text-secondary); }
.opt-tab-btn.active  { color: var(--color-accent); border-bottom-color: var(--card-accent, var(--color-accent)); }

/* ── Tab body ───────────────────────────────────────────────── */
.opt-card-body {
    display: none;
    flex-direction: column;
    padding: 6px 10px 8px;
    gap: 2px;
    flex: 1;
}

.opt-card-body.active { display: flex; }

/* Data rows inside tab body */
.ocd-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    min-height: 18px;
}

.ocd-label {
    font-size: 10px;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.ocd-value {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.ocd-value.positive { color: var(--color-pnl-positive); }
.ocd-value.negative { color: var(--color-pnl-negative); }

/* Section sub-label within a tab (e.g. "Raw" vs "Position") */
.ocd-section-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-faint);
    margin-top: 4px;
    margin-bottom: 1px;
    border-top: 1px solid var(--color-border-default);
    padding-top: 4px;
}
.ocd-section-label:first-child { margin-top: 0; border-top: none; padding-top: 0; }

/* ── Option-card Alerts tab ─────────────────────────────────── */
.opt-alerts-panel { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.opt-alerts-props { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.opt-alerts-rules { display: flex; flex-direction: column; gap: 6px; }
.opt-alerts-list { display: flex; flex-direction: column; gap: 5px; }
.opt-alerts-hint { font-size: 11px; color: var(--color-text-faint); padding: 4px 0; }
.opt-alerts-err { color: var(--color-negative, #e05a5a); }
.opt-alerts-ok  { color: var(--color-positive, #4caf78); }
.opt-alert-row {
    display: grid;
    grid-template-columns: auto minmax(0, 2fr) minmax(0, 1.4fr) auto auto auto;
    align-items: center;
    gap: 5px;
    padding: 4px;
    background: var(--color-bg-opt-card-tabs, rgba(255,255,255,0.03));
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
}
.opt-alert-en { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--color-text-faint); white-space: nowrap; }
.opt-alert-expr {
    resize: vertical; min-height: 22px; font-family: var(--font-mono, monospace);
    font-size: 11px; padding: 3px 5px; border-radius: var(--r-sm);
    border: 1px solid var(--color-border-default); background: var(--color-bg-input, transparent);
    color: var(--color-text-primary); width: 100%;
}
.opt-alert-comment {
    font-size: 11px; padding: 3px 5px; border-radius: var(--r-sm);
    border: 1px solid var(--color-border-default); background: var(--color-bg-input, transparent);
    color: var(--color-text-primary); width: 100%;
}
.opt-alert-tg { display: flex; align-items: center; gap: 2px; font-size: 10px; color: var(--color-text-faint); white-space: nowrap; }
.opt-alert-cd { width: 44px; font-size: 11px; padding: 3px; border-radius: var(--r-sm); border: 1px solid var(--color-border-default); background: var(--color-bg-input, transparent); color: var(--color-text-primary); }
.opt-alert-del { border: none; background: transparent; color: var(--color-negative, #e05a5a); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.opt-alert-del:hover { background: var(--color-bg-hover, rgba(255,255,255,0.06)); border-radius: var(--r-sm); }
.opt-alerts-tokens { display: flex; flex-wrap: wrap; gap: 3px; }
.opt-alert-tok {
    font-family: var(--font-mono, monospace); font-size: 10px; padding: 2px 5px;
    border: 1px solid var(--color-border-default); border-radius: var(--r-sm);
    background: transparent; color: var(--color-text-secondary); cursor: pointer;
}
.opt-alert-tok:hover { background: var(--color-bg-hover, rgba(255,255,255,0.06)); color: var(--color-text-primary); }
.opt-alerts-actions { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.opt-alerts-add, .opt-alerts-save {
    font-size: 11px; padding: 4px 10px; border-radius: var(--r-sm); cursor: pointer;
    border: 1px solid var(--color-border-default); background: var(--color-bg-input, transparent);
    color: var(--color-text-primary);
}
.opt-alerts-save { border-color: var(--color-accent, #4a90d9); color: var(--color-accent, #4a90d9); }
.opt-alerts-add:hover, .opt-alerts-save:hover { background: var(--color-bg-hover, rgba(255,255,255,0.06)); }
.opt-alerts-status { font-size: 11px; }

/* Card Alerts tab — read-only summary + Manage button (editing is in the window) */
.opt-alerts-summary { display: flex; flex-direction: column; gap: 3px; }
.opt-alert-sum { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.opt-alert-sum.off { opacity: 0.5; }
.opt-alert-sum-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-positive, #4caf78); flex-shrink: 0; }
.opt-alert-sum.off .opt-alert-sum-dot { background: var(--color-text-faint); }
.opt-alert-sum-expr { font-family: var(--font-mono, monospace); font-size: 11px; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.opt-alert-sum-tg { font-size: 9px; padding: 0 4px; border: 1px solid var(--color-accent, #4a90d9); border-radius: var(--r-sm); color: var(--color-accent, #4a90d9); flex-shrink: 0; }
.opt-alerts-manage {
    font-size: 11px; padding: 4px 10px; border-radius: var(--r-sm); cursor: pointer; margin-top: 4px;
    border: 1px solid var(--color-accent, #4a90d9); background: transparent; color: var(--color-accent, #4a90d9);
}
.opt-alerts-manage:hover { background: var(--color-bg-hover, rgba(255,255,255,0.06)); }

/* Floating option-alert editor window (inherits .note-window chrome) */
.opt-alert-window { min-width: 480px; min-height: 260px; width: 620px; height: 480px; }
.opt-alert-titlebar { justify-content: space-between; }
.opt-alert-win-title { font-size: 12px; font-weight: 600; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-alert-win-body { flex: 1; overflow-y: auto; padding: 8px 10px; }
.opt-alert-editor-list { display: flex; flex-direction: column; gap: 6px; }
.opt-alert-win-footer {
    flex-shrink: 0; display: flex; flex-direction: column; gap: 6px;
    padding: 8px 10px; border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-titlebar-base, transparent);
}

/* ── Options summary bar ────────────────────────────────────── */
.opt-summary-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 7px 12px;
    background: var(--color-bg-opt-card-tabs);
    border-top: 1px solid var(--color-border-default);
    font-size: 12px;
    margin-top: 4px;
}

.opt-summary-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
}

.opt-summary-sep  { color: var(--color-border-strong); font-size: 14px; }

.opt-summary-item { color: var(--color-text-muted); font-size: 11px; }
.opt-summary-breakdown { display: inline-flex; align-items: center; gap: 10px; margin-left: 4px; }

/* Stocks table: options-only underlyings block + two-step totals */
.portfolio-table tr.stk-optonly-head td { padding-top: 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); border-bottom: 1px dashed var(--color-border-default); }
.portfolio-table tr.stk-optonly-head .stk-optonly-sub { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 6px; }
.portfolio-table tr.stk-optonly-row td { color: var(--color-text-muted); }
.portfolio-table tr.stk-optonly-row td.positive { color: var(--color-status-success); }
.portfolio-table tr.stk-optonly-row td.negative { color: var(--color-status-danger); }
.portfolio-table tr.stk-optonly-total td { font-weight: 500; }
.portfolio-table tr.stk-net-total td { font-weight: 700; }
.opt-summary-breakdown .opt-group-label { font-size: 9px; padding: 1px 5px; }
.opt-summary-item span { font-weight: 600; }

/* Grand total bar at the bottom */
.portfolio-grand-total {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    background-color: var(--color-border-default);
    border-top: 2px solid var(--color-accent);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.portfolio-grand-total-label {
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
}

.portfolio-grand-total-sep {
    color: var(--color-border-default);
    font-size: 14px;
    padding: 0 2px;
}

.portfolio-grand-total-item {
    font-weight: 500;
    color: var(--color-text-muted);
    font-size: 12px;
}

.portfolio-grand-total-item span {
    font-weight: 600;
}

/* Watchlist name cell */
.portfolio-table td.name-cell {
    color: var(--color-text-muted);
    font-size: 12px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left !important;
}

/* Watchlist industry cell */
.portfolio-table td.industry-cell {
    color: var(--color-text-muted);
    font-size: 11px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left !important;
}

/* Right-align actions in watchlist */
#watchlist-table .actions-cell {
    text-align: right;
    white-space: nowrap;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 6px;
    margin: 0 2px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background-color: var(--color-border-default);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.action-btn svg {
    display: block;
}

/* Symbol cell content in watchlist */
.symbol-cell-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.alert-status-icon {
    cursor: pointer;
    padding: 2px;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.alert-status-icon.alert-active {
    color: var(--color-accent);
}

.alert-status-icon.alert-active:hover {
    color: var(--color-status-danger);
    background-color: var(--color-status-danger-tint-soft);
}

.alert-status-icon.alert-disabled {
    color: var(--color-text-disabled);
    opacity: 0.6;
}

.alert-status-icon.alert-disabled:hover {
    color: var(--color-status-success);
    opacity: 1;
    background-color: var(--color-status-success-tint-soft);
}

/* Updated indicator for calculated values */
#calculated-leverage.updated {
    color: var(--color-accent);
    transition: color 0.2s ease;
}

/* Watchlist section */
#watchlist {
    margin-top: 24px;
    margin-bottom: 16px;
}

#watchlist h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#watchlist .collapsible-content {
    padding-top: 12px;
}

#watchlist-container {
    /* Background/border now provided by individual .wl-list-card elements */
    max-width: 100%;
}

#watchlist-table {
    max-width: 100%;
    table-layout: auto;
}

/* Limit name column width in watchlist list cards */
.wl-list-table td.name-cell {
    max-width: 50px;
    width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Watchlist Alerts section */
#watchlist-alerts {
    margin-top: 24px;
    margin-bottom: 16px;
}

#watchlist-alerts h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#watchlist-alerts .collapsible-content {
    padding-top: 12px;
}

/* Minute Charts section */
#minute-charts {
    margin-top: 24px;
    margin-bottom: 16px;
}

#minute-charts h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#minute-charts .collapsible-content {
    padding-top: 12px;
}

#minute-charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

@media (max-width: 600px) {
    #minute-charts-container {
        grid-template-columns: 1fr;
    }
}

.minute-chart-card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.minute-chart-header {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
    background-color: var(--color-border-default);
    border-bottom: 1px solid var(--color-border-strong);
    flex-wrap: wrap;
}

.minute-chart-control-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.minute-chart-control-label {
    font-size: 8px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 500;
    white-space: nowrap;
}

.minute-chart-symbol-input {
    width: 70px;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-accent);
}

.minute-chart-symbol-input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.minute-chart-interval-select,
.minute-chart-days-input {
    padding: 4px 6px;
    font-size: 11px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
}

.minute-chart-interval-select:focus,
.minute-chart-days-input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.minute-chart-interval-select {
    min-width: 50px;
}

.minute-chart-days-input {
    width: 50px;
}

/* Minute chart uses .indicator-dropdown class (same as watchlist) */

.minute-chart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.minute-chart-order-btn,
.minute-chart-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background-color: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.minute-chart-order-btn:hover {
    background-color: var(--color-border-strong);
    color: var(--color-accent);
}

.minute-chart-close-btn:hover {
    background-color: var(--color-status-danger-tint-strong);
    color: var(--color-status-danger);
}

.minute-chart-order-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.minute-chart-body {
    padding: 12px;
}

.minute-chart-canvas-container {
    position: relative;
    height: 250px;
}

.minute-chart-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.minute-chart-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.minute-chart-status .last-update {
    margin-left: auto;
}

.minute-chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 250px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.minute-chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 250px;
    color: var(--color-status-danger);
    font-size: 14px;
}

/* Active alerts */
.active-alerts-container {
    background-color: var(--color-bg-alert-banner);
    border: 1px solid var(--color-border-alert-banner);
    border-radius: var(--r-lg);
    margin-top: 16px;
    margin-bottom: 16px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.active-alerts-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background-color: var(--color-bg-alert-banner-header);
    color: var(--color-status-danger);
    font-weight: 600;
    font-size: 13px;
    user-select: none;
}

.active-alerts-header:hover {
    background-color: var(--color-bg-alert-banner-header-hover);
}

.active-alerts-header svg {
    color: var(--color-status-danger);
}

/* ── Risk Gates panel ─────────────────────────────────────────────────── */
.rg-section {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    margin-bottom: 6px;
    overflow: hidden;
}

.rg-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: var(--color-bg-rg-section-header);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
}

.rg-section-header:hover { background: var(--color-bg-rg-section-header-hover); }

.rg-chevron { flex-shrink: 0; transition: transform 0.15s; }
.rg-chevron-collapsed { transform: rotate(-90deg); }

.rg-section-title { font-weight: 600; color: var(--palette-gh-text-300); flex-shrink: 0; }

.rg-cur-val {
    font-size: 11px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.rg-active-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--r-lg);
    flex-shrink: 0;
}

.rg-pill-none { background: var(--color-border-strong); color: var(--color-text-muted); }

.rg-section-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rg-add-btn {
    padding: 2px 8px;
    font-size: 11px;
    background: var(--color-bg-rg-add-btn);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-accent);
    cursor: pointer;
    flex-shrink: 0;
}
.rg-add-btn:hover { background: var(--color-bg-rg-add-btn-hover); }

.rg-export-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-accent-tint-soft);
}

.rg-export-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg-rg-add-btn);
    color: var(--color-accent);
    cursor: pointer;
    white-space: nowrap;
}

.rg-export-btn:hover {
    background: var(--color-bg-rg-add-btn-hover);
}

.rg-json-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.rg-json-textarea {
    width: 100%;
    min-height: 220px;
    max-height: 480px;
    resize: vertical;
    box-sizing: border-box;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.35;
    padding: 10px;
    background: var(--color-bg-rg-section-body);
    color: var(--palette-gh-text-300);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    margin-bottom: 12px;
}

.rg-json-textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.rg-preview-wrap {
    background: var(--color-bg-rg-section-header);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    padding: 8px 10px;
}

.rg-preview-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.rg-preview-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-rg-section-divider);
    font-size: 12px;
}

.rg-preview-row:last-child {
    border-bottom: none;
}

.rg-eval-hint {
    font-size: 10px;
    color: var(--color-text-dim);
    font-family: ui-monospace, monospace;
}

.rg-section-body { background: var(--color-bg-rg-section-body); }

.rg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.rg-table thead th {
    padding: 4px 8px;
    color: var(--color-text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--color-border-strong);
    text-align: left;
    background: var(--color-bg-rg-section-header);
}

.rg-row td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border-rg-row);
    vertical-align: middle;
    color: var(--palette-gh-text-300);
}

.rg-row:last-child td { border-bottom: none; }
.rg-edit-row td { padding: 5px 6px; background: var(--color-bg-rg-add-btn); }

.rg-min    { font-family: monospace; font-size: 11px; width: 90px; }
.rg-label  { max-width: 160px; }
.rg-color  { width: 36px; text-align: center; }
.rg-swatch { display: inline-block; width: 16px; height: 16px; border-radius: var(--r-sm); vertical-align: middle; border: 1px solid var(--color-overlay-divider); }
.rg-tooltip-cell { color: var(--color-text-muted); font-size: 10px; max-width: 200px; }
.rg-actions { white-space: nowrap; width: 56px; }

.rg-btn {
    padding: 2px 5px;
    font-size: 11px;
    cursor: pointer;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    background: transparent;
    margin-left: 2px;
}
.rg-btn-edit   { color: var(--color-accent); border-color: var(--color-border-strong); }
.rg-btn-del    { color: var(--color-status-danger); border-color: var(--color-border-strong); }
.rg-btn-save   { color: var(--color-accent); border-color: var(--color-border-strong); }
.rg-btn-cancel { color: var(--color-text-muted); border-color: var(--color-border-strong); }
.rg-btn:hover  { background: var(--color-border-strong); }

.rg-input {
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-size: 11px;
    padding: 3px 5px;
    width: 100%;
    box-sizing: border-box;
}
.rg-input:focus { outline: none; border-color: var(--color-border-focus); }
.rg-wide  { min-width: 130px; }
.rg-color-pick { width: 36px; padding: 2px; height: 24px; cursor: pointer; }

.rg-badge { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: var(--r-lg); }

/* ── About Updates settings panel ─────────────────────────────────────── */
.about-settings-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 12px;
    align-items: center;
    font-size: 12px;
}
.about-setting-label {
    color: var(--color-text-muted);
    font-weight: 600;
    white-space: nowrap;
}
.about-setting-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.about-num-input {
    width: 80px;
    padding: 3px 6px;
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-size: 12px;
    font-family: monospace;
}
.about-num-input:focus { outline: none; border-color: var(--color-border-focus); }
.about-model-select {
    flex: 1;
    min-width: 180px;
    max-width: 320px;
    padding: 3px 6px;
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-size: 12px;
}
.about-model-select:focus { outline: none; border-color: var(--color-border-focus); }
.about-setting-unit {
    color: var(--color-text-muted);
    font-size: 11px;
    white-space: nowrap;
}
.about-setting-label-top {
    align-self: flex-start;
    padding-top: 4px;
}
.about-setting-control-full {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.about-prompt-ta {
    width: 100%;
    padding: 6px 8px;
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-family: monospace;
    font-size: 11px;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}
.about-prompt-ta:focus { outline: none; border-color: var(--color-border-focus); }
.about-prompt-ta code {
    background: var(--color-bg-rg-add-btn);
    padding: 1px 4px;
    border-radius: var(--r-sm);
    font-size: 10px;
}

/* ── AI Settings — MCP servers ─────────────────────────────────────────── */
.mcp-toolbar {
    margin-bottom: 10px;
}
.mcp-table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
}
.mcp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.mcp-table thead th {
    text-align: left;
    padding: 6px 10px;
    background: var(--color-bg-rg-section-header);
    color: var(--color-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--color-border-strong);
}
.mcp-table tbody td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border-rg-row);
    color: var(--palette-gh-text-300);
    vertical-align: middle;
}
.mcp-table tbody tr:last-child td { border-bottom: none; }
.mcp-td-url {
    font-family: monospace;
    font-size: 11px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mcp-td-en { text-align: center; width: 72px; }
.mcp-td-act { white-space: nowrap; width: 120px; }
.mcp-td-notes { font-size: 11px; color: var(--color-text-muted); max-width: 160px; }
.mcp-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 16px !important;
}
.mcp-form-card {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    background: var(--color-bg-rg-section-body);
    max-width: 520px;
}
.mcp-form-title {
    font-weight: 600;
    color: var(--color-accent);
    margin-bottom: 10px;
    font-size: 13px;
}
.mcp-form-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px 12px;
    align-items: center;
    font-size: 12px;
}
.mcp-name-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.mcp-prompt-hint {
    margin: 0;
    font-size: 10px;
    line-height: 1.45;
    color: var(--color-text-muted);
}
.mcp-prompt-hint code {
    font-size: 10px;
    background: var(--color-bg-rg-add-btn);
    padding: 1px 5px;
    border-radius: var(--r-sm);
    color: var(--color-accent);
}
.mcp-form-label-top { align-self: start; padding-top: 4px; }
.mcp-form-input {
    width: 100%;
    padding: 4px 8px;
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-size: 12px;
    box-sizing: border-box;
}
.mcp-form-input:focus { outline: none; border-color: var(--color-border-focus); }
.mcp-form-ta {
    width: 100%;
    padding: 6px 8px;
    background: var(--color-bg-rg-section-body);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-size: 12px;
    resize: vertical;
    min-height: 48px;
    box-sizing: border-box;
    font-family: monospace;
}
.mcp-form-ta:focus { outline: none; border-color: var(--color-border-focus); }
.mcp-form-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--palette-gh-text-300);
}
.mcp-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.alert-count {
    background-color: var(--palette-red-500);
    color: var(--palette-white);
    padding: 2px 8px;
    border-radius: var(--r-lg);
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

.active-alerts-list {
    padding: 8px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background-color: var(--color-bg-card);
    border-radius: var(--r-md);
    margin-bottom: 6px;
    border-left: 4px solid var(--alert-color, var(--color-accent));
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.alert-item:last-child {
    margin-bottom: 0;
}

.alert-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.alert-top-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.alert-symbol {
    font-weight: 600;
    color: var(--color-accent);
    min-width: 60px;
    flex-shrink: 0;
}

.alert-list-name {
    font-size: 10px;
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 2px 6px;
    background-color: var(--color-border-strong);
    border-radius: var(--r-sm);
    margin: 0 8px;
    flex-shrink: 0;
}

.alert-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-style: normal;
    padding: 2px 6px;
    background-color: var(--color-accent-tint-soft);
    white-space: pre-wrap;
    border-radius: var(--r-sm);
    margin-right: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.alert-condition {
    display: block;
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
}

.alert-comment {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.alert-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 90px;
}

.alert-datetime {
    color: var(--color-text-muted);
    font-size: 11px;
    white-space: nowrap;
    text-align: right;
}

.alert-actions {
    display: flex;
    gap: 6px;
}

.alert-btn {
    background: transparent;
    border: 1px solid var(--color-text-disabled);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    font-size: 10px;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.alert-btn:hover {
    color: var(--palette-white);
}

.alert-btn-keep {
    border-color: var(--color-status-success);
    color: var(--color-status-success);
}

.alert-btn-keep:hover {
    background-color: var(--color-status-success);
    border-color: var(--color-status-success);
    color: var(--color-bg-page);
}

.alert-btn-stop {
    border-color: var(--color-status-danger);
    color: var(--color-status-danger);
}

.alert-btn-stop:hover {
    background-color: var(--color-status-danger);
    border-color: var(--color-status-danger);
    color: var(--palette-white);
}

/* Hashtable Browser section */
#hashtable-browser {
    margin-top: 24px;
    margin-bottom: 16px;
}

#hashtable-browser h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#hashtable-browser .collapsible-content {
    padding-top: 12px;
}

/* Configuration section */
#configuration {
    margin-top: 24px;
    margin-bottom: 16px;
}

#configuration h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#configuration .collapsible-content {
    padding-top: 12px;
}

/* Configuration tabs */
.config-tabs {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.config-tab-buttons {
    display: flex;
    background-color: var(--color-border-default);
    border-bottom: 1px solid var(--color-border-default);
}

.config-tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.config-tab-btn:hover {
    color: var(--palette-gh-text-300);
    background-color: var(--color-accent-tint-subtle);
}

.config-tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    background-color: var(--color-bg-card);
}

.config-tab-content {
    padding: 20px;
}

.config-tab-panel {
    display: none;
}

.config-tab-panel.active {
    display: block;
}

/* ── API Control Panel ──────────────────────────────────────────────────── */
.acp-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border-default);
    flex-wrap: wrap;
}

.acp-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-secondary);
    letter-spacing: 0.04em;
    flex: 1;
}

.acp-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.acp-timestamp {
    font-size: 11px;
    color: var(--color-text-faint);
    font-style: italic;
}

.acp-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg-acp-card);
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.acp-btn:hover    { border-color: var(--color-border-focus); color: var(--color-text-secondary); }
.acp-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.acp-btn-refresh { border-color: var(--color-border-strong); }
.acp-btn-refresh:hover { border-color: var(--color-border-focus); color: var(--color-accent); }

.acp-btn-danger { border-color: var(--color-border-acp-danger-idle); color: var(--color-text-acp-danger-idle); }
.acp-btn-danger:hover { border-color: var(--color-status-danger); color: var(--color-status-danger); }

.acp-btn-primary { background: var(--color-accent-tint-soft); border-color: var(--color-accent-tint-medium); color: var(--color-accent); }
.acp-btn-primary:hover { background: var(--color-accent-tint-medium); }

.acp-btn-on  { background: var(--color-bg-badge-on); border-color: var(--color-border-badge-on); color: var(--palette-green-500); }
.acp-btn-on:hover  { background: var(--color-bg-badge-on-strong); }

.acp-btn-off { background: var(--color-bg-badge-off); border-color: var(--color-border-badge-off); color: var(--color-status-danger); }
.acp-btn-off:hover { background: var(--color-bg-badge-off-strong); }

.acp-loading, .acp-error {
    text-align: center;
    padding: 24px 16px;
    font-size: 13px;
    color: var(--color-text-faint);
    border: 1px dashed var(--color-border-default);
    border-radius: var(--r-md);
}
.acp-error { color: var(--color-status-danger); border-color: var(--color-border-badge-off); }

.acp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.acp-card {
    background: var(--color-bg-acp-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 14px 16px;
}

.acp-card-wide {
    grid-column: span 2;
}

.acp-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: 10px;
}

.acp-help {
    font-size: 11px;
    color: var(--color-text-faint);
    margin-bottom: 10px;
    line-height: 1.5;
}

.acp-state-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.acp-state-label {
    font-size: 11px;
    color: var(--color-text-muted);
    min-width: 110px;
}

.acp-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: var(--r-sm);
}

.acp-badge-level    { background: var(--color-bg-badge-level); color: var(--color-status-info-alt); border: 1px solid var(--color-border-badge-level); }
.acp-badge-on       { background: var(--color-bg-badge-on);    color: var(--palette-green-500);    border: 1px solid var(--color-border-badge-on); }
.acp-badge-off      { background: var(--color-bg-badge-off);   color: var(--color-status-danger);  border: 1px solid var(--color-border-badge-off); }
.acp-badge-unknown  { background: var(--color-bg-badge-unknown); color: var(--color-text-badge-unknown); border: 1px solid var(--color-border-badge-unknown); }

.acp-tag-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.acp-tag-badge {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: var(--r-sm);
    background: var(--color-accent-tint-soft);
    color: var(--color-accent);
    border: 1px solid var(--color-accent-tint-medium);
}

.acp-muted { font-size: 11px; color: var(--color-text-faint); font-style: italic; }

.acp-row-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.acp-select {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 5px 8px;
    outline: none;
    cursor: pointer;
}
.acp-select:focus { border-color: var(--color-border-focus); }

.acp-tag-input {
    flex: 1;
    min-width: 200px;
    background: var(--color-bg-acp-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.2s;
}
.acp-tag-input:focus { border-color: var(--color-border-focus); }

.acp-orders-status {
    margin-top: 10px;
    font-size: 11px;
    color: var(--color-text-faint);
}

.acp-audit {
    margin-top: 6px;
    font-size: 10px;
    color: var(--color-text-very-faint);
    font-style: italic;
}

/* ── Timeout / number-field grid ── */
.acp-to-grid {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.acp-to-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.acp-to-label {
    flex: 1;
    font-size: 11px;
    color: var(--color-text-muted);
    min-width: 160px;
}

.acp-to-input {
    width: 80px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 4px 7px;
    outline: none;
    text-align: right;
    transition: border-color 0.2s;
    /* hide browser spin arrows */
    -moz-appearance: textfield;
}
.acp-to-input::-webkit-outer-spin-button,
.acp-to-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.acp-to-input:focus { border-color: var(--color-border-focus); }

.acp-to-unit {
    font-size: 10px;
    color: var(--color-text-faint);
    min-width: 52px;
}

/* ── API Usage Panel ────────────────────────────────────────────────────── */
.au-autorefresh {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}
.au-autorefresh input { cursor: pointer; margin: 0; }

.au-empty, .au-error {
    text-align: center;
    padding: 24px 16px;
    font-size: 13px;
    color: var(--color-text-faint);
    border: 1px dashed var(--color-border-default);
    border-radius: var(--r-md);
}
.au-error { color: var(--color-status-danger); border-color: var(--color-border-badge-off); }

.au-warning {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: var(--r-md);
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-status-danger);
    background: var(--color-bg-badge-off);
    border: 1px solid var(--color-border-badge-off);
}

.au-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.au-table th,
.au-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border-default);
    text-align: left;
}
.au-table thead th {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}
.au-table thead .au-subhead th {
    font-size: 10px;
    color: var(--color-text-faint);
    border-bottom: 1px solid var(--color-border-strong);
}
.au-table th.au-num,
.au-table td.au-num { text-align: right; font-variant-numeric: tabular-nums; }
.au-table td.au-cat { color: var(--color-text-secondary); }
.au-table td.au-ndc, .au-table th.au-ndc { color: var(--color-text-muted); }

.au-tag {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    margin-left: 6px;
    vertical-align: middle;
}
.au-tag-fmp   { background: var(--color-accent-tint-soft); color: var(--color-accent); border: 1px solid var(--color-accent-tint-medium); }
.au-tag-rogue { background: var(--color-bg-badge-off); color: var(--color-status-danger); border: 1px solid var(--color-border-badge-off); }

.au-table tr.au-fmp td.au-cat { color: var(--color-accent); font-weight: 600; }
.au-table tr.au-rogue td.au-ndc { color: var(--color-status-danger); font-weight: 700; }

.au-table tr.au-subtotal td,
.au-table tr.au-total td {
    border-top: 1px solid var(--color-border-strong);
    font-weight: 700;
}
.au-table tr.au-total td { color: var(--color-text-secondary); }

.au-sessions-wrap { margin-top: 16px; }
.au-sessions-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}
.au-sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.au-session {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 5px 8px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-acp-card);
}
.au-session.au-rogue { border-color: var(--color-border-badge-off); }
.au-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}
.au-badge-dc  { background: var(--color-bg-badge-on); color: var(--palette-green-500); border: 1px solid var(--color-border-badge-on); }
.au-badge-ndc { background: var(--color-bg-badge-off); color: var(--color-status-danger); border: 1px solid var(--color-border-badge-off); }
.au-sess-id { font-family: monospace; color: var(--color-text-secondary); }
.au-sess-meta { color: var(--color-text-faint); margin-left: auto; }

.au-note {
    margin-top: 12px;
    font-size: 10px;
    color: var(--color-text-very-faint);
    line-height: 1.5;
}
.au-note code { font-family: monospace; color: var(--color-text-faint); }

.config-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border-default);
}

.config-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.config-section h4 {
    color: var(--palette-gh-text-300);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.config-help-text {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Theme toggle (Configuration → Appearance) */
.theme-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle-label {
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.theme-toggle-group {
    display: inline-flex;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--color-bg-input);
}

.theme-toggle-btn {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: background 0.15s, color 0.15s;
}

.theme-toggle-btn + .theme-toggle-btn {
    border-left: 1px solid var(--color-border-default);
}

.theme-toggle-btn:hover {
    background: var(--color-bg-row-hover);
    color: var(--color-text-primary);
}

.theme-toggle-btn.active {
    background: var(--color-accent);
    color: var(--color-text-on-accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-text-on-accent);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-accent-hover-bright);
}

.btn-secondary {
    background-color: var(--color-border-default);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-default);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-bg-card);
    border-color: var(--color-border-focus);
    color: var(--color-accent);
}

.btn-danger {
    background-color: var(--palette-red-500);
    color: var(--palette-white);
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--color-status-danger-hover);
}

/* Outline-style danger button (red text + red border on transparent background) */
.btn-danger-outline {
    color: var(--color-status-danger);
    border-color: var(--color-status-danger);
}

/* "Clear" button in the conversation context bar — pushes itself to the right edge */
.conv-clear-btn {
    margin-left: auto;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-bg-modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Modal band sits ABOVE every floating window. Windows draw from a shared counter capped at
       999999 (see _winZ/nextWinZ in monitor.js); 1100000 guarantees a modal dialog always covers
       and blocks the windows beneath it, so a required response can't be bypassed. */
    z-index: 1100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal container */
.modal {
    background-color: var(--color-bg-modal);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-modal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-sm {
    max-width: 380px;
}

.modal-md {
    max-width: 520px;
}

.modal-lg {
    max-width: 700px;
}

/* Help modal content */
.help-content {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.help-content h4 {
    color: var(--color-accent);
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px 0;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-default);
}

.help-content h4:first-child {
    padding-top: 0;
    border-top: none;
}

.help-content p {
    color: var(--palette-gh-text-300);
    font-size: 13px;
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.help-content code {
    background-color: var(--color-border-default);
    color: var(--color-accent);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
}

.help-operators {
    color: var(--palette-gh-text-300);
    font-size: 13px;
    margin-bottom: 12px;
}

.help-variables {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.help-var-group {
    font-size: 12px;
    color: var(--color-text-muted);
}

.help-var-group strong {
    color: var(--palette-gh-text-300);
}

.help-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-example {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background-color: var(--color-bg-page);
    border-radius: var(--r-md);
    border-left: 3px solid var(--color-border-default);
}

.help-example code {
    font-size: 13px;
}

.help-example span {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Modal header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-default);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--color-border-default);
    color: var(--color-status-danger);
}

/* Modal body */
.modal-body {
    padding: 20px;
}

/* Modal footer — the button row at the foot of a dialog (the same look as .form-actions).
   Several dialogs used this class with no rule behind it, so their buttons sat unpadded
   against the bottom-left corner. */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--color-border-default);
}
.modal-footer .modal-actions {
    display: flex;
    gap: 8px;
}

.modal-body p {
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Forms */
#watchlist-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-of-type {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus-ring-accent);
}

.form-group input[type="text"]::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-disabled);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 12px;
}

.form-group-half {
    flex: 1;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--color-border-default);
}

.modal-tab {
    background: transparent;
    border: none;
    padding: 10px 20px;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modal-tab:hover {
    color: var(--color-text-primary);
}

.modal-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.tab-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-accent);
}

.modal-tab-content {
    display: none;
    padding: 16px 20px;
}

.modal-tab-content.active {
    display: block;
}

/* =============================================================================
   WATCHLIST EDIT FLOATING WINDOW
   ============================================================================= */

#wl-edit-win {
    position: fixed;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    width: 680px;
    min-width: 480px;
    min-height: 540px;
    max-height: 92vh;
    background: var(--color-bg-modal);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    resize: both;          /* user can resize freely */
}

/* Titlebar / drag handle */
.wl-titlebar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    background: var(--color-bg-ticker-editor);
    border-bottom: 1px solid var(--color-border-default);
    cursor: move;
    user-select: none;
}
.wl-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-window-title);
}
.wl-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 3px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.wl-close:hover {
    color: var(--color-status-danger);
    background: var(--color-status-danger-tint-soft);
}

/* Form layout inside the window */
.wl-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Top section — always visible fields */
.wl-top {
    flex-shrink: 0;
    padding: 12px 16px 6px;
    border-bottom: 1px solid var(--color-border-default);
}
.wl-comment-group {
    margin-top: 8px;
    margin-bottom: 2px;
}
.wl-comment-group textarea {
    width: 100%;
    resize: vertical;
    min-height: 52px;
    max-height: 140px;
    font-size: 12px;
    line-height: 1.45;
    box-sizing: border-box;
}

/* Bottom section — tabbed area, fills remaining height */
.wl-bot {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.wl-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 2px;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-ticker-editor);
}
.wl-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s, border-color 0.15s;
}
.wl-tab:hover  { color: var(--color-text-primary); }
.wl-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.wl-tab-pane {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}
.wl-tab-pane.active {
    display: block;
}

/* Footer actions */
.wl-form-actions {
    flex-shrink: 0;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-ticker-editor);
}

.form-label-text {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-form-label);
    margin-bottom: 4px;
}
.wl-list-help {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 0 0 8px 0;
    line-height: 1.4;
}
.wl-list-names-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 6px 8px;
    background: var(--color-bg-ticker-editor);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
}
.wl-list-cb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-text-primary);
    cursor: pointer;
}
.wl-list-cb.wl-list-cb-archived {
    opacity: 0.55;
}
.wl-list-cb-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-default);
    flex-shrink: 0;
}
.wl-list-cb-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wl-list-cb-edit {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
    border-radius: var(--r-sm);
    line-height: 1;
}
.wl-list-cb-edit:hover {
    color: var(--color-accent);
    border-color: var(--color-border-default);
    background: var(--color-bg-ticker-editor);
}
.wl-list-cb-empty {
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 4px;
}
.wl-list-actions {
    display: flex;
    gap: 6px;
    margin-top: 2px;
    margin-bottom: 10px;
}

/* =============================================================================
   Visible-columns checkbox group (inside the list-def modal).
   Lets users pick which organic + property columns the list's table renders
   between Symbol and Chart on the main Watchlist page.
   ============================================================================= */
.wl-list-cols-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px 10px;
    padding: 6px 8px;
    background: var(--color-bg-ticker-editor);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    max-height: 180px;
    overflow-y: auto;
}
.wl-list-col-cb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-primary);
    cursor: pointer;
}
.wl-list-col-cb input[type="checkbox"] {
    margin: 0;
}
.wl-list-col-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}
.wl-list-col-divider::before,
.wl-list-col-divider::after {
    content: '';
    flex: 1 1 auto;
    border-top: 1px dashed var(--color-border-default);
}

/* Property columns in the main watchlist tables */
.wl-prop-col-header {
    font-weight: 600;
    white-space: nowrap;
}
.wl-prop-col-numeric,
.wl-prop-cell-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.wl-prop-cell {
    font-size: 12px;
    color: var(--color-text-prop-cell);
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wl-prop-cell-bool { text-align: center; }
.wl-prop-cell-empty { color: var(--color-text-prop-cell-empty); }

/* =============================================================================
   Per-list property inputs (shared field markup).
   Used by the Per-List Properties panel in the symbol detail window.
   ============================================================================= */
.wl-prop-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px 10px;
}
.wl-prop-field label {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}
.wl-prop-field input[type="text"],
.wl-prop-field input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 12px;
}
.wl-prop-type {
    font-weight: normal;
    color: var(--color-text-prop-cell-empty);
    font-size: 10px;
}

/* =============================================================================
   Per-List Properties panel — symbol detail window.
   Outer <div class="wl-plp-container"> wraps one <details class="wl-plp-list">
   per watchlist the symbol is a member of.
   ============================================================================= */
.wl-plp-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 2px;
}
.wl-plp-empty {
    color: var(--color-text-muted);
    font-size: 12px;
    font-style: italic;
    margin: 4px 0;
}
.wl-plp-list {
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-ticker-editor);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.wl-plp-list[open] {
    border-color: var(--color-border-disclosure-open);
}
.wl-plp-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
    user-select: none;
    list-style: none;
}
.wl-plp-summary::-webkit-details-marker { display: none; }
.wl-plp-summary::before {
    content: '';   /* chevron: see .chev-mask below */
    margin-right: 4px;
    vertical-align: -1px;
    color: var(--color-text-muted);
}
.wl-plp-list[open] > .wl-plp-summary::before {
    transform: rotate(90deg);
}
.wl-plp-summary:hover {
    background: var(--color-bg-disclosure-hover);
}
.wl-plp-list-name {
    flex: 1 1 auto;
}
.wl-plp-count {
    font-weight: normal;
    font-size: 10px;
    color: var(--color-text-muted);
    padding: 1px 6px;
    background: var(--color-accent-tint-subtle);
    border: 1px solid var(--color-accent-tint-soft);
    border-radius: var(--r-lg);
    white-space: nowrap;
}
.wl-plp-body {
    padding: 8px 10px 10px;
    border-top: 1px dashed var(--color-border-default);
}
.wl-plp-hint {
    color: var(--color-text-muted);
    font-size: 12px;
    margin: 0;
}
.wl-plp-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.wl-plp-status {
    font-size: 11px;
    color: var(--color-text-muted);
}
.wl-plp-status-success { color: var(--color-status-success); }
.wl-plp-status-error   { color: var(--color-status-danger); }
.wl-plp-status-info    { color: var(--color-text-muted); }
.wl-plp-membership-count {
    /* Reuses the .news-count look — override only count-specific bits. */
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-tint-medium);
}

/* =============================================================================
   END WATCHLIST EDIT FLOATING WINDOW
   ============================================================================= */

/* Alert Editor */
.alert-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert-expression-container {
    display: flex;
    flex-direction: column;
}

.alert-expression-container label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.alert-expression-container textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-accent);
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    min-height: 70px;
}

.alert-expression-container textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus-ring-accent);
}

.alert-expression-help {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 6px;
}

/* Alert navigation header */
.alert-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-default);
    margin-bottom: 16px;
}

.alert-nav-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-nav-indicator {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

.alert-nav-actions {
    display: flex;
    gap: 8px;
}

/* Alert form layout */
.alert-enabled-container {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.alert-full-width {
    width: 100%;
    margin-bottom: 16px;
}

.alert-inline-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.alert-notify-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.alert-notify-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
}
.alert-notify-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}
.alert-notify-opt input { cursor: pointer; }

/* ── Option Watch builder modal ─────────────────────────────────────────── */
.option-watch-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100000;   /* the dialog band — above every window (see .modal-overlay) */
}
.option-watch-dialog {
    background: var(--color-surface, #1b1e24);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--r-lg);
    width: min(460px, 92vw);
    max-height: 88vh;
    overflow: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.option-watch-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #333);
    font-weight: 600;
}
.option-watch-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.7;
}
.option-watch-close:hover { opacity: 1; }
.option-watch-body { padding: 16px; }
.option-watch-hint { font-size: 12px; opacity: 0.75; margin: 0 0 14px; line-height: 1.5; }
.option-watch-hint code { font-size: 11px; opacity: 0.9; }
.option-watch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.option-watch-row label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
    min-width: 78px;
}
.option-watch-row input[type="text"],
.option-watch-row select {
    flex: 1;
    min-width: 90px;
    padding: 6px 8px;
    background: var(--color-input-bg, #0e1013);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--r-sm);
    color: inherit;
    font-size: 13px;
}
.option-watch-underprice { font-size: 12px; opacity: 0.8; margin: -4px 0 12px 88px; }
.option-watch-occ {
    font-family: monospace;
    font-size: 13px;
    color: var(--color-accent, #64ffda);
    margin: 4px 0 14px;
    min-height: 18px;
}
.option-watch-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

.alert-inline-row > * {
    flex: 1;
}

.alert-enabled-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.alert-enabled-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.alert-color-container,
.alert-comment-container,
.alert-cooldown-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-color-container label,
.alert-comment-container label,
.alert-cooldown-container label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.alert-color-container select {
    padding: 8px 10px;
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-text-primary);
    font-size: 13px;
    cursor: pointer;
}

.alert-color-container select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.color-preview {
    width: 100%;
    height: 8px;
    border-radius: var(--r-sm);
    margin-top: 4px;
    background-color: var(--color-accent);
    transition: background-color 0.2s ease;
}

.alert-comment-container input,
.alert-comment-container textarea,
.alert-cooldown-container input {
    padding: 8px 10px;
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-text-primary);
    font-size: 13px;
    font-family: inherit;
}

.alert-comment-container textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.4;
}

.alert-comment-container input:focus,
.alert-comment-container textarea:focus,
.alert-cooldown-container input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus-ring-accent);
}

.alert-comment-container textarea::placeholder {
    color: var(--color-text-disabled);
}

.alert-cooldown-container input {
    width: 100%;
}

.alert-variables {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.alert-var-section {
    background-color: var(--color-bg-page);
    border-radius: var(--r-md);
    padding: 10px;
}

.alert-var-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.alert-var-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.alert-var-btn {
    background-color: var(--color-border-default);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    padding: 4px 8px;
    font-size: 11px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.15s ease;
}

.alert-var-btn:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-on-accent);
}

.alert-op-btn {
    background-color: var(--color-bg-card);
    font-weight: 600;
}

/* Invalid alert indicator */
.alert-invalid {
    border-left-color: var(--palette-orange-500) !important;
    background-color: var(--color-status-orange-tint-soft);
}

.alert-invalid .alert-symbol::after {
    content: ' (invalid)';
    color: var(--palette-orange-500);
    font-size: 10px;
    font-weight: normal;
}

.alert-error {
    color: var(--palette-orange-500) !important;
    font-weight: 600;
    cursor: help;
}

/* Rich text editor */
.rich-text-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background-color: var(--color-border-default);
    border: 1px solid var(--color-border-default);
    border-bottom: none;
    border-radius: var(--r-md) var(--r-md) 0 0;
    flex-wrap: wrap;
}

.rich-text-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

.rich-text-toolbar button:hover {
    background-color: var(--color-bg-card);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.rich-text-toolbar button.active {
    background-color: var(--color-accent);
    color: var(--color-text-on-accent);
}

.rich-text-toolbar .separator {
    width: 1px;
    background-color: var(--color-bg-page);
    margin: 0 4px;
}

.rich-text-editor {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: 0 0 var(--r-md) var(--r-md);
    color: var(--color-text-primary);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
    max-height: 300px;
}

.rich-text-editor:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus-ring-accent);
}

.rich-text-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-disabled);
}

.rich-text-editor b, .rich-text-editor strong {
    font-weight: 600;
}

.rich-text-editor i, .rich-text-editor em {
    font-style: italic;
}

.rich-text-editor u {
    text-decoration: underline;
}

.rich-text-editor ul, .rich-text-editor ol {
    margin-left: 20px;
    padding-left: 0;
}

.rich-text-editor a {
    color: var(--color-accent);
}

.input-with-datalist {
    position: relative;
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border-default);
    background-color: var(--color-portfolio-greeks-row-bg);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
}

#watchlist-form .form-actions {
    margin: 0 -20px -20px;
}

/* Action buttons in tables */
.action-btn.edit-btn:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.action-btn.delete-btn:hover {
    color: var(--color-status-danger);
    border-color: var(--color-status-danger);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 60px;
    right: 20px;
    z-index: 1200000;   /* above windows AND dialogs, or a toast raised from a window is hidden behind it */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    color: var(--color-text-primary);
    font-size: 13px;
    box-shadow: var(--shadow-card-hover);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left: 3px solid var(--color-status-success);
}

.toast.error {
    border-left: 3px solid var(--color-status-danger);
}

.toast.info {
    border-left: 3px solid var(--color-accent);
}

/* Collapsible sections */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-header .collapse-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.collapsible-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    /* overflow is managed by JS: hidden only during collapse/expand animation */
    transition: max-height 0.3s ease, padding 0.3s ease, border 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0 !important;
    overflow: hidden;
    padding-top: 0 !important;
}

/* Hide borders on containers inside collapsed sections */
.collapsible-content.collapsed > * {
    border: none !important;
}

/* Group header collapse */
.portfolio-table .group-header td {
    cursor: pointer;
    user-select: none;
}

.portfolio-table .group-header .collapse-icon {
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.2s ease;
}

.portfolio-table .group-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.portfolio-table tr.group-collapsed {
    display: none;
}

/* Expandable watchlist rows */
/* Expand cell in watchlist */
.expand-cell {
    width: 30px;
    text-align: center !important;
    padding: 4px !important;
}

.watchlist-expand-btn {
    background: transparent;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.watchlist-expand-btn:hover {
    background-color: var(--color-border-default);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.watchlist-expand-btn .expand-icon {
    transition: transform 0.2s ease;
}

.watchlist-expand-btn.expanded .expand-icon {
    transform: rotate(90deg);
}

.watchlist-detail-row {
    background-color: var(--color-bg-subtotal-row);
}

.watchlist-detail-row > td {
    padding: 12px;
    border-bottom: 2px solid var(--color-border-default);
}

/* Bold accent border around expanded watchlist item (data row + detail row) */
tr.watchlist-row-expanded td {
    border-top: 2px solid var(--color-accent) !important;
    border-left: none;
    border-right: none;
}
tr.watchlist-row-expanded td:first-child {
    border-left: 3px solid var(--color-accent) !important;
}
tr.watchlist-row-expanded td:last-child {
    border-right: 3px solid var(--color-accent) !important;
}
tr.watchlist-detail-expanded > td {
    border-bottom: 3px solid var(--color-accent) !important;
    border-left: 3px solid var(--color-accent) !important;
    border-right: 3px solid var(--color-accent) !important;
}

.watchlist-detail-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.watchlist-comment {
    color: var(--color-text-secondary);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 12px;
    background-color: var(--color-bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--color-border-default);
    margin-bottom: 12px;
}

.watchlist-alert-expr {
    padding: 10px 12px;
    background-color: var(--color-bg-card);
    border-radius: var(--r-md);
    border: 1px solid var(--color-border-default);
    border-left: 3px solid var(--color-accent);
    margin-bottom: 12px;
    font-size: 13px;
}

.watchlist-alert-expr .alert-expr-label {
    color: var(--color-accent);
    font-weight: 600;
    margin-right: 6px;
}

.watchlist-alert-expr code {
    color: var(--color-text-secondary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: none;
    padding: 0;
}

/* Chart container */
.chart-container {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 16px;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* SDW chart controls — label above each control, matching heights */
.sdw-chart-controls {
    align-items: flex-end;  /* bottom-align all groups */
    gap: 8px;
    margin-bottom: 8px;
}

/* Each labelled control group */
.sdw-ctrl-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* The label text above a control */
.sdw-ctrl-label {
    font-size: 9px;
    color: var(--palette-gh-text-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
}

/* SDW days input — override width to fit 3-digit numbers */
.sdw-days-input {
    width: 56px;
}

/* SDW chart canvas — taller than the default 250px (overridden by an inline
   height once the user drag-resizes; this is the fallback default). */
.sdw-body .chart-canvas-wrapper {
    height: 320px;
}

/* SDW chart vertical resize handle (drag to grow/shrink the chart + section) */
.sdw-chart-resizer {
    height: 10px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--color-border-default);
    user-select: none;
}
.sdw-chart-resizer::after {
    content: '';
    width: 44px;
    height: 3px;
    border-radius: var(--r-sm);
    background: var(--color-border-default);
    opacity: 0.7;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}
.sdw-chart-resizer:hover::after {
    opacity: 1;
    background: var(--color-accent);
}

/* SDW indicator dropdown opens upward so it isn't clipped by the canvas below */
.sdw-body .indicator-dropdown-content {
    top: auto;
    bottom: 100%;
    border-radius: var(--r-md) var(--r-md) 0 0;
}

/* Suppress CSS caret on SDW Indicators button (▾ is inline text) */
.sdw-chart-controls .indicator-dropdown-btn::after {
    display: none;
}

/* Action buttons sit in a row (Refresh, then Reset Zoom to its right). */
.sdw-ctrl-action {
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
    justify-content: flex-end;
}

/* Compare group — add-symbol input + chips */
.sdw-compare-row {
    display: flex;
    gap: 4px;
    align-items: center;
}
.sdw-compare-input {
    width: 84px;
}
.sdw-compare-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    max-width: 220px;
}
.sdw-compare-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 4px 1px 7px;
    font-size: 11px;
    border-radius: var(--r-lg);
    background: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    color: var(--color-text-primary);
}
.sdw-compare-chip-x {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0 1px;
}
.sdw-compare-chip-x:hover {
    color: var(--color-accent);
}

/* ── AdvancedChart toolbar ──────────────────────────────────────────────────
   Grouped control clusters separated by thin dividers; actions pushed right.
   Designed to stay tidy as more controls are added (it wraps gracefully). */
.ac-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
}
.ac-cluster {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ac-divider {
    width: 1px;
    align-self: stretch;
    min-height: 22px;
    background: var(--color-border-default);
    margin: 0 2px;
}
.ac-spacer { flex: 1 1 auto; }

.ac-field {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Unified control chrome — selects, inputs, buttons share height + styling. */
.ac-select,
.ac-input,
.ac-btn,
.ac-toolbar .indicator-dropdown-btn {
    height: 26px;
    box-sizing: border-box;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-text-primary);
    font-size: 11px;
    font-family: inherit;
    padding: 0 8px;
    cursor: pointer;
    white-space: nowrap;
}
.ac-input { cursor: text; width: 56px; }
.ac-compare-input { width: 108px; }
.ac-select { padding-right: 4px; }

.ac-btn:hover,
.ac-select:hover,
.ac-toolbar .indicator-dropdown-btn:hover {
    border-color: var(--color-border-strong-hover);
    background: var(--color-border-default);
}
.ac-btn:focus,
.ac-input:focus,
.ac-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}
/* The ▾ caret is inline text in the button label — hide the CSS pseudo-caret. */
.ac-toolbar .indicator-dropdown-btn::after {
    display: none;
}
/* Compare chips sit inline within their cluster (no top margin needed here). */
.ac-compare .sdw-compare-chips {
    margin-top: 0;
}

.sdw-ctrl-refresh {
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.sdw-ctrl-refresh:hover {
    background-color: var(--color-border-default);
    border-color: var(--color-border-strong-hover);
}

.chart-controls label {
    color: var(--color-text-muted);
    font-size: 12px;
}

.chart-controls select,
.chart-controls input[type="number"] {
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
}

.chart-controls select:focus,
.chart-controls input[type="number"]:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.chart-canvas-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

.chart-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Indicator dropdown */
.indicator-dropdown {
    position: relative;
    display: inline-block;
}

.indicator-dropdown-btn {
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    padding: 4px 20px 4px 6px;
    font-size: 11px;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.indicator-dropdown-btn::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--color-text-muted);
}

.indicator-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-card-hover);
}

.indicator-dropdown-content.show {
    display: block;
}

.indicator-dropdown-content label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--color-text-primary);
    font-size: 12px;
    transition: background-color 0.15s ease;
}

.indicator-dropdown-content label:hover {
    background-color: var(--color-border-default);
}

.indicator-dropdown-content input[type="checkbox"] {
    accent-color: var(--color-accent);
}

/* Overlay dropdown extras */
.ov-color-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ov-dd-empty {
    display: block;
    padding: 8px 12px;
    color: var(--palette-gh-text-500);
    font-size: 11px;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .portfolio-table {
        font-size: 12px;
    }
    
    .portfolio-table th,
    .portfolio-table td {
        padding: 3px 6px;
    }
}

@media (max-width: 600px) {
    #status-bar {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 14px;
        padding: 10px 14px;
    }

    .status-item {
        width: auto;
        flex-shrink: 0;
    }
    #status-bar #market-close-countdown { white-space: nowrap; }

    .config-tab-content {
        padding: 16px;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .card-label {
        font-size: 12px;
    }
    
    .card-value {
        font-size: 13px;
    }
    
    .portfolio-table {
        min-width: 800px;
    }
}

/* ============================================================================
   DETAIL SECTIONS (Collapsible Chart/News in expanded watchlist)
   ============================================================================ */

.detail-section {
    margin-bottom: 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    overflow: hidden;
}

.detail-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--color-bg-card);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text-muted);
    user-select: none;
}

.detail-section-header:hover {
    background-color: var(--color-bg-subtotal-row);
}

.detail-section-header .collapse-icon {
    transition: transform 0.2s ease;
}

.detail-section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.detail-section-content {
    padding: 12px;
    background-color: var(--color-bg-detail-content);
}

.news-count {
    color: var(--color-accent);
    font-size: 12px;
    margin-left: auto;
}

/* ── About section ────────────────────────────────────────── */

/* Age badge in the About header */
.about-age {
    font-size: 11px;
    color: var(--color-text-disabled);
    font-weight: 400;
    margin-left: 4px;
}

/* Convert-Markdown + Refresh buttons in the About header (grouped at the right) */
.about-mdhtml-btn {
    margin-left: auto;
    padding: 2px 6px !important;
    font-size: 10px !important;
    line-height: 1.4;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.about-mdhtml-btn:hover {
    opacity: 1;
}
.about-refresh-btn {
    margin-left: 4px;
    padding: 2px 6px !important;
    font-size: 11px !important;
    line-height: 1.4;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.about-refresh-btn:hover {
    opacity: 1;
}

/* The rendered HTML content area */
.about-content {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
}
.about-content h4 {
    margin: 10px 0 4px;
    font-size: 13px;
    color: var(--color-accent);
    font-weight: 600;
    letter-spacing: 0.02em;
}
.about-content p {
    margin: 0 0 8px;
}
.about-content ul {
    margin: 0 0 8px 18px;
    padding: 0;
}
.about-content li {
    margin-bottom: 3px;
}
.about-content strong {
    color: var(--palette-slate-200);
}

/* Status states */
.about-empty,
.about-loading,
.about-error {
    color: var(--color-text-muted);
    font-size: 13px;
    font-style: italic;
    padding: 4px 0;
}
.about-error {
    color: var(--color-status-danger);
}

/* ── End About section ────────────────────────────────────── */

/* Symbol notes add button in section header */
.symbol-notes-add-btn {
    margin-left: 8px;
    padding: 2px 8px !important;
    font-size: 11px !important;
    line-height: 1.4;
}

/* Symbol notes empty state */
.symbol-notes-empty {
    color: var(--color-text-muted);
    font-size: 13px;
    padding: 8px 0;
    font-style: italic;
}

/* Symbol notes grid */
.symbol-notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    padding: 8px 0;
}
/* Prevent symbol note cards from expanding past their grid column */
.symbol-notes-grid > .note-card {
    min-width: 0;
    overflow: hidden;
}
@media (max-width: 600px) {
    .symbol-notes-grid { grid-template-columns: 1fr; }
}

/* Symbols tag shown in note card footer when inside a symbol panel */
.symbol-note-symbols-tag {
    font-size: 11px;
    color: var(--color-accent);
    font-weight: 500;
    opacity: 0.8;
}

/* Section count badges */
.section-count {
    background-color: var(--color-accent);
    color: var(--color-text-on-accent);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-lg);
    margin-left: 8px;
}

.section-count:empty {
    display: none;
}

/* Section header buttons inside h2 */
h2.collapsible-header .section-header-buttons {
    margin-left: auto;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

h2.collapsible-header .section-header-buttons .btn {
    font-size: 12px;
    padding: 4px 10px;
}

.mini-charts-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 10px;
    background-color: var(--color-accent-tint-soft);
    border-radius: var(--r-sm);
    transition: background-color 0.2s;
}

.mini-charts-toggle:hover {
    background-color: var(--color-accent-tint-medium);
}

.mini-charts-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Mini chart interval/days controls shown next to the checkbox */
.mini-chart-controls {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    background: var(--color-accent-tint-subtle);
    border-radius: var(--r-sm);
    border: 1px solid var(--color-accent-tint-soft);
}

.mini-chart-ctrl-label {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.mini-chart-ctrl-select {
    background: var(--color-bg-mini-chart-ctrl);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-mini-chart-ctrl);
    border-radius: var(--r-sm);
    font-size: 11px;
    padding: 1px 2px;
    height: 22px;
    cursor: pointer;
}

.mini-chart-ctrl-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.mini-chart-ctrl-days {
    background: var(--color-bg-mini-chart-ctrl);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-mini-chart-ctrl);
    border-radius: var(--r-sm);
    font-size: 11px;
    padding: 1px 4px;
    height: 22px;
    width: 48px;
    text-align: right;
}

.mini-chart-ctrl-days:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.mini-chart-cell {
    padding: 4px !important;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

.mini-chart-canvas {
    width: 80px;
    height: 35px;
    display: block;
    margin: 0 auto;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .mini-chart-cell {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
    
    .mini-chart-canvas {
        width: 60px;
        height: 30px;
    }
    
    .wl-list-table td.name-cell {
        max-width: 50px;
        width: 50px;
    }
}

#watchlist-alerts-container {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    overflow-x: auto;   /* scroll horizontally if table is wider than the grid cell */
}

#watchlist-alerts-container .portfolio-table {
    margin-top: 0;
}

#watchlist-alerts-container .alert-expression-cell {
    max-width: 160px;
    width: 160px;
    word-wrap: break-word;
    white-space: normal;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    color: var(--palette-gh-text-300);
}

#watchlist-alerts-container .alert-triggered-yes {
    color: var(--color-status-danger);
    font-weight: 600;
}

#watchlist-alerts-container .alert-triggered-no {
    color: var(--color-text-muted);
}

#watchlist-alerts-container .alert-disabled-row {
    opacity: 0.5;
}

/* Symbol details cell */
.symbol-details-cell {
    vertical-align: top;
    padding: 12px !important;
}

.symbol-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.symbol-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.symbol-main strong {
    font-size: 13px;
    color: var(--color-accent);
    font-weight: 500;
}

.symbol-price {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: normal;
}

.symbol-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.symbol-list {
    font-weight: 500;
    color: var(--color-accent);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.symbol-name {
    color: var(--color-text-secondary);
}

.symbol-industry {
    color: var(--color-text-muted);
    font-style: italic;
}

/* Alerts cell */
.alerts-cell {
    vertical-align: top;
    padding: 8px 12px !important;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-list-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 12px;
    background-color: var(--color-accent-tint-subtle);
    border-left: 3px solid var(--alert-color, var(--color-accent));
    border-radius: var(--r-sm);
    font-size: 12px;
    line-height: 1.4;
}

.alert-list-item.alert-disabled {
    opacity: 0.4;
    background-color: var(--color-bg-slate-overlay-soft);
    border-left-color: var(--color-text-disabled);
}

.alert-list-item.alert-status-triggered {
    background-color: var(--color-bg-alert-triggered);
    border-left-width: 4px;
}

.alert-item-left {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.alert-item-right {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    min-width: 0;
}

.alert-status-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.alert-disabled-badge {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-text-muted);
    background-color: var(--color-bg-slate-overlay-medium);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.alert-item-label {
    font-style: italic;
    color: var(--color-accent);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.alert-item-expression {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: var(--color-text-secondary);
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    font-size: 11px;
    color: var(--color-text-muted);
}

#watchlist-alerts-container .alert-disabled-row td {
    color: var(--color-state-neutral);
}

/* ============================================================================
   NEWS TABLE
   ============================================================================ */

.news-container {
    max-height: 300px;
    overflow-y: auto;
}

.news-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.news-table th {
    text-align: left;
    padding: 6px 10px;
    background-color: var(--color-bg-card);
    color: var(--color-text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--color-border-default);
    position: sticky;
    top: 0;
    z-index: 2;
}

.news-table td {
    padding: 0 10px;
    border-bottom: 1px solid var(--color-border-default);
    color: var(--palette-gh-text-300);
    text-align: left;
    line-height: 1.6;
    height: 22px;
}

.news-row:hover {
    background-color: var(--color-bg-card);
}

.news-row.clickable {
    cursor: pointer;
}

.news-row.clickable:hover {
    background-color: var(--color-bg-subtotal-row);
}

.news-date {
    white-space: nowrap;
    color: var(--color-text-muted);
    font-size: 11px;
    width: 130px;
}

.news-table td.news-title {
    color: var(--color-text-primary);
    text-align: left !important;
}

.news-source {
    color: var(--color-text-muted);
    font-size: 11px;
    width: 120px;
    min-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-news-text {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* ============================================================================
   NEWS ARTICLE MODAL
   ============================================================================ */

.news-article-meta {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border-default);
    font-size: 13px;
}

.news-meta-source {
    color: var(--color-accent);
    font-weight: 500;
}

.news-meta-date {
    color: var(--color-text-muted);
}

.news-meta-link {
    color: var(--palette-blue-400);
    text-decoration: none;
    margin-left: auto;
}

.news-meta-link:hover {
    text-decoration: underline;
}

.news-article-body {
    color: var(--palette-gh-text-300);
    font-size: 14px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.news-article-body p {
    margin-bottom: 12px;
}

.news-article-body a {
    color: var(--palette-blue-400);
}

/* ============================================================================
   AI EXPORT MODAL
   ============================================================================ */

.ai-export-options {
    margin-bottom: 16px;
    padding: 12px;
    background-color: var(--color-bg-detail-content);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
}

.export-option-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.export-section {
    margin-bottom: 8px;
}

.export-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    transition: background-color 0.2s ease;
}

.export-checkbox-item:hover {
    background-color: var(--color-border-strong);
}

.export-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.export-checkbox-item span {
    font-size: 12px;
    color: var(--color-text-primary);
    user-select: none;
}

.export-subsection {
    margin-left: 32px;
    margin-top: 6px;
    padding: 8px;
    background-color: var(--color-bg-card);
    border-left: 2px solid var(--color-border-strong);
    border-radius: var(--r-sm);
}

.export-sub-item {
    padding: 4px 6px;
}

.export-days-select {
    margin-left: 32px;
    padding: 4px 8px;
    font-size: 11px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    cursor: pointer;
}

.export-days-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.export-note {
    margin-left: 32px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--color-text-muted);
    font-style: italic;
}

.export-list-config {
    margin-top: 8px;
}

.export-list-config-label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.export-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background-color: var(--color-bg-detail-content);
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-strong);
}

.export-list-name {
    flex: 1;
    font-size: 11px;
    color: var(--color-text-primary);
    font-weight: 500;
}

.export-list-symbol-count {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-right: 8px;
}

.export-list-days-select {
    padding: 3px 6px;
    font-size: 10px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    cursor: pointer;
    min-width: 80px;
}

.export-list-days-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.ai-export-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.ai-export-textarea {
    width: 100%;
    height: 450px;
    background-color: var(--color-bg-detail-content);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--palette-gh-text-300);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    padding: 12px;
    resize: vertical;
    line-height: 1.4;
}

.export-status {
    font-size: 12px;
    color: var(--color-accent);
    margin-left: auto;
}

/* Disabled AI Export button */
#btn-ai-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   DATA COLLECTOR CHECKBOX
   ============================================================================ */

.dc-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background-color: transparent;
    border: 1px solid var(--color-border-default);
    margin-right: 8px;
}

.dc-checkbox-label:hover {
    background-color: var(--color-bg-card);
}

.dc-checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.dc-checkbox-text {
    white-space: nowrap;
}

.dc-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-weight: 500;
}

.dc-status.active {
    background-color: var(--color-accent-tint-medium);
    color: var(--color-accent);
}

.dc-status.standby {
    background-color: var(--color-status-paused-tint-medium);
    color: var(--color-status-paused);
}

.dc-status.inactive {
    background-color: transparent;
    color: var(--color-text-muted);
}

.dc-status.locked {
    background-color: var(--color-status-danger-tint-medium);
    color: var(--color-status-danger);
}

.dc-checkbox-label:has(input:disabled) {
    opacity: 0.6;
    cursor: not-allowed;
}

.dc-checkbox-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

/* Responsive: Stack alert inline row on mobile */
@media (max-width: 600px) {
    .alert-inline-row {
        flex-direction: column;
        gap: 12px;
    }
}

/* ============================================================================
   NOTES SECTION
   ============================================================================ */

#notes {
    margin-top: 24px;
    margin-bottom: 16px;
}

#notes h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#notes .collapsible-content {
    padding-top: 12px;
}

/* Notes filter dropdown */
.notes-filter-dropdown {
    position: relative;
}

.notes-filter-btn {
    display: flex;
    align-items: center;
    gap: 5px;
}

.notes-filter-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 10px 14px;
    z-index: 200;
    min-width: 170px;
    box-shadow: var(--shadow-dropdown);
    flex-direction: column;
    gap: 10px;
}

.notes-filter-panel.open {
    display: flex;
}

.notes-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--palette-gh-text-300);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.notes-filter-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.notes-filter-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-status-info);
    font-weight: 600;
}

.notes-filter-divider {
    height: 1px;
    background-color: var(--color-border-default);
    margin: 2px 0;
}

#hashtag-filter-options,
#priority-filter-options,
#function-filter-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Disabled filter options (zero matching notes) */
.notes-filter-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.notes-filter-option.disabled input[type="checkbox"] {
    cursor: not-allowed;
}

/* Per-option match counts and priority dot in the filter dropdown */
.notes-filter-count {
    color: var(--color-text-muted);
    font-size: 10px;
    margin-left: auto;
}
.notes-priority-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: var(--shadow-priority-dot-ring);
    flex-shrink: 0;
}

/* ── Notes Order select (in section header) ─────────────────────────────── */
.notes-order-select {
    cursor: pointer;
    padding: 2px 6px;
    font-size: 11px;
}

/* ── Per-tag collapsible accordion sections ─────────────────────────────── */

/* Each section spans all grid columns so it runs edge-to-edge.
   Sections are joined into one accordion block — no gap between them. */
.notes-tag-section {
    grid-column: 1 / -1;
    border: 1px solid var(--color-border-notes-section);
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 0;
}
/* Collapse the double-border between adjacent sections */
.notes-tag-section + .notes-tag-section {
    border-top: none;
}
/* Round only the outermost corners */
.notes-tag-section:first-child  { border-radius: var(--r-md) var(--r-md) 0 0; }
.notes-tag-section:last-child   { border-radius: 0 0 var(--r-md) var(--r-md); }
.notes-tag-section:only-child   { border-radius: var(--r-md); }

/* Accordion header — full width bar */
.notes-tag-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: var(--color-bg-notes-accordion-header);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    border-left: 3px solid var(--color-accent);
    transition: background 0.15s;
}
.notes-tag-section-header:hover {
    background: var(--color-bg-notes-accordion-header-hover);
}

/* Arrow rotates between ▸ (collapsed) and ▾ (expanded) */
.notes-tag-arrow {
    color: var(--color-status-info);
    flex-shrink: 0;
    width: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notes-tag-label {
    flex: 1;
    min-width: 0;
}

.notes-tag-count {
    font-size: 10px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-bg-notes-accordion-body);
    border: 1px solid var(--color-border-notes-section);
    border-radius: var(--r-lg);
    padding: 1px 8px;
    flex-shrink: 0;
}

/* Body — padding around the inner card grid */
.notes-tag-section-body {
    padding: 12px 14px 14px;
    background: var(--color-bg-notes-accordion-body);
    border-top: 1px solid var(--color-border-notes-section);
}

/* Inner grid inside a section body reuses .notes-grid */
.notes-tag-section-body .notes-grid {
    margin: 0;
    padding: 0;
}

/* When the outer notes-grid is holding accordion sections, kill the row/col gap
   so sections share borders with no space between them */
#notes-grid:has(> .notes-tag-section) {
    gap: 0;
    padding: 8px 0 0;
}

.notes-tag-empty {
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 4px 0;
}

/* Notes Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

/* Note Card */
.note-card {
    background-color: var(--color-bg-card);
    background-image: linear-gradient(135deg, color-mix(in srgb, var(--note-color, var(--color-accent)) 14%, transparent) 0%, transparent 70%);
    border-radius: var(--r-lg);
    border: 1px solid var(--color-border-default);
    border-left: 4px solid var(--note-color, var(--color-accent));
    /* Slightly stronger than --shadow-card so the dark dropshadow reads through
       the note's colored gradient overlay + bright left border (watchlist cards
       don't have those visual elements competing with the shadow). */
    box-shadow: var(--shadow-note-card);
    padding: 16px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: none;
    /* Prevent grid item from expanding beyond its column */
    min-width: 0;
    overflow: hidden;
}

/* Archived Note Overlay */
.note-card.archived {
    opacity: 0.5;
    background-color: var(--color-bg-note-archived);
}

.note-card.archived::before {
    content: "ARCHIVED";
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: var(--color-bg-note-archived-badge);
    color: var(--color-text-muted);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    letter-spacing: 0.5px;
}

/* Minimized Note — collapses to a single title-bar line */
.note-card.minimized {
    padding: 4px 8px 4px 10px;
    gap: 0;
    opacity: 0.75;
}

/* Minimized cards collapse back to a single row — override the column layout
   used by expanded cards so the whole header stays on one line. Also suppress
   the title-bar gradient + divider on the ::before pseudo (they don't make
   sense in the compact single-line layout). */
.note-card.minimized .note-card-header {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding-bottom: 0;
}
.note-card.minimized .note-card-header::before {
    display: none;
}

.note-card.minimized .note-card-title {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: normal;
    overflow-wrap: normal;
}

.note-card.minimized .note-card-content,
.note-card.minimized .note-card-footer {
    display: none;
}

/* Grid break - forces next item to start on new row */
.notes-grid-break {
    grid-column: 1 / -1;
    height: 0;
    margin: 8px 0 0 0;
}

/* Note Card Header — two-row layout: function tag + actions on the top row,
   title on its own row below taking the full card width. Minimized cards
   override this back to a single row (see .note-card.minimized rules above).
   The ::before pseudo paints a subtle vertical gradient tinted by the note's
   accent color that bleeds out to the card's inner edges (via negative inset
   matching the card's 16px padding), giving the title block a faint title-bar
   feel that separates it from the preview below. */
.note-card-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    position: relative;
    padding-bottom: 6px;
}

.note-card-header::before {
    content: '';
    position: absolute;
    top: -16px;          /* bleed up to the card's inner top (card padding = 16px) */
    left: -16px;
    right: -16px;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--note-color, var(--color-accent)) 12%, transparent) 0%,
        transparent 100%
    );
    /* Full-card-width divider sits at the header's bottom — drawn on the pseudo
       (not the header itself) so it bleeds to the card's inner edges instead of
       stopping at the header's padding. */
    border-bottom: 1px solid color-mix(in srgb, var(--color-border-default) 60%, transparent);
    pointer-events: none;
}

/* Top row of the header — function tag (or status indicators) on the left,
   action buttons pushed to the right. */
.note-card-header-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}
.note-card-header-top .note-card-actions {
    margin-left: auto;
}

.note-pin-icon {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; padding: 0; border: none; border-radius: var(--r-sm); background: transparent;
    color: var(--color-text-muted); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s;
}
.note-card:hover .note-pin-icon, .note-pin-icon:focus-visible { opacity: .6; }
.note-pin-icon.on { opacity: 1; color: var(--color-accent); }
.note-pin-icon:hover { opacity: 1; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
body.is-phone .note-pin-icon { opacity: .5; }

.note-card-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-bright);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.note-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    visibility: hidden;
}

.note-card:hover .note-card-actions {
    visibility: visible;
}

.note-action-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-action-btn:hover {
    color: var(--color-accent);
}

.note-action-btn svg {
    width: 14px;
    height: 14px;
}

/* Chat button on note cards — slightly brighter accent */
.note-chat-btn:hover {
    color: var(--color-accent) !important;
}

/* Note Card Content Preview */
.note-card-content {
    font-size: 10px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    cursor: pointer;
    padding-right: 4px;
}

/* Custom scrollbar styling for note preview */
.note-card-content::-webkit-scrollbar {
    width: 6px;
}

.note-card-content::-webkit-scrollbar-track {
    background: var(--color-bg-track-tint);
    border-radius: var(--r-sm);
}

.note-card-content::-webkit-scrollbar-thumb {
    background: var(--color-accent-tint-strong);
    border-radius: var(--r-sm);
}

.note-card-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-border-bright);
}

/* HTML formatting in preview */
.note-card-content p {
    margin: 6px 0;
}

.note-card-content h1,
.note-card-content h2,
.note-card-content h3 {
    color: var(--color-text-bright);
    font-weight: 600;
    margin: 8px 0 4px 0;
}

.note-card-content h1 { font-size: 12px; }
.note-card-content h2 { font-size: 11px; }
.note-card-content h3 { font-size: 10px; }

.note-card-content strong,
.note-card-content b {
    color: var(--color-text-bright);
    font-weight: 600;
}

.note-card-content em,
.note-card-content i {
    font-style: italic;
    color: var(--color-text-italic-soft);
}

.note-card-content ul,
.note-card-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.note-card-content li {
    margin: 2px 0;
}

.note-card-content a {
    color: var(--color-accent);
    text-decoration: none;
}

/* Code block in note preview — constrained to card width with its own scroll */
.note-card-content pre {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: pre;
    background: var(--color-bg-code-translucent);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    padding: 5px 8px;
    margin: 5px 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 9px;
    color: var(--color-text-code-light);
    line-height: 1.5;
}

/* Thin scrollbar for the code block in card previews */
.note-card-content pre::-webkit-scrollbar       { height: 4px; }
.note-card-content pre::-webkit-scrollbar-track  { background: var(--color-bg-track-tint); }
.note-card-content pre::-webkit-scrollbar-thumb  { background: var(--color-accent-tint-strong); border-radius: var(--r-sm); }

/* Reset inline-code styles when nested inside a block in preview */
.note-card-content pre code {
    background: none;
    border-radius: 0;
    padding: 0;
    font-size: inherit;
    color: inherit;
    font-family: inherit;
}

/* Inline code (outside a pre) */
.note-card-content code {
    background-color: var(--color-accent-tint-soft);
    padding: 2px 4px;
    border-radius: var(--r-sm);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 9px;
    color: var(--color-accent);
}

.note-card-content blockquote {
    border-left: 3px solid var(--color-accent);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Tables in note preview */
.note-card-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 9px;
}

.note-card-content table td,
.note-card-content table th {
    border: 1px solid var(--color-border-default);
    padding: 6px 8px;
    text-align: left;
}

.note-card-content table th {
    background-color: var(--color-accent-tint-soft);
    font-weight: 600;
    color: var(--color-accent);
}

.note-card-content table tr:nth-child(even) {
    background-color: var(--color-bg-track-tint);
}

.note-card-content table tr:hover {
    background-color: var(--color-accent-tint-subtle);
}

/* Collapsible sections in preview - collapsed, not interactive */
.note-card-content details {
    border-left: 2px solid var(--color-accent);
    padding: 6px 8px;
    margin: 6px 0;
    background-color: var(--color-accent-tint-subtle);
    border-radius: var(--r-sm);
    pointer-events: none;
}

.note-card-content details summary {
    font-weight: 600;
    color: var(--color-accent);
    font-size: 10px;
    padding: 2px 0;
    list-style: none;
    cursor: default;
}

.note-card-content details summary::before {
    content: '▶ ';
    margin-right: 4px;
    color: var(--color-accent);
}

.note-card-content details[open] summary::before {
    content: '▼ ';
}

.note-card-content details details {
    margin-left: 12px;
    border-left-color: var(--color-text-link-blue);
    background-color: var(--color-bg-blue-tint-faint);
}

.note-card-content details details summary {
    color: var(--color-text-link-blue);
}

/* Note Card Footer */
.note-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 9px;
    color: var(--color-text-muted);
    gap: 8px;
}

.note-card-footer .note-card-date {
    margin-left: auto;
}

.note-card-ticker-symbols {
    font-size: 10px;
    color: var(--color-accent);
    font-weight: 600;
    opacity: 0.85;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55%;
}

/* ── Metadata-driven card visuals ───────────────────────────────────────── */

/* Priority dot in card header */
.note-card-priority-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    box-shadow: var(--shadow-priority-dot-ring);
}

/* FUNCTION tag next to title */
.note-card-func-tag {
    font-size: 8px;
    font-weight: 700;
    color: var(--color-text-muted);
    background: var(--color-bg-slate-overlay-faint);
    padding: 2px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 0.5px;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
    white-space: nowrap;
}

/* DEPRECATED ribbon across the top of the card */
.note-card-deprecated-ribbon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--color-status-error-tint-soft);
    color: var(--color-status-error);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    letter-spacing: 1px;
    text-align: center;
    border-bottom: 1px solid var(--color-status-error-border);
    pointer-events: auto;
    z-index: 1;
}

/* Shift the card header down to make room for the ribbon */
.note-card.deprecated .note-card-header {
    margin-top: 14px;
}
.note-card.deprecated.minimized .note-card-header {
    margin-top: 16px;
}

/* relatedGuids link-count badge in card footer */
.note-card-link-badge {
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-tint-medium);
    padding: 1px 6px;
    border-radius: var(--r-lg);
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.note-card-link-badge:hover {
    color: var(--color-accent);
    background: var(--color-accent-tint-medium);
}

/* Note Editor Modal */
.modal-xl {
    max-width: 900px;
    width: 90%;
    height: 88vh;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Note modal body fills remaining height and passes it to the form */
#note-modal .modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

#note-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Title input lives in the modal header — styled to look like the h3 it replaces */
.note-modal-title-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--color-text-primary);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    padding: 2px 4px;
    margin-right: 12px;
    outline: none;
    transition: border-color 0.15s;
}

.note-modal-title-input::placeholder {
    color: var(--color-text-form-placeholder);
    font-weight: 400;
}

.note-modal-title-input:focus {
    border-bottom-color: var(--color-border-focus);
}

/* Note symbols row */
.note-symbols-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--color-border-default);
}

.note-symbols-label {
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.note-symbols-input {
    flex: 1;
    background-color: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    font-size: 12px;
    padding: 5px 8px;
    transition: border-color 0.2s;
}

.note-symbols-input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.note-symbols-input::placeholder {
    color: var(--color-text-disabled);
}

/* ── Note footer tab container ──────────────────────────────── */
.note-footer-tabs {
    margin-top: 12px;
    border-top: 1px solid var(--color-border-default);
}

.note-tabs-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border-default);
}

.note-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.note-tab-btn:hover {
    color: var(--color-text-secondary);
}
.note-tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.note-tab-panel {
    display: none;
}
.note-tab-panel.active {
    display: block;
}

/* Properties panel: strip top border/margin so it looks flush */
.nw-props-panel .note-options-row,
.note-tab-panel .note-options-row {
    margin-top: 0;
    border-top: none;
    padding-top: 10px;
    padding-bottom: 4px;
}

/* Symbols tab / properties panel inner layout */
.note-symbols-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 4px;
}

/* ── End Note footer tabs ────────────────────────────────────── */

/* AI Chat button in note modal footer */
.btn-ai {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    transition: background 0.15s, color 0.15s;
}
.btn-ai:hover {
    background: var(--color-accent-tint-soft);
}

.note-options-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-default);
}

.note-color-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.note-color-container select {
    padding: 4px 8px;
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    font-size: 12px;
    cursor: pointer;
}

.note-color-container select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* Circle swatch to the left of the dropdown */
.note-color-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--color-accent);
    border: 2px solid var(--color-overlay-ring-soft);
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

.note-pin-container,
.note-minimize-container,
.note-archive-container {
    display: flex;
    align-items: center;
}

/* Pill-style label — matches dc-checkbox-label pattern */
.note-pin-label,
.note-minimize-label,
.note-archive-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-muted);
    padding: 4px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-default);
    background-color: transparent;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

.note-pin-label:hover,
.note-minimize-label:hover,
.note-archive-label:hover {
    background-color: var(--color-bg-card);
    color: var(--color-text-secondary);
}

/* Checked state — highlight the pill */
.note-pin-label:has(input:checked),
.note-minimize-label:has(input:checked),
.note-archive-label:has(input:checked) {
    border-color: var(--color-accent-border-strong);
    background-color: var(--color-accent-tint-soft);
    color: var(--color-accent);
}

/* Custom checkbox box */
.note-pin-label input[type="checkbox"],
.note-minimize-label input[type="checkbox"],
.note-archive-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--color-text-form-placeholder);
    border-radius: var(--r-sm);
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background-color 0.15s, border-color 0.15s;
}

.note-pin-label input[type="checkbox"]:checked,
.note-minimize-label input[type="checkbox"]:checked,
.note-archive-label input[type="checkbox"]:checked {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
}

/* Checkmark tick */
.note-pin-label input[type="checkbox"]:checked::after,
.note-minimize-label input[type="checkbox"]:checked::after,
.note-archive-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 8px;
    border: 2px solid var(--color-checkmark-on-accent);
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* TipTap Editor Container — grows to fill available modal space */
.note-editor-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    overflow: hidden;
}

/* ── TipTap Toolbar ──────────────────────────────────────────────────── */
.tiptap-toolbar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-default) transparent;
    align-items: center;
    gap: 2px;
    padding: 5px 8px;
    background-color: var(--color-bg-tiptap-toolbar);
    border-bottom: 1px solid var(--color-border-default);
}

.tt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 5px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.tt-btn:hover {
    background-color: var(--color-accent-tint-soft);
    border-color: var(--color-accent-border-soft);
    color: var(--color-accent);
}

.tt-btn.active {
    background-color: var(--color-accent-tint-medium);
    border-color: var(--color-accent-border-bright);
    color: var(--color-accent);
}

.tt-sep {
    width: 1px;
    height: 18px;
    background-color: var(--color-border-strong);
    margin: 0 3px;
    flex-shrink: 0;
}

.tt-select {
    height: 26px;
    padding: 0 6px;
    background-color: var(--color-bg-tiptap-select);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.tt-select:hover,
.tt-select:focus {
    border-color: var(--color-accent-border-medium);
    outline: none;
    color: var(--color-text-bright);
}

.tt-font-select {
    max-width: 110px;
}

/* Color picker button */
.tt-color-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 5px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    position: relative;
}

.tt-color-label:hover {
    background-color: var(--color-accent-tint-soft);
    border-color: var(--color-accent-border-soft);
}

.tt-color-a {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 2px;
    pointer-events: none;
    user-select: none;
}

.tt-color-label:hover .tt-color-a { color: var(--color-accent); }

.tt-color-label input[type="color"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ── TipTap Editor Content Area — flex-fills the container ──────────── */
.tiptap-editor-content {
    background-color: var(--color-bg-tiptap-editor);
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    cursor: text;
    /* Dark scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) var(--color-bg-tiptap-scrollbar-track);
}

.tiptap-editor-content::-webkit-scrollbar       { width: 6px; }
.tiptap-editor-content::-webkit-scrollbar-track  { background: var(--color-bg-tiptap-scrollbar-track); }
.tiptap-editor-content::-webkit-scrollbar-thumb  { background-color: var(--color-border-strong); border-radius: var(--r-sm); }

.tiptap-editor-content .ProseMirror {
    padding: 14px 18px;
    min-height: 100%;
    box-sizing: border-box;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.65;
    color: var(--color-text-secondary);
}

.tiptap-editor-content .ProseMirror > * + * { margin-top: 0.45em; }

.tiptap-editor-content .ProseMirror p     { margin: 0 0 0.4em; }
.tiptap-editor-content .ProseMirror h1    { font-size: 1.6em;  font-weight: 700; margin: 0.8em 0 0.35em; color: var(--color-text-bright); }
.tiptap-editor-content .ProseMirror h2    { font-size: 1.3em;  font-weight: 600; margin: 0.75em 0 0.3em; color: var(--color-text-bright); }
.tiptap-editor-content .ProseMirror h3    { font-size: 1.12em; font-weight: 600; margin: 0.6em 0 0.25em; color: var(--color-text-bright); }

.tiptap-editor-content .ProseMirror ul,
.tiptap-editor-content .ProseMirror ol   { padding-left: 1.6em; margin: 0.3em 0; }
.tiptap-editor-content .ProseMirror li   { margin: 0.15em 0; }

.tiptap-editor-content .ProseMirror blockquote {
    border-left: 3px solid var(--color-border-strong);
    padding-left: 1em;
    color: var(--color-text-muted);
    margin: 0.5em 0;
}

.tiptap-editor-content .ProseMirror code {
    background-color: var(--color-bg-tiptap-code);
    border-radius: var(--r-sm);
    padding: 0.1em 0.35em;
    font-family: 'Courier New', monospace;
    font-size: 0.88em;
    color: var(--color-accent);
}

.tiptap-editor-content .ProseMirror pre {
    background-color: var(--color-bg-tiptap-pre);
    border: 1px solid var(--color-border-strong);
    border-top: 2px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    padding: 0.75em 1em 0.85em;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.87em;
    color: var(--color-text-code-light);
    position: relative;
    white-space: pre;
    tab-size: 4;
}

/* "CODE" label in the top-right corner of the code block */
.tiptap-editor-content .ProseMirror pre::before {
    content: 'CODE';
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    color: var(--color-text-deeper-muted);
    letter-spacing: 0.1em;
    pointer-events: none;
}

/* Reset inline-code styles when nested inside a block */
.tiptap-editor-content .ProseMirror pre code {
    background: none;
    border-radius: 0;
    padding: 0;
    font-size: inherit;
    color: inherit;
    font-family: inherit;
}

.tiptap-editor-content .ProseMirror hr {
    border: none;
    border-top: 1px solid var(--color-border-strong);
    margin: 1em 0;
}

/* Table styles */
.tiptap-editor-content .ProseMirror table {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
    margin: 0.6em 0;
}

.tiptap-editor-content .ProseMirror th,
.tiptap-editor-content .ProseMirror td {
    border: 1px solid var(--color-border-strong);
    padding: 6px 10px;
    font-size: 13px;
    vertical-align: top;
    min-width: 60px;
    position: relative;
}

.tiptap-editor-content .ProseMirror th {
    background-color: var(--color-bg-tiptap-th);
    color: var(--color-text-secondary);
    font-weight: 600;
}

.tiptap-editor-content .ProseMirror .selectedCell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-accent-tint-table-cell);
    pointer-events: none;
}

/* ── Details / Summary (collapsible block) ─────────────────────────────────── */
/*
 * TipTap v3 Details uses custom NodeViews in the editor:
 *   div[data-type="details"]          — outer container (has .is-open when expanded)
 *     button                          — toggle arrow (no text, styled via ::before)
 *     div                             — contentDOM wrapper
 *       summary                       — editable title
 *       div[data-type="detailsContent"] — body (hidden attr toggled by JS)
 *
 * Saved/rendered HTML uses native elements:
 *   <details>
 *     <summary>Title</summary>
 *     <div data-type="detailsContent">Body</div>
 *   </details>
 */

/* ── Editor (NodeView-based) ── */
.tiptap-editor-content .ProseMirror div[data-type="details"] {
    display: flex;
    align-items: flex-start;   /* button only as tall as the summary row */
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
    margin: 0.6em 0;
    background: transparent;   /* inherits editor background — no extra dark box */
}

/* Arrow toggle button — matches summary vertical padding so arrow centers on that line */
.tiptap-editor-content .ProseMirror div[data-type="details"] > button {
    flex-shrink: 0;
    align-self: flex-start;
    border: none;
    background: none;
    color: var(--color-accent);
    cursor: pointer;
    padding: 7px 5px 7px 8px;  /* mirrors summary 7px top/bottom so arrow is centered on it */
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tiptap-editor-content .ProseMirror div[data-type="details"] > button::before {
    content: '▸';
    display: inline-block;
    transition: transform 0.2s;
}
.tiptap-editor-content .ProseMirror div[data-type="details"].is-open > button::before {
    transform: rotate(90deg);
}

/* ContentDOM wrapper div */
.tiptap-editor-content .ProseMirror div[data-type="details"] > div {
    flex: 1;
    min-width: 0;
}

/* Editable summary row inside editor */
.tiptap-editor-content .ProseMirror div[data-type="details"] summary {
    padding: 7px 12px 7px 0;
    font-weight: 600;
    color: var(--color-accent);
    list-style: none;
    display: block;
}

/* Body content (hidden attribute toggled by the NodeView JS) */
.tiptap-editor-content .ProseMirror div[data-type="detailsContent"] {
    padding: 8px 12px 10px 0;
    border-top: 1px solid var(--color-border-strong);
}
/* Ensure the hidden attribute always collapses content even if CSS resets interfere */
.tiptap-editor-content .ProseMirror div[data-type="detailsContent"][hidden] {
    display: none !important;
}

/* ── Rendered HTML in notes / about (native <details>) ── */
.note-content details,
.about-content details {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
    margin: 0.6em 0;
    background: transparent;
    overflow: hidden;
}

.note-content details summary,
.about-content details summary {
    padding: 7px 12px 7px 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-accent);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: background 0.15s;
}
.note-content details summary:hover,
.about-content details summary:hover {
    background: var(--color-accent-tint-faint);
}

.note-content details summary::before,
.about-content details summary::before {
    content: '▸';
    font-size: 10px;
    display: inline-block;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.note-content details[open] summary::before,
.about-content details[open] summary::before {
    transform: rotate(90deg);
}

.note-content details div[data-type="detailsContent"],
.about-content details div[data-type="detailsContent"] {
    padding: 8px 14px 10px;
    border-top: 1px solid var(--color-border-strong);
}

/* ── AI Block ─────────────────────────────────────────────────────────────── */

.tiptap-editor-content .ProseMirror .ai-block,
.note-content .ai-block,
.about-content .ai-block {
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
    margin: 0.8em 0;
    background: transparent;
    overflow: hidden;
}

.ai-block-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--color-accent-tint-subtle);
    border-bottom: 1px solid var(--color-border-strong);
}

.ai-block-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.ai-block-model-select {
    flex: 1;
    min-width: 0;
    background: var(--color-bg-tiptap-scrollbar-track);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-code-light-alt);
    font-size: 11px;
    padding: 3px 6px;
    cursor: pointer;
}
.ai-block-model-select:focus { outline: none; border-color: var(--color-border-focus); }

.ai-block-repeat-select {
    flex-shrink: 0;
    background: var(--color-bg-tiptap-scrollbar-track);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    color: var(--color-text-deep-muted);
    font-size: 10px;
    padding: 3px 5px;
    cursor: pointer;
    max-width: 80px;
}
.ai-block-repeat-select:focus { outline: none; border-color: var(--color-border-focus); color: var(--color-text-code-light-alt); }
.ai-block-repeat-select:not(:has(option[value=""]:checked)) { color: var(--color-accent); }

.ai-block-last-run {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--color-text-light-blue);
    white-space: nowrap;
    padding: 0 4px;
    opacity: 0.85;
}

.ai-block-gen-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-border-soft);
    border-radius: var(--r-sm);
    color: var(--color-accent);
    font-size: 11px;
    padding: 3px 9px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.ai-block-gen-btn:hover   { background: var(--color-accent-tint-medium); border-color: var(--color-accent); }
.ai-block-gen-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-block-section-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-deep-muted);
    padding: 5px 12px 3px;
    cursor: default;
    user-select: none;
}

.ai-section-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-text-deep-muted);
    cursor: pointer;
    padding: 0 2px;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-section-toggle:hover { color: var(--color-accent); }

.ai-block-prompt-section {
    border-bottom: 1px solid var(--color-border-strong);
}

.ai-block-prompt-content {
    padding: 6px 12px 8px;
    min-height: 2.5em;
}
.ai-block-prompt-content p { margin: 0 0 0.3em; }

.ai-block-response-section { }

.ai-block-response-content {
    padding: 8px 12px 10px;
    color: var(--color-text-secondary);
    font-size: 0.92em;
    line-height: 1.6;
}
.ai-block-response-content p    { margin: 0 0 0.5em; }
.ai-block-response-content ul,
.ai-block-response-content ol   { padding-left: 1.4em; margin: 0.3em 0; }
.ai-block-response-content h4   { font-size: 0.95em; color: var(--color-text-bright); margin: 0.6em 0 0.2em; }
.ai-block-response-content strong { color: var(--color-text-bright); }

.ai-muted  { color: var(--color-text-deep-muted); font-style: italic; }
.ai-error  { color: var(--color-status-danger); }

/* ── Placeholder ── */
/* Placeholder */
.tiptap-editor-content .ProseMirror p.is-editor-empty:first-child::before {
    content: 'Start writing your note…';
    color: var(--color-text-deep-muted);
    pointer-events: none;
    float: left;
    height: 0;
}

/* Collapsible sections in content preview on cards */
.note-card-content details {
    pointer-events: none;
}

.note-card-content details summary {
    list-style: none;
}

.note-card-content details summary::before {
    content: '▶ ';
}

/* Note Modified Timestamp */
.note-modified {
    font-size: 9px;
    color: var(--color-text-muted);
}

/* =============================================================================
   NOTE MODAL — SPLIT-PANE LAYOUT
   ============================================================================= */

/* When split is active the modal widens to use available viewport */
#note-modal-dialog.split-active {
    width: 95vw;
    max-width: 95vw;
}

/* Split control buttons in the modal header */
.note-split-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.note-split-btn,
.note-split-orient-btn,
.note-split-close-btn,
.note-split-clear-btn {
    white-space: nowrap;
}
.note-split-close-btn {
    color: var(--color-text-muted);
    border-color: var(--color-text-muted);
}
.note-split-close-btn:hover {
    color: var(--color-status-danger);
    border-color: var(--color-status-danger);
    background: var(--color-status-danger-tint-soft);
}
.note-split-clear-btn {
    color: var(--color-status-danger);
    border-color: var(--color-status-danger);
}
.note-split-clear-btn:hover {
    background: var(--color-status-danger-tint-soft);
}

/* Split container — fills the form's available space */
.note-split-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column; /* no-split: editor pane fills column */
    --split-ratio: 50%;
}

/* Vertical split (side by side) */
.note-split-container.split-vertical {
    flex-direction: row;
}

/* Horizontal split (top / bottom) */
.note-split-container.split-horizontal {
    flex-direction: column;
}

/* ── Editor pane ─────────────────────────────────────────────────────────── */
.note-editor-pane {
    flex: 1;          /* fills all space when no split */
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.note-split-container.split-vertical .note-editor-pane,
.note-split-container.split-horizontal .note-editor-pane {
    flex: 0 0 var(--split-ratio, 50%);
}

/* ── Resizer ─────────────────────────────────────────────────────────────── */
.note-split-resizer {
    display: none;
    flex-shrink: 0;
    background: var(--color-border-default);
    position: relative;
    z-index: 2;
    transition: background 0.15s;
}
.note-split-container.split-vertical .note-split-resizer {
    display: block;
    width: 5px;
    cursor: col-resize;
}
.note-split-container.split-horizontal .note-split-resizer {
    display: block;
    height: 5px;
    cursor: row-resize;
}
.note-split-resizer:hover,
.note-split-resizer.dragging {
    background: var(--color-accent);
}
/* Widen the hit-target with an invisible pseudo-element */
.note-split-container.split-vertical .note-split-resizer::before {
    content: '';
    position: absolute;
    inset: 0 -4px;
}
.note-split-container.split-horizontal .note-split-resizer::before {
    content: '';
    position: absolute;
    inset: -4px 0;
}

/* ── Inline AI conversation pane ────────────────────────────────────────── */
.note-conv-pane {
    display: none;  /* hidden until split activates */
    flex: 1;
    min-height: 0;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    background: var(--palette-navy-900);
}
.note-split-container.split-vertical .note-conv-pane {
    display: flex;
    border-left: 1px solid var(--color-border-default);
}
.note-split-container.split-horizontal .note-conv-pane {
    display: flex;
    border-top: 1px solid var(--color-border-default);
}

/* The inline conv pane's messages thread grows to fill available height */
.note-conv-pane .conversation-messages {
    flex: 1;
    min-height: 0;
}

/* Notice shown when the note hasn't been saved yet */
.inline-conv-unsaved-notice {
    flex-shrink: 0;
    padding: 6px 12px;
    background: var(--color-status-warning-tint-soft);
    border-bottom: 1px solid var(--color-status-warning-tint-strong);
    color: var(--color-status-warning);
    font-size: 11px;
    text-align: center;
}

/* =============================================================================
   END NOTE MODAL — SPLIT-PANE LAYOUT
   ============================================================================= */

/* Note Modal Footer */
#note-form .modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    padding-bottom: 16px;
    border-top: none;
    flex-shrink: 0;
}

#note-form .modal-footer .modal-actions {
    display: flex;
    gap: 8px;
}

/* Responsive Grid Breakpoints */
@media (max-width: 600px) {
    .notes-grid {
        grid-template-columns: 1fr;
    }
    
    .note-options-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .modal-xl {
        width: 95%;
    }
}

/* =============================================================================
   AI CONVERSATION — RIGHT-SIDE DRAWER PANEL
   ============================================================================= */

/* Backdrop */
.conversation-panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--color-overlay-backdrop);
    z-index: 1090;
}
.conversation-panel-backdrop.active { display: block; }

/* Drawer */
.conversation-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: 100vw;
    background: var(--palette-navy-900);
    border-left: 1px solid var(--color-border-default);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-drawer);
}
.conversation-panel.active {
    transform: translateX(0);
}

/* Header */
.conversation-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 12px 16px;
    border-bottom: 1px solid var(--color-border-default);
    flex-shrink: 0;
    background: var(--palette-navy-800);
    gap: 10px;
}
.conversation-panel-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}
.conversation-label {
    font-size: 10px;
    color: var(--color-accent);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.conversation-note-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-panel-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 0;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    transition: color 0.15s, background 0.15s;
}
.conv-panel-close:hover { color: var(--color-text-bright); background: var(--color-overlay-row-hover); }

/* System message bar */
.conv-system-bar {
    flex-shrink: 0;
    padding: 8px 14px;
    background: var(--color-bg-detail-content);
    border-bottom: 1px solid var(--color-border-default);
}
.conv-system-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.conv-system-label {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    font-weight: 600;
}
.conv-system-select {
    flex: 1;
    min-width: 0;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 3px 6px;
    cursor: pointer;
}
.conv-system-select:focus { outline: none; border-color: var(--color-border-focus); }
.conv-system-edit-btn {
    white-space: nowrap;
    flex-shrink: 0;
}
.conv-system-custom {
    width: 100%;
    margin-top: 8px;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-accent);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 6px 8px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
}
.conv-system-custom:focus { outline: none; }
.conv-system-custom::placeholder { color: var(--color-text-disabled); }

/* Collapsible note context bar */
.conversation-context-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-detail-content);
}
.conversation-context-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-muted);
    user-select: none;
}
.conversation-context-toggle:hover { color: var(--color-text-secondary); }
.conversation-context-toggle .collapse-icon { transition: transform 0.2s; }
.conversation-context-content {
    padding: 0 14px 10px;
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    max-height: 160px;
    overflow-y: auto;
    border-top: 1px solid var(--color-border-default);
}

/* Scrollable messages thread */
.conversation-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}
.conversation-empty {
    color: var(--color-text-disabled);
    font-size: 13px;
    font-style: italic;
    text-align: center;
    margin: auto;
}

/* Message bubbles */
.conv-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 94%;
}
.conv-message--user    { align-self: flex-end; }
.conv-message--assistant { align-self: flex-start; }

.conv-message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--color-text-disabled);
}
.conv-role-label { font-weight: 600; color: var(--color-text-muted); }
.conv-role-ai    { color: var(--color-accent); }
.conv-model      { font-size: 10px; color: var(--color-text-disabled); font-style: italic; }
.conv-tokens     { font-size: 10px; color: var(--color-text-disabled); }
.conv-time       { font-size: 10px; color: var(--color-text-disabled); margin-left: auto; }

/* Per-message delete button */
.conv-msg-delete {
    background: transparent;
    border: none;
    color: var(--color-text-disabled);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    border-radius: var(--r-sm);
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.conv-msg-delete:hover { color: var(--color-status-danger); background: var(--color-status-danger-tint-soft); }

.conv-message-body {
    padding: 9px 12px;
    border-radius: var(--r-lg);
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}
.conv-message--user .conv-message-body {
    background: var(--color-bg-conv-user-bubble);
    color: var(--color-text-bright);
    border-bottom-right-radius: var(--r-sm);
}
.conv-message--assistant .conv-message-body {
    background: var(--color-bg-detail-content);
    border: 1px solid var(--color-border-default);
    color: var(--color-text-secondary);
    border-bottom-left-radius: var(--r-sm);
}
/* Rich HTML inside assistant messages */
.conv-message--assistant .conv-message-body h4 { color: var(--color-accent); margin: 10px 0 4px; font-size: 13px; }
.conv-message--assistant .conv-message-body p  { margin: 0 0 6px; }
.conv-message--assistant .conv-message-body ul { margin: 0 0 6px 18px; }
.conv-message--assistant .conv-message-body li { margin-bottom: 2px; }
.conv-message--assistant .conv-message-body strong { color: var(--color-text-bright); }
.conv-message--assistant .conv-message-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; }
.conv-message--assistant .conv-message-body th { background: var(--color-bg-card); color: var(--color-accent); padding: 4px 8px; border: 1px solid var(--color-border-default); text-align: left; }
.conv-message--assistant .conv-message-body td { padding: 4px 8px; border: 1px solid var(--color-border-default); }

/* Input area */
.conversation-input-area {
    flex-shrink: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border-default);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--palette-navy-900);
}
.conversation-model-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.conversation-model-label {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.conversation-model-select {
    flex: 1;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 4px 6px;
}
.conversation-model-select:focus { outline: none; border-color: var(--color-border-focus); }
/* Compact variant — sits inline next to the Send button, no flex expansion */
.conv-model-compact {
    flex: 0 1 160px;
    min-width: 80px;
    max-width: 200px;
}
/* Context-insert buttons row above the textarea */
.conv-context-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.conv-ctx-btn {
    font-size: 11px;
    padding: 2px 8px;
    border-color: var(--color-border-default);
    color: var(--color-text-muted);
    background: var(--color-bg-conv-context-btn);
}
.conv-ctx-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-bg-conv-context-btn-hover);
}
.conversation-input {
    width: 100%;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    color: var(--color-text-secondary);
    font-size: 13px;
    padding: 8px 10px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.conversation-input:focus { outline: none; border-color: var(--color-border-focus); }
.conversation-input::placeholder { color: var(--color-text-disabled); }
.conversation-actions-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.conversation-status {
    font-size: 11px;
    color: var(--color-text-disabled);
    margin-right: auto;
    transition: color 0.4s;
}
/* Pulsing amber while a request is in flight (text starts with "Waiting") */
.conversation-status:not(:empty) {
    color: var(--color-text-muted);
}
@keyframes conv-status-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}
.conversation-status.waiting {
    color: var(--color-status-amber);
    animation: conv-status-pulse 1.4s ease-in-out infinite;
}

/* =============================================================================
   END AI CONVERSATION DRAWER
   ============================================================================= */

/* =============================================================================
   SYSTEM MESSAGES MANAGER MODAL
   ============================================================================= */

.sysmsgs-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.sysmsgs-count {
    font-size: 12px;
    color: var(--color-text-muted);
}
.sysmsgs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 55vh;
    overflow-y: auto;
}
.sysmsgs-empty {
    color: var(--color-text-disabled);
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 24px 0;
}
.sysmsg-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 10px 12px;
    transition: border-color 0.15s;
}
.sysmsg-row:hover { border-color: var(--color-border-strong-hover); }
.sysmsg-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sysmsg-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-bright);
}
.sysmsg-default-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--r-sm);
    padding: 1px 4px;
    margin-left: 6px;
    vertical-align: middle;
}
.sysmsg-desc {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sysmsg-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.btn-danger-xs {
    color: var(--color-status-danger);
    border-color: var(--color-status-danger);
}
.btn-danger-xs:hover {
    background: var(--color-status-danger-tint-soft);
}

/* Edit form */
.sysmsgs-edit-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
}

/* ── Memories section in system message editor ─────────────────────────── */
.memories-list {
    min-height: 28px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.memories-empty,
.memories-loading {
    font-size: 12px;
    color: var(--color-text-muted);
    font-style: italic;
    padding: 4px 0;
}
.memory-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 8px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    font-size: 12px;
    line-height: 1.4;
}
.memory-text {
    flex: 1;
    color: var(--color-text-primary);
    word-break: break-word;
}
.memory-delete-btn {
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.memory-delete-btn:hover { opacity: 1; }
.memory-source-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: var(--r-sm);
    margin-left: 4px;
    vertical-align: middle;
}
.memory-source-ai {
    background: var(--color-memory-ai-bg);
    color: var(--color-memory-ai-fg);
    border: 1px solid var(--color-memory-ai-border);
}
.memories-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.memories-add-row .form-input {
    flex: 1;
}

/* ── System prompt name badge on AI messages ──────────────────────────── */
.conv-sys-name {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    background: var(--color-sysmsg-bg);
    color: var(--color-sysmsg-fg);
    border: 1px solid var(--color-sysmsg-border);
    margin-left: 4px;
    vertical-align: middle;
    cursor: default;
}
.form-row {
    margin-bottom: 12px;
}
.form-row--inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.form-label {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}
.form-label-inline {
    font-size: 12px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-hint {
    font-weight: 400;
    color: var(--color-text-disabled);
}
.form-input {
    width: 100%;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 13px;
    padding: 6px 8px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--color-border-focus); }
.form-input-sm {
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 3px 6px;
    font-family: inherit;
}
.form-textarea {
    width: 100%;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 13px;
    padding: 8px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.form-textarea:focus { outline: none; border-color: var(--color-border-focus); }

/* =============================================================================
   END SYSTEM MESSAGES MANAGER
   ============================================================================= */

/* =============================================================================
   PRICE SOURCE BADGE (portfolio table — shows when price is AH / PM / Close)
   ============================================================================= */

.price-cell {
    white-space: nowrap;
}

.price-source-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 1px 4px;
    border-radius: var(--r-sm);
    vertical-align: middle;
    margin-left: 4px;
    line-height: 14px;
    text-transform: uppercase;
}

/* After-hours — amber */
.ps-afterhours {
    background: var(--color-ps-afterhours-bg);
    color: var(--color-ps-afterhours-fg);
    border: 1px solid var(--color-ps-afterhours-border);
}
/* Pre-market — blue */
.ps-premarket {
    background: var(--color-ps-premarket-bg);
    color: var(--color-ps-premarket-fg);
    border: 1px solid var(--color-ps-premarket-border);
}
/* Today's close — muted green */
.ps-close {
    background: var(--color-ps-close-bg);
    color: var(--color-ps-close-fg);
    border: 1px solid var(--color-ps-close-border);
}
/* Previous close — gray, warning state */
.ps-prevclose {
    background: var(--color-ps-prevclose-bg);
    color: var(--color-ps-prevclose-fg);
    border: 1px solid var(--color-ps-prevclose-border);
}

/* =============================================================================
   FLOATING NOTE WINDOWS
   ============================================================================= */

/* Container fills viewport but pointer-events: none lets clicks reach the page */
#note-windows-container {
    /* display:contents so this wrapper creates NO box and NO stacking context — its
       position:fixed note windows then join the ROOT stacking context and interleave by
       z-index with every other window type (symbol, comms, etc.). A position:fixed wrapper
       with a z-index would trap them in a private layer that can never rise above other
       windows, which was the "note windows always on top / never restack" bug. */
    display: contents;
}

.note-window {
    position: fixed;
    pointer-events: all;
    background: color-mix(in srgb, var(--nw-color, var(--color-accent)) 12%, var(--color-bg-note-window-base) 88%);
    border: 1px solid var(--color-border-note-window);
    border-top: 3px solid var(--nw-color, var(--color-accent));
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-note-window);
    min-width: 440px;
    min-height: 320px;
    width: 680px;
    height: 560px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;           /* native browser resize handle */
}

/* Maximized state — fills the viewport. Mirrors .sdw.maximized so both window
   types behave the same. !important overrides the inline left/top/width/height
   the drag/resize code writes; restoring re-applies the saved values. */
.note-window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
    border-radius: 0 !important;
    resize: none !important;
}
.note-window.maximized .nw-titlebar {
    cursor: default;
    border-radius: 0;
}

/* Title bar — drag handle */
.nw-titlebar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px 6px 10px;
    background: color-mix(in srgb, var(--nw-color, var(--color-accent)) 8%, var(--color-bg-note-window-titlebar-base) 92%);
    border-bottom: 1px solid var(--color-border-default);
    cursor: grab;
    user-select: none;
    border-radius: var(--r-md) var(--r-md) 0 0;
    min-height: 34px;
    flex-shrink: 0;
}
.nw-titlebar:active { cursor: grabbing; }

/* ── Titlebar inline color picker ───────────────────────────────────────── */
.nw-color-pick {
    position: relative;
    flex-shrink: 0;
}

.nw-color-swatch-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--color-overlay-ring-faint);
    cursor: pointer;
    padding: 0;
    display: block;
    transition: border-color 0.15s, transform 0.1s;
    box-shadow: var(--shadow-note-swatch);
}
.nw-color-swatch-btn:hover {
    border-color: var(--color-overlay-ring-strong);
    transform: scale(1.15);
}

.nw-color-picker-popup {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--palette-navy-950);
    border: 1px solid var(--color-border-note-window);
    border-radius: var(--r-md);
    padding: 6px;
    box-shadow: var(--shadow-note-popover);
    z-index: 100;
    display: grid;
    grid-template-columns: repeat(5, 18px);
    gap: 5px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s;
}
.nw-color-picker-popup.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.nw-cp-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    background: var(--sw);
    transition: transform 0.1s, border-color 0.1s;
}
.nw-cp-swatch:hover   { transform: scale(1.2); border-color: var(--color-overlay-ring-medium); }
.nw-cp-swatch.selected { border-color: var(--palette-white); box-shadow: var(--shadow-swatch-selected-ring); }

.nw-title-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 5px currentColor;
}

.nw-title-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nw-titlebar-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.nw-btn {
    padding: 2px 8px;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--color-border-note-window);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1.5;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nw-btn:hover          { border-color: var(--color-accent); color: var(--color-accent); }
.nw-btn:disabled       { opacity: 0.35; cursor: default; pointer-events: none; }
.nw-ai-btn             { color: var(--color-accent); border-color: var(--color-accent-border-soft); }
.nw-ai-btn:hover       { background: var(--color-accent-tint-soft); }
.nw-close-btn:hover    { color: var(--color-status-danger); border-color: var(--color-status-danger); background: var(--color-status-danger-tint-soft); }

/* Window body */
.nw-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.nw-title-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--color-border-default);
    flex-shrink: 0;
}
.nw-title-row:focus-within {
    border-bottom-color: var(--nw-color, var(--color-accent));
}

.nw-title-input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 9px 12px;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 15px;
    font-weight: 500;
    outline: none;
}
.nw-title-input[readonly] {
    color: var(--color-text-muted);
    cursor: default;
}
.nw-title-input::placeholder { color: var(--color-text-note-placeholder); }

.nw-title-lock-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.15s;
    line-height: 1;
}
.nw-title-lock-btn:hover  { opacity: 0.85; }
.nw-title-lock-btn.active { opacity: 1; }

/* Editor area grows to fill available space */
.nw-editor-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.nw-editor-area .tiptap-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}
.nw-editor-area .tiptap-editor-content {
    flex: 1;
}

/* Footer tabs */
.nw-footer-tabs {
    flex-shrink: 0;
    border-top: 1px solid var(--color-border-default);
}
.nw-tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--color-border-default);
    /* Hide nav if only one tab is present */
}
.nw-tabs-nav:has(.nw-tab-btn:only-child) { display: none; }
.nw-tab-btn {
    padding: 4px 14px;
    font-size: 11px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-note-tab-inactive);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.15s, border-color 0.15s;
}
.nw-tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.nw-tab-btn:hover  { color: var(--color-text-muted); }

.nw-tab-panel         { display: none; padding: 6px 12px; }
.nw-tab-panel.active  { display: block; }
.nw-props-panel       { overflow-y: auto; max-height: 90px; }
.nw-props-row         { padding: 6px 0 2px; }

/* ── Properties panel (metadata editor) ─────────────────────────────────── */
.nw-props {
    border-top: 1px solid var(--color-border-default);
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-props);
    flex-shrink: 0;
}
.nw-props-summary {
    padding: 5px 10px;
    font-size: 11px;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    user-select: none;
}
.nw-props-summary::-webkit-details-marker { display: none; }
.nw-props-summary::before {
    content: "▸";
    font-size: 9px;
    color: var(--color-text-note-tab-inactive);
    flex-shrink: 0;
}
details[open] > .nw-props-summary::before { content: "▾"; }

.nw-props-summary-label { font-weight: 600; color: var(--color-text-secondary); letter-spacing: 0.5px; text-transform: uppercase; font-size: 10px; flex-shrink: 0; }
/* Collapsed Properties: one chip per set property on the header row, scrolling sideways. */
.nw-props-chips { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden; padding: 1px 0; }
.note-window .nw-props-summary .nw-props-title { flex: 0 0 auto; white-space: nowrap; }   /* never wraps under its icon when the chips are long (2026-11-12) */
.nw-props-chips.nw-props-chips-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.nw-props-chip { flex: 0 0 auto; padding-right: 8px; cursor: pointer; }
.nw-props-chip .nw-props-chip-k { font-size: 9px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); margin-right: 4px; }
.nw-props-chip .nw-linked-chip-title { white-space: nowrap; max-width: 220px; }
.nw-props-chip-deprecated { border-color: var(--color-status-error); color: var(--color-status-error); background: var(--color-status-error-tint-soft); }
.nw-props-summary-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: var(--shadow-priority-dot-ring);
    flex-shrink: 0;
    vertical-align: middle;
}
.nw-props-summary-tag {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-text-muted);
    background: var(--color-bg-slate-overlay-faint);
    padding: 1px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 0.5px;
}
.nw-props-summary-version {
    font-size: 10px;
    color: var(--color-text-muted);
    font-family: monospace;
}
.nw-props-summary-deprecated {
    font-size: 9px;
    font-weight: 700;
    color: var(--color-status-error);
    background: var(--color-status-error-tint-soft);
    padding: 1px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 1px;
}

.nw-props-body {
    padding: 8px 12px 10px;
    border-top: 1px dashed var(--color-border-default);
    max-height: 280px;
    overflow-y: auto;
}

.nw-props-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    align-items: end;
}
.nw-props-grid > label {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    color: var(--color-text-muted);
    gap: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.nw-props-grid > label.nw-prop-check-label {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 14px;
}
.nw-props-grid > label.nw-prop-deprecated-reason-row {
    grid-column: 1 / -1;
}
.nw-props-grid select,
.nw-props-grid input[type="text"],
.nw-props-grid input[type="date"] {
    padding: 4px 6px;
    background: var(--color-bg-note-window-input);
    border: 1px solid var(--color-border-default);
    color: var(--color-text-bright);
    border-radius: var(--r-sm);
    font-size: 12px;
    outline: none;
    text-transform: none;
    letter-spacing: normal;
}
.nw-props-grid select:focus,
.nw-props-grid input:focus {
    border-color: var(--nw-color, var(--color-accent));
}
.nw-prop-date-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nw-prop-date-row input { flex: 1; }

.nw-props-raw {
    margin-top: 10px;
    border-top: 1px dashed var(--color-border-default);
    padding-top: 8px;
}
.nw-props-raw summary {
    font-size: 10px;
    color: var(--color-text-note-tab-inactive);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 0;
}
.nw-props-raw textarea {
    width: 100%;
    margin-top: 6px;
    padding: 6px 8px;
    background: var(--color-bg-note-window-input);
    border: 1px solid var(--color-border-default);
    color: var(--color-text-bright);
    border-radius: var(--r-sm);
    font-size: 11px;
    font-family: monospace;
    outline: none;
    resize: vertical;
    min-height: 60px;
}
.nw-props-raw-help {
    font-size: 10px;
    color: var(--color-text-note-tab-inactive);
    margin: 4px 0 0;
}

/* ── Linked Notes row (relatedGuids chip editor) ────────────────────────── */
.nw-linked-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-input);
    flex-wrap: wrap;
    position: relative;
    flex-shrink: 0;
}
.nw-linked-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.nw-linked-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.nw-linked-empty {
    font-size: 11px;
    color: var(--color-text-note-tab-inactive);
    font-style: italic;
}
.nw-linked-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 3px 2px 8px;
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-tint-medium);
    border-radius: var(--r-lg);
    font-size: 11px;
    color: var(--color-text-secondary);
    cursor: pointer;
    max-width: 200px;
    transition: background 0.15s, border-color 0.15s;
}
.nw-linked-chip:hover {
    background: var(--color-accent-tint-medium);
    border-color: var(--color-accent-border-medium);
}
.nw-linked-chip-backlink {
    background: var(--color-bg-slate-overlay-soft);
    border-color: var(--color-border-otm-badge);
}
.nw-linked-chip-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}
.nw-linked-chip-x {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 3px;
    font-size: 13px;
    line-height: 1;
    border-radius: 50%;
}
.nw-linked-chip-x:hover { color: var(--color-status-error); background: var(--color-status-error-tint-soft); }

/* ── Linked-note picker dialog (search + select) ─────────────────────────── */
.nw-link-picker-modal { max-width: 540px; display: flex; flex-direction: column; }
.nw-link-picker-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px 20px;
}
.nw-link-picker-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 1px solid var(--color-border-default);
    color: var(--color-text-primary);
    border-radius: var(--r-md);
    font-size: 13px;
    outline: none;
}
.nw-link-picker-input:focus { border-color: var(--color-accent); }
.nw-link-picker-results {
    overflow-y: auto;
    max-height: 52vh;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 4px;
}
.nw-link-picker-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
}
.nw-link-picker-item:hover,
.nw-link-picker-item.active { background: var(--color-accent-tint-soft, color-mix(in srgb, var(--color-accent) 14%, transparent)); }
.nw-link-picker-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nw-link-picker-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--color-text-secondary);
}
.nw-link-picker-syms { font-variant-numeric: tabular-nums; }
.nw-link-picker-dot { color: var(--color-text-disabled); }
.nw-link-picker-empty {
    padding: 14px 10px;
    font-size: 12px;
    color: var(--color-text-secondary);
    font-style: italic;
    text-align: center;
    margin: 0;
}

.nw-linked-backlinks-btn {
    background: transparent;
    border: 1px dashed var(--color-border-default);
    color: var(--color-text-muted);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    letter-spacing: 0.3px;
}
.nw-linked-backlinks-btn:hover { color: var(--color-accent); border-color: var(--color-accent-border-medium); }

.nw-linked-backlinks {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--color-border-default);
    margin-top: 4px;
}
.nw-linked-backlinks-label {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-right: 2px;
}

/* ── History drawer ─────────────────────────────────────────────────────── */
.nw-history-drawer {
    border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-props);
    flex-shrink: 0;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}
.nw-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-input);
}
.nw-history-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: row;
}
.nw-history-list {
    flex: 0 0 40%;
    border-right: 1px solid var(--color-border-default);
    overflow-y: auto;
    padding: 4px 0;
}
.nw-history-item {
    padding: 5px 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 6px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-note-window-faint);
    font-size: 11px;
    color: var(--color-text-secondary);
}
.nw-history-item:hover { background: var(--color-accent-tint-subtle); }
.nw-history-item.active { background: var(--color-accent-tint-soft); }
.nw-history-item-when { color: var(--color-text-muted); font-size: 10px; grid-column: 1; }
.nw-history-item-type {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
}
.nw-history-type-update { background: var(--color-accent-tint-medium); color: var(--color-accent); }
.nw-history-type-delete { background: var(--color-status-error-tint-soft); color: var(--color-status-error); }
.nw-history-item-title {
    grid-column: 1 / -1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.nw-history-preview {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--color-text-secondary);
}
.nw-history-restore-btn { margin-left: auto; white-space: nowrap; }
.nw-history-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border-default);
}
.nw-history-preview-content {
    line-height: 1.5;
}
.nw-history-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--color-text-secondary);
    background: var(--color-bg-slate-overlay-faint);
    padding: 1px 6px;
    border-radius: var(--r-sm);
    letter-spacing: 0.3px;
}
.nw-history-empty {
    font-size: 11px;
    color: var(--color-text-note-tab-inactive);
    font-style: italic;
    padding: 10px;
    margin: 0;
}

.nw-color-preview {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--color-border-default);
    cursor: pointer;
    flex-shrink: 0;
}

/* Footer action bar */
.nw-footer {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-note-window-props);
    gap: 6px;
    flex-shrink: 0;
}

.nw-symbols-footer {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid var(--color-border-note-window-soft);
    border-radius: var(--r-sm);
    color: var(--color-text-muted);
    font-size: 11px;
    padding: 3px 7px;
    outline: none;
    transition: border-color 0.15s, color 0.15s;
}
.nw-symbols-footer::placeholder { color: var(--color-bg-disabled); }
.nw-symbols-footer:focus { border-color: var(--nw-color, var(--color-accent)); color: var(--color-text-secondary); }

.nw-footer-right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* "Modified: …" timestamp shown in the footer, between the symbols input
   (which is flex:1) and the right-side Close/Save button group. */
.nw-modified-text {
    font-size: 10px;
    color: var(--color-text-note-placeholder);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.2px;
}
.nw-modified-text:empty { display: none; }   /* hide gap on brand-new (unsaved) notes */

/* Split container */
.nw-split-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;   /* default: unsplit (editor fills everything) */
    overflow: hidden;
}
.nw-split-container.split-vertical  { flex-direction: row;    }
.nw-split-container.split-horizontal{ flex-direction: column; }

/* Editor pane always shown */
.nw-editor-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drag resizer */

/* AI conversation pane */
.nw-conv-pane {
    flex: 1 1 42%;      /* can grow AND shrink so it tracks window resize */
    min-width: 240px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--color-border-default);
}

/* ── Channels pane (Channels-in-Notes) ── */
.nw-ch-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 8px; border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-slate-overlay-soft);
}
.nw-ch-tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.nw-ch-bar-tools { flex: 0 0 auto; }
.nw-ch-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: var(--r-xl); font-size: 12px; cursor: pointer;
    border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary);
    max-width: 180px;
}
.nw-ch-tab .nw-ch-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-ch-tab:hover { background: var(--color-overlay-row-hover); }
.nw-ch-tab.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.nw-ch-unread {
    font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: var(--r-lg);
    background: var(--color-danger, #d9534f); color: #fff;
}
.nw-ch-detach { opacity: 0.5; font-weight: 700; padding: 0 2px; }
.nw-ch-detach:hover { opacity: 1; color: var(--color-danger, #d9534f); }
.nw-ch-none { font-size: 12px; color: var(--color-text-tertiary, var(--color-text-secondary)); padding: 2px 4px; }

.nw-ch-attach-panel {
    padding: 6px 8px; border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-modal, var(--color-bg-secondary));
    max-height: 200px; overflow-y: auto;
}
.nw-chap-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.nw-chap-item {
    padding: 3px 9px; border-radius: var(--r-xl); font-size: 12px; cursor: pointer;
    border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-primary);
}
.nw-chap-item:hover { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.nw-ch-messages { flex: 1; }
.nw-ch-input-area { border-top: 1px solid var(--color-border-default); padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; }
.nw-ch-actions-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.nw-ch-actions-row .conversation-status { margin-right: auto; font-size: 11px; opacity: 0.6; }

/* Rich-text message editor host — matches the note body (dark text on a light surface). */
.nw-ch-editor-host {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    background: var(--color-bg-note-window-base, #fbfbfb);
    overflow: hidden;
}
.nw-ch-editor-host .tiptap-editor-content {
    min-height: 52px;
    max-height: 150px;
    overflow-y: auto;
    padding: 6px 8px;
    background: var(--color-bg-note-window-base, #fbfbfb);
    color: var(--color-text-primary);
}
/* Keep the shared editor toolbar tidy inside the small input area. */
.nw-ch-editor-host .tiptap-toolbar { border-bottom: 1px solid var(--color-border-default); }
.nw-split-container.split-horizontal .nw-conv-pane {
    border-left: none;
    border-top: 1px solid var(--color-border-default);
    flex: 1 1 45%;
    min-height: 180px;
}

/* ── Notes graph pane (in-note, mirrors the AI conv pane) ─────────────────── */
.nw-graph-pane {
    flex: 1 1 42%;
    min-width: 240px;
    min-height: 180px;
    overflow: hidden;
    border-left: 1px solid var(--color-border-default);
}
.nw-split-container.split-horizontal .nw-graph-pane {
    border-left: none;
    border-top: 1px solid var(--color-border-default);
    flex: 1 1 45%;
    min-height: 180px;
}

/* Graph button active glow (matches the AI button) */
.nw-graph-btn.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-tint-soft);
    box-shadow: 0 0 6px var(--color-accent-border-soft);
}

/* ── Reusable graph canvas host (used by pane AND standalone window) ──────── */
.notes-graph-host {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: color-mix(in srgb, var(--nw-color, var(--color-accent)) 6%, var(--color-bg-note-window-conv-base) 94%);
}
.notes-graph-canvas {
    position: absolute;
    inset: 0;
    display: block;
}
.notes-graph-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}
.notes-graph-tbtn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    color: var(--color-text-secondary);
    background: var(--color-bg-note-window-input, rgba(10, 14, 26, 0.85));
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.12s;
}
.notes-graph-tbtn:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-tint-soft);
}
.notes-graph-tbtn.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-tint-medium, var(--color-accent-tint-soft));
    box-shadow: 0 0 6px var(--color-accent-border-soft);
}
.notes-graph-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 13px;
    font-style: italic;
    pointer-events: none;
}

/* ── Standalone notes-graph window (inherits .note-window chrome) ─────────── */
.notes-graph-window {
    min-width: 380px;
    min-height: 300px;
}
.notes-graph-titlebar {
    justify-content: space-between;
}
.notes-graph-wtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notes-graph-titlebar .nw-titlebar-btns { margin-left: auto; }
.notes-graph-wbody {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* Compact system bar in window conv pane */
.nw-conv-system-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-default);
}

/* ── Color tint applied to inner zones of the note window ───────────────── */

/* Editor writing area */
.note-window .tiptap-editor-content {
    background: color-mix(in srgb, var(--nw-color) 8%, var(--color-bg-tiptap-editor) 92%);
}

/* Conversation messages thread */
.note-window .conversation-messages {
    background: color-mix(in srgb, var(--nw-color) 6%, var(--color-bg-note-window-conv-base) 94%);
}

/* "Ask a question" input area */
.note-window .conversation-input-area {
    background: color-mix(in srgb, var(--nw-color) 10%, var(--palette-navy-900) 90%);
}

/* Bottom action bar */
.note-window .nw-footer {
    background: color-mix(in srgb, var(--nw-color) 8%, var(--color-bg-note-window-props) 92%);
}

/* Active AI button glow */
.nw-ai-btn.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-tint-soft);
    box-shadow: 0 0 6px var(--color-accent-border-soft);
}
.nw-db-btn.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-tint-soft);
    box-shadow: 0 0 6px var(--color-accent-border-soft);
}

/* ════════════════════════════════════════════════════════════════════════
   NOTE WINDOW — DATABASE (SCHEMA-DRIVEN TABLE) PANE
   The HTML editor and the table share .nw-editor-pane via .nw-ed-db-split.
   ════════════════════════════════════════════════════════════════════════ */

.nw-ed-db-split {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;   /* default unsplit: editor area fills */
    overflow: hidden;
}
.nw-ed-db-split.db-split-vertical   { flex-direction: row;    }
.nw-ed-db-split.db-split-horizontal { flex-direction: column; }

/* Drag handle between editor and table */

/* The table pane */
.nw-db-pane {
    flex: 1 1 50%;
    min-width: 0;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: color-mix(in srgb, var(--nw-color) 5%, var(--color-bg-note-window-props, var(--color-bg-secondary)) 95%);
}
.nw-ed-db-split.db-split-vertical   .nw-db-pane { border-left: 1px solid var(--color-border-default); }
.nw-ed-db-split.db-split-horizontal .nw-db-pane { border-top:  1px solid var(--color-border-default); }

/* ── Database tab strip — refined segmented tabs ───────────────────────────── */
.nw-db-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 8px 0;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border-default);
    padding: 6px 8px;
}
/* One row that scrolls sideways (wheel scrolls it; ☰ lists everything). */
.nw-db-tablist {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
    padding-right: 20px;
}
.nw-db-tablist::-webkit-scrollbar { display: none; }
.nw-db-picker-btn { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.nw-db-tabtools {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
    padding: 0 0 0 8px;
}
.nw-db-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.nw-db-tab:hover {
    color: var(--color-text-primary);
    background-color: color-mix(in srgb, var(--color-accent) 8%, transparent);
}
.nw-db-tab.active {
    color: var(--color-accent);
    font-weight: 600;
    background-color: color-mix(in srgb, var(--color-accent) 14%, transparent);
    border-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
}
.nw-db-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 16px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    background: color-mix(in srgb, var(--color-text-primary) 12%, transparent);
    color: var(--color-text-secondary);
}
.nw-db-tab.active .nw-db-tab-count {
    background: color-mix(in srgb, var(--color-accent) 18%, transparent);
    color: var(--color-accent);
}
.nw-db-tab-empty { display: inline-flex; align-items: center; padding: 7px 14px; font-size: 12px; color: var(--color-text-secondary); }
/* Pop-out control on each database tab: faint until the tab is hovered or active. */
.nw-db-tab-pop {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; margin-left: 2px; border-radius: var(--r-sm);
    font-size: 12px; line-height: 1; opacity: 0.25; cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}
.nw-db-tab:hover .nw-db-tab-pop, .nw-db-tab.active .nw-db-tab-pop { opacity: 0.75; }
.nw-db-tab .nw-db-tab-pop:hover { opacity: 1; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* ── Collapsible description/about bar (between tabs and the data grid) ────── */
.nw-db-info {
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-default);
    background: color-mix(in srgb, var(--color-accent) 3%, var(--color-bg-card));
}
.nw-db-info > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
}
.nw-db-info > summary::-webkit-details-marker { display: none; }
.nw-db-info > summary::before {
    content: '';   /* chevron: see .chev-mask below */
    color: var(--color-accent);
}
.nw-db-info[open] > summary::before { transform: rotate(90deg); }
.nw-db-info > summary:hover { color: var(--color-text-primary); }
.nw-db-info-body {
    padding: 2px 14px 10px 28px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--color-text-secondary);
    max-height: 240px;
    overflow: auto;
}
.nw-db-info-body p { margin: 0 0 6px; }
.nw-db-info-body p:last-child { margin-bottom: 0; }
/* The active database's content fills the rest of the pane. */
.nw-db-active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.nw-db-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border-default);
    background: color-mix(in srgb, var(--nw-color) 10%, var(--color-bg-secondary) 90%);
}
.nw-db-toolbar-left,
.nw-db-toolbar-right { display: flex; align-items: center; gap: 6px; }
.nw-db-toolbar-right { margin-left: auto; }
.nw-db-filter {
    flex: 1;
    min-width: 60px;
    max-width: 220px;
    padding: 3px 8px;
    font-size: 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input, var(--color-bg-primary));
    color: var(--color-text-primary);
}
.nw-db-count { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; }

/* Table */
.nw-db-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.nw-db-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
    color: var(--color-text-primary);
}
.nw-db-th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 5px 8px;
    cursor: pointer;
    white-space: nowrap;
    background: var(--color-bg-secondary);
    border-bottom: 2px solid var(--color-border-default);
    user-select: none;
}
.nw-db-th:hover { background: var(--color-accent-tint-soft, var(--color-bg-tertiary)); }
.nw-db-th-num  { text-align: right; }
.nw-db-th-type {
    display: block;
    font-size: 9px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
}
.nw-db-th-actions { width: 1%; cursor: default; }
.nw-db-th-actions:hover { background: var(--color-bg-secondary); }
.nw-db-req { color: var(--color-danger, #ef4444); margin-left: 2px; }

.nw-db-td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border-default);
    vertical-align: top;
}
.nw-db-table tbody tr:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.nw-db-td-num  { text-align: right; font-variant-numeric: tabular-nums; }
.nw-db-num     { font-variant-numeric: tabular-nums; }
.nw-db-td-bool { text-align: center; }
.nw-db-td-actions { white-space: nowrap; text-align: right; }
.nw-db-null { color: var(--color-text-secondary); opacity: 0.6; }
.nw-db-bool-true  { color: var(--color-success, #22c55e); font-weight: 700; }
.nw-db-bool-false { color: var(--color-text-secondary); }

/* select / multiselect chips */
.nw-db-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.nw-db-chip {
    display: inline-block;
    padding: 1px 8px;
    font-size: 11px;
    line-height: 1.6;
    border-radius: var(--r-lg);
    background: var(--color-accent-tint-subtle, color-mix(in srgb, var(--color-accent) 16%, transparent));
    color: var(--color-text-primary);
    border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
    white-space: nowrap;
}

.nw-db-json { max-width: 260px; }
.nw-db-json > summary { cursor: pointer; color: var(--color-accent); }
.nw-db-json > pre {
    margin: 4px 0 0;
    padding: 6px;
    max-height: 200px;
    overflow: auto;
    font-size: 11px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    white-space: pre-wrap;
    word-break: break-word;
}

/* richtext cell — sanitized HTML, constrained so a tall body doesn't blow out the row */
.nw-db-richtext {
    max-height: 140px;
    overflow: auto;
    font-size: 12px;
    line-height: 1.4;
}
.nw-db-richtext > :first-child { margin-top: 0; }
.nw-db-richtext > :last-child  { margin-bottom: 0; }
.nw-db-richtext img { max-width: 100%; height: auto; }
.nw-db-richtext table { border-collapse: collapse; }
.nw-db-richtext td, .nw-db-richtext th { border: 1px solid var(--color-border-default); padding: 2px 4px; }

/* richtext editor host inside the row form */
.nw-db-richtext-host {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--color-bg-tiptap-editor, var(--color-bg-primary));
}
.nw-db-richtext-host .tiptap-editor-content {
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
}

.nw-db-rowbtn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
}
.nw-db-rowbtn:hover { background: var(--color-bg-tertiary); color: var(--color-text-primary); }
.nw-db-rowbtn-del:hover { color: var(--color-danger, #ef4444); }

.nw-db-empty,
.nw-db-empty-cell {
    padding: 16px;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 12px;
}
.nw-db-more {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--color-text-secondary);
    border-top: 1px dashed var(--color-border, #444);
}
.nw-db-more-tr > td { padding: 0 !important; }
.nw-db-hint {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin: 4px 0;
}
.nw-db-warn {
    font-size: 11px;
    margin: 4px 0;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    background: color-mix(in srgb, var(--color-warning, #eab308) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-warning, #eab308) 45%, transparent);
}

/* "hidden from table" tag in the row editor */
.nw-db-hidden-tag {
    margin-left: 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 4px;
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary, var(--color-bg-secondary));
}

/* Row-opener list shown when every column is hidden from the table */
.nw-db-rowlist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    overflow: auto;
}
.nw-db-rowlist-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nw-db-rowlist-item .btn { flex: 1; text-align: left; }

/* ── View switcher (tabs left, actions far right) ──────────────────────────── */
.nw-db-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-secondary);
}
.nw-db-vtabs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
}
.nw-db-vtools {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
/* View tabs reuse the standard .btn.btn-secondary.btn-xs look; the active tab
   gets the accent treatment so the current selection reads clearly. */
.nw-db-vtab { white-space: nowrap; }
.nw-db-vtab.active {
    background-color: var(--color-accent);
    color: var(--color-text-on-accent);
    border-color: var(--color-accent);
}
.nw-db-vtab.active:hover:not(:disabled) {
    background-color: var(--color-accent-hover-bright);
    color: var(--color-text-on-accent);
}
.nw-db-vtab-default {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: var(--r-md);
}

/* ── Card view — mirrors the watchlist .wl-item-card look ──────────────────── */
.nw-db-cards {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: start;
}
.nw-db-card {
    flex: 1 1 280px;
    max-width: 360px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.nw-db-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border-default);
}
.nw-db-card-titles { min-width: 0; }
.nw-db-card-title { font-size: 15px; font-weight: 600; color: var(--color-accent); word-break: break-word; }
.nw-db-card-subtitle { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; word-break: break-word; }
.nw-db-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.nw-db-card-body { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; }
.nw-db-card-field { display: flex; flex-direction: column; gap: 1px; }
.nw-db-card-flabel {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}
.nw-db-card-fval { font-size: 12px; color: var(--color-text-primary); }
/* Tall-field clamp for cards; clamped richtext scrolls (like note-card
   previews); the card's ⤢ toggle (.nw-db-card-expanded) releases it to full. */
.nw-db-card-fval .nw-db-richtext { font-size: 12px; max-height: 220px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.nw-db-card-expanded .nw-db-card-fval .nw-db-richtext { max-height: none; overflow: visible; padding-right: 0; }

/* Thin accent scrollbar to match the note-card previews. */
.nw-db-td-richtext .nw-db-richtext::-webkit-scrollbar,
.nw-db-card-fval .nw-db-richtext::-webkit-scrollbar { width: 6px; }
.nw-db-td-richtext .nw-db-richtext::-webkit-scrollbar-track,
.nw-db-card-fval .nw-db-richtext::-webkit-scrollbar-track { background: var(--color-bg-track-tint); border-radius: var(--r-sm); }
.nw-db-td-richtext .nw-db-richtext::-webkit-scrollbar-thumb,
.nw-db-card-fval .nw-db-richtext::-webkit-scrollbar-thumb { background: var(--color-accent-tint-strong); border-radius: var(--r-sm); }
.nw-db-td-richtext .nw-db-richtext::-webkit-scrollbar-thumb:hover,
.nw-db-card-fval .nw-db-richtext::-webkit-scrollbar-thumb:hover { background: var(--color-accent-border-bright); }

/* ── Per-type column sizing in table views ────────────────────────────────── */
/* boolean always hugs its content (as little space as possible). */
.nw-db-th-boolean, .nw-db-td-boolean, .nw-db-td-bool {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}
/* When a richtext column is present (.nw-db-table--rich), shrink every other
   column to its content so the richtext column(s) absorb ALL remaining width.
   This is more reliable than width:100%, which auto table-layout can ignore
   when sibling columns are also flexible. */
.nw-db-table--rich .nw-db-th-string,   .nw-db-table--rich .nw-db-td-string,
.nw-db-table--rich .nw-db-th-number,   .nw-db-table--rich .nw-db-td-number,
.nw-db-table--rich .nw-db-th-datetime, .nw-db-table--rich .nw-db-td-datetime,
.nw-db-table--rich .nw-db-th-json,     .nw-db-table--rich .nw-db-td-json {
    width: 1%;
    white-space: nowrap;
}
.nw-db-table--rich .nw-db-th-richtext,
.nw-db-table--rich .nw-db-td-richtext {
    width: 100%;          /* with siblings minimized, this forces the cell to fill */
    white-space: normal;
    min-width: 240px;
}
/* Tall-field clamp: long richtext is capped by default and scrolls (like the
   note-card previews); the row's ⤢ toggle (.nw-db-row-expanded) releases it to
   full height. */
.nw-db-td-richtext .nw-db-richtext { max-height: 150px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
tr.nw-db-row-expanded .nw-db-td-richtext .nw-db-richtext { max-height: none; overflow: visible; padding-right: 0; }

/* ── Raw JSON viewer (read-only, full width) ──────────────────────────────── */
.nw-db-rawjson {
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nw-db-rawjson-text {
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    resize: none;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 12px;
    line-height: 1.45;
    tab-size: 2;
    padding: 8px 10px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    white-space: pre;
}
.nw-db-rawjson-text:focus { outline: none; border-color: var(--color-border-focus); }

/* ── Date presets (Configuration) + inline date picker ───────────────────── */
.dp-cfg-list { display: flex; flex-direction: column; gap: 6px; }
.dp-cfg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.dp-cfg-ic { display: inline-flex; justify-content: center; min-width: 28px; padding: 2px 6px; border-radius: var(--r-md); border: 1px solid var(--color-border-default); background: var(--color-bg-secondary); font-size: 12px; }
.dp-cfg-row input[type=text] { width: 170px; }
.dp-cfg-row select { width: auto; }
.dp-cfg-row input[type=number] { width: 64px; }
.dp-cfg-daysw, .dp-cfg-inc { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.dp-cfg-preview { color: var(--color-text-secondary); white-space: nowrap; }
.dp-cfg-actions { display: flex; gap: 8px; margin-top: 10px; }

.nw-db-dp-cell { cursor: pointer; }
.nw-db-dpfield { cursor: pointer; }
.nw-db-dpfield:focus { outline: 1px solid var(--color-accent); }
.nw-db-dp-cell:hover { outline: 1px dashed var(--color-accent); outline-offset: -2px; }

.nw-dp-pop {
    position: fixed; width: 300px; padding: 10px; box-sizing: border-box;
    background: var(--color-bg-secondary); color: var(--color-text-primary, inherit);
    border: 1px solid var(--color-border-default); border-radius: var(--r-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.nw-dp-col { color: var(--color-text-secondary); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-dp-cur { color: inherit; }
.nw-dp-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.nw-dp-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; cursor: pointer;
    border: 1px solid var(--color-border-default); border-radius: var(--r-xl); background: transparent; color: inherit; font-size: 11px;
}
.nw-dp-chip:hover { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nw-dp-chip-ic { font-size: 11px; font-weight: 700; color: var(--color-accent); }
.nw-dp-head { display: flex; align-items: center; justify-content: space-between; }
.nw-dp-title { font-weight: 600; }
.nw-dp-nav button { border: 0; background: transparent; color: var(--color-text-secondary); cursor: pointer; font-size: 14px; padding: 0 5px; line-height: 1; }
.nw-dp-nav button:hover { color: var(--color-accent); }
.nw-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.nw-dp-dow { text-align: center; font-size: 10px; color: var(--color-text-secondary); padding: 2px 0; }
.nw-dp-day {
    height: 30px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; font-size: 12px;
}
.nw-dp-day:hover { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.nw-dp-day.muted { color: var(--color-text-secondary); opacity: .55; }
.nw-dp-day.today { font-weight: 700; color: var(--color-accent); }
.nw-dp-day.sel, .nw-dp-day.sel:hover { background: var(--color-accent); color: #fff; opacity: 1; }
.nw-dp-time { display: flex; align-items: center; gap: 8px; padding-top: 6px; border-top: 1px solid var(--color-border-default); }
.nw-dp-time span { color: var(--color-text-secondary); }
.nw-dp-time input { width: auto; }
.nw-dp-foot { display: flex; justify-content: flex-end; gap: 8px; }
.nw-dp-foot .btn { flex: 1; }

/* ── View editor ──────────────────────────────────────────────────────────── */
.nw-db-ve-flthead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nw-db-ve-flthead select { width: auto; min-width: 180px; max-width: 360px; }
.nw-db-ve-fltedit { margin-top: 6px; }
.nw-db-ve {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.nw-db-ve-top { display: flex; gap: 12px; flex-wrap: wrap; }
.nw-db-ve-card {
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    padding: 8px 10px;
    background: var(--color-bg-secondary);
}
.nw-db-ve-cols { display: flex; flex-direction: column; gap: 6px; }
.nw-db-ve-list { display: flex; flex-direction: column; gap: 6px; }
.nw-db-ve-entry {
    border: 1px solid var(--color-border);
    border-radius: var(--r-md);
    padding: 6px 8px;
    background: var(--color-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.nw-db-ve-entry-main { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-db-ve-colname { font-size: 12px; font-weight: 600; color: var(--color-text-primary); min-width: 90px; }
.nw-db-ve-entry-main .nw-db-ve-label { flex: 1; min-width: 100px; }
.nw-db-ve-move { display: flex; gap: 2px; margin-left: auto; }
.nw-db-ve-entry-fmt { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-left: 6px; }
.nw-db-ve-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Default-query (filter/contains/sort/dir) editor */
.nw-db-ve-query { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; padding-top: 8px; border-top: 1px dashed var(--color-border-default); }
.nw-db-ve-sort  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nw-db-ve-sort .nw-db-form-row { flex: 0 1 auto; }
.nw-db-ve-rules { display: flex; flex-direction: column; gap: 4px; }
.nw-db-ve-rule  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-db-ve-rule .nw-db-ve-ruleval { flex: 1; min-width: 100px; }
.nw-db-ve-norules { margin: 0; }
.nw-db-ve-error {
    font-size: 11px;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    color: var(--color-danger, #ef4444);
    background: color-mix(in srgb, var(--color-danger, #ef4444) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-danger, #ef4444) 40%, transparent);
}
.nw-db-warn-inline { color: var(--color-danger, #ef4444); font-style: normal; }
.nw-db-num { font-variant-numeric: tabular-nums; }

/* ── Shared editor system (view editor + schema editor) ─────────────────────
   Consistent cards, aligned label/control grids, and uniform control styling so
   the database editors match the rest of the app (rounded corners, input look). */
.nw-dbe-card {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    background: var(--color-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nw-dbe-card-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}
.nw-dbe-card-sub {
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--color-text-muted);
}
.nw-dbe-grid {
    display: grid;
    grid-template-columns: 96px minmax(200px, 380px);
    gap: 8px 10px;
    align-items: center;
}
.nw-dbe-lbl { font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; }
.nw-dbe-inline { display: flex; gap: 8px; align-items: center; }
.nw-dbe-inline > select { flex: 1; }
.nw-dbe-addbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Uniform control styling across both editors (view + schema). */
.nw-db-ve input[type="text"],
.nw-db-ve input[type="number"],
.nw-db-ve select,
.nw-db-struct input[type="text"],
.nw-db-struct input[type="number"],
.nw-db-struct select {
    padding: 5px 8px;
    font-size: 12px;
    color: var(--color-text-primary);
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    box-sizing: border-box;
}
.nw-db-ve input:focus,
.nw-db-ve select:focus,
.nw-db-struct input:focus,
.nw-db-struct select:focus {
    outline: none;
    border-color: var(--color-border-focus, var(--color-accent));
}
/* Query condition rows: fixed grid so the controls line up across rows. */
.nw-db-ve-rule {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 96px minmax(140px, 1.6fr) auto;
    gap: 6px;
    align-items: center;
}
.nw-db-ve-rule .nw-db-ve-ruleval { min-width: 0; }

/* ── Schema-filter bar (filter dropdown + dynamic inputs on the data view) ── */
.nw-db-fbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-secondary);
    flex: 0 0 auto;
}
.nw-db-fbar label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--color-text-secondary); }
.nw-db-fbar select,
.nw-db-fbar input {
    padding: 3px 8px;
    font-size: 12px;
    color: var(--color-text-primary);
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
}
.nw-db-fbar select:focus, .nw-db-fbar input:focus { outline: none; border-color: var(--color-border-focus, var(--color-accent)); }
.nw-db-fbar-dyn input { width: 150px; }

/* ── View body container (rows area re-rendered independently of the toolbar) ── */
.nw-db-viewbody {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
}
.nw-db-viewbody > .nw-db-table-wrap,
.nw-db-viewbody > .nw-db-cards { flex: 0 0 auto; min-height: auto; overflow: visible; }

/* ── Group sections (schema-filter grouping; table + card views) ─────────────
   Each group gets a stable hue via --grp-h; header + left accent share it. */
.nw-db-group-chip {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: var(--r-sm);
    background: hsl(var(--grp-h, 211) 70% 50%);
    flex: 0 0 auto;
}
.nw-db-group-label { font-size: 12px; font-weight: 600; color: var(--color-text-primary); }
.nw-db-group-count {
    font-size: 10px;
    color: var(--color-text-secondary);
    background: color-mix(in srgb, hsl(var(--grp-h, 211) 70% 50%) 15%, transparent);
    border-radius: var(--r-lg);
    padding: 1px 7px;
}
tr.nw-db-group-tr > td {
    padding: 5px 8px;
    border-top: 1px solid var(--color-border-default);
    background: color-mix(in srgb, hsl(var(--grp-h, 211) 70% 50%) 10%, var(--color-bg-secondary));
    box-shadow: inset 3px 0 0 hsl(var(--grp-h, 211) 70% 50%);
}
tr.nw-db-group-tr .nw-db-group-chip { margin-right: 7px; vertical-align: -1px; }
tr.nw-db-group-tr .nw-db-group-count { margin-left: 8px; }
.nw-db-group-sec {
    margin: 6px 8px;
    border: 1px solid color-mix(in srgb, hsl(var(--grp-h, 211) 70% 50%) 35%, var(--color-border-default));
    border-left: 3px solid hsl(var(--grp-h, 211) 70% 50%);
    border-radius: var(--r-lg);
    overflow: hidden;
    flex: 0 0 auto;
}
.nw-db-group-sec .nw-db-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: color-mix(in srgb, hsl(var(--grp-h, 211) 70% 50%) 10%, var(--color-bg-secondary));
}
.nw-db-group-sec .nw-db-cards { margin: 0; }

/* ── Filters editor (schema pane) ──────────────────────────────────────────── */
.nw-se-filters { margin-top: 12px; }
.nw-se-flt-list { display: flex; flex-direction: column; gap: 10px; }
.nw-se-flt {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 8px 10px;
    background: var(--color-bg-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nw-se-flt-head { display: flex; align-items: center; gap: 8px; }
.nw-se-flt-head .nw-se-flt-name { flex: 1; max-width: 320px; font-weight: 600; }
.nw-se-flt-head .btn { margin-left: auto; }
.nw-se-flt-sec { display: flex; flex-direction: column; gap: 6px; padding-left: 6px; }
.nw-se-flt-none { margin: 0; }
/* Condition rows: aligned grid — column / op / value / ask-user / label / remove. */
.nw-se-flt-cond {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 92px minmax(120px, 1.4fr) auto minmax(110px, 1fr) auto;
    gap: 6px;
    align-items: center;
}
.nw-se-fc-dynl { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; }
/* Sort rows: column / direction / move / remove. */
.nw-se-flt-sort {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 120px auto auto;
    gap: 6px;
    align-items: center;
    justify-content: start;
}
/* Group rows: column / color chip / remove. */
.nw-se-flt-group {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    justify-content: start;
    max-width: 320px;
}
.nw-se-flt-actions { display: flex; gap: 8px; align-items: center; padding-top: 2px; }

/* ── Live updates ──────────────────────────────────────────────────────────
   Subtle pulse on the rows area when a remote change is applied, and the
   note-body banner shown when the note itself changed in another session
   (content is never auto-replaced — the user chooses to reload). */
@keyframes nw-db-live-pulse {
    0%   { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-accent) 55%, transparent); }
    100% { box-shadow: inset 0 0 0 2px transparent; }
}
.nw-db-live-flash { animation: nw-db-live-pulse 1.3s ease-out 1; }
.nw-remote-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--color-text-primary);
    background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-secondary));
    border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 40%, var(--color-border-default));
    flex: 0 0 auto;
}
.nw-remote-banner-msg { flex: 1; }

/* ── Spreadsheet view (kind = "spreadsheet") ────────────────────────────────
   Hand-rolled grid: sticky row/column headers, keyboard-driven selection with
   an accent outline, range tint, in-cell edit input, and a formula bar. */
.ss-toolbar .nw-db-toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.ss-addrbox {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--color-text-primary);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 3px 6px;
}
.ss-fx {
    flex: 1;
    min-width: 120px;
    max-width: 520px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--color-text-primary);
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
}
.ss-fx:focus { outline: none; border-color: var(--color-border-focus, var(--color-accent)); }
.ss-scroll { outline: none; }
.ss-scroll:focus-visible { outline: none; }
.ss-grid {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.ss-grid th, .ss-grid td {
    border-right: 1px solid var(--color-border-default);
    border-bottom: 1px solid var(--color-border-default);
    padding: 2px 6px;
    height: 22px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Width now comes from <colgroup> (table-layout: fixed), so the old content-driven
   min/max-width are gone: a column is exactly as wide as it is set to be, and overflow
   clips — which is what Excel does unless the cell wraps. */
.ss-grid td.ss-td { background: var(--color-bg-primary); color: var(--color-text-primary); cursor: cell; }
.ss-grid .ss-num { text-align: right; }
.ss-grid .ss-b { font-weight: 600; }
.ss-grid .ss-err { color: var(--color-danger, #ef4444); font-weight: 600; }
.ss-grid .ss-live-exc { background: color-mix(in srgb, var(--color-warning, #f59e0b) 14%, var(--color-bg-primary)) !important; }
.ss-tb-sep { display: inline-block; width: 1px; height: 16px; background: var(--color-border-default); margin: 0 4px; vertical-align: middle; }

/* ── Conversation (chat) pane ─────────────────────────────────────────────── */
.convo-log { padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.convo-empty { color: var(--color-text-secondary); font-style: italic; padding: 16px; text-align: center; }
.convo-msg {
    max-width: 82%; align-self: flex-start; border-radius: var(--r-lg); padding: 6px 10px;
    background: var(--color-bg-secondary); border: 1px solid var(--color-border-default);
}
.convo-msg.convo-mine {
    align-self: flex-end;
    background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-secondary));
    border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
}
.convo-head { display: flex; gap: 8px; align-items: baseline; font-size: 11px; margin-bottom: 2px; color: var(--color-text-secondary); }
.convo-from { font-weight: 700; color: var(--color-text-primary); }
.convo-to { color: var(--color-accent); }
.convo-reply { opacity: .8; }
.convo-seq { opacity: .55; }
.convo-when { margin-left: auto; opacity: .7; }
.convo-body { font-size: 13px; overflow-wrap: break-word; }
.convo-body p { margin: 0 0 4px; }
.convo-body p:last-child { margin-bottom: 0; }
/* Lists must render their markers INSIDE the bubble (site-wide resets strip list padding). */
.convo-body ul, .convo-body ol { margin: 4px 0 6px; padding-left: 1.6em; list-style-position: outside; }
.convo-body ul { list-style-type: disc; }
.convo-body ol { list-style-type: decimal; }
.convo-body li { margin: 2px 0; }
.convo-body li > ul, .convo-body li > ol { margin: 2px 0; }
.convo-body h1, .convo-body h2, .convo-body h3, .convo-body h4 { font-size: 13px; font-weight: 700; margin: 8px 0 4px; }
.convo-body blockquote { margin: 4px 0; padding: 2px 8px; border-left: 3px solid var(--color-border-default); opacity: .9; }
.convo-body pre, .convo-body code { font-size: 12px; }
.convo-body table { max-width: 100%; }
.convo-inputrow { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--color-border-default); align-items: flex-end; }
.convo-input {
    flex: 1; resize: none; border-radius: var(--r-lg); padding: 6px 10px; font-size: 13px;
    background: var(--color-bg-primary); color: var(--color-text-primary);
    border: 1px solid var(--color-border-default);
}
.convo-name {
    width: 120px; font-size: 12px; padding: 2px 8px; border-radius: var(--r-lg);
    background: var(--color-bg-primary); color: var(--color-text-primary);
    border: 1px solid var(--color-border-default);
}
.convo-me-label { font-size: 11px; color: var(--color-text-secondary); }
.ss-live-chip {
    display: inline-block; padding: 1px 8px; border-radius: var(--r-lg); font-size: 11px; font-weight: 600;
    cursor: pointer; user-select: none; border: 1px solid var(--color-border-default);
    color: var(--color-text-secondary); background: var(--color-bg-secondary); white-space: nowrap;
}
.ss-live-chip.ss-live-live    { color: #16a34a; border-color: color-mix(in srgb, #16a34a 45%, transparent); }
.ss-live-chip.ss-live-delayed { color: #d97706; border-color: color-mix(in srgb, #d97706 45%, transparent); }
.ss-live-chip.ss-live-frozen  { color: #0284c7; border-color: color-mix(in srgb, #0284c7 45%, transparent); }
.ss-live-chip.ss-live-mixed,
.ss-live-chip.ss-live-stale   { color: #d97706; border-color: color-mix(in srgb, #d97706 60%, transparent); }
.ss-live-chip.ss-live-unavailable,
.ss-live-chip.ss-live-error   { color: var(--color-danger, #ef4444); border-color: color-mix(in srgb, var(--color-danger, #ef4444) 55%, transparent); }
/* (2026-11-07) formula cells are no longer marked with an inset accent edge — Joey: it read as a stray border. */
.ss-grid th.ss-corner, .ss-grid th.ss-colh, .ss-grid th.ss-rowh {
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-align: center;
    position: sticky;
    z-index: 2;
}
.ss-grid th.ss-colh { top: 0; }
.ss-grid th.ss-rowh { left: 0; min-width: 40px; }
.ss-grid th.ss-corner { top: 0; left: 0; z-index: 3; }
.ss-grid th.ss-hl { background: color-mix(in srgb, var(--color-accent) 18%, var(--color-bg-secondary)); color: var(--color-text-primary); }

/* ── Column / row resize grips ───────────────────────────────────────────────
   A thin strip on the trailing edge of each header. The hit area is deliberately wider than
   the visible line (the line is only shown on hover) because a 1px target is unusable. */
/* NB: do NOT set position:relative on the headers — they are position:sticky above, which
   already establishes a containing block for the absolutely-positioned grip. Overriding it
   un-sticks the row gutter and the column strip. */
.ss-grip { position: absolute; z-index: 4; }
.ss-grip-col { top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; }
.ss-grip-row { left: 0; bottom: -3px; height: 7px; width: 100%; cursor: row-resize; }
.ss-grip:hover { background: var(--color-accent); }
/* While dragging, keep the resize cursor everywhere and stop the drag selecting text. */
body.ss-resizing, body.ss-resizing * { cursor: col-resize !important; user-select: none !important; }

/* Columns are sized by <colgroup>, so the cell rules must not fight it with their own widths. */
.ss-grid { table-layout: fixed; }
/* The grid is a flex item of the scroll body: don't let it stretch to the viewport width
   (that squeezed every column to fit and hid the horizontal scrollbar). Its width is the sum
   of its columns, set inline by the renderer. */
.ss-scroll > table.ss-grid { align-self: flex-start; flex: 0 0 auto; }
/* Cells a formula is pointing at while editing ("=SUM(" + arrows / click). */
.ss-grid td.ss-point { position: relative; outline: 2px dashed var(--color-warning, #d97706); outline-offset: -2px; background: color-mix(in srgb, var(--color-warning, #d97706) 10%, var(--color-bg-primary)); }

/* Name Box: was a static label, now a typable Go To box (F5 / Ctrl+G). */
input.ss-addrbox {
    width: 84px;
    text-align: center;
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    padding: 2px 4px;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--r-sm);
}
input.ss-addrbox:focus { outline: 2px solid var(--color-accent); outline-offset: -2px; }

/* Frozen panes: the sticky cells need an opaque background or the scrolling rows show through. */
.ss-grid td[style*="position:sticky"] { background: var(--color-bg-primary); }
.ss-grid col.ss-col-head { width: 44px; }
.ss-grid td.ss-sel {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
    background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg-primary));
}
.ss-grid td.ss-range { background: color-mix(in srgb, var(--color-accent) 12%, var(--color-bg-primary)); }

/* Marching border on the copy/cut source — one of the Excel cues worth keeping, because it is
   the only thing that tells you WHICH block a paste is about to bring in. Drawn as dashed box
   shadows on the outer edges only, so the inner grid lines stay intact. */
@keyframes ss-march-scroll {
    to { background-position: 12px 0, 12px 100%, 0 -12px, 100% -12px; }
}
.ss-grid td.ss-march { position: relative; }
/* All four edges are drawn as separate background LAYERS of one pseudo-element. They cannot be
   separate rules each setting background-image — the last matching rule would win and a single
   copied cell would show only one edge. Each edge class just switches its own layer's size on. */
.ss-grid td.ss-march::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-repeat: no-repeat;
    background-image:
        repeating-linear-gradient(90deg, var(--color-accent) 0 6px, transparent 6px 12px),
        repeating-linear-gradient(90deg, var(--color-accent) 0 6px, transparent 6px 12px),
        repeating-linear-gradient(0deg,  var(--color-accent) 0 6px, transparent 6px 12px),
        repeating-linear-gradient(0deg,  var(--color-accent) 0 6px, transparent 6px 12px);
    background-position: 0 0, 0 100%, 0 0, 100% 0;
    background-size:
        var(--ss-mt, 0) 2px,
        var(--ss-mb, 0) 2px,
        2px var(--ss-ml, 0),
        2px var(--ss-mr, 0);
    animation: ss-march-scroll 0.7s linear infinite;
}
.ss-grid td.ss-march-t::after { --ss-mt: 100%; }
.ss-grid td.ss-march-b::after { --ss-mb: 100%; }
.ss-grid td.ss-march-l::after { --ss-ml: 100%; }
.ss-grid td.ss-march-r::after { --ss-mr: 100%; }

/* Fill handle: the small square on the selection's bottom-right corner. The element itself is a
   generously sized transparent GRAB AREA — a 6px target is miserable to hit with a mouse — and the
   visible 6px square is drawn inside it. */
.ss-grid td .ss-fill-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 15px;
    height: 15px;
    background: transparent;
    cursor: crosshair;
    z-index: 3;
}
.ss-grid td .ss-fill-handle::after {
    content: '';
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 6px;
    height: 6px;
    background: var(--color-accent);
    border: 1px solid var(--color-bg-primary);
}
.ss-grid td.ss-sel, .ss-grid td.ss-range { position: relative; }
.ss-grid td.ss-editing { padding: 0; overflow: visible; }

/* ── Format Cells dialog ─────────────────────────────────────────────────── */
.ss-fmt-body { display: flex; flex-direction: column; gap: 8px; }
.ss-fmt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ss-fmt-row > label:first-child {
    min-width: 92px;
    font-size: 12px;
    color: var(--color-text-secondary);
}
.ss-fmt-row select, .ss-fmt-row input[type="text"] {
    padding: 3px 6px;
    font-size: 12px;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--r-sm);
}
.ss-fmt-row input[type="text"] { flex: 1; min-width: 180px; font-family: var(--font-mono, monospace); }
.ss-fmt-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.ss-fmt-sample {
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    padding: 3px 8px;
    border: 1px dashed var(--color-border);
    border-radius: var(--r-sm);
    min-width: 140px;
}
.ss-fmt-footer { display: flex; align-items: center; gap: 8px; }
.ss-swatches { display: inline-flex; gap: 4px; }
.ss-swatch {
    width: 20px;
    height: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    color: var(--color-text-secondary);
    padding: 0;
}
.ss-swatch-on { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.btn.btn-on { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.ss-edit {
    width: 100%;
    height: 100%;
    min-width: 86px;
    box-sizing: border-box;
    padding: 2px 6px;
    font: inherit;
    color: var(--color-text-primary);
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 2px solid var(--color-accent);
    border-radius: 0;
    outline: none;
}

/* Schema-editor polish: the meta / column-list / add bars read as rounded cards
   consistent with the shared editor system above. */
.nw-se-meta,
.nw-se-list,
.nw-se-addbar {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    background: var(--color-bg-secondary);
}
.nw-se-addbar { margin-top: 10px; border-top: 1px solid var(--color-border-default); }
.nw-se-row { border-radius: var(--r-lg); }

/* Row add/edit form + structure/create editors */
.nw-db-form,
.nw-db-struct {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nw-db-form-row { display: flex; flex-direction: column; gap: 3px; }
.nw-db-form-label { font-size: 12px; font-weight: 600; color: var(--color-text-primary); }
.nw-db-form-type { font-weight: 400; font-style: normal; font-size: 10px; text-transform: uppercase; color: var(--color-text-secondary); }
.nw-db-form input[type="text"],
.nw-db-form input[type="number"],
.nw-db-form input[type="datetime-local"],
.nw-db-form textarea,
.nw-db-struct input[type="text"],
.nw-db-struct select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input, var(--color-bg-primary));
    color: var(--color-text-primary);
}
.nw-db-form textarea { font-family: var(--font-mono, monospace); resize: vertical; }
.nw-db-form select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input, var(--color-bg-primary));
    color: var(--color-text-primary);
}
.nw-db-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-default);
}

/* Click-anywhere-to-edit affordance on data rows / cards. */
.nw-db-row-clickable { cursor: pointer; }
tr.nw-db-row-clickable:hover > .nw-db-td { background: var(--color-accent-tint-subtle, color-mix(in srgb, var(--color-accent) 8%, transparent)); }
.nw-db-card.nw-db-row-clickable:hover { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); }

/* ── Floating row-editor window (movable / resizable, like note windows) ───── */
.row-ed-window {
    /* inherits .note-window: position:fixed, resize:both, flex column, shadow */
    min-width: 380px;
    min-height: 280px;
}
.row-ed-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: move;
}
.row-ed-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Row `_id` badge in the editor title / toolbar. */
.row-ed-rowid {
    font-size: 11px;
    font-weight: 400;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--color-text-muted);
    background: var(--color-bg-tertiary);
    border-radius: var(--r-sm);
    padding: 1px 5px;
}
/* The form body is the flex/scroll region; richtext rows grow to fill it and the
   body scrolls once they hit their minimum height. */
.row-ed-form { flex: 1; min-height: 0; gap: 12px; }
.nw-db-form--grid .nw-db-richtext-host .tiptap-editor-content {
    flex: 1;
    min-height: 150px;
    max-height: none;
}
.row-ed-footer { flex-shrink: 0; padding: 8px 10px; }

/* ── Wrapping row-editor grid ──────────────────────────────────────────────
   The form body is a vertical stack of wrap-groups and full-width richtext
   blocks. Within a group, fields flow left→right, top→bottom in column order:
   narrow types (number / boolean / datetime) pack several per line; select /
   multiselect get a moderate share; text / json take the full width. Each
   richtext column is its own block that grows to share the spare vertical
   space equally with the other richtext columns (down to a minimum control
   height, after which the body scrolls). Applies to both row editors. */
.nw-db-form--grid {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}
/* A run of consecutive non-richtext fields, packed into a wrapping row. */
.nw-db-fgroup {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: 10px 14px;
    flex: 0 0 auto;
}
.nw-db-form--grid .nw-db-form-row { box-sizing: border-box; }
.nw-db-fgroup .nw-db-fcell--narrow { flex: 1 1 150px; max-width: 240px; }
.nw-db-fgroup .nw-db-fcell--mid    { flex: 1 1 240px; max-width: 440px; }
.nw-db-fgroup .nw-db-fcell--full   { flex: 1 1 100%;  max-width: 100%;  }
/* Controls fill their cell so the wrap widths take visible effect. */
.nw-db-form--grid .nw-db-form-row input[type="text"],
.nw-db-form--grid .nw-db-form-row input[type="number"],
.nw-db-form--grid .nw-db-form-row input[type="datetime-local"],
.nw-db-form--grid .nw-db-form-row textarea,
.nw-db-form--grid .nw-db-form-row select { width: 100%; box-sizing: border-box; }
/* Richtext blocks: full width, sharing the body's spare vertical space equally
   (flex-basis 0 + equal grow), never shrinking past the editor's minimum. */
.nw-db-form--grid > .row-ed-row--rich { flex: 1 1 0; min-height: 0; }
.nw-db-form--grid > .row-ed-row--rich .nw-db-richtext-host { flex: 1; min-height: 0; }
/* Richtext column with an explicit editor height: the block stops growing and the
   editor content takes exactly the configured height (scrolling internally). The
   unset-height behavior above (grow to fill) remains the maximum. */
.nw-db-form--grid > .row-ed-row--rich.row-ed-row--fixed { flex: 0 0 auto; }
.nw-db-form--grid .nw-db-richtext-host.nw-db-rt-fixed .tiptap-editor-content {
    flex: 0 0 auto;
    height: var(--rt-h, 150px);
    min-height: 60px;
    overflow-y: auto;
}

.nw-db-struct-list { display: flex; flex-direction: column; gap: 6px; }
.nw-db-struct-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.nw-db-struct-row .nw-db-struct-name,
.nw-db-struct-row .nw-db-draft-name,
.nw-db-struct-row .nw-db-newcol-name { flex: 1; min-width: 90px; }
/* The allowed-values input for select/multiselect drops to its own full-width line. */
.nw-db-struct-row .nw-db-opts-input { flex: 1 1 100%; min-width: 0; }

/* multiselect checkbox group in the row editor */
.nw-db-ms {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 4px 0;
}
.nw-db-ms-opt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-primary);
    white-space: nowrap;
}
.nw-db-ms-empty { font-size: 12px; color: var(--color-text-secondary); }

/* boolean toggle switch (row editor) — left-aligned, clearer true/false */
.nw-db-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    align-self: flex-start;   /* keep left-aligned within the flex-column form row */
    user-select: none;
}
.nw-db-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.nw-db-switch-track {
    position: relative;
    width: 38px;
    height: 20px;
    border-radius: 999px;
    background: var(--color-border-strong, #555);
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.nw-db-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.nw-db-switch input:checked + .nw-db-switch-track { background: var(--color-accent); }
.nw-db-switch input:checked + .nw-db-switch-track .nw-db-switch-thumb { left: 20px; }
.nw-db-switch input:focus-visible + .nw-db-switch-track { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.nw-db-switch-text { font-size: 12px; font-weight: 600; color: var(--color-text-primary); min-width: 34px; }

/* column reorder up/down controls in the schema editor */
.nw-db-struct-move { display: inline-flex; gap: 2px; flex-shrink: 0; }
.nw-db-struct-req {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}
.nw-db-struct-add {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-default);
}

/* Database badge on note cards */
.note-card-db-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    padding: 1px 3px;
    border-radius: var(--r-sm);
    color: var(--color-accent);
    background: var(--color-accent-tint-soft, transparent);
}
.note-card-ch-badge {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; line-height: 1; padding: 1px 3px; border-radius: var(--r-sm); margin-left: 2px;
    background: var(--color-bg-slate-overlay-soft, transparent);
}
/* Schedule active-days row */
.comms-sched-days { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-secondary); margin: 6px 0; }
.comms-sched-days label { display: inline-flex; align-items: center; gap: 3px; }
.comms-sched-days-hint { color: var(--color-text-tertiary, var(--color-text-secondary)); font-size: 11px; }

/* ── Titlebar flag icon buttons (pin / minimize / archive) ───────────────── */
.nw-flag-btn {
    padding: 2px 6px;
    font-size: 12px;
    opacity: 0.4;
    transition: opacity 0.15s, background 0.15s;
}
.nw-flag-btn:hover  { opacity: 0.9 !important; }
.nw-flag-btn.active { opacity: 1; background: var(--color-accent-tint-medium); border-color: var(--color-accent); }

/* ── Token counter ───────────────────────────────────────────────────────── */
.nw-token-counter {
    font-size: 10px;
    color: var(--color-text-note-tab-inactive);
    white-space: nowrap;
    margin-right: 4px;
}

/* ── Auto-grow conv input ────────────────────────────────────────────────── */
.nw-conv-input {
    resize: none;
    overflow-y: auto;
    transition: height 0.1s ease;
}

/* ── Collapsible long user messages ─────────────────────────────────────── */
.conv-body-collapsed,
.conv-body-full {
    white-space: pre-wrap;
    word-break: break-word;
}
.conv-expand-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 11px;
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-tint-medium);
    border-radius: var(--r-sm);
    color: var(--color-accent);
    cursor: pointer;
    transition: background 0.15s;
}
.conv-expand-btn:hover { background: var(--color-accent-tint-medium); }

/* ── Markdown-rendered AI responses ─────────────────────────────────────── */
.conv-message-body h1,
.conv-message-body h2,
.conv-message-body h3,
.conv-message-body h4,
.conv-message-body h5,
.conv-message-body h6 {
    color: var(--color-text-secondary);
    margin: 0.6em 0 0.3em;
    font-weight: 600;
}
.conv-message-body h1 { font-size: 1.15em; }
.conv-message-body h2 { font-size: 1.05em; }
.conv-message-body h3 { font-size: 0.98em; }
.conv-message-body ul,
.conv-message-body ol {
    margin: 0.4em 0;
    padding-left: 1.4em;
}
.conv-message-body li { margin: 2px 0; }
.conv-message-body code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-tint-soft);
    border-radius: var(--r-sm);
    padding: 1px 4px;
}
.conv-message-body pre {
    background: var(--color-bg-conv-pre);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}
.conv-message-body pre code {
    background: none;
    border: none;
    padding: 0;
}
.conv-message-body blockquote {
    border-left: 3px solid var(--color-accent);
    margin: 6px 0;
    padding: 4px 10px;
    color: var(--color-text-muted);
}
.conv-message-body a { color: var(--color-accent); text-decoration: underline; }
.conv-message-body p { margin: 0.3em 0; }
.conv-message-body strong { color: var(--color-text-secondary); }

/* =============================================================================
   END FLOATING NOTE WINDOWS
   ============================================================================= */

/* =============================================================================
   SYSTEM MESSAGES FLOATING WINDOWS
   ============================================================================= */

#sysmsgs-windows-container {
    /* display:contents — no box, no stacking context; its position:fixed windows join the
       root context and interleave with all other windows (see #note-windows-container). */
    display: contents;
}

.sm-window {
    position: fixed;
    pointer-events: all;
    background: var(--color-bg-note-window-base);
    border: 1px solid var(--color-border-note-window);
    border-top: 3px solid var(--color-accent);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-note-window);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 340px;
    min-height: 260px;
    width: 420px;
    height: 500px;
}
.sm-window--edit {
    width: 640px;
    height: 700px;
}

.sm-win-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: var(--color-bg-note-window-titlebar-base);
    border-bottom: 1px solid var(--color-border-default);
    cursor: grab;
    user-select: none;
    border-radius: var(--r-md) var(--r-md) 0 0;
    flex-shrink: 0;
}
.sm-win-titlebar:active { cursor: grabbing; }

.sm-win-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sm-win-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* List window body */
.sm-win-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Edit window body — flex column, content editor grows */
.sm-edit-body {
    overflow-y: auto;
    padding: 0;
    gap: 0;
}

.sm-edit-meta {
    flex-shrink: 0;
    padding: 10px 14px 6px;
    border-bottom: 1px solid var(--color-border-default);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sm-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sm-edit-row--inline {
    flex-wrap: wrap;
    gap: 14px;
}
.sm-edit-label {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    width: 72px;
    flex-shrink: 0;
}
.sm-edit-input {
    flex: 1;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 4px 8px;
    outline: none;
    min-width: 0;
}
.sm-edit-input:focus { border-color: var(--color-border-focus); }
.sm-edit-input-sm {
    width: 55px;
    background: var(--palette-navy-800);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: 3px 6px;
    outline: none;
    margin-left: 4px;
}
.sm-edit-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}
.sm-edit-inline input[type="checkbox"] { accent-color: var(--color-accent); }

/* Content editor section — grows to fill space */
.sm-edit-content-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sm-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-note-tab-inactive);
    padding: 6px 14px 4px;
    border-bottom: 1px solid var(--color-border-note-window-faint);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sm-section-hint {
    font-size: 10px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-text-note-placeholder);
}
.sm-edit-content-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sm-edit-content-area .tiptap-toolbar { flex-shrink: 0; }
.sm-content-editor {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Memories section — fixed height at bottom, scrollable list */
.sm-edit-memories-section {
    flex-shrink: 0;
    border-top: 2px solid var(--color-border-default);
    display: flex;
    flex-direction: column;
    max-height: 260px;
    min-height: 120px;
}
.sm-mem-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}
.sm-mem-add {
    flex-shrink: 0;
    padding: 6px 14px 8px;
    border-top: 1px solid var(--color-border-note-window-faint);
    background: var(--color-bg-note-window-props);
}

/* Memory row buttons */
.memory-row-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Memory editor window — compact */
.smw-mem {
    width: 520px;
    height: 320px;
}

/* =============================================================================
   END SYSTEM MESSAGES FLOATING WINDOWS
   ============================================================================= */

/* =============================================================================
   ORDERS (portfolio sub-section)
   ============================================================================= */

/* Orders section-header controls (status select, Cancel All, refresh, New Order)
   use the shared .btn/.btn-secondary/.btn-sm/.btn-danger-outline/.btn-primary
   classes for visual consistency with every other section header (Notes,
   Strategies, Transactions, etc.). The IDs (#orders-status-select,
   #orders-cancel-all-btn, #orders-refresh-btn) are kept solely as JS hooks for
   updating disabled state and the filter selection. */
.orders-status-select {
    /* Match the trimmed-down dropdown look used by .notes-order-select */
    padding: 2px 6px;
    font-size: 11px;
}

/* "Last [N] hrs" filter — small inline number input next to the status select.
   Persisted in localStorage (key: ordersHoursFilter). Blank = no limit. */
.orders-hours-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-secondary);
    cursor: default;
    user-select: none;
}

.orders-hours-filter {
    width: 48px;
    padding: 2px 4px;
    font-size: 11px;
    background-color: var(--color-bg-input, var(--color-bg-tertiary, #1e1e1e));
    color: var(--color-text-primary, inherit);
    border: 1px solid var(--color-border, #444);
    border-radius: var(--r-sm);
    text-align: right;
    -moz-appearance: textfield;
}

.orders-hours-filter::-webkit-outer-spin-button,
.orders-hours-filter::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Table tweaks */
.orders-table th,
.orders-table td {
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

/* Symbol + contract stacked display */
.order-sym {
    font-weight: 600;
    color: var(--color-text-secondary);
    display: block;
}

.order-contract {
    font-size: 10px;
    color: var(--color-text-muted);
    display: block;
}

/* Action BUY / SELL */
.order-buy  { color: var(--color-status-success); font-weight: 700; }
.order-sell { color: var(--color-status-danger); font-weight: 700; }

/* Status badges */
.order-status-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: var(--r-lg);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.order-status-open      { background: var(--color-status-warning-tint-soft); color: var(--color-status-warning); border: 1px solid var(--color-status-warning-tint-strong); }
.order-status-partial   { background: var(--color-status-info-blue-alt); color: var(--palette-blue-400); border: 1px solid var(--color-status-info-blue-alt-border); }
.order-status-filled    { background: var(--color-status-success-green-bg); color: var(--color-status-success); border: 1px solid var(--color-status-success-green-border); }
.order-status-cancelled { background: var(--color-bg-cancelled-row);  color: var(--color-text-pale-grey);    border: 1px solid var(--color-border-cancelled-row); }
.order-status-inactive  { background: var(--color-bg-inactive-row);  color: var(--color-text-dim-grey);    border: 1px solid var(--color-border-inactive-row); }
.order-status-unknown   { background: transparent; color: var(--color-text-dim-grey); border: 1px solid var(--color-border-deep-grey); }

/* Filled rows get a subtle tint */
.order-row-filled td { opacity: 0.7; }

/* Ref column — muted, truncated */
.order-ref-cell {
    color: var(--color-text-muted);
    font-size: 11px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-updated-cell { color: var(--color-text-muted); font-size: 11px; white-space: nowrap; }
.order-actions-cell { white-space: nowrap; }

/* Per-row Cancel button */
.order-cancel-btn {
    background: transparent;
    border: 1px solid var(--color-status-danger-tint-strong);
    border-radius: var(--r-sm);
    color: var(--color-status-danger);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 8px;
    transition: background 0.15s, border-color 0.15s;
}

.order-cancel-btn:hover:not(:disabled) {
    background: var(--color-status-danger-tint-soft);
    border-color: var(--color-status-danger);
}

.order-cancel-btn:disabled { opacity: 0.4; cursor: default; }

.order-cancel-btn.order-cancel-failed {
    border-color: var(--color-status-warning);
    color: var(--color-status-warning);
}

/* #orders-cancel-all-btn uses .btn.btn-sm.btn-danger-outline — no custom rule needed.
   The :disabled opacity comes from the shared .btn rule. */
.order-comm-cell    { text-align: right; font-variant-numeric: tabular-nums; }
.order-qty-cell     { text-align: right; font-variant-numeric: tabular-nums; }
.order-price-cell   { text-align: right; font-variant-numeric: tabular-nums; }

/* =============================================================================
   END ORDERS
   ============================================================================= */

/* =============================================================================
   TRANSACTIONS
   ============================================================================= */

#transactions h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#transactions .collapsible-content {
    padding-top: 12px;
}

#strategies h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--color-accent);
}

#strategies .collapsible-content {
    padding-top: 12px;
}

/* Filter bar */
.tx-filter-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-default);
    align-items: center;
    flex-wrap: wrap;
}

.tx-filter-bar input[type="text"] {
    width: 140px;
    padding: 4px 8px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    font-size: 12px;
}

.tx-filter-bar select {
    padding: 4px 8px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    font-size: 12px;
}

/* "Get All History" dropdown panel */
.tx-history-wrapper {
    position: relative;
    display: inline-block;
}

.tx-history-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    min-width: 240px;
    box-shadow: var(--shadow-card-hover);
}

.tx-history-panel label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--color-text-muted);
    gap: 3px;
}

.tx-history-panel input[type="date"] {
    padding: 4px 8px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    font-size: 12px;
}

.tx-fetch-status {
    font-size: 11px;
    color: var(--color-text-muted);
    min-height: 16px;
}

/* Table wrapper (horizontal scroll on small screens) */
.tx-table-wrap {
    overflow-x: auto;
    padding: 8px 12px;
}

/* Main transactions table */
.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}

.tx-table th {
    padding: 5px 8px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-bg-section-header);
}

.tx-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border-divider);
    vertical-align: middle;
    color: var(--color-text-primary);
}

.tx-table tbody tr:hover td {
    background: var(--color-overlay-row-tint);
}

/* Compact variant (used in watchlist detail + options card) */
.tx-table-compact th,
.tx-table-compact td {
    padding: 3px 6px;
    font-size: 11px;
}

/* ── Option card Orders tab ─────────────────────────────────── */
.opt-orders-empty {
    font-size: 11px;
    color: var(--color-text-fainter-slate);
    font-style: italic;
    padding: 6px 2px;
    margin: 0;
}
.opt-orders-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.opt-ord-filter-select {
    font-size: 10px;
    padding: 2px 5px;
    background: var(--palette-navy-900);
    border: 1px solid var(--color-border-trade-card-input);
    border-radius: var(--r-sm);
    color: var(--palette-slate-400);
    cursor: pointer;
}
.opt-orders-table .opt-ord-id { color: var(--color-text-fainter-slate); font-size: 10px; }
.opt-ord-status {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 0.04em;
}
.opt-ord-status-open      { background: var(--color-status-info-cornflower-bg); color: var(--color-status-info-cornflower); }
.opt-ord-status-filled    { background: var(--color-bg-pnl-positive-alt-tint);  color: var(--color-pnl-positive-alt); }
.opt-ord-status-cancelled { background: var(--color-bg-slate-cancelled); color: var(--palette-slate-400); }

/* Column-specific styles */
.tx-date   { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.tx-symbol { font-weight: 600; }
.tx-type   { color: var(--color-text-muted); font-size: 10px; }
.tx-qty    { text-align: right; font-variant-numeric: tabular-nums; }
.tx-price,
.tx-proceeds,
.tx-comm,
.tx-net    { text-align: right; font-variant-numeric: tabular-nums; }

/* Buy / Sell direction color */
.tx-buy  { color: var(--color-status-success); font-weight: 600; }
.tx-sell { color: var(--color-status-danger); font-weight: 600; }

/* Option contract label (inline below symbol) */
.tx-contract {
    font-size: 10px;
    color: var(--color-text-muted);
    display: inline-block;
    margin-left: 4px;
}

/* Contract cell in compact Trades tab table */
.tx-contract-cell {
    font-size: 11px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

/* Pagination toolbar */
.tx-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border-default);
    font-size: 12px;
    color: var(--color-text-muted);
    flex-wrap: wrap;
}

.tx-pagination + .tx-table-wrap {
    border-top: none;
}

/* second pagination bar (below table) gets a top border instead */
.tx-table-wrap + .tx-pagination {
    border-bottom: none;
    border-top: 1px solid var(--color-border-default);
}

.tx-page-info {
    min-width: 90px;
}

.tx-page-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tx-page-btn {
    background: var(--color-bg-button-secondary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 7px;
    transition: background 0.15s;
}

.tx-page-btn:hover:not(:disabled) {
    background: var(--color-bg-button-secondary-hover);
}

.tx-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.tx-page-num {
    padding: 0 6px;
    white-space: nowrap;
    color: var(--color-text-primary);
}

.tx-page-size-label {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tx-page-size-select {
    padding: 2px 6px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    font-size: 12px;
}

/* Empty-state message */
.tx-empty {
    padding: 16px 12px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-style: italic;
    text-align: center;
    margin: 0;
}

/* =============================================================================
   END TRANSACTIONS
   ============================================================================= */

/* =============================================================================
   FUTURES TABLE
   ============================================================================= */

.fut-table th,
.fut-table td { font-size: 12px; }

/* Symbol cell — symbol + LONG/SHORT badge on one row */
.fut-symbol {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.fut-underlying { font-weight: 700; color: var(--color-text-light-slate); white-space: nowrap; }

.fut-dir-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

.fut-long  { color: var(--color-pnl-positive-alt); }
.fut-short { color: var(--color-pnl-negative-alt); }

.fut-dir-badge.fut-long  { background: var(--color-bg-pnl-positive-alt-tint); border: 1px solid var(--color-border-pnl-positive-alt-tint); color: var(--color-pnl-positive-alt); }
.fut-dir-badge.fut-short { background: var(--color-bg-pnl-negative-alt-tint); border: 1px solid var(--color-border-pnl-negative-alt-tint); color: var(--color-pnl-negative-alt); }

.fut-local-cell  { color: var(--color-text-mid-slate); font-family: monospace; font-size: 11px; }
.fut-expiry-cell { white-space: nowrap; color: var(--color-text-mid-slate); }
.fut-pos-cell    { font-weight: 700; text-align: right; }
.fut-mult-cell   { text-align: right; color: var(--palette-slate-400); }
.fut-notional-cell { color: var(--palette-slate-400); text-align: right; }

/* Trade button in actions cell */
.fut-trade-btn {
    background: var(--color-accent-tint-ghost);
    border: 1px solid var(--color-accent-border-soft);
    color: var(--color-accent);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.fut-trade-btn:hover {
    background: var(--color-accent-tint-medium);
}

/* =============================================================================
   TRADE CARD — Order Entry Modal
   ============================================================================= */

/* Raise trade card above other modals */
#trade-card-overlay {
    z-index: 1100010;   /* the dialog band, a step above the other dialogs */
}

.trade-card-modal {
    width: 660px;
    max-width: 96vw;
    max-height: 92vh;
    overflow-y: auto;
    background: var(--color-bg-trade-card);
    border: 1px solid var(--color-border-trade-card);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-trade-card);
    display: flex;
    flex-direction: column;
}

/* Header */
.trade-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px 13px;
    border-bottom: 1px solid var(--color-border-trade-card-section);
    flex-shrink: 0;
}

.trade-card-header h3 {
    margin: 0;
    flex: 1;
    color: var(--color-accent);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    user-select: none;
}

/* Body */
.trade-card-body {
    padding: 18px 20px 14px;
    flex: 1;
    overflow-y: auto;
}

/* Two-column form grid */
.trade-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 28px;
}

.trade-card-section {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.trade-card-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--color-border-trade-card-section);
    margin-bottom: 1px;
}

.trade-card-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.trade-card-field label {
    font-size: 11px;
    color: var(--palette-slate-400);
    font-weight: 500;
}

.tc-hint {
    color: var(--color-text-disabled);
    font-weight: 400;
}

/* Checkbox row */
.trade-card-check-field {
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.trade-card-check-field label {
    order: 1;
    cursor: pointer;
}

.tc-check {
    order: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--color-accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Inputs and selects */
/* ── Bid / Mid / Ask price selector ──────────────────────────── */
.tc-price-btns {
    display: flex;
    gap: 5px;
    width: 100%;
}
.tc-price-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--r-sm);
    border: 1px solid var(--color-border-trade-card-input);
    background: var(--color-bg-trade-card-price-btn);
    color: var(--palette-slate-400);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tc-price-bid { border-color: var(--color-border-pnl-positive-alt-faint);  color: var(--color-pnl-positive-alt); }
.tc-price-mid { border-color: var(--color-border-mid-slate-faint); color: var(--color-text-light-slate); }
.tc-price-ask { border-color: var(--color-border-pnl-negative-alt-faint); color: var(--color-pnl-negative-alt); }
.tc-price-btn:hover  { background: var(--color-status-info-cornflower-bg-hover); border-color: var(--color-status-info-cornflower); color: var(--palette-white); }
.tc-price-btn:active { background: var(--color-status-info-cornflower-bg-active); }
.tc-price-btn:disabled { opacity: 0.5; cursor: default; }

.tc-input,
.tc-select {
    background: var(--color-bg-trade-card-input);
    border: 1px solid var(--color-border-trade-card-input);
    border-radius: var(--r-sm);
    color: var(--color-text-light-slate);
    font-size: 13px;
    padding: 5px 8px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.tc-input:focus,
.tc-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-focus-ring-trade);
}

.tc-input::placeholder {
    color: var(--color-text-trade-placeholder);
}

/* Action selector tinting */
.tc-action-select {
    font-weight: 700;
    font-size: 14px;
}

.tc-action-buy  { color: var(--color-pnl-positive-alt); }
.tc-action-sell { color: var(--color-pnl-negative-alt); }

/* Preview panel */
.trade-card-preview {
    margin-top: 18px;
    background: var(--color-bg-trade-card-input);
    border: 1px solid var(--color-border-trade-card-input);
    border-radius: var(--r-md);
    padding: 13px 16px;
}

.trade-card-preview-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.trade-card-preview-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    align-items: start;
}

.tc-preview-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tc-preview-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-fainter-slate);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.tc-preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
    border-bottom: 1px solid var(--color-border-trade-card-row);
}

.tc-preview-row span { color: var(--palette-slate-400); flex-shrink: 0; }
.tc-preview-row strong {
    color: var(--color-text-light-slate);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
    text-align: right;
}

.tc-buy  { color: var(--color-pnl-positive-alt) !important; }
.tc-sell { color: var(--color-pnl-negative-alt) !important; }

/* Margin impact — spans both preview columns */
.tc-margin-section {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--color-bg-trade-card-margin);
    border: 1px solid var(--color-border-trade-card-section);
    border-radius: var(--r-md);
}

.tc-margin-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 7px;
}

.tc-margin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.tc-margin-table th {
    color: var(--color-text-faint-slate);
    font-weight: 600;
    font-size: 10px;
    text-align: right;
    padding: 0 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tc-margin-table th:first-child { text-align: left; padding-left: 0; }

.tc-margin-table td {
    text-align: right;
    padding: 3px 8px;
    color: var(--color-text-light-slate);
    border-bottom: 1px solid var(--color-border-trade-card-row-faint);
    font-size: 12px;
    white-space: nowrap;
}

.tc-margin-table td:first-child {
    text-align: left;
    padding-left: 0;
    color: var(--palette-slate-400);
}

.tc-margin-table tbody tr:last-child td { border-bottom: none; }

/* Change column colors */
.tc-margin-pos { color: var(--color-pnl-warn-alt); }   /* Margin increase — amber (more capital required) */
.tc-margin-neg { color: var(--color-pnl-negative-alt); }   /* Equity decrease — red (cost) */

/* Special case: equity gain is green */
.tc-margin-table tr:last-child .tc-margin-pos { color: var(--color-pnl-positive-alt); }  /* equity increase = good */
.tc-margin-table tr:last-child .tc-margin-neg { color: var(--color-pnl-negative-alt); }  /* equity decrease = cost */

.tc-margin-commission {
    margin-top: 7px;
    font-size: 11px;
    color: var(--palette-slate-400);
    text-align: right;
}

.tc-margin-commission strong {
    color: var(--color-text-light-slate);
}

.tc-preview-note {
    grid-column: 1 / -1;
    font-size: 11px;
    color: var(--color-accent);
    opacity: 0.75;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--color-border-trade-card-section);
}

.tc-preview-error {
    grid-column: 1 / -1;
    color: var(--color-pnl-negative-alt);
    font-size: 12px;
    padding: 4px 0;
}

/* Status bar */
.trade-card-status {
    margin-top: 10px;
    font-size: 12px;
    min-height: 18px;
    line-height: 1.4;
}

.tc-status-error   { color: var(--color-pnl-negative-alt); }
.tc-status-success { color: var(--color-pnl-positive-alt); }

/* Footer */
.trade-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 14px;
    border-top: 1px solid var(--color-border-trade-card-section);
    flex-shrink: 0;
}

.trade-card-footer-spacer { flex: 1; }

.tc-transmit-btn {
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    font-weight: 700;
    font-size: 13px;
    padding: 7px 22px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 0.03em;
}

.tc-transmit-btn:hover:not(:disabled) {
    background: var(--color-accent-tint-strong-alt);
}

.tc-transmit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* "+ New Order" button uses the shared .btn.btn-primary.btn-sm classes —
   no custom rule needed; matches "+ New Strategy" in the Strategies header. */

/* ── Option Details section (dry-run preview) ──────────────────────────────── */

.tc-opt-section {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--color-bg-trade-card-margin);
    border: 1px solid var(--color-border-trade-card-section);
    border-radius: var(--r-md);
}

.tc-opt-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 9px;
}

/* Premium line */
.tc-opt-premium {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--color-border-trade-card-section);
    flex-wrap: wrap;
}

.tc-opt-premium-label {
    font-size: 12px;
    color: var(--palette-slate-400);
    font-weight: 600;
    flex-shrink: 0;
}

.tc-opt-premium-calc {
    font-size: 11px;
    color: var(--color-text-faint-slate);
    flex: 1;
}

.tc-opt-premium-value {
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.tc-opt-cost   { color: var(--color-pnl-negative-alt); }   /* BUY = cost = red */
.tc-opt-credit { color: var(--color-pnl-positive-alt); }   /* SELL = credit received = green */

/* Two-column Greeks grid */
.tc-opt-greeks-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

.tc-opt-greeks-col {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tc-opt-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-fainter-slate);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 5px;
}

.tc-opt-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
    border-bottom: 1px solid var(--color-border-trade-card-row-fainter);
}

.tc-opt-row span   { color: var(--palette-slate-400); }
.tc-opt-row strong { color: var(--color-text-light-slate); font-weight: 600; }

/* IV gets a slightly larger highlight */
.tc-opt-iv-row strong { font-size: 13px; }
.tc-opt-iv    { color: var(--color-pnl-warn-alt) !important; }  /* amber */
.tc-opt-theta { color: var(--color-pnl-negative-alt) !important; }  /* red — theta decay is a cost */
.tc-opt-itm   { color: var(--color-pnl-positive-alt); }
.tc-opt-otm   { color: var(--palette-slate-400); }

/* Probability of profit row */
.tc-pop-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 10px;
    margin-bottom: 10px;
    background: var(--color-bg-trade-card-pop);
    border: 1px solid var(--color-border-trade-card-section);
    border-radius: var(--r-md);
    flex-wrap: wrap;
}

.tc-pop-label {
    font-size: 11px;
    color: var(--palette-slate-400);
    font-weight: 600;
    flex-shrink: 0;
}

.tc-pop-value {
    font-size: 22px;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

.tc-pop-high { color: var(--color-pnl-positive-alt); }
.tc-pop-med  { color: var(--color-pnl-warn-alt); }
.tc-pop-low  { color: var(--color-pnl-negative-alt); }

.tc-pop-desc {
    font-size: 11px;
    color: var(--color-text-fainter-slate);
    font-style: italic;
    flex: 1;
    min-width: 0;
}

.tc-opt-no-greeks {
    font-size: 11px;
    color: var(--color-text-fainter-slate);
    font-style: italic;
    padding: 4px 0;
}

/* =============================================================================
   BRACKET ORDER — toggle row, field group, and preview leg headers
   ============================================================================= */

/* Toggle row — visually distinct from normal check fields */
.tc-bracket-toggle-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border-strong);
}
.tc-bracket-toggle-row label {
    color: var(--color-accent);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
}

/* Divider label inside the bracket fields block */
.tc-bracket-divider {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.7;
    padding: 6px 0 2px 0;
    border-top: 1px solid var(--color-accent-tint-medium);
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Preview panel — per-leg section headers */
.tc-bracket-leg-header {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 5px 10px 3px 10px;
    margin-top: 8px;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tc-bracket-entry { background: var(--color-status-info-cornflower-bg-hover); color: var(--color-status-info-cornflower); }
.tc-bracket-tp    { background: var(--color-bg-bracket-tp-tint);  color: var(--color-pnl-positive-alt); }
.tc-bracket-sl    { background: var(--color-bg-bracket-sl-tint); color: var(--color-pnl-negative-alt); }

.tc-bracket-leg-contract { margin-bottom: 6px; }

/* Leg content — slight indent to group under header */
.tc-bracket-leg {
    padding: 2px 0 4px 0;
    border-bottom: 1px solid var(--color-border-trade-card-row);
}

/* =============================================================================
   END TRADE CARD
   ============================================================================= */

/* =============================================================================
   SYMBOL DETAIL WINDOW  (.sdw)
   ============================================================================= */

.sdw {
    position: fixed;
    display: flex;
    flex-direction: column;
    /* z-index set dynamically from the shared window counter (_winZ/nextWinZ in monitor.js);
       increments on focus so any window can be brought over any other. Modals sit above all. */
    width: 680px;
    height: 720px;
    /* Use min() so the floor can never exceed the viewport — without this,
       min-width:420px would override max-width:98vw on a narrow phone and
       force the window wider than the screen. */
    min-width: min(420px, calc(100vw - 16px));
    min-height: min(320px, calc(100vh - 16px));
    max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px);
    resize: both;
    overflow: hidden;
    background: var(--color-bg-sdw);
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sdw);
    /* position set by JS */
}

.sdw-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--color-bg-sdw-header);
    border-bottom: 1px solid var(--color-border-sdw);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
}

.sdw-header:active {
    cursor: grabbing;
}

.sdw-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-sdw-title);
    white-space: nowrap;
}

.sdw-subtitle {
    font-size: 11px;
    color: var(--color-text-sdw-subtitle);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sdw-close,
.sdw-maximize {
    background: none;
    border: none;
    color: var(--color-text-sdw-subtitle);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.sdw-close:hover,
.sdw-maximize:hover {
    color: var(--color-text-sdw-title);
    background: var(--shadow-sdw-close-hover);
}

/* Maximized state — fills the viewport. !important wins over inline left/top/
   width/height set by the drag/resize code (those persist between sessions and
   are restored on un-maximize via _sdwSavedRect). */
.sdw.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    resize: none !important;
}
.sdw.maximized .sdw-header {
    cursor: default;
    border-radius: 0;
}

.sdw-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    min-height: 0;
}

/* watchlist-detail-content inside the SDW */
.sdw-body .watchlist-detail-content {
    padding: 4px 8px 8px;
}

/* Tighten detail sections inside SDW */
.sdw-body .detail-section-content {
    padding: 4px 6px 6px;
}

/* Clickable symbol triggers in portfolio / option cards */
.sdw-trigger {
    cursor: pointer;
    color: inherit;
    border-bottom: 1px dashed var(--color-border-sdw-trigger-dashed);
    transition: color 0.15s, border-color 0.15s;
}

.sdw-trigger:hover {
    color: var(--color-text-sdw-link);
    border-bottom-color: var(--color-text-sdw-link);
}

/* Loading / error states inside SDW sections */
.sdw-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    color: var(--color-text-sdw-muted);
    font-size: 12px;
}

.sdw-error {
    padding: 10px;
    color: var(--color-status-danger);
    font-size: 12px;
    font-style: italic;
}

/* ── Fundamentals ─────────────────────────────────────────────── */
.fund-header {
    margin-bottom: 6px;
}

.fund-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-sdw-strong);
    margin-bottom: 2px;
}

.fund-meta {
    font-size: 10px;
    color: var(--color-text-sdw-muted);
}

/* Two-column layout for metric rows */
.fund-two-col {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}

.fund-col {
    flex: 1;
    min-width: 0;
}

/* Each metric as a compact label: value row */
.fund-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 4px;
    border-bottom: 1px solid var(--color-overlay-row-tint);
    gap: 6px;
}

.fund-row:last-child {
    border-bottom: none;
}

.fund-rl {
    font-size: 10px;
    color: var(--color-text-sdw-muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}

.fund-rv {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-sdw-strong);
    text-align: right;
    white-space: nowrap;
}

.fund-description {
    font-size: 11px;
    color: var(--color-text-sdw-muted);
    line-height: 1.45;
    max-height: 54px;
    overflow: hidden;
    cursor: pointer;
    transition: max-height 0.25s ease;
    border-top: 1px solid var(--color-border-sdw-divider);
    padding-top: 5px;
    margin-top: 2px;
}

.fund-description.expanded {
    max-height: 500px;
}

/* ── Analyst ──────────────────────────────────────────────────── */
.analyst-rating-row {
    margin-bottom: 6px;
}

.analyst-rating-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--r-md);
    border: 1px solid;
    min-width: 60px;
    text-align: center;
}

.analyst-score {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.analyst-rec {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    opacity: 0.85;
}

.analyst-rating-date {
    font-size: 9px;
    opacity: 0.6;
    margin-top: 1px;
}

.analyst-rating-badge.rating-buy {
    color: var(--color-rating-buy-fg);
    border-color: var(--color-rating-buy-border);
    background: var(--color-rating-buy-bg);
}

.analyst-rating-badge.rating-neutral {
    color: var(--color-rating-hold-fg);
    border-color: var(--color-rating-hold-border);
    background: var(--color-rating-hold-bg);
}

.analyst-rating-badge.rating-sell {
    color: var(--color-rating-sell-fg);
    border-color: var(--color-rating-sell-border);
    background: var(--color-rating-sell-bg);
}

.analyst-rating-badge.rating-unknown {
    color: var(--color-rating-na-fg);
    border-color: var(--color-rating-na-border);
    background: var(--color-rating-na-bg);
}

.analyst-table,
.earnings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.analyst-table th,
.analyst-table td,
.earnings-table th,
.earnings-table td {
    padding: 3px 5px;
    text-align: right;
    border-bottom: 1px solid var(--color-border-sdw-divider);
    white-space: nowrap;
}

.analyst-table th,
.earnings-table th {
    color: var(--color-text-sdw-muted);
    font-weight: 500;
    text-align: right;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.analyst-table td:first-child,
.analyst-table th:first-child,
.earnings-table td:first-child,
.earnings-table th:first-child {
    text-align: left;
}

.analyst-table tr.current-year td {
    background: var(--color-bg-sdw-link-tint);
}

.analyst-range {
    color: var(--color-text-sdw-muted);
    font-size: 10px;
}

/* ── Earnings ─────────────────────────────────────────────────── */
.earnings-next-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    background: var(--color-bg-sdw-badge);
    border: 1px solid var(--color-border-sdw-badge);
    color: var(--color-text-sdw-link);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 5px;
}

.earnings-time-badge {
    font-size: 10px;
    font-weight: 400;
    color: var(--color-text-sdw-muted);
    background: var(--color-bg-sdw-pill-tint);
    border-radius: var(--r-sm);
    padding: 1px 4px;
}

/* =============================================================================
   END SYMBOL DETAIL WINDOW
   ============================================================================= */

/* =============================================================================
   STRATEGIES SECTION
   ============================================================================= */

/* ── Table ─────────────────────────────────────────────────────────────────── */
.strat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.strat-table th {
    padding: 6px 10px;
    text-align: left;
    color: var(--color-text-sdw-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--color-border-sdw-divider);
    white-space: nowrap;
}

.strat-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--color-bg-sdw-header);
    vertical-align: middle;
}

.strat-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.strat-row:hover {
    background-color: var(--color-bg-sdw-section-band);
}

.strat-name-cell {
    min-width: 180px;
}

.strat-expand-icon {
    color: var(--color-text-sdw-link);
    margin-right: 5px;
    font-size: 10px;
}

.strat-desc {
    display: block;
    font-size: 10px;
    color: var(--color-text-sdw-muted);
    margin-top: 1px;
}

.strat-id-hint {
    display: block;
    font-size: 10px;
    opacity: 0.7;
    font-family: ui-monospace, monospace;
    margin-top: 2px;
    color: var(--color-text-sdw-muted);
}

.strat-live-line {
    font-size: 10px;
    margin-top: 4px;
    color: var(--color-text-sdw-link-light);
    font-family: ui-monospace, monospace;
}

.strat-state-cell {
    font-family: monospace;
    font-size: 11px;
    color: var(--palette-gh-text-100);
}

.strat-actions-cell {
    white-space: nowrap;
    text-align: right;
}

.strat-btn {
    margin-left: 3px;
}

.strat-btn-stop {
    background-color: var(--color-bg-strat-suspended);
    border: 1px solid var(--color-border-strat-suspended);
    color: var(--color-fg-strat-suspended);
}

.strat-btn-stop:hover {
    background-color: var(--color-bg-strat-suspended-pill);
}

.strat-btn-delete {
    background-color: var(--color-bg-strat-killswitch);
    border: 1px solid var(--color-border-strat-killswitch);
    color: var(--color-fg-strat-killswitch);
}

.strat-btn-delete:hover {
    background-color: var(--color-bg-strat-killswitch-pill);
    color: var(--palette-white);
}

/* ── Status Badges ─────────────────────────────────────────────────────────── */
.strat-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--r-lg);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.strat-badge-active     { background: var(--color-strat-active-bg);  color: var(--color-strat-active-fg); border: 1px solid var(--color-strat-active-border);  }
.strat-badge-paused     { background: var(--color-strat-paused-bg);  color: var(--color-strat-paused-fg); border: 1px solid var(--color-strat-paused-border);  }
.strat-badge-stopped    { background: var(--color-strat-stopped-bg);color: var(--color-strat-stopped-fg); border: 1px solid var(--color-strat-stopped-border);}
.strat-badge-created    { background: var(--color-strat-created-bg); color: var(--color-strat-created-fg); border: 1px solid var(--color-strat-created-border); }
.strat-badge-error      { background: var(--color-strat-error-bg);  color: var(--color-strat-error-fg); border: 1px solid var(--color-strat-error-border);  }
.strat-badge-flattening { background: var(--color-strat-flatten-bg);  color: var(--color-strat-flatten-fg); border: 1px solid var(--color-strat-flatten-border);  }
.strat-badge-unknown    { background: var(--color-strat-unknown-bg); color: var(--color-strat-unknown-fg); border: 1px solid var(--color-strat-unknown-border);}

/* ── Symbol link badge (in strategy name cell and order rows) ──────────────── */
.strat-symbol-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    font-size: 10px;
    font-weight: 700;
    background: var(--color-bg-strat-badge);
    color: var(--color-fg-strat-badge);
    border: 1px solid var(--color-border-strat-badge);
    cursor: pointer;
    margin-left: 6px;
    letter-spacing: 0.4px;
    transition: background 0.15s;
    white-space: nowrap;
}
.strat-symbol-badge:hover { background: var(--color-bg-strat-badge-hover); }

.sdw-trigger-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    font-size: 10px;
    font-weight: 700;
    background: var(--color-bg-strat-badge);
    color: var(--color-fg-strat-badge);
    border: 1px solid var(--color-border-strat-badge);
    cursor: pointer;
    letter-spacing: 0.4px;
    transition: background 0.15s;
    white-space: nowrap;
}
.sdw-trigger-badge:hover { background: var(--color-bg-strat-badge-hover); }

/* ── PnL colours (reusable) ────────────────────────────────────────────────── */
.strat-pnl-pos { color: var(--color-strat-pnl-pos); }
.strat-pnl-neg { color: var(--color-strat-pnl-neg); }

td.pnl-positive { color: var(--color-strat-pnl-pos); }
td.pnl-negative { color: var(--color-strat-pnl-neg); }

/* ── Detail Panel ──────────────────────────────────────────────────────────── */
.strat-detail-row td {
    padding: 0;
    border-bottom: 2px solid var(--color-border-strat-row-divider);
}

.strat-detail-cell {
    background-color: var(--color-bg-strat-row-selected);
    border-left: 3px solid var(--color-border-strat-row-selected);
    border-right: 3px solid var(--color-border-strat-row-divider);
    border-bottom: 3px solid var(--color-border-strat-row-divider);
}

.strat-detail-panel {
    padding: 12px 14px 14px;
}

/* Highlight the row that is currently expanded */
.strat-row.expanded-row {
    background: var(--color-bg-strat-row-expanded);
    border-left: 3px solid var(--color-border-strat-row-selected);
}

/* ── Tab Bar ───────────────────────────────────────────────────────────────── */
.strat-tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border-strat-row-divider);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.strat-tab-btn {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--color-text-sdw-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.strat-tab-btn:hover {
    background: var(--color-bg-sdw-badge);
    color: var(--palette-gh-text-100);
}

.strat-tab-btn.active {
    background: var(--color-bg-strat-badge);
    border-color: var(--color-text-sdw-link);
    color: var(--color-text-sdw-link);
}

/* ── Status Grid ───────────────────────────────────────────────────────────── */
.strat-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.strat-stat-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: var(--color-bg-strat-detail-card);
    border: 1px solid var(--color-border-strat-detail-card);
    border-radius: var(--r-md);
}

.strat-stat-label {
    font-size: 10px;
    color: var(--color-text-strat-label);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
}

.strat-stat-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-strat-value);
}

.strat-stat-value.strat-state-value {
    font-family: monospace;
    font-size: 12px;
    color: var(--color-text-strat-value-emphasis);
}

.strat-stat-value.strat-small {
    font-size: 11px;
    font-weight: 400;
}

.strat-error-bar {
    background: var(--color-bg-strat-error-banner);
    border: 1px solid var(--color-border-strat-error-banner);
    border-radius: var(--r-sm);
    color: var(--color-text-strat-error);
    padding: 6px 10px;
    font-size: 11px;
    margin-bottom: 12px;
}

.strat-subsection-header {
    font-size: 11px;
    color: var(--color-text-strat-label);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin: 10px 0 6px;
}

/* ── Inner Tables (active orders, cycles, log) ─────────────────────────────── */
.strat-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.strat-inner-table th {
    padding: 4px 8px;
    text-align: left;
    color: var(--color-text-sdw-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--color-border-sdw-divider);
    white-space: nowrap;
}

.strat-inner-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-bg-sdw-header);
    color: var(--palette-gh-text-100);
    vertical-align: middle;
}

.strat-inner-table tr:last-child td {
    border-bottom: none;
}

.num-cell {
    text-align: right;
}

.strat-role-badge {
    display: inline-block;
    padding: 1px 6px;
    background: var(--color-bg-strat-pop-tint);
    border: 1px solid var(--color-border-strat-pop-tint);
    border-radius: var(--r-sm);
    color: var(--color-text-sdw-link-light);
    font-size: 10px;
    font-family: monospace;
}

.strat-oca-cell {
    font-family: monospace;
    font-size: 10px;
    color: var(--color-text-sdw-muted);
}

.strat-exit-reason {
    font-family: monospace;
    font-size: 10px;
    color: var(--color-text-strat-tan);
}

.strat-log-time {
    white-space: nowrap;
    font-size: 10px;
    color: var(--color-text-sdw-muted);
}

.strat-log-msg {
    color: var(--color-text-strat-pop);
    max-width: 400px;
}

/* ── Event Type Badges ─────────────────────────────────────────────────────── */
.strat-ev-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    font-family: monospace;
}

.strat-ev-blue   { background: var(--color-strat-ev-blue-bg); color: var(--color-strat-ev-blue-fg); }
.strat-ev-green  { background: var(--color-strat-ev-green-bg);  color: var(--color-strat-ev-green-fg); }
.strat-ev-orange { background: var(--color-strat-ev-orange-bg);  color: var(--color-strat-ev-orange-fg); }
.strat-ev-red    { background: var(--color-strat-ev-red-bg);  color: var(--color-strat-ev-red-fg); }
.strat-ev-yellow { background: var(--color-strat-ev-yellow-bg);  color: var(--color-strat-ev-yellow-fg); }
.strat-ev-purple { background: var(--color-strat-ev-purple-bg);color: var(--color-strat-ev-purple-fg); }
.strat-ev-gray   { background: var(--color-strat-ev-gray-bg);color: var(--color-strat-ev-gray-fg); }

/* ── Parameters Tab ────────────────────────────────────────────────────────── */
.strat-params-container {
    max-width: 420px;
}

.strat-params-table {
    margin-bottom: 10px;
}

.strat-param-key {
    font-family: monospace;
    color: var(--color-text-sdw-link-light);
}

.strat-param-input {
    width: 140px;
    padding: 3px 6px;
    font-size: 11px;
    font-family: monospace;
    background: var(--color-bg-sdw-header);
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-sm);
    color: var(--color-text-sdw-strong);
}

.strat-param-input:focus {
    outline: none;
    border-color: var(--color-text-sdw-link);
}

.strat-params-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
}

.strat-param-status {
    font-size: 11px;
}

.strat-param-ok  { color: var(--color-strat-param-ok); }
.strat-param-err { color: var(--color-strat-param-err); }

/* ── Cycles Table ──────────────────────────────────────────────────────────── */
.strat-cycles-table {
    overflow-x: auto;
    display: block;
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.strat-empty {
    color: var(--color-text-sdw-muted);
    font-size: 12px;
    font-style: italic;
    padding: 8px 0;
    margin: 0;
}

/* =============================================================================
   END STRATEGIES SECTION
   ============================================================================= */

/* =============================================================================
   STRATEGY BUILDER MODAL
   ============================================================================= */

.strat-builder-modal {
    /* JS sets position:fixed + left/top/width/height on open */
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
    background: var(--color-bg-strat-builder);
    border: 1px solid var(--color-border-strat-builder);
    box-shadow: var(--shadow-strat-builder);
    /* Resizable — requires overflow != visible */
    resize: both;
    overflow: hidden;
    min-width: 320px;
    min-height: 300px;
    /* No max-width or max-height — let the user size it as large as they want */
    max-width: none;
    max-height: none;
}

.strat-builder-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--color-border-strat-row-divider);
    gap: 12px;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.strat-builder-header:active {
    cursor: grabbing;
}

.strat-builder-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.strat-builder-title-row h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-sdw-strong);
}

.strat-builder-mode-toggle {
    display: flex;
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-md);
    overflow: hidden;
}

.strat-mode-btn {
    padding: 3px 12px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--color-text-sdw-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.strat-mode-btn.active {
    background: var(--color-bg-strat-builder-tab-active);
    color: var(--color-text-sdw-link);
}

.strat-mode-btn:hover:not(.active) {
    background: var(--color-bg-strat-builder-tab-hover);
    color: var(--palette-gh-text-100);
}

.strat-builder-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    min-height: 0; /* critical: lets flex child shrink below content height */
}

.strat-builder-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

/* ── JSON Panel ─────────────────────────────────────────────────────────────── */
.strat-json-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.strat-json-hint {
    font-size: 11px;
    color: var(--color-text-sdw-muted);
}

.strat-json-hint code {
    background: var(--color-bg-strat-pop-tint);
    color: var(--color-text-sdw-link-light);
    padding: 1px 5px;
    border-radius: var(--r-sm);
    font-size: 11px;
}

.strat-json-toolbar-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Wrapper that provides the anchor point for the dropdown */
.strat-template-wrapper {
    position: relative;
}

.strat-template-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--color-bg-strat-builder-card);
    border: 1px solid var(--color-border-strat-builder);
    border-radius: var(--r-md);
    min-width: 240px;
    z-index: 1100;
    box-shadow: var(--shadow-strat-builder-popup);
    padding: 4px 0;
}

.strat-template-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 14px;
    background: transparent;
    border: none;
    color: var(--palette-gh-text-100);
    font-size: 12px;
    cursor: pointer;
}

.strat-template-dropdown button:hover {
    background: var(--color-bg-sdw-badge);
    color: var(--color-text-sdw-link);
}

.strat-json-editor {
    flex: 1;
    min-height: 340px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.55;
    padding: 12px 14px;
    background: var(--color-bg-sdw);
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-md);
    color: var(--color-text-sdw-strong);
    resize: vertical;
    tab-size: 2;
}

.strat-json-editor:focus {
    outline: none;
    border-color: var(--color-text-sdw-link);
}

.strat-json-error {
    background: var(--color-bg-strat-json-error);
    border: 1px solid var(--color-border-strat-error-banner);
    border-radius: var(--r-md);
    color: var(--color-strat-param-err);
    font-size: 12px;
    font-family: monospace;
    padding: 8px 12px;
    white-space: pre-wrap;
}

/* ── Guided Form Panel ──────────────────────────────────────────────────────── */
.strat-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.strat-form-section {
    background: var(--color-bg-sdw);
    border: 1px solid var(--color-border-sdw-divider);
    border-radius: var(--r-md);
    padding: 10px 12px;
}

.strat-form-section-full {
    grid-column: 1 / -1;
}

.strat-form-heading {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-sdw-muted);
}

.strat-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.strat-form-row label {
    font-size: 11px;
    color: var(--color-text-sdw-muted);
    min-width: 140px;
    flex-shrink: 0;
}

.strat-form-hint {
    font-size: 10px;
    color: var(--color-text-strat-builder-dim);
    font-weight: 400;
}

.strat-form-input, .strat-form-select {
    flex: 1;
    padding: 4px 7px;
    font-size: 11px;
    font-family: inherit;
    background: var(--color-bg-sdw-header);
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-sm);
    color: var(--color-text-sdw-strong);
}

.strat-form-input:focus, .strat-form-select:focus {
    outline: none;
    border-color: var(--color-text-sdw-link);
}

.strat-form-input-sm { max-width: 120px; flex: 0 0 auto; }

.strat-form-checkbox-row {
    gap: 14px;
}

.strat-form-checkbox-row label {
    min-width: unset;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--palette-gh-text-100);
    cursor: pointer;
}

.sf-params-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 8px;
}

.sf-param-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sf-param-key, .sf-param-val {
    padding: 3px 7px;
    font-size: 11px;
    font-family: monospace;
    background: var(--color-bg-sdw-header);
    border: 1px solid var(--color-border-sdw);
    border-radius: var(--r-sm);
    color: var(--color-text-sdw-strong);
}

.sf-param-key { width: 160px; }
.sf-param-val { width: 120px; }

.sf-param-remove {
    background: transparent;
    border: none;
    color: var(--color-text-strat-builder-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
}

.sf-param-remove:hover { color: var(--color-strat-param-err); }

.strat-form-preview-label {
    font-size: 10px;
    color: var(--color-text-strat-builder-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.strat-form-preview {
    min-height: 160px;
    opacity: 0.7;
    background: var(--color-bg-strat-builder-pre);
    resize: vertical;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.strat-builder-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px 14px;
    border-top: 1px solid var(--color-border-strat-row-divider);
    gap: 12px;
    flex-shrink: 0;
}

.strat-builder-status {
    font-size: 12px;
    flex: 1;
}

.strat-builder-status.ok  { color: var(--color-strat-param-ok); }
.strat-builder-status.err { color: var(--color-strat-param-err); }

.strat-builder-actions {
    display: flex;
    gap: 8px;
}

/* =============================================================================
   END STRATEGY BUILDER MODAL
   ============================================================================= */

/* =============================================================================
   HASHTABLE BROWSER
   ============================================================================= */

/* ── Section header prefix input — matches btn-sm height ── */
.ht-prefix-input {
    width: 200px;
    padding: 4px 10px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-symbol-search-input);
    color: var(--color-text-symbol-search);
    font-size: 12px;
    font-family: inherit;
    line-height: 1.4;
}
.ht-prefix-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* ── Saved-prefix chips (shared across sessions via hashtable) ── */
.ht-saved-prefixes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    max-width: 60vw;
}

.ht-prefix-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px 2px 10px;
    border-radius: var(--r-xl);
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-symbol-search-input);
    color: var(--color-text-symbol-search);
    font-size: 11px;
    font-family: monospace;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ht-prefix-chip:hover {
    border-color: var(--color-accent);
    background: var(--color-bg-symbol-search-active);
}

.ht-prefix-chip.active {
    border-color: var(--color-accent);
    background: var(--color-accent-tint-table-cell);
    color: var(--color-accent);
}

.ht-prefix-chip-label {
    pointer-events: none;
}

.ht-prefix-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ht-prefix-chip-x:hover {
    opacity: 1;
    background: var(--color-status-danger-tint-medium);
    color: var(--color-status-danger);
}

/* ── Results table ── */
.ht-results-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
}
.ht-results-table th,
.ht-results-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-default);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ht-results-table th {
    background: var(--color-bg-ht-header);
    color: var(--color-text-ht-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}
.ht-results-table tr:hover td {
    background: var(--color-bg-ht-row-hover);
}
.ht-col-key     { width: 28%; font-family: monospace; font-size: 11px; }
.ht-col-value   { width: 34%; color: var(--color-text-ht-secondary); font-family: monospace; font-size: 11px; }
.ht-col-update  { width: 18%; }
.ht-col-ttl     { width: 8%;  }
.ht-col-actions { width: 12%; }

/* ── Edit modal overlay ── */
.ht-edit-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100000;
    /* transparent — dialog is positioned, not centred, so no backdrop needed */
    pointer-events: none;
}
.ht-edit-overlay[style*="block"] {
    pointer-events: all;
}

/* ── Edit dialog ── */
.ht-edit-dialog {
    position: fixed;
    min-width: 400px;
    min-height: 300px;
    max-width: 98vw;
    max-height: 96vh;
    background: var(--color-bg-ht-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-ht-modal);
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    z-index: 1100001;
    box-sizing: border-box;
}

/* ── Header (drag handle) ── */
.ht-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--color-bg-ht-header);
    border-bottom: 1px solid var(--color-border-default);
    cursor: move;
    user-select: none;
    flex-shrink: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.ht-edit-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-ht-primary);
}

/* ── Body ── */
.ht-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

/* 2-column meta grid */
.ht-edit-meta-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 4px 12px;
    font-size: 12px;
}
.ht-meta-label {
    color: var(--color-text-ht-secondary);
    font-weight: 600;
    padding-top: 2px;
}
.ht-meta-value {
    color: var(--color-text-ht-primary);
    font-family: monospace;
    word-break: break-all;
}
.ht-edit-key-input {
    width: 100%;
    max-width: 100%;
    padding: 4px 8px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-ht-primary);
    font-family: monospace;
    font-size: 12px;
    box-sizing: border-box;
}
.ht-edit-key-input:focus {
    outline: none;
    border-color: var(--color-accent);
}
.ht-edit-ttl-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.ht-edit-ttl-input {
    width: 100px;
    padding: 4px 8px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-ht-primary);
    font-family: monospace;
    font-size: 12px;
}
.ht-edit-ttl-input:focus {
    outline: none;
    border-color: var(--color-accent);
}
.ht-meta-hint {
    font-size: 10px;
    color: var(--color-text-ht-secondary);
    line-height: 1.3;
}

.ht-value-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-ht-secondary);
}

/* ── Value textarea ── */
.ht-edit-value {
    flex: 1;
    width: 100%;
    min-height: 140px;
    padding: 8px 10px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    color: var(--color-text-ht-primary);
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
    box-sizing: border-box;
}
.ht-edit-value:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* ── Footer ── */
.ht-edit-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--color-border-default);
    background: var(--color-bg-ht-header);
    flex-shrink: 0;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* =============================================================================
   END HASHTABLE BROWSER
   ============================================================================= */

/* ── Put Protection Score (PPS) ───────────────────────────────────────────── */
.pps-dashboard-row {
    cursor: pointer;
}
.pps-dashboard-row:focus {
    outline: 1px solid var(--color-accent-border-bright);
    outline-offset: 2px;
}
.pps-dashboard-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
}
.pps-dashboard-label #pps-dashboard-rating-pill:empty {
    display: none;
}
.pps-dashboard-value {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex-shrink: 0;
}
.pps-score-num {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.pps-progress-track {
    width: 96px;
    max-width: 28vw;
    height: 6px;
    background: var(--color-bg-pps-track);
    border-radius: var(--r-sm);
    overflow: hidden;
    flex-shrink: 0;
}
.pps-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--r-sm);
    transition: width 0.25s ease, background 0.2s ease;
}
button.pps-inline-gear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    padding: 0 4px;
    min-width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
    background: transparent;
    border: 1px solid var(--color-border-pps-gear);
    border-radius: var(--r-sm);
    color: var(--palette-slate-500);
    cursor: pointer;
}
button.pps-inline-gear:hover {
    color: var(--color-accent);
    border-color: var(--color-border-pps-gear-hover);
}
.pps-floating-win {
    left: max(12px, calc(50vw - min(460px, 48vw)));
    top: max(24px, 6vh);
}
.pps-drilldown-body,
.pps-settings-body {
    min-height: 0;
}
.pps-drilldown-scroll,
.pps-settings-scroll {
    flex: 1;
    overflow: auto;
    min-height: 0;
}
.pps-drilldown-foot {
    flex-shrink: 0;
    margin-top: 10px;
    font-size: 12px;
    color: var(--palette-slate-500);
    line-height: 1.4;
}
.pps-excluded strong {
    color: var(--palette-slate-300);
}
.pps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.pps-table th,
.pps-table td {
    border: 1px solid var(--palette-navy-600);
    padding: 6px 8px;
    text-align: right;
}
.pps-table th:first-child,
.pps-table td:first-child {
    text-align: left;
}
.pps-table thead th {
    background: var(--palette-navy-900);
    color: var(--palette-slate-500);
    font-weight: 600;
}
.pps-note {
    color: var(--palette-slate-300);
    font-size: 13px;
    line-height: 1.45;
}
.pps-muted {
    color: var(--palette-slate-500);
    font-size: 13px;
}
.pps-settings-version {
    font-size: 11px;
    color: var(--palette-slate-500);
    margin: 0 0 8px 0;
}
.pps-settings-section {
    margin-bottom: 14px;
}
.pps-settings-section h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--palette-slate-300);
}
.pps-settings-section label {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--palette-slate-500);
}
.pps-hint {
    font-size: 11px;
    color: var(--palette-slate-600);
    margin: 6px 0 0 0;
    max-width: 52em;
}
.pps-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.pps-edit-table th,
.pps-edit-table td {
    border: 1px solid var(--palette-navy-600);
    padding: 4px 6px;
}
.pps-edit-table input.pps-inp {
    width: 100%;
    max-width: 120px;
    box-sizing: border-box;
    background: var(--palette-navy-900);
    border: 1px solid var(--color-border-trade-card);
    color: var(--color-text-ht-primary);
    border-radius: var(--r-sm);
    padding: 3px 5px;
}
.pps-edit-table input.pps-color {
    max-width: 48px;
    padding: 2px;
    height: 28px;
}
.pps-settings-error {
    color: var(--color-text-pps-warning);
    font-size: 12px;
    margin-top: 8px;
    white-space: pre-wrap;
}
.pps-weight-sum {
    font-size: 11px;
    color: var(--palette-slate-500);
    margin: 0 0 8px 0;
}

.pps-inclusion-section h4 {
    margin-bottom: 8px;
}
.pps-inclusion-doc {
    background: var(--color-bg-pps-doc);
    border: 1px solid var(--palette-navy-600);
    border-radius: var(--r-md);
    padding: 10px 12px;
    margin-bottom: 4px;
}
.pps-inclusion-formula {
    margin: 0 0 10px 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--palette-slate-300);
}
.pps-inclusion-formula:last-child {
    margin-bottom: 0;
}
.pps-inclusion-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--palette-slate-500);
    max-width: 40em;
}
.pps-inclusion-label .pps-inp {
    max-width: 140px;
}

/* PPS drill-down — inclusion transparency */
.pps-inclusion-transparency {
    margin-bottom: 16px;
    border: 1px solid var(--palette-navy-600);
    border-radius: var(--r-md);
    background: var(--color-bg-pps-transparency);
}
.pps-transparency-summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    padding: 8px 12px;
    list-style-position: inside;
}
.pps-transparency-wrap {
    padding: 0 12px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.pps-transparency-block {
    border-top: 1px solid var(--color-border-pps-transparency-divider);
    padding-top: 12px;
}
.pps-transparency-block:first-of-type {
    border-top: none;
    padding-top: 0;
}
.pps-transparency-symbol {
    font-weight: 700;
    font-size: 13px;
    color: var(--color-text-pps-trans-symbol);
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}
.pps-transparency-dl {
    display: grid;
    grid-template-columns: minmax(7.5rem, auto) 1fr;
    gap: 4px 14px;
    margin: 0;
    font-size: 11px;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.45;
    color: var(--color-text-pps-trans-mono);
}
.pps-transparency-dl dt {
    margin: 0;
    color: var(--color-text-pps-trans-dt);
    text-align: right;
}
.pps-transparency-dl dd {
    margin: 0;
    color: var(--color-text-pps-trans-dd);
}
.pps-transparency-sub {
    color: var(--palette-slate-600);
    font-size: 10px;
    font-weight: normal;
}
.pps-transparency-yes {
    color: var(--color-text-pps-trans-yes);
    font-weight: 600;
}
.pps-transparency-no {
    color: var(--color-text-pps-trans-no);
    font-weight: 600;
}
.pps-drilldown-subhead {
    font-size: 12px;
    font-weight: 600;
    color: var(--palette-slate-300);
    margin: 8px 0 8px 0;
}

/* =============================================================================
   PAGE-LEVEL TABS
   Strip lives at the top of #main-content. Sections not assigned to the
   active tab get .tab-hidden (display:none !important — overrides the inline
   display set by renderActiveAlerts on #active-alerts-container).
   ============================================================================= */

:root,
:root[data-theme="dark"],
:root[data-theme="light"] {
    --tabs-bar-height: 36px;
}

.tabs-bar {
    position: sticky;
    top: 0;
    z-index: 300;
    /* #main-content is a flex column; without flex:0 0 auto the bar gets
       shrunk by flex layout, which makes it appear as a zero-height line. */
    flex: 0 0 var(--tabs-bar-height);
    min-height: var(--tabs-bar-height);
    height: var(--tabs-bar-height);
    margin: 0 -16px 8px -16px;
    padding: 0 12px;
    /* Use --color-bg-toolbar (distinct from page bg) so the strip and its
       active tab (which uses page bg) are clearly distinguishable. */
    background: var(--color-bg-toolbar);
    border-bottom: 1px solid var(--color-border-strong);
    display: flex;
    align-items: stretch;
    gap: 4px;
    overflow: hidden;
    box-sizing: border-box;
}

.tabs-strip {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    gap: 2px;
    flex: 1 1 auto;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.tabs-strip li.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 12px;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-top-left-radius: var(--r-md);
    border-top-right-radius: var(--r-md);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    position: relative;
    top: 5px;
    height: calc(100% - 5px);
    box-sizing: border-box;
}

.tabs-strip li.tab:hover {
    background: var(--color-bg-section-header-hover);
    color: var(--color-text-primary);
}

.tabs-strip li.tab.active {
    color: var(--color-accent);
    background: var(--color-bg-page);
    border-color: var(--color-border-strong);
    border-bottom-color: var(--color-bg-page);
    font-weight: 600;
    z-index: 1;
}

.tabs-strip li.tab.active::after {
    /* Style D: pill tabs float inside the strip — nothing to merge. */
    display: none;
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--color-bg-page);
}

.tabs-strip li.tab.dragging {
    opacity: 0.4;
}

.tabs-strip li.tab.drop-target {
    box-shadow: inset 2px 0 0 var(--color-accent);
}

.tabs-strip li.tab .tab-label {
    line-height: 1;
}

.tabs-strip li.tab .tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 16px;
    line-height: 1;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.tabs-strip li.tab .tab-close:hover {
    background: var(--color-bg-button-secondary-hover);
    color: var(--color-text-primary);
}

.tabs-strip li.tab .tab-rename-input {
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-focus);
    border-radius: var(--r-sm);
    font-size: 12px;
    padding: 2px 6px;
    width: 9em;
    outline: none;
}

.tabs-add-btn {
    flex: 0 0 auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.tabs-add-btn:hover {
    background: var(--color-bg-button-secondary-hover);
    color: var(--color-text-primary);
    border-color: var(--color-border-strong-hover, var(--color-border-strong));
}

/* Right-click context menu for tabs */
.tabs-context-menu {
    position: fixed;
    z-index: 1000500;   /* above every window (they top out at 999999), below dialogs */
    min-width: 140px;
    background: var(--color-bg-card-elevated);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}

.tabs-context-menu button {
    text-align: left;
    background: transparent;
    color: var(--color-text-primary);
    border: none;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
}

.tabs-context-menu button:hover {
    background: var(--color-bg-row-hover);
}
.tabs-context-menu button:disabled {
    color: var(--color-text-muted);
    opacity: 0.5;
    cursor: default;
    background: transparent;
}

/* Empty-state callout when active tab has no assigned sections */
.tabs-empty-state {
    margin: 32px auto;
    max-width: 480px;
    padding: 16px 20px;
    background: var(--color-bg-card);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--r-lg);
    color: var(--color-text-secondary);
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}

.tabs-empty-state strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Hide rule: !important needed to override renderActiveAlerts inline style */
.tab-hidden {
    display: none !important;
}

/* Per-section Tab picker. The element itself gets `.btn.btn-secondary.btn-sm`
   classes from JS so it inherits the full button styling AND the
   section-header padding override at `h2.collapsible-header .section-header-buttons .btn`
   (`padding: 4px 10px`), which keeps it the same height as other dropdowns
   like the Notes "Order" select. This class only adds picker-specific limits. */
.section-tab-picker {
    max-width: 160px;
    cursor: pointer;
    flex-shrink: 0;
    /* Native <select> elements have a slightly different intrinsic height
       than <button>; line-height + box-sizing makes them visually match. */
    line-height: 1.2;
    box-sizing: border-box;
}

/* Active-alerts picker — push to the right edge of the header */
.active-alerts-header .section-tab-picker {
    margin-left: auto;
    margin-right: 8px;
}

/* Dashboard picker — sits next to Hide/Pin (which are 22px tall). */
.dashboard-controls .section-tab-picker {
    padding: 2px 8px;
    font-size: 11px;
    height: 22px;
}

/* =============================================================================
   CONFIGURATION > TABS PANEL
   Fallback management surface for tabs and section assignments. Always
   visible regardless of which sections are hidden on the current tab.
   ============================================================================= */

.tabs-config-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.tabs-cfg-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tabs-cfg-help {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
    flex: 1 1 200px;
}

.tabs-cfg-help code {
    background: var(--color-bg-input);
    padding: 1px 4px;
    border-radius: var(--r-sm);
    font-size: 11px;
}

.tabs-cfg-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tabs-cfg-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
}

.tabs-cfg-name {
    flex: 1 1 auto;
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-input);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    font-size: 12px;
    min-width: 100px;
}

.tabs-cfg-name:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.tabs-cfg-default-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-secondary);
    user-select: none;
    cursor: pointer;
}

.tabs-cfg-divider {
    border: none;
    border-top: 1px solid var(--color-border-default);
    margin: 8px 0 4px 0;
}

.tabs-cfg-subhead {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tabs-cfg-assign-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 6px 12px;
}

.tabs-cfg-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: var(--r-sm);
}

.tabs-cfg-assign-row:hover {
    background: var(--color-bg-row-hover);
}

.tabs-cfg-assign-label {
    flex: 1 1 auto;
    font-size: 12px;
    color: var(--color-text-primary);
}

.tabs-cfg-assign-select {
    flex: 0 0 auto;
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-input);
    border-radius: var(--r-sm);
    font-size: 11px;
    padding: 3px 6px;
    min-width: 100px;
    max-width: 160px;
    cursor: pointer;
}

.tabs-cfg-assign-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

.tabs-cfg-grip { color: var(--color-text-muted); cursor: grab; font-size: 14px; line-height: 1; user-select: none; padding: 0 2px; }
.tabs-cfg-row.dragging, .tabs-cfg-chip.dragging { opacity: .45; }
.tabs-cfg-row.drop-target { box-shadow: 0 -2px 0 0 var(--color-accent); }
.tabs-cfg-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; align-items: start; }
.tabs-cfg-col { border: 1px solid var(--color-border-default); border-radius: var(--r-lg); background: var(--color-bg-card); min-height: 80px; display: flex; flex-direction: column; }
.tabs-cfg-col.drop-into { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg-card)); }
.tabs-cfg-col-h { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--color-text-primary); border-bottom: 1px solid var(--color-border-default); }
.tabs-cfg-col-n { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--color-text-muted); background: var(--color-bg-secondary); border-radius: var(--r-pill); padding: 1px 7px; }
.tabs-cfg-col-body { display: flex; flex-direction: column; gap: 4px; padding: 6px; flex: 1 1 auto; }
.tabs-cfg-col-empty { font-size: 11px; color: var(--color-text-muted); text-align: center; padding: 14px 6px; border: 1px dashed var(--color-border-default); border-radius: var(--r-md); }
.tabs-cfg-chip { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: var(--r-md); background: var(--color-bg-secondary); border: 1px solid transparent; font-size: 12px; color: var(--color-text-primary); }
.tabs-cfg-chip:hover { border-color: var(--color-border-default); }
.tabs-cfg-chip.drop-target { box-shadow: 0 -2px 0 0 var(--color-accent); }
.tabs-cfg-chip-l { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs-cfg-chip .nw-se-move { opacity: 0; }
.tabs-cfg-chip:hover .nw-se-move, body.is-phone .tabs-cfg-chip .nw-se-move { opacity: 1; }

/* ── Boolean filter editor (Tasks panels, Notes saved filters) ── */
.fl-group { display: flex; flex-direction: column; gap: 6px; }
.fl-sub { margin: 2px 0 2px 14px; padding: 6px 8px 8px; border-left: 3px solid var(--color-border-default); border-radius: 0 var(--r-md) var(--r-md) 0; background: color-mix(in srgb, var(--color-text-primary) 3%, transparent); }
.fl-sub.fl-not, .fl-group.fl-not > .fl-head .fl-notl { color: var(--color-status-danger, #c0392b); }
.fl-sub.fl-not { border-left-color: var(--color-status-danger, #c0392b); }
.fl-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.fl-lead { font-weight: 600; color: var(--color-text-primary); }
.fl-op { width: auto; font-size: 12px; padding: 2px 6px; }
.fl-notl { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--color-text-secondary); user-select: none; cursor: pointer; }
.fl-head-sp { flex: 1 1 auto; }
.fl-body { display: flex; flex-direction: column; gap: 6px; padding-left: 6px; }
.fl-empty { font-size: 11.5px; color: var(--color-text-muted); padding: 2px 0; }
.nf-days { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.nf-days-n { min-width: 64px; width: 64px; }
.nf-ve-preview { font-size: 12px; color: var(--color-text-secondary); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-border-default); }
.nf-ve-del { color: var(--color-status-danger, #c0392b); }

/* ── Notes rail: saved filters above the tag tree ── */
.nf-row .nt-name::before { content: '⚲'; color: var(--color-text-muted); margin-right: 5px; font-size: 11px; }
.nf-row.sel .nt-name::before { color: var(--color-accent); }
.nf-edit { font-weight: 700; letter-spacing: .5px; }
.nf-empty { font-size: 11px; color: var(--color-text-muted); padding: 2px 6px 4px 24px; }
.nf-gap { height: 8px; }
.nf-crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-accent); background: var(--color-accent-tint-soft); border-radius: var(--r-pill); padding: 2px 6px 2px 9px; margin-right: 8px; }
.nf-crumb-x { background: none; border: none; color: inherit; cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }

/* ── Redesigned note-database schema editor (db meta + sections + descriptions) ── */
.nw-se-meta {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    margin: 10px 0 14px;
}
.nw-se-meta-grid {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 9px 12px;
    align-items: center;
}
.nw-se-meta-grid > label {
    font-size: 12px;
    color: var(--color-text-secondary);
}
.nw-se-meta input[type="text"] {
    width: 100%;
    padding: 6px 9px;
    font-size: 13px;
    color: var(--color-text-primary);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    box-sizing: border-box;
}
.nw-se-about-host {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    background: var(--color-bg-input);
    overflow: hidden;
}
.nw-se-meta-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}
.nw-se-list { display: flex; flex-direction: column; gap: 6px; }
.nw-se-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1.15fr) 118px auto minmax(0, 1.35fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
}
.nw-se-row input[type="text"],
.nw-se-row input[type="number"],
.nw-se-row select {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--color-text-primary);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    box-sizing: border-box;
}
.nw-se-move { display: flex; flex-direction: column; gap: 1px; }
.nw-se-move button {
    background: transparent; border: 0; cursor: pointer;
    color: var(--color-text-muted); font-size: 10px; line-height: 1; padding: 1px 3px;
}
.nw-se-move button:hover:not(:disabled) { color: var(--color-accent); }
.nw-se-move button:disabled { opacity: .3; cursor: default; }
.nw-se-req {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--color-text-secondary); white-space: nowrap;
}
.nw-se-desc::placeholder { color: var(--color-text-muted); font-style: italic; }
.nw-se-rowact { display: flex; gap: 3px; }
.nw-se-iconbtn {
    background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
    color: var(--color-text-muted); cursor: pointer; padding: 3px 7px; font-size: 13px; line-height: 1;
}
.nw-se-iconbtn:hover { color: var(--color-accent); border-color: var(--color-border-default); }
.nw-se-iconbtn.danger:hover { color: var(--color-negative, #ff6b6b); border-color: var(--color-negative, #ff6b6b); }
.nw-se-opts { grid-column: 2 / -1; }
/* Second-line strip: default value + (richtext) editor height. */
.nw-se-extra { grid-column: 2 / -1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-se-extra-l { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; }
.nw-se-extra .nw-db-default-cell { flex: 1 1 160px; min-width: 120px; display: flex; }
.nw-se-extra .nw-db-default-cell > select,
.nw-se-extra .nw-db-default-cell > input { width: 100%; }
.nw-se-height { width: 82px !important; flex: 0 0 auto; }
.nw-db-default-na { color: var(--color-text-muted); padding: 0 6px; }
.nw-se-addbar .nw-db-default-cell { display: inline-flex; min-width: 140px; }
.nw-se-sechead {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; margin-top: 8px;
    background: var(--color-accent-tint-soft);
    border: 1px solid var(--color-accent-border-soft);
    border-radius: var(--r-lg);
}
.nw-se-secchev { cursor: pointer; color: var(--color-accent); font-size: 11px; width: 12px; }
.nw-se-sectitle { font-size: 13px; font-weight: 600; color: var(--color-accent); }
.nw-se-secmeta { font-size: 11px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-se-secact { margin-left: auto; display: flex; gap: 2px; }
.nw-se-secbody {
    border-left: 2px solid var(--color-accent-border-soft);
    margin: 4px 0 4px 5px; padding-left: 9px;
    display: flex; flex-direction: column; gap: 6px;
}
.nw-se-addbar {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border-default);
}
.nw-se-addbar input[type="text"], .nw-se-addbar input[type="number"], .nw-se-addbar select {
    padding: 5px 8px; font-size: 12px;
    color: var(--color-text-primary); background: var(--color-bg-input);
    border: 1px solid var(--color-border-default); border-radius: var(--r-md);
}

/* Row-editor sections (collapsible groups of fields) + per-field help */
.nw-db-form-section {
    width: 100%; flex-basis: 100%; grid-column: 1 / -1;
    border: 1px solid var(--color-border-default); border-radius: var(--r-lg);
    margin: 4px 0; padding: 0 10px 8px;
    background: var(--color-bg-secondary);
}
.nw-db-form-sectitle {
    list-style: none; cursor: pointer; user-select: none;
    font-size: 12px; font-weight: 600; color: var(--color-accent);
    padding: 8px 2px; display: flex; align-items: center; gap: 8px;
}
.nw-db-form-sectitle::-webkit-details-marker { display: none; }
.nw-db-form-sectitle::before { content: ""; }   /* chevron: see .chev-mask below */
details[open] > .nw-db-form-sectitle::before { transform: rotate(90deg); }
.nw-db-form-sechelp { font-weight: 400; font-size: 11px; color: var(--color-text-muted); }
.nw-db-form-help { display: block; font-size: 11px; color: var(--color-text-muted); margin: 1px 0 3px; }

/* ── Linked databases & reference columns ─────────────────────────────────── */
.nw-db-tab-link { font-size: 10px; opacity: .85; }
.nw-db-tab-linked { font-style: italic; }
.nw-db-ro-tag {
    font-size: 10px; font-weight: 600; color: var(--color-text-muted);
    border: 1px solid var(--color-border-default); border-radius: var(--r-lg); padding: 0 6px; margin-left: 6px;
}
.nw-db-linkbanner {
    font-size: 12px; color: var(--color-text-secondary);
    background: var(--color-accent-tint-soft); border: 1px solid var(--color-accent-border-bright);
    border-radius: var(--r-md); padding: 8px 10px; margin: 4px 0 10px;
}
.nw-db-linkbanner code { font-size: 11px; background: var(--color-bg-tertiary); padding: 0 4px; border-radius: var(--r-sm); }
.nw-se-row--ro { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.nw-se-roname { font-weight: 600; font-size: 12px; color: var(--color-text-primary); }

/* Reference cell (read-only table/card display) */
.nw-db-ref { display: inline-flex; align-items: center; gap: 4px; }
.nw-db-ref-glyph { font-size: 10px; opacity: .7; }
.nw-db-ref-broken { color: var(--color-danger); font-size: 11px; }
.nw-db-ref-empty { color: var(--color-text-muted); font-style: italic; }
.nw-db-ref-src { font-size: 10px; color: var(--color-text-muted); }

/* Reference field (row editor) */
.nw-db-ref-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nw-db-ref-edit-disp { flex: 1; min-width: 0; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.nw-db-ref-edit-act { display: inline-flex; gap: 4px; }
.nw-db-ref-btn {
    font-size: 11px; padding: 2px 8px; cursor: pointer;
    background: var(--color-bg-tertiary); color: var(--color-text-primary);
    border: 1px solid var(--color-border-input); border-radius: var(--r-sm);
}
.nw-db-ref-btn:hover { border-color: var(--color-border-focus); }

/* Reference / link-database picker modal */
.nw-refpick-backdrop {
    position: fixed; inset: 0; background: var(--color-bg-modal-overlay);
    display: flex; align-items: center; justify-content: center; z-index: 1100000;
}
.nw-refpick {
    width: 460px; max-width: 92vw; max-height: 86vh; display: flex; flex-direction: column;
    background: var(--color-bg-modal); color: var(--color-text-primary);
    border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.nw-refpick-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--color-border-default);
}
.nw-refpick-title { font-weight: 600; font-size: 13px; }
.nw-refpick-x { background: none; border: none; color: var(--color-text-muted); cursor: pointer; font-size: 14px; }
.nw-refpick-body { padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.nw-refpick-lbl { font-size: 11px; font-weight: 600; color: var(--color-text-secondary); margin-top: 6px; }
.nw-refpick-body input[type="text"], .nw-refpick-body select {
    width: 100%; box-sizing: border-box; padding: 5px 7px; font-size: 12px;
    background: var(--color-bg-secondary); color: var(--color-text-primary);
    border: 1px solid var(--color-border-input); border-radius: var(--r-sm);
}
.nw-refpick-note-results { max-height: 150px; overflow: auto; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nw-refpick-note {
    text-align: left; padding: 4px 8px; font-size: 12px; cursor: pointer;
    background: var(--color-bg-secondary); color: var(--color-text-primary);
    border: 1px solid transparent; border-radius: var(--r-sm);
}
.nw-refpick-note:hover { border-color: var(--color-border-input); }
.nw-refpick-note.sel { background: var(--color-accent-tint-soft); border-color: var(--color-accent-border-bright); }
.nw-refpick-none { font-size: 12px; color: var(--color-text-muted); padding: 6px 2px; }
.nw-refpick-foot {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    border-top: 1px solid var(--color-border-default);
}
.nw-refpick-msg { flex: 1; font-size: 11px; color: var(--color-text-muted); }
.nw-refpick-msg.bad { color: var(--color-danger); }

/* ============================================================================
   DASHBOARD CARD KIT                                         added 2026-08-19
   ----------------------------------------------------------------------------
   A shared vocabulary for the dashboard cards so they read as one family:
   title + status pill, a coloured accent bar, labelled section dividers,
   one headline metric per section, sub-rows, and a fixed-width right rail so
   every value column lines up whether the row has a sparkline, a bar or nothing.

   OPT-IN: add `card-kit` alongside `card`. Existing `.card` users elsewhere in
   the app are untouched. Every colour comes from the monitor.css token system,
   so light / dark / system all work with no extra rules.
   ========================================================================== */

.card.card-kit {
    position: relative;
    overflow: hidden;
    padding: 0 16px 12px;
}
.card.card-kit::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--kit-accent, transparent);
}
.card-kit.kit-pos  { --kit-accent: var(--color-pnl-positive); }
.card-kit.kit-neg  { --kit-accent: var(--color-pnl-negative); }
.card-kit.kit-info { --kit-accent: var(--color-accent); }
.card-kit.kit-mute { --kit-accent: var(--color-border-strong); }

/* ── header ─────────────────────────────────────────────────────────────── */
.kit-head {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 0 9px;
    border-bottom: 1px solid var(--color-border-strong);
}
.kit-title {
    font-size: 12px; font-weight: 600;
    letter-spacing: .05em; text-transform: uppercase;
    color: var(--color-text-primary);
}
.kit-head-spacer { flex: 1; }
.kit-head-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 13px; line-height: 1; padding: 2px 4px;
}
.kit-head-btn:hover { color: var(--color-accent); }

/* ── section divider ────────────────────────────────────────────────────── */
.kit-sect {
    font-size: 9px; letter-spacing: .11em; text-transform: uppercase;
    color: var(--color-text-dim);
    margin: 11px 0 3px;
}

/* ── rows ───────────────────────────────────────────────────────────────── */
.card-kit .card-row { align-items: flex-start; gap: 12px; }
.card-kit .card-row:last-child { border-bottom: none; }
.card-kit .card-label { color: var(--color-text-secondary); }
.card-kit .card-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

.card-kit .kit-headline .card-label { color: var(--color-text-primary); font-weight: 500; }
.card-kit .kit-headline .card-value { font-size: 19px; font-weight: 600; }

.card-kit .kit-sub .card-label { font-size: 11.5px; color: var(--color-text-dim); padding-left: 11px; }
.card-kit .kit-sub .card-value { font-size: 12px; color: var(--color-text-muted); }

.kit-note { font-size: 10.5px; color: var(--color-text-dim); margin-top: 2px; line-height: 1.35; }

/* ── pills ──────────────────────────────────────────────────────────────── */
.kit-pill {
    font-size: 9px; padding: 1px 7px; border-radius: var(--r-lg); margin-left: 6px;
    white-space: nowrap; letter-spacing: .03em; vertical-align: middle;
    display: inline-block;
}
.kit-good { background: var(--color-bg-badge-on);      color: var(--color-pnl-positive); }
.kit-bad  { background: var(--color-bg-badge-off);     color: var(--color-pnl-negative); }
.kit-inf  { background: var(--color-bg-badge-level);   color: var(--color-accent); }
.kit-mut  { background: var(--color-bg-badge-unknown); color: var(--color-text-dim); }

/* ── right rail: sparkline / bar / placeholder, always the same width ───── */
.kit-rail { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.kit-spark { width: 96px; height: 26px; display: block; }
.kit-nospark {
    font-size: 9px; color: var(--color-text-dim); opacity: .55;
    width: 96px; text-align: center; padding: 6px 0;
    border: 1px dashed var(--color-border-default); border-radius: var(--r-sm);
}
.kit-bar {
    display: inline-block; width: 96px; height: 6px; border-radius: var(--r-sm);
    background: var(--color-bg-badge-unknown);
}
.kit-bar > i { display: block; height: 100%; border-radius: var(--r-sm); background: var(--color-pnl-positive); }

/* ── data-quality banner ────────────────────────────────────────────────── */
.kit-warn {
    background: var(--color-bg-badge-unknown);
    color: var(--color-text-secondary);
    border-left: 3px solid var(--color-accent);
    padding: 7px 10px; border-radius: var(--r-sm);
    font-size: 10.5px; margin: 11px 0 2px; line-height: 1.4;
}

/* ── feed provenance line ─────────────────────────────────── */
/* Informational by default: a Tradier-sourced reading overnight is healthy, not degraded,
   so this must read quieter than .kit-warn. Turns warm only when quota is actually at risk. */
.kit-src {
    font-size: 10px; color: var(--color-text-dim);
    padding: 5px 0 0; margin-bottom: 2px; line-height: 1.4;
    border-top: 1px dotted var(--color-border-default);
}
.kit-src b { color: var(--color-text-secondary); font-weight: 600; }
.kit-src-hot {
    color: var(--color-text-secondary);
    border-top-color: var(--color-accent);
}
.kit-src-hot b { color: var(--color-accent); }

/* ── day-range selector ─────────────────────────────────────────────────── */
.kit-days { display: inline-flex; gap: 2px; }
.kit-day-btn {
    background: transparent; border: 1px solid var(--color-border-default);
    color: var(--color-text-muted);
    font-size: 10px; padding: 2px 6px; border-radius: var(--r-sm); cursor: pointer;
}
.kit-day-btn:hover { color: var(--color-text-primary); border-color: var(--color-border-strong); }
.kit-day-active {
    background: var(--color-bg-badge-level);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* signed values reuse the existing P&L tokens */
.kit-pos { color: var(--color-pnl-positive); }
.kit-neg { color: var(--color-pnl-negative); }

.kit-spark-wrap { width: 96px; height: 26px; display: block; }

/* ── worst-value legs table (Protection Cost card) ─────────────────────── */
.kit-wv-head, .kit-wv-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 10px;
    align-items: baseline;
    padding: 3px 0;
}
.kit-wv-head {
    font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--color-text-dim);
    border-bottom: 1px solid var(--color-border-default);
    padding-bottom: 3px;
}
.kit-wv-head span:not(:first-child), .kit-wv-row span:not(:first-child) { text-align: right; }
.kit-wv-row {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border-default);
}
.kit-wv-row:last-child { border-bottom: none; }
.kit-wv-leg { color: var(--color-text-primary); font-size: 11.5px; }
.kit-wv-leg em { font-style: normal; color: var(--color-text-dim); font-size: 10px; margin-left: 3px; }
.kit-wv-ratio { font-weight: 600; }
.kit-wv-bad .kit-wv-ratio { color: var(--color-pnl-negative); }
.kit-wv-bad .kit-wv-leg { color: var(--color-pnl-negative); }

/* clickable worst-value rows — click to search for cheaper protection */
.kit-wv-click { cursor: pointer; transition: background 0.12s; }
.kit-wv-click:hover { background: var(--color-bg-card-hover-tint); }
.kit-wv-alt:not(:empty) {
    margin: 2px 0 8px 10px;
    padding: 6px 0 6px 10px;
    border-left: 2px solid var(--color-accent);
}

/* ── Channels (Comms) — Slack-like collaboration section ──────────────────── */
.comms-wrap { display: flex; gap: 0; width: 100%; height: calc(100vh - 235px); min-height: 420px; border: 1px solid var(--border-color, #333); border-radius: var(--r-md); overflow: hidden; background: var(--bg-color, #fff); }
/* Popped out: the chat floats over the app, resizable from the corner, dragged by its header. */
.comms-wrap.comms-float { position: fixed; top: 70px; left: 14vw; width: 72vw; height: 78vh; min-width: 480px; min-height: 320px; z-index: 1200; resize: both; box-shadow: 0 10px 44px rgba(0,0,0,0.45); border-radius: var(--r-lg); }
.comms-float .comms-head { cursor: move; }
.comms-float-placeholder { padding: 22px; text-align: center; opacity: 0.65; font-size: 13px; cursor: pointer; border: 1px dashed var(--border-color, #555); border-radius: var(--r-md); }
.comms-rail { width: 200px; min-width: 160px; overflow-y: auto; border-right: 1px solid var(--border-color, #333); background: rgba(128,128,128,0.05); padding: 6px 4px; display: flex; flex-direction: column; gap: 2px; }
.comms-chan { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; text-align: left; padding: 6px 8px; border: none; border-radius: var(--r-sm); background: transparent; color: inherit; cursor: pointer; font-size: 13px; }
.comms-chan:hover { background: rgba(128,128,128,0.15); }
.comms-chan.active { background: rgba(80,140,255,0.22); font-weight: 600; }
.comms-chan.archived { opacity: 0.5; }
.comms-chan-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comms-chan-unread { background: #d9534f; color: #fff; border-radius: var(--r-lg); font-size: 11px; padding: 1px 6px; min-width: 18px; text-align: center; }
.comms-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.comms-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border-color, #333); }
.comms-head-name { font-weight: 700; }
.comms-head-topic { flex: 1; opacity: 0.7; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comms-head-tools { display: flex; gap: 6px; }
.comms-msgs { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.comms-msg { max-width: 92%; padding: 6px 10px; border-radius: var(--r-lg); background: rgba(128,128,128,0.10); }
.comms-msg.mine { align-self: flex-end; background: rgba(80,140,255,0.16); }
.comms-msg.mentioned { outline: 2px solid rgba(240,173,78,0.55); }
.comms-msg-head { display: flex; align-items: baseline; gap: 8px; font-size: 11px; opacity: 0.75; margin-bottom: 3px; }
.comms-msg-from { font-weight: 700; opacity: 1; }
.comms-msg-model { font-size: 10px; padding: 0 5px; border-radius: var(--r-lg); background: var(--color-accent-tint-soft, rgba(80,140,255,0.14));
    color: var(--color-text-secondary, #aaa); font-variant-numeric: tabular-nums; }
/* Per-message actions (copy + human-only remove); revealed on hover of the message. */
.comms-msg-actions { margin-left: auto; display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.comms-msg:hover .comms-msg-actions { opacity: 0.7; }
.comms-msg-actions button { font: inherit; font-size: 12px; line-height: 1; padding: 0 4px; cursor: pointer; background: transparent; border: none; }
.comms-msg-actions button:hover { opacity: 1; }
.comms-msg-copy { color: var(--color-text-secondary, #aaa); }
.comms-msg-copy:hover { color: var(--color-text-primary, #eee); }
.comms-msg-del { color: var(--color-status-error, #e5534b); }
.comms-msg-body { font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.comms-msg-body p { margin: 0 0 6px; }
/* Markdown niceties for AI replies rendered in the channel */
.comms-msg-body pre { background: var(--color-bg-slate-overlay-soft); padding: 6px 8px; border-radius: var(--r-md); overflow-x: auto; }
.comms-msg-body code { background: var(--color-bg-slate-overlay-soft); padding: 0 3px; border-radius: var(--r-sm); font-size: 12px; }
.comms-msg-body pre code { background: none; padding: 0; }
.comms-msg-body ul, .comms-msg-body ol { margin: 4px 0 6px; padding-left: 20px; }
.comms-msg-body table { border-collapse: collapse; margin: 4px 0; }
.comms-msg-body th, .comms-msg-body td { border: 1px solid var(--color-border-default); padding: 2px 6px; font-size: 12px; }
/* Per-message token/cost readout + running totals */
.comms-msg-meta { margin-top: 3px; font-size: 10px; opacity: 0.55; font-variant-numeric: tabular-nums; }
.comms-cost-total { padding: 3px 4px 0; font-size: 11px; opacity: 0.6; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nw-ch-cost { font-size: 11px; opacity: 0.6; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── @participant chips under the composer (click to insert @mention) ── */
/* Comms-tab footer: participant chips (left) opposite the session-cost readout (right). */
.comms-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 3px 12px 4px; }
.comms-footer .comms-cost-total { padding: 3px 0 0; }
.comms-participants { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; flex: 1; min-width: 0; max-height: 46px; overflow-y: auto; }
/* Note-pane row: chips (left) opposite the per-channel cost (right). */
.nw-ch-partrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 4px; }
.nw-ch-participants { max-height: 40px; }
.comms-chip {
    font: inherit; font-size: 11px; line-height: 1.4; padding: 1px 8px; border-radius: var(--r-lg); cursor: pointer;
    border: 1px solid var(--color-accent-tint-medium); background: var(--color-accent-tint-soft);
    color: var(--color-text-secondary);
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.comms-chip:hover { border-color: var(--color-accent-border-medium); background: var(--color-accent-tint-medium); color: var(--color-text-primary); }
.comms-chip-bot { border-color: var(--color-accent-border-medium); }
.comms-chip-off { opacity: 0.55; }

/* ── Live AI-bot activity indicator ("🤖 glm53 is thinking…") ── */
.comms-activity { padding: 4px 12px; font-size: 12px; color: var(--color-text-secondary); display: flex; flex-wrap: wrap; gap: 14px; }
.nw-ch-activity { padding: 3px 2px 5px; font-size: 11px; }
.comms-activity-item { display: inline-flex; align-items: center; gap: 6px; }
.comms-activity-item b { color: var(--color-text-primary); font-weight: 600; }
.comms-activity-t { opacity: 0.6; font-variant-numeric: tabular-nums; }
.comms-activity-dots { display: inline-flex; gap: 2px; }
.comms-activity-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--color-accent-border-medium); animation: comms-dot 1.2s infinite ease-in-out both; }
.comms-activity-cancel { margin-left: 8px; font: inherit; font-size: 11px; line-height: 1; padding: 1px 6px; cursor: pointer;
    border: 1px solid var(--color-status-error, #e5534b); border-radius: var(--r-lg); background: transparent;
    color: var(--color-status-error, #e5534b); opacity: 0.7; }
.comms-activity-cancel:hover { opacity: 1; background: var(--color-status-error-tint-soft, rgba(229,83,75,0.12)); }
.comms-activity-cancel:disabled { opacity: 0.4; cursor: default; }
.comms-activity-dots i:nth-child(2) { animation-delay: 0.15s; }
.comms-activity-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes comms-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── AI error notice (posted in-channel when a bot fails) ── */
.comms-msg-error { background: var(--color-status-error-tint-soft, rgba(229,83,75,0.10)) !important;
    border-left: 3px solid var(--color-status-error, #e5534b) !important; }
.comms-msg-error .comms-msg-body { color: var(--color-status-error, #e5534b); }

/* ── Members & AI Bots manager: tabs ── */
.comms-ai-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--border-color, #333); }
.comms-ai-tab { font: inherit; font-size: 13px; padding: 8px 14px; background: transparent; border: none;
    border-bottom: 2px solid transparent; color: var(--color-text-secondary, #aaa); cursor: pointer; }
.comms-ai-tab:hover { color: var(--color-text-primary, #eee); }
.comms-ai-tab.active { color: var(--color-text-primary, #eee); border-bottom-color: var(--color-accent-border-medium, #4a9eff); font-weight: 600; }
.comms-ai-ctxname { font-size: 12px; font-weight: 400; opacity: 0.6; }

/* ── Channel settings dialog ── */
.comms-settings-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.comms-settings-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.comms-settings-grid input[type=text], .comms-settings-grid input[type=number] {
    font: inherit; padding: 6px 8px; border: 1px solid var(--border-color, #444); border-radius: var(--r-sm); background: inherit; color: inherit; }
.comms-settings-grid label.comms-ai-check { flex-direction: row; align-items: center; gap: 6px; }

/* ── Comms tab rich-text composer host (parity with note Channels pane) ── */
.comms-compose .comms-editor-host { flex: 1; min-width: 0; }

/* ── Members & AI Bots manager (Stage 2 config UI) ── */
.comms-ai-section { margin-bottom: 18px; }
.comms-ai-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--color-text-secondary); }
.comms-ai-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.comms-ai-member { display: flex; align-items: center; gap: 8px; }
.comms-ai-mname { flex: 1; }
.comms-ai-kind { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: var(--r-lg); background: var(--color-bg-slate-overlay-medium); }
.comms-ai-kind-human { background: hsla(210,62%,50%,0.18); }
.comms-ai-kind-ai-api { background: hsla(25,62%,50%,0.18); }
.comms-ai-kind-ai { background: hsla(135,62%,45%,0.18); }
.comms-ai-addrow { display: flex; gap: 6px; }
.comms-ai-addrow input { flex: 1; }
.comms-ai-bot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); flex-wrap: wrap; }
.comms-ai-bot-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comms-ai-bot-id { color: var(--color-text-tertiary, var(--color-text-secondary)); font-size: 12px; }
.comms-ai-bot-model { font-size: 11px; padding: 1px 6px; border-radius: var(--r-lg); background: var(--color-bg-slate-overlay-soft); }
.comms-ai-bot-trig { font-size: 11px; color: var(--color-text-secondary); }
.comms-ai-bot-override { font-size: 10px; padding: 1px 6px; border-radius: var(--r-lg); background: hsla(35,80%,50%,0.16); color: var(--color-text-secondary); }
/* Tag grouping in the bots list */
.comms-ai-group { border: 1px solid var(--color-border-default); border-radius: var(--r-md); margin-bottom: 8px; padding: 4px 6px; }
.comms-ai-group > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; list-style: none; }
.comms-ai-group > summary::-webkit-details-marker { display: none; }
.comms-ai-group > summary::before { content: '▸'; color: var(--color-text-tertiary, var(--color-text-secondary)); }
.comms-ai-group[open] > summary::before { content: '▾'; }
.comms-ai-group .comms-ai-bot { margin-top: 6px; }
.comms-ai-grouptag { font-weight: 700; color: var(--color-accent-primary, #64ffda); }
.comms-ai-grouptag-none { color: var(--color-text-tertiary, var(--color-text-secondary)); font-weight: 600; }
.comms-ai-groupn { font-size: 10px; padding: 0 6px; border-radius: var(--r-lg); background: var(--color-bg-slate-overlay-soft); color: var(--color-text-secondary); }
.comms-ai-group > summary .btn { margin-left: auto; }
.comms-ai-tagpill { font-size: 10px; padding: 1px 6px; border-radius: var(--r-lg); background: hsla(170,70%,45%,0.16); color: var(--color-text-secondary); }
.comms-ai-bot-metrics { font-size: 10px; color: var(--color-text-tertiary, var(--color-text-secondary)); font-variant-numeric: tabular-nums; }
.comms-ai-upgrade { border-color: hsla(140,60%,45%,0.7) !important; color: var(--color-status-success, #35c26a) !important; }
/* Group (#tag) chips in the compose participant row */
.comms-chip-group { border-style: dashed; }
.comms-chip-groupn { font-size: 9px; opacity: 0.75; }
.comms-ai-off { font-size: 10px; font-weight: 700; color: var(--color-danger, #d9534f); }
.comms-ai-bot-actions { display: flex; gap: 4px; }
.comms-ai-formgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; margin-bottom: 8px; }
.comms-ai-formgrid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--color-text-secondary); }
.comms-ai-formgrid input, .comms-ai-formgrid select { padding: 4px 6px; }
.comms-ai-check { flex-direction: row !important; align-items: center; gap: 6px !important; }
.comms-ai-promptlabel { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--color-text-secondary); }
.comms-ai-promptlabel textarea { width: 100%; resize: vertical; }
.comms-ai-formactions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; }
.comms-ai-testresult { font-size: 11px; margin-right: auto; font-variant-numeric: tabular-nums; opacity: 0.85;
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comms-ai-testresult.ok { color: var(--color-status-success, #35c26a); }
.comms-ai-testresult.err { color: var(--color-status-error, #e5534b); }

/* Scrollable lists — cap height and scroll once there are many members/bots */
.comms-ai-list-scroll { max-height: 360px; overflow-y: auto; padding-right: 4px; }
#comms-ai-members { max-height: 300px; overflow-y: auto; padding-right: 4px; }
/* Bots tab toolbar: heading left, New/Export/Import right */
.comms-ai-bots-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.comms-ai-bots-toolbar h4 { margin: 0; }
.comms-ai-bots-tools { display: flex; gap: 6px; flex-wrap: wrap; }

/* Searchable model picker — spans the full modal width so long model names are readable */
.comms-ai-model-field { grid-column: 1 / -1; }
.comms-ai-modelpick { position: relative; }
.comms-ai-modelpick input[type="text"] { width: 100%; padding: 4px 6px; }
.comms-ai-modeldrop {
    position: absolute; z-index: 5; left: 0; right: 0; top: 100%;
    max-height: 300px; overflow-y: auto;
    background: var(--color-bg-modal, var(--color-bg-secondary));
    border: 1px solid var(--color-border-default); border-radius: var(--r-md);
    box-shadow: var(--shadow-overlay-strong, 0 8px 24px rgba(0,0,0,0.3));
}
.comms-ai-modelopt {
    display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline;
    padding: 5px 8px; cursor: pointer; font-size: 12px;
}
.comms-ai-modelopt:hover { background: var(--color-overlay-row-hover, rgba(255,255,255,0.06)); }
.comms-ai-mo-name { overflow-wrap: anywhere; }
.comms-ai-mo-prov { font-size: 10px; text-transform: uppercase; opacity: 0.6; }
.comms-ai-mo-cost { font-size: 11px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.comms-ai-mo-none { padding: 6px 8px; font-size: 12px; color: var(--color-text-tertiary, var(--color-text-secondary)); }
.comms-msg-body p:last-child { margin-bottom: 0; }
.comms-compose { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border-color, #333); align-items: flex-end; }
.comms-compose textarea { flex: 1; resize: vertical; min-height: 38px; max-height: 160px; font: inherit; padding: 6px 8px; border-radius: var(--r-sm); border: 1px solid var(--border-color, #444); background: inherit; color: inherit; }
.comms-empty { opacity: 0.6; text-align: center; padding: 30px 10px; font-size: 13px; }

/* Comms message bodies: restore proper list rendering (app-level resets strip it) */
.comms-msg-body ul, .comms-msg-body ol { margin: 4px 0 8px; padding-left: 24px; list-style-position: outside; }
.comms-msg-body ul { list-style-type: disc; }
.comms-msg-body ol { list-style-type: decimal; }
.comms-msg-body li { margin: 2px 0; display: list-item; }
.comms-msg-body li p { margin: 0; display: inline; }
.comms-msg-body h1, .comms-msg-body h2, .comms-msg-body h3, .comms-msg-body h4 { margin: 8px 0 4px; font-size: 14px; }
.comms-msg-body table { border-collapse: collapse; margin: 6px 0; }
.comms-msg-body td, .comms-msg-body th { border: 1px solid rgba(128,128,128,0.35); padding: 3px 8px; font-size: 12px; }
.comms-msg-body code { background: rgba(128,128,128,0.15); padding: 1px 4px; border-radius: var(--r-sm); font-size: 12px; }

/* ── Database-only note windows (Phase 2): the database pane is the whole body ── */
.note-window.nw-dbonly .nw-title-row,
.note-window.nw-dbonly .nw-props,
.note-window.nw-dbonly .nw-editor-area,
.note-window.nw-dbonly .nw-color-pick,
.note-window.nw-dbonly .nw-flag-btn,
.note-window.nw-dbonly .nw-db-btn,
.note-window.nw-dbonly .nw-ai-btn,
.note-window.nw-dbonly .nw-graph-btn,
.note-window.nw-dbonly .nw-hist-btn,
.note-window.nw-dbonly .nw-conv-pane,
.note-window.nw-dbonly .nw-graph-pane,
.note-window.nw-dbonly .nw-history-drawer,
.note-window.nw-dbonly .nw-db-tabs { display: none !important; }
.note-window.nw-dbonly .nw-db-pane { display: flex !important; flex: 1 1 auto !important; min-height: 0; height: auto !important; }
.note-window.nw-dbonly .nw-ed-db-split { flex-direction: column !important; }

/* ── Databases panel ── */
.dbp-filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dbp-check { font-size: 12px; color: var(--color-text-secondary); display: inline-flex; gap: 4px; align-items: center; }
.dbp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dbp-table th, .dbp-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-border-default, #333); text-align: left; vertical-align: middle; }
.dbp-table th { color: var(--color-text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.dbp-table .dbp-num { text-align: right; font-variant-numeric: tabular-nums; }
.dbp-name a { font-weight: 600; text-decoration: none; }
.dbp-name a:hover { text-decoration: underline; }
.dbp-life { font-size: 10px; padding: 1px 6px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-accent) 20%, transparent); margin-left: 4px; }
.dbp-tags { font-size: 11px; color: var(--color-text-secondary); margin-left: 6px; }
/* Archived databases (2026-11-12) */
.dbp-life.dbp-archived { background: color-mix(in srgb, var(--color-text-muted) 22%, transparent); color: var(--color-text-secondary); }
.dbp-table tr.dbp-row-archived td { opacity: .7; }
.nw-db-tab.nw-db-tab-archived { opacity: .65; }
.nw-db-pick-archived .nw-popmenu-label { color: var(--color-text-secondary); }
.nw-db-arch-mark { font-size: 11px; }
.nw-db-archbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; margin: 4px 0; border-radius: var(--r-md); background: color-mix(in srgb, var(--color-text-muted) 14%, transparent); border-left: 4px solid var(--color-text-muted); font-size: 12px; }
.nw-db-archbar-t { color: var(--color-text-secondary); flex: 1 1 200px; min-width: 0; }
/* Publish to the web (2026-11-12) */
.tk-d-pub, .pub-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pub-on { font-size: 12px; font-weight: 700; color: var(--color-status-success, #2e9d5b); white-space: nowrap; }
.pub-url { font: inherit; font-size: 12px; flex: 1 1 220px; min-width: 160px; max-width: 360px; padding: 3px 8px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-input, var(--color-bg-card)); color: var(--color-text-secondary); }
a.nw-btn.btn-xs { text-decoration: none; display: inline-flex; align-items: center; }
.pub-hint { font-size: 11px; }
.tk-card-pub { font-size: 12px; line-height: 1; opacity: .8; flex: 0 0 auto; }
.tk-card-pub[hidden] { display: none; }
.pub-popmenu { min-width: 340px; max-width: min(560px, 94vw); }
.pub-pop { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 8px; }
.pub-pop .pub-url { max-width: none; }
.pub-opts { display: flex; flex-direction: column; gap: 4px; }
.pub-opt-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); margin-top: 2px; }
.pub-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.pub-note { font-size: 11px; color: var(--color-text-muted); }
.pub-list-table tr.pub-row-off td { opacity: .65; }
.pub-list-table .dbp-actions { white-space: nowrap; }
#config-tab-published .config-hint { font-size: 12px; color: var(--color-text-secondary); margin: 0 0 10px; }
.dbp-att { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.dbp-chip { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; padding: 1px 4px 1px 8px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent); }
.dbp-chip-home { border-style: solid; border-color: var(--color-accent); }
.dbp-chip a { text-decoration: none; color: inherit; }
.dbp-chip-x, .dbp-chip-add { border: 0; background: transparent; color: var(--color-text-secondary); cursor: pointer; font-size: 12px; line-height: 1; padding: 0 3px; }
.dbp-chip-x:hover { color: var(--color-danger, #ff6b6b); }
.dbp-chip-add { border: 1px dashed var(--color-border-default, #555); border-radius: var(--r-lg); padding: 0 6px; }
.dbp-mod { color: var(--color-text-secondary); white-space: nowrap; font-size: 11px; }
.dbp-actions { white-space: nowrap; text-align: right; }
.dbp-del:hover { color: var(--color-danger, #ff6b6b); }
.nw-link-picker-item { padding: 6px 8px; cursor: pointer; border-radius: var(--r-sm); }
.nw-link-picker-item:hover { background: color-mix(in srgb, var(--color-accent) 15%, transparent); }

/* ── Row audit trail (Phase 3) ── */
.nw-db-rowhist { margin-top: 10px; padding: 8px 10px; border-top: 1px dashed var(--color-border-default, #444); font-size: 12px; }
.nw-db-rowhist-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.nw-db-rowhist-sub { color: var(--color-text-secondary); font-size: 11px; }
.nw-db-rowhist-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.nw-db-rowhist-item { padding: 6px 8px; border-radius: var(--r-md); background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.nw-db-rowhist-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nw-db-rowhist-ver { font-weight: 700; font-variant-numeric: tabular-nums; }
.nw-db-rowhist-type { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-accent) 20%, transparent); }
.nw-db-rowhist-delete .nw-db-rowhist-type { background: color-mix(in srgb, var(--color-danger, #ff6b6b) 25%, transparent); }
.nw-db-rowhist-restore .nw-db-rowhist-type { background: color-mix(in srgb, #69db7c 25%, transparent); }
.nw-db-rowhist-when, .nw-db-rowhist-src { color: var(--color-text-secondary); font-size: 11px; }
.nw-db-rowhist-cols { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--color-text-secondary); }
.nw-db-rowhist-cells { margin-top: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Relations (Phase 4) ── */
.nw-db-relchip { cursor: pointer; }
.nw-db-relchip:hover { text-decoration: underline; }
.nw-db-relchip-deleted { text-decoration: line-through; opacity: .6; }
.nw-db-relchip-x { border: 0; background: transparent; color: inherit; cursor: pointer; margin-left: 4px; padding: 0 2px; font-size: 12px; line-height: 1; opacity: .7; }
.nw-db-relchip-x:hover { opacity: 1; color: var(--color-danger, #ff6b6b); }
.nw-db-rel-edit { display: flex; flex-direction: column; gap: 4px; }
.nw-db-rel-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; }
.nw-db-rel-pick { position: relative; }
.nw-db-rel-search { width: 100%; box-sizing: border-box; }
.nw-db-rel-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; max-height: 220px; overflow: auto; background: var(--color-bg-elevated, #222); border: 1px solid var(--color-border-default, #444); border-radius: var(--r-md); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.nw-db-rel-opt { padding: 6px 8px; cursor: pointer; font-size: 12.5px; }
.nw-db-rel-opt:hover { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.nw-db-rel-empty { padding: 6px 8px; font-size: 12px; color: var(--color-text-secondary); }
.nw-db-computed { color: var(--color-text-secondary); font-size: 12.5px; padding: 4px 0; }
/* Relation config strip shares the second line with the default/height strip:
   cfg takes the name+type+req columns, the related button the next slot, default the rest. */
.nw-se-cfg { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nw-se-row .nw-se-cfg:not(:empty) { grid-column: 2 / 4; }
.nw-se-cfg:empty { display: none; }
.nw-se-row .nw-se-related { grid-column: 4 / 5; justify-self: start; white-space: nowrap; }
.nw-se-row .nw-se-cfg:not(:empty) ~ .nw-se-extra { grid-column: 5 / -1; }
.nw-se-cfg-l { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; }
.nw-se-row .nw-se-cfg select, .nw-se-addbar .nw-se-cfg select { width: auto; min-width: 140px; max-width: 320px; font-size: 12px; }
.nw-se-row .nw-se-cfg select.nw-db-struct-path { flex: 1 1 200px; }
.nw-se-row .nw-se-cfg input[type=text], .nw-se-addbar .nw-se-cfg input[type=text] { width: auto; flex: 1 1 200px; min-width: 160px; max-width: 420px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.nw-refby { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.nw-refby-label { font-size: 11px; color: var(--color-text-secondary); margin-right: 4px; }
.nw-refby-chip { cursor: pointer; }
.nw-se-related { font-size: 11px; white-space: nowrap; }

/* ── Excel-97 chrome: menu bar, toolbars, formula bar, status bar ───────────
   Excel 97's *geometry* — square corners, flat buttons that only raise under the
   pointer and sink when pressed, 1px separators, a sunken formula bar — drawn in the
   dashboard's own theme variables rather than literal 1997 grey, so the pane still
   belongs to the app in both light and dark mode. */
.ss-chrome {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border-default);
    flex: 0 0 auto;
    user-select: none;
}

/* Menu bar ---------------------------------------------------------------- */
.ss-menubar {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0 2px;
    border-bottom: 1px solid var(--color-border-default);
}
.ss-menu-btn {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0;
    color: var(--color-text-primary);
    font-size: 12px;
    line-height: 1;
    padding: 5px 9px;
    cursor: default;
}
.ss-menu-btn:hover { background: var(--color-bg-hover, var(--color-bg-tertiary)); }
.ss-menu-btn.ss-menu-open {
    background: var(--color-accent);
    color: #fff;
}

.ss-menu-pop {
    position: fixed;
    z-index: 1000500;
    min-width: 210px;
    padding: 3px 0;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-strong, var(--color-border-default));
    border-radius: 0;
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.28);
    font-size: 12px;
}
.ss-menu-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 4px;
    color: var(--color-text-primary);
    cursor: default;
    white-space: nowrap;
}
.ss-menu-item:hover { background: var(--color-accent); color: #fff; }
.ss-menu-dis { color: var(--color-text-tertiary, var(--color-text-secondary)); opacity: 0.55; }
.ss-menu-dis:hover { background: transparent; color: var(--color-text-tertiary, var(--color-text-secondary)); }
.ss-menu-tick { display: inline-block; width: 14px; text-align: center; flex: 0 0 14px; }
.ss-menu-label { flex: 1; }
.ss-menu-accel { opacity: 0.7; font-size: 11px; padding-left: 18px; }
.ss-menu-item:hover .ss-menu-accel { opacity: 0.85; }
.ss-menu-sep { height: 1px; margin: 3px 2px; background: var(--color-border-default); }

/* Toolbars ---------------------------------------------------------------- */
.ss-tb {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 2px 4px;
    border-bottom: 1px solid var(--color-border-default);
    flex-wrap: wrap;
}
.ss-tb-spacer { flex: 1 1 auto; min-width: 8px; }
.ss-tbbtn {
    appearance: none;
    min-width: 23px;
    height: 23px;
    padding: 0 5px;
    font-size: 12px;
    line-height: 1;
    color: var(--color-text-primary);
    background: transparent;
    /* Excel 97's toolbar buttons are flat until the pointer is over them. */
    border: 1px solid transparent;
    border-radius: 0;
    cursor: default;
}
.ss-tbbtn:hover {
    border-color: var(--color-border-strong, var(--color-border-default));
    border-top-color: var(--color-bg-primary);
    border-left-color: var(--color-bg-primary);
    background: var(--color-bg-hover, var(--color-bg-tertiary));
}
.ss-tbbtn:active,
.ss-tbbtn.ss-tbbtn-on {
    /* pressed / latched: the raised edges swap over, which is how 97 showed state */
    border-color: var(--color-bg-primary);
    border-top-color: var(--color-border-strong, var(--color-border-default));
    border-left-color: var(--color-border-strong, var(--color-border-default));
    background: var(--color-accent-tint-soft, var(--color-bg-tertiary));
}
.ss-tbbtn-split { padding-right: 2px; }
.ss-swatch-a {
    display: inline-block;
    border-bottom: 3px solid currentColor;
    line-height: 1;
    padding-bottom: 1px;
}
.ss-combo {
    height: 21px;
    font-size: 11px;
    padding: 0 2px;
    border-radius: 0;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-input, var(--color-bg-primary));
    color: var(--color-text-primary);
}
.ss-combo-font { width: 118px; }
.ss-combo-size { width: 52px; }

/* Toolbar drop-downs (colour palette, borders, AutoCalculate) -------------- */
.ss-pop {
    position: fixed;
    z-index: 1000500;
    padding: 3px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-strong, var(--color-border-default));
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.28);
    font-size: 12px;
}
.ss-pop-none {
    display: block;
    width: 100%;
    margin-bottom: 3px;
    padding: 3px 6px;
    font-size: 11px;
    color: var(--color-text-primary);
    background: transparent;
    border: 1px solid var(--color-border-default);
    border-radius: 0;
    cursor: default;
}
.ss-pop-none:hover { background: var(--color-accent); color: #fff; }
.ss-palette { display: grid; grid-template-columns: repeat(8, 16px); gap: 2px; }
.ss-sw { width: 16px; height: 16px; border: 1px solid var(--color-border-default); border-radius: 0; cursor: default; padding: 0; }
.ss-sw:hover { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.ss-pop-list { min-width: 130px; padding: 2px 0; }
.ss-pop-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 4px 10px 4px 2px;
    font-size: 12px;
    text-align: left;
    color: var(--color-text-primary);
    background: transparent;
    border: 0;
    cursor: default;
}
.ss-pop-item:hover { background: var(--color-accent); color: #fff; }

/* Formula bar ------------------------------------------------------------- */
.ss-fxbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px;
}
.ss-fx-btns { display: inline-flex; gap: 1px; }
.ss-fxbtn {
    appearance: none;
    width: 21px;
    height: 21px;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0;
    cursor: default;
}
.ss-fxbtn:hover {
    border-color: var(--color-border-strong, var(--color-border-default));
    background: var(--color-bg-hover, var(--color-bg-tertiary));
}
.ss-fxbtn-ok:hover { color: var(--color-success, #10b981); }
.ss-fxbtn-x:hover { color: var(--color-danger, #ef4444); }

/* Status bar -------------------------------------------------------------- */
.ss-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border-default);
    flex: 0 0 auto;
    user-select: none;
}
.ss-status-mode { min-width: 40px; font-weight: 600; }
.ss-status-calc {
    font-variant-numeric: tabular-nums;
    padding: 1px 6px;
    border: 1px solid transparent;
    cursor: default;
}
.ss-status-calc:hover { border-color: var(--color-border-default); }

/* Insert Function dialog -------------------------------------------------- */
.ss-fn-body { display: flex; flex-direction: column; gap: 8px; }
.ss-fn-search {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--color-text-primary);
    background: var(--color-bg-input, var(--color-bg-primary));
    border: 1px solid var(--color-border-default);
}
.ss-fn-list {
    height: 240px;
    overflow-y: auto;
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-primary);
}
.ss-fn-item {
    display: block;
    width: 100%;
    padding: 3px 8px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    text-align: left;
    color: var(--color-text-primary);
    background: transparent;
    border: 0;
    cursor: default;
}
.ss-fn-item:hover { background: var(--color-bg-hover, var(--color-bg-tertiary)); }
.ss-fn-item.ss-fn-on { background: var(--color-accent); color: #fff; }
.ss-fn-empty { padding: 10px; font-size: 12px; color: var(--color-text-secondary); font-style: italic; }
.ss-fn-sig { min-height: 32px; font-size: 12px; color: var(--color-text-secondary); }

/* Square off the two inputs inherited from the old flat toolbar. */
.ss-fxbar .ss-addrbox { border-radius: 0; min-width: 62px; }
.ss-fxbar .ss-fx { border-radius: 0; max-width: none; }

/* ── Edge / corner resize handles for floating windows ───────────────────────
   Eight invisible strips along the edges and corners (see _winAttachEdgeResize).
   They sit INSIDE the window because .note-window clips overflow; 6px is wide enough
   to grab without stealing much of the titlebar's drag area. */
.note-window.win-rz-on { resize: none; }
.win-rz { position: absolute; z-index: 40; touch-action: none; }
.win-rz-n  { top: 0;    left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.win-rz-s  { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.win-rz-e  { right: 0;  top: 12px; bottom: 12px; width: 6px;  cursor: ew-resize; }
.win-rz-w  { left: 0;   top: 12px; bottom: 12px; width: 6px;  cursor: ew-resize; }
.win-rz-nw { top: 0;    left: 0;  width: 12px; height: 12px; cursor: nwse-resize; }
.win-rz-ne { top: 0;    right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.win-rz-sw { bottom: 0; left: 0;  width: 12px; height: 12px; cursor: nesw-resize; }
/* The bottom-right corner keeps a visible grip, standing in for the native one it replaces. */
.win-rz-se {
    bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize;
    background: linear-gradient(135deg,
        transparent 0 52%, var(--color-text-tertiary, #9ca3af) 52% 60%,
        transparent 60% 70%, var(--color-text-tertiary, #9ca3af) 70% 78%, transparent 78%);
    opacity: 0.6;
}
.note-window.maximized .win-rz { display: none; }
/* While dragging: no text selection, and the resize cursor wins over whatever is under the pointer. */
body.win-rz-active { user-select: none; }
body.win-rz-active iframe { pointer-events: none; }
body.win-rz-cursor-n *,  body.win-rz-cursor-s *  { cursor: ns-resize !important; }
body.win-rz-cursor-e *,  body.win-rz-cursor-w *  { cursor: ew-resize !important; }
body.win-rz-cursor-nw *, body.win-rz-cursor-se * { cursor: nwse-resize !important; }
body.win-rz-cursor-ne *, body.win-rz-cursor-sw * { cursor: nesw-resize !important; }

/* ── Linked / Linked From sections (note window foot) ────────────────────────
   Two stacked, independently resizable sections; each renders its notes as
   Cards, Chips or a List. Heights come from the shared links prefs. */
.nw-links-dock {
    /* The saved heights are PREFERENCES, not claims: the dock may take at most 45% of
       the window and shrinks before the editor / database pane does, so a tall Linked
       section can never squeeze a spreadsheet grid down to nothing. */
    flex: 0 1 auto;
    min-height: 0;
    max-height: 35%;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-note-window-input);
    border-top: 1px solid var(--color-border-default);
}

.nw-links-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 10px 3px;
}
.nw-links-toggle {
    background: transparent;
    border: 0;
    padding: 0 2px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}
.nw-links-count {
    font-size: 10px;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.nw-links-spacer { flex: 1; }
.nw-links-modes {
    display: inline-flex;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.nw-links-mode {
    background: transparent;
    border: 0;
    border-left: 1px solid var(--color-border-default);
    padding: 1px 7px;
    font-size: 10px;
    color: var(--color-text-muted);
    cursor: pointer;
}
.nw-links-mode:first-child { border-left: 0; }
.nw-links-mode:hover { color: var(--color-text-primary); }
.nw-links-mode.on { background: var(--color-accent-tint-soft); color: var(--color-accent); font-weight: 600; }
.nw-links-sec {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-height: 0;
}
.nw-links-body {
    flex: 0 1 auto;          /* height is the preferred size; it may shrink to 26px */
    min-height: 26px;
    overflow: auto;
    padding: 2px 10px 6px;
    box-sizing: border-box;
}
/* Collapsed: header and chips share one row — "Linked → 4  [chip] [chip] …" — the chip
   strip scrolls sideways when it overflows. */
.nw-links-sec.nw-links-collapsed { display: flex; flex-direction: row; align-items: center; gap: 6px; padding-right: 10px; }
.nw-links-collapsed .nw-links-head { flex: 0 0 auto; padding: 1px 0 1px 10px; }
.nw-links-collapsed .nw-links-spacer { display: none; }
.nw-links-collapsed .nw-links-body.nw-links-chip {
    flex: 1 1 auto; min-width: 0; height: auto !important; min-height: 0;
    display: flex; flex-wrap: nowrap; align-items: center; gap: 4px;
    padding: 1px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.nw-links-collapsed .nw-links-body.nw-links-chip .nw-linked-chip { flex: 0 0 auto; }
.nw-links-collapsed .nw-links-body.nw-links-chip .nw-linked-chip-title { white-space: nowrap; }
/* An empty section needs one line, not its saved height. */
.nw-links-none .nw-links-body { height: auto !important; }
.nw-links-collapsed .nw-links-modes { display: none; }

/* chips */
.nw-links-chip { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; }

/* cards */
.nw-links-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 6px;
    align-content: start;
}
.nw-links-card > .nw-linked-empty { grid-column: 1 / -1; }
.nw-links-cd {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-default);
    border-left: 3px solid var(--note-color, var(--color-accent));
    border-radius: var(--r-md);
    cursor: pointer;
    min-width: 0;
}
.nw-links-cd:hover { border-color: var(--color-accent-border-medium); border-left-color: var(--note-color, var(--color-accent)); }
.nw-links-card-head { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nw-links-card-title {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nw-links-card-text {
    font-size: 11px;
    line-height: 1.35;
    color: var(--color-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nw-links-card-foot { display: flex; gap: 8px; font-size: 10px; color: var(--color-text-muted); }
.nw-links-card-syms { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* list */
.nw-links-list { display: flex; flex-direction: column; gap: 1px; }
.nw-links-li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) auto auto;
    align-items: center;
    gap: 10px;
    padding: 3px 6px;
    border-left: 3px solid var(--note-color, var(--color-accent-tint-medium));
    border-radius: var(--r-sm);
    font-size: 12px;
    cursor: pointer;
}
.nw-links-li:hover { background: var(--color-accent-tint-soft); }
.nw-links-li-title { color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-links-li-meta { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.nw-links-li-date { font-size: 10px; color: var(--color-text-muted); white-space: nowrap; }

/* ── Link-a-database picker (every database, any kind, sorted by name) ─────── */
.nw-refpick.nw-linkdb { width: min(560px, calc(100vw - 32px)); }
.nw-linkdb-filters { display: flex; gap: 6px; }
/* .nw-refpick-body gives every input/select width:100%, which crushed the search box */
.nw-linkdb-filters .nw-refpick-note-search { flex: 1 1 auto; width: auto; min-width: 0; }
.nw-linkdb-filters select {
    flex: 0 0 auto;
    width: auto;
    font-size: 12px;
    padding: 3px 6px;
    background: var(--color-bg-input, var(--color-bg-primary));
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
}
.nw-linkdb-list {
    margin-top: 8px;
    max-height: min(52vh, 440px);
    overflow-y: auto;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.nw-linkdb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    cursor: pointer;
}
.nw-linkdb-item:hover { background: var(--color-accent-tint-soft); }
.nw-linkdb-item.sel { background: var(--color-accent-tint-medium); border-color: var(--color-accent-border-medium); }
.nw-linkdb-item.nw-linkdb-here { opacity: 0.5; cursor: default; }
.nw-linkdb-item.nw-linkdb-here:hover { background: transparent; }
/* kind icon pinned at the far left, fixed width so names line up */
.nw-linkdb-icon { flex: 0 0 22px; text-align: center; font-size: 15px; line-height: 1; }
.nw-linkdb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.nw-linkdb-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-linkdb-where { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-linkdb-count { flex: 0 0 auto; font-size: 11px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* ── Phone mode: one full-screen window at a time (see _phoneReconcile) ──────
   Specificity (body.is-phone .phone-full = 0,2,1) beats .note-window.maximized and
   .sdw.maximized (0,2,0), so these win even though those rules are !important too.
   100dvh, not 100vh: on a phone 100vh runs under the browser's own toolbar and would
   hide the window's footer (Save / Close). */
body.is-phone.phone-has-window { overflow: hidden; }
body.is-phone .phone-full {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    resize: none !important;
    box-shadow: none !important;
}
body.is-phone .phone-stack-hidden { display: none !important; }

/* Titlebars keep the colour swatch, ⋯ and ✕; everything else moves into the ⋯ menu. */
body.is-phone .phone-full > .nw-titlebar button:not(.phone-more):not(.nw-close-btn):not([title="Close"]):not(.nw-color-swatch-btn):not(.nw-cp-swatch):not(.hdr-more-btn):not(.hdr-more-panel button) { display: none !important; }
body.is-phone .phone-full > .sdw-header .sdw-maximize { display: none !important; }
body.is-phone .phone-full .phone-more,
body.is-phone .phone-full > .nw-titlebar .nw-close-btn,
body.is-phone .phone-full > .nw-titlebar [title="Close"],
body.is-phone .phone-full > .sdw-header .sdw-close,
body.is-phone .phone-full > .ticker-editor-titlebar .ticker-editor-close {
    min-width: 40px;
    min-height: 36px;
    font-size: 18px;
}
body.is-phone .phone-full > .nw-titlebar { cursor: default; }

/* Side-by-side panes don't fit a phone: stack them top-to-bottom. */
body.is-phone .phone-full .nw-split-container.split-vertical,
body.is-phone .phone-full .nw-ed-db-split.db-split-vertical { flex-direction: column; }

body.is-phone .phone-full .nw-ed-db-split.db-split-vertical .nw-db-pane {
    border-left: 0;
    border-top: 1px solid var(--color-border-default);
}

/* The ⋯ menu: proxied titlebar actions, then the other open windows. */
.phone-menu {
    position: fixed;
    right: 8px;
    min-width: 230px;
    max-width: calc(100vw - 16px);
    max-height: 70dvh;
    overflow-y: auto;
    padding: 4px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.phone-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    background: transparent;
    border: 0;
    border-radius: var(--r-md);
    color: var(--color-text-primary);
    font-size: 15px;
    text-align: left;
}
.phone-menu-item:active, .phone-menu-item.on { background: var(--color-accent-tint-soft); }
.phone-menu-icon { flex: 0 0 22px; text-align: center; }
.phone-menu-head {
    padding: 8px 12px 4px;
    margin-top: 4px;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border-default);
}
.phone-menu-head:first-child { margin-top: 0; border-top: 0; }

/* ── Touch: drag handles (see the touch bridge in monitor.js) ────────────────
   touch-action affects only touch, never a mouse, so it applies everywhere: on these
   handles a finger drags instead of scrolling the page. The selected spreadsheet cell
   is one of them — a drag from it selects a range, a drag from anywhere else scrolls. */
.nw-titlebar,
.sdw-header,
.sm-win-titlebar,
#wl-titlebar,
.ticker-editor-titlebar,
.ht-edit-header,
.strat-builder-header,
.trade-card-header,
.comms-float .comms-head,
#note-split-resizer,
.sdw-chart-resizer,
.ss-grip,
.ss-fill-handle,
.ss-grid td.ss-sel,
.notes-graph-wbody canvas,
.nw-graph-pane canvas {
    touch-action: none; /* touch bridge */
}
/* Phone windows don't drag, so their titlebars can scroll-chain normally. */
body.is-phone .phone-full > .nw-titlebar,
body.is-phone .phone-full > .sdw-header,
body.is-phone .phone-full > .ticker-editor-titlebar { touch-action: auto; cursor: default; }
/* Dialog titlebars don't drag on a phone either (full screen). */
body.is-phone :is(.ht-edit-header, .strat-builder-header, .trade-card-header) { touch-action: auto; }

/* Finger-sized targets wherever the primary pointer is coarse (phones, tablets). */
@media (pointer: coarse) {
    .win-rz-n, .win-rz-s { height: 14px; }
    .win-rz-e, .win-rz-w { width: 14px; }
    .win-rz-nw, .win-rz-ne, .win-rz-sw, .win-rz-se { width: 22px; height: 22px; }
    .ss-grip-col { width: 16px; right: -8px; }
    .ss-grip-row { height: 16px; bottom: -8px; }
    /* a 28px grab box centred on the corner; the visible dot stays exactly where it was */
    .ss-grid td .ss-fill-handle { width: 28px; height: 28px; right: -14px; bottom: -14px; }
    .ss-grid td .ss-fill-handle::after { right: 11px; bottom: 11px; }
    
    
}

/* ── Phone: control rows scroll sideways instead of wrapping ─────────────────
   On a phone, button rows that wrap (section headers, the database tabs, the
   spreadsheet toolbars, filter and summary bars) stacked three to five lines deep
   and used up most of the screen. Each becomes ONE line you swipe sideways; a
   control cut off at the right edge is the cue that the row scrolls. Children don't
   shrink, so buttons keep their size rather than squashing. */
body.is-phone h2.collapsible-header .section-header-buttons,
body.is-phone .nw-db-tablist,
body.is-phone .nw-db-tabtools,
body.is-phone .minute-chart-header,
body.is-phone .ss-tb,
body.is-phone .tx-filter-bar,
body.is-phone .tx-pagination,
body.is-phone .rg-export-toolbar,
body.is-phone .opt-summary-bar,
body.is-phone .portfolio-grand-total,
body.is-phone .ht-saved-prefixes,
body.is-phone .nw-db-toolbar,
body.is-phone .nw-db-switcher,
body.is-phone .comms-head-tools {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    scrollbar-width: none;            /* swipe, no scrollbar eating a line */
    overscroll-behavior-x: contain;   /* a swipe that reaches the end doesn't drag the page */
}
body.is-phone h2.collapsible-header .section-header-buttons::-webkit-scrollbar,
body.is-phone .nw-db-tablist::-webkit-scrollbar,
body.is-phone .nw-db-tabtools::-webkit-scrollbar,
body.is-phone .minute-chart-header::-webkit-scrollbar,
body.is-phone .ss-tb::-webkit-scrollbar,
body.is-phone .tx-filter-bar::-webkit-scrollbar,
body.is-phone .tx-pagination::-webkit-scrollbar,
body.is-phone .rg-export-toolbar::-webkit-scrollbar,
body.is-phone .opt-summary-bar::-webkit-scrollbar,
body.is-phone .portfolio-grand-total::-webkit-scrollbar,
body.is-phone .ht-saved-prefixes::-webkit-scrollbar,
body.is-phone .nw-db-toolbar::-webkit-scrollbar,
body.is-phone .nw-db-switcher::-webkit-scrollbar,
body.is-phone .comms-head-tools::-webkit-scrollbar { display: none; }
body.is-phone h2.collapsible-header .section-header-buttons > *,
body.is-phone .nw-db-tablist > *,
body.is-phone .nw-db-tabtools > *,
body.is-phone .minute-chart-header > *,
body.is-phone .ss-tb > *,
body.is-phone .tx-filter-bar > *,
body.is-phone .tx-pagination > *,
body.is-phone .rg-export-toolbar > *,
body.is-phone .opt-summary-bar > *,
body.is-phone .portfolio-grand-total > *,
body.is-phone .ht-saved-prefixes > *,
body.is-phone .nw-db-toolbar > *,
body.is-phone .nw-db-switcher > *,
body.is-phone .comms-head-tools > * { flex-shrink: 0; }
/* In a scrolling strip a flex:1 filter box collapses to its minimum; keep it typable. */
body.is-phone .nw-db-toolbar .nw-db-filter { min-width: 130px; }

/* Section header: title on the left, the button strip takes the rest and scrolls.
   (margin-left:auto stays, but a scrolling strip must start at its left edge — content
   pushed off a right-aligned strip's LEFT side could never be scrolled back to.) */
body.is-phone h2.collapsible-header { min-width: 0; }
body.is-phone h2.collapsible-header .section-header-buttons {
    flex: 1 1 auto;
    justify-content: flex-start;
}

/* Database header: tabs on one line, the database tools on a second — both swipe.
   Side by side, the tools (which can't shrink) took the whole width, crushed the tabs
   into five lines and drew over them. */
body.is-phone .nw-db-tabs {
    flex-wrap: wrap;
    row-gap: 0;
    padding: 4px 8px 0;
}
body.is-phone .nw-db-tablist { flex: 1 0 100%; align-items: flex-end; }
body.is-phone .nw-db-tabtools {
    flex: 1 0 100%;
    margin-left: 0;
    padding: 4px 0;
    border-top: 1px solid var(--color-border-default);
}

/* Chat: the 160–200px channel rail beside the conversation left the messages ~117px
   wide on a phone. The rail becomes a one-line swipeable strip ABOVE the conversation. */
body.is-phone .comms-wrap { flex-direction: column; height: calc(100dvh - 150px); min-height: 360px; }
body.is-phone .phone-full.comms-wrap { height: 100dvh !important; }
body.is-phone .comms-rail {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    width: auto;
    min-width: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--border-color, #333);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}
body.is-phone .comms-rail::-webkit-scrollbar { display: none; }
body.is-phone .comms-rail > * { flex-shrink: 0; }
body.is-phone .comms-rail .comms-chan { width: auto; white-space: nowrap; }
/* Stacked in a column, the conversation must be allowed to shrink below its content
   (min-height:auto would grow it to every message) so the message list scrolls inside. */
body.is-phone .comms-main { flex: 1 1 auto; min-height: 0; }

/* Chat header: channel name and topic on the first line, its tools on a second. */
body.is-phone .comms-head { flex-wrap: wrap; row-gap: 4px; }
body.is-phone .comms-head-tools { flex: 1 0 100%; }

/* ── Phone: a note window scrolls as one page ────────────────────────────────
   On a phone the editor, the database pane and the Linked sections all competed for
   one screen, and the database rows got ~17px. Instead the window body scrolls: the
   editor + database split fills a screen on its own, the Linked sections sit below it,
   and the footer (Save / Close / Delete) stays pinned to the bottom. Database-only
   windows keep their fixed layout — there the grid or table scrolls by itself. */
body.is-phone .phone-full:not(.nw-dbonly) > .nw-body {
    overflow-y: auto;
    overscroll-behavior: contain;
}
/* Pane heights on a phone: DOCUMENTS take their natural height, VIEWPORTS keep a frame.
   A note can't be squeezed into one screen — several panes may be open and the note text
   alone can run many screens — so the window scrolls as ONE page:
     - the note text, a database's table / card view and the Linked sections are documents:
       full natural height, no inner scrollbar, so one thumb-scroll moves through all of it
       (scrolls nested inside a scroll were the problem with fixed pane heights);
     - a spreadsheet grid, the AI / Channels pane and the notes graph are viewports — they
       need a frame (sticky headers, a stream anchored at the bottom, a canvas) — so they
       keep a set height of most of a screen and scroll inside it.
   `overflow: clip` (not hidden) on the wrappers: it still clips, but unlike hidden it is not
   a scroll container, so the editor toolbar below can stick to the top of the WINDOW.
   These !important flex values beat the inline ones the dividers write; phone mode never
   saves divider positions, so desktop layouts are untouched. */
body.is-phone .phone-full:not(.nw-dbonly) > .nw-body > .nw-split-container {
    flex: 0 0 auto;
    /* Always a column here. With no AI pane open this container is a ROW, and flex-basis
       auto would size the editor pane's WIDTH to its widest content (a one-line tab strip
       thousands of px long) instead of the screen. */
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - 140px);
    overflow: clip;
}
body.is-phone .phone-full:not(.nw-dbonly) .nw-editor-pane,
body.is-phone .phone-full:not(.nw-dbonly) .nw-ed-db-split {
    flex: 1 0 auto !important;
    overflow: clip;
    min-width: 0;
    max-width: 100%;
}
/* The note text: natural height (an empty note still gets a usable area). */
body.is-phone .phone-full:not(.nw-dbonly) .nw-editor-area {
    flex: 1 0 auto !important;
    min-height: 200px;
    overflow: visible;
}
body.is-phone .phone-full:not(.nw-dbonly) .nw-editor-area > .nw-editor-el {
    flex: 0 0 auto;
    overflow: visible;
}
/* …with its formatting toolbar kept in reach while you are anywhere inside it. */
body.is-phone .phone-full:not(.nw-dbonly) .nw-editor-area > .tiptap-toolbar {
    position: sticky;
    top: 0;
    z-index: 4;
}
/* A table or card database: natural height. Wide tables still scroll sideways. */
body.is-phone .phone-full:not(.nw-dbonly) .nw-db-pane:not(:has(.ss-scroll)) {
    flex: 0 0 auto !important;
    overflow: clip;
    min-width: 0;
    max-width: 100%;
}
body.is-phone .phone-full:not(.nw-dbonly) .nw-db-pane:not(:has(.ss-scroll)) .nw-db-active {
    flex: 0 0 auto;
    overflow: visible;
    min-width: 0;
}
body.is-phone .phone-full:not(.nw-dbonly) .nw-db-pane:not(:has(.ss-scroll)) .nw-db-viewbody {
    flex: 0 0 auto;
    overflow-x: auto;
    overflow-y: visible;
}
/* A spreadsheet is a viewport: a frame of most of a screen, the grid scrolling inside. */
body.is-phone .phone-full:not(.nw-dbonly) .nw-db-pane:has(.ss-scroll) {
    flex: 0 0 80dvh !important;
    min-width: 0;
    max-width: 100%;
}
body.is-phone .phone-full:not(.nw-dbonly) .nw-conv-pane { flex: 0 0 80dvh !important; min-width: 0; }
/* A task-only window on a phone is nothing but the Tasks pane: let it fill the whole body (the 80dvh basis is
   for a chat/graph pane stacked under a note). */
body.is-phone .phone-full.nw-taskonly > .nw-body > .nw-split-container { height: 100% !important; min-height: 0 !important; max-height: 100% !important; overflow: hidden; }
body.is-phone .phone-full.nw-taskonly .nw-tk-pane { flex: 1 1 auto !important; min-height: 0; max-height: 100%; overflow: hidden; }
body.is-phone .phone-full.nw-taskonly .nw-tk-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
body.is-phone .phone-full:not(.nw-dbonly) .nw-graph-pane { flex: 0 0 70dvh !important; min-width: 0; }
/* Scrolling replaces the dividers. */

/* The Linked sections follow the panes at their natural height; the footer
   (Save / Close / Delete) stays pinned to the bottom however far down you are. */
body.is-phone .phone-full:not(.nw-dbonly) .nw-links-dock {
    flex: 0 0 auto;
    max-height: none;
}
/* Each section's saved height (an inline style, set by its drag bar) is a desktop pane size.
   On a phone the sections are documents like the rest of the note: Cards, Chips and List all
   show every item at full height, and the drag bars — meaningless once the page scrolls —
   are hidden. Collapse still works, and the saved height is untouched for desktop. */
body.is-phone .phone-full:not(.nw-dbonly) .nw-links-body {
    height: auto !important;
    overflow: visible;
}

body.is-phone .phone-full:not(.nw-dbonly) .nw-links-sec ~ .nw-links-sec {
    border-top: 1px dashed var(--color-border-default);
}
body.is-phone .phone-full:not(.nw-dbonly) > .nw-body > .nw-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
}
/* A database's description is one line until tapped open. */
body.is-phone .nw-db-info > summary {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.is-phone .nw-db-info[open] > summary { white-space: normal; }
body.is-phone .nw-db-info > summary::before { margin-right: 6px; }

/* ── Phase 3: content reflow for phones and touch ────────────────────────────
   Measured at 375px wide, tab by tab; each rule below fixes something that was
   unreachable, invisible or too small to hit there. */

/* Wide tables scroll sideways inside their section instead of being cut off.
   (Orders, watchlist alerts and transactions already did.) */
body.is-phone #stocks-container,
body.is-phone #dbp-container,
body.is-phone .wl-list-card-body {
    overflow-x: auto;
    overscroll-behavior-x: contain;
}
/* …and the Symbol column stays put while the numbers slide under it, so a row is
   still identifiable when you are looking at its P&L. Body cells are transparent,
   so the pinned one paints the page colour. */
body.is-phone #stocks-container .portfolio-table td:first-child,
body.is-phone .portfolio-table-scroll .portfolio-table td:first-child,
body.is-phone .wl-list-card-body .portfolio-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--color-bg-page);
}
body.is-phone #stocks-container .portfolio-table th:first-child,
body.is-phone .portfolio-table-scroll .portfolio-table th:first-child,
body.is-phone .wl-list-card-body .portfolio-table th:first-child {
    position: sticky;
    left: 0;
    /* every header cell is already sticky at z-index 2 (for vertical scrolling); the
       pinned one has to sit above them or they paint over it as they slide past */
    z-index: 3;
}

/* Configuration: the fixed 140px label column left the controls no room — label above,
   control below. */
body.is-phone .about-settings-grid { grid-template-columns: minmax(0, 1fr); gap: 4px 0; }
body.is-phone .about-setting-label { white-space: normal; margin-top: 8px; }
body.is-phone .about-setting-control { min-width: 0; }

/* Controls that only appeared on hover, which a touch screen can't do. */
@media (hover: none) {
    .note-card .note-card-actions { visibility: visible; }
    .wl-list-header-btn { opacity: 1; }      /* :disabled keeps its own 0.25 */
}

/* Finger-sized controls wherever the primary pointer is a finger. 32px is the
   compromise for a dense trading screen (the guidelines say 44–48, which would
   double every row); the tiniest icon buttons get a bigger hit box. */
@media (pointer: coarse) {
    .btn, .btn-xs, .btn-sm, .nw-btn, .ss-tbbtn, .ss-fxbtn, .action-btn, .opt-tab-btn, .tt-btn,
    .minute-chart-order-btn, .minute-chart-close-btn, .indicator-dropdown-btn,
    select, input[type="text"]:not(.ss-edit), input[type="number"], input[type="search"],
    input[type="date"], input:not([type]) {
        min-height: 32px;
    }
    .comms-msg-copy, .comms-msg-del, .dbp-chip-x, .dbp-chip-add, .opt-card-alert-btn,
    .opt-card-order-btn, .nw-linked-chip-x, .nw-db-rowbtn {
        min-width: 28px;
        min-height: 28px;
    }
    /* A floor for every other button, whatever its class — except colour swatches, which
       are meant to be small squares in a palette grid. */
    button:not(.ss-sw):not(.nw-cp-swatch):not(.ss-swatch):not(.nw-color-swatch-btn) {
        min-height: 28px;
    }
    /* Ticker links inside table rows: a taller hit area without changing the row
       (the negative margin gives back exactly what the padding adds). */
    .sdw-trigger { display: inline-block; padding: 6px 0; margin: -6px 0; }
}

/* ═══ Phase 4: dialogs on a phone ═══════════════════════════════════════════
   A dialog fills the screen, as the windows do. The dialog itself scrolls as one page,
   with its title bar pinned to the top and its buttons pinned to the bottom, so OK /
   Cancel are always in reach however long the form. The two short delete
   confirmations stay a centred card. Any position, size or drag offset a dialog's own
   script set inline (the trade card and strategy builder are draggable, the strategy
   builder sizes itself on open) is overridden: a phone has one place to put it.
   The phone's Back button closes the top dialog (_phoneCloseDialog). */
body.is-phone .modal-overlay:not(#delete-modal):not(#delete-note-modal):not(.ui-dlg-overlay) > .modal,
body.is-phone .nw-refpick,
body.is-phone .option-watch-dialog,
body.is-phone .ht-edit-dialog {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: none;
    border-radius: 0;
    resize: none;
    transform: none;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;     /* reaching the end doesn't scroll the page behind */
}
/* Parts keep their natural height; the dialog scrolls instead of squeezing them. */
body.is-phone .modal-overlay > .modal > *,
body.is-phone .nw-refpick > *,
body.is-phone .option-watch-dialog > *,
body.is-phone .ht-edit-dialog > * {
    flex-shrink: 0;
}
body.is-phone .modal-overlay > .modal > :is(.modal-header, .trade-card-header, .strat-builder-header),
body.is-phone .nw-refpick > .nw-refpick-head,
body.is-phone .option-watch-dialog > .option-watch-titlebar,
body.is-phone .ht-edit-dialog > .ht-edit-header {
    position: sticky;
    top: 0;
    z-index: 3;
    background: inherit;
    cursor: default;                  /* not draggable here */
}
/* margin-top:auto sits the buttons at the bottom of the screen when the form is short. */
body.is-phone .modal-overlay > .modal > :is(.modal-footer, .trade-card-footer, .strat-builder-footer, .form-actions),
body.is-phone .nw-refpick > .nw-refpick-foot,
body.is-phone .ht-edit-dialog > .ht-edit-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin-top: auto;
    background: inherit;
    border-radius: 0;
}
/* The watchlist form's buttons are inside the form, not the dialog. */
body.is-phone .modal-overlay > .modal form > .form-actions:last-child {
    position: sticky;
    bottom: 0;
    z-index: 3;
    border-radius: 0;
}
/* Inner scroll boxes sized for a desktop dialog: the dialog scrolls now. */
body.is-phone .modal-overlay > .modal .help-content,
body.is-phone .nw-refpick-body {
    max-height: none;
    overflow: visible;
}
body.is-phone .nw-refpick-body { flex: 1 0 auto; }
body.is-phone .ht-edit-dialog > .ht-edit-body { flex: 1 0 auto; min-height: 50dvh; }
/* The confirmations: a card with a margin, not edge to edge. */
body.is-phone :is(#delete-modal, #delete-note-modal, .ui-dlg-overlay) > .modal {
    width: calc(100% - 32px);
}

/* Tabs on touch: a long press opens the tab menu, so it mustn't also select the label
   text or raise iOS's callout. */
@media (pointer: coarse) {
    .tabs-strip li.tab { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    .tabs-context-menu button { padding: 10px 18px; font-size: 14px; }
}

/* Pickers — a search box over one long list (Link a note, Attach to a note, Link a
   database, Create from template, Insert Function). Here the list itself fills the rest
   of the screen and scrolls, so the search box above it and the buttons below stay put. */
body.is-phone .modal-overlay > .modal:is(.nw-link-picker-modal, :has(> .ss-fn-body)),
body.is-phone .nw-refpick:is(.nw-linkdb, #nw-tpl-modal > .nw-refpick) {
    overflow: hidden;
}
body.is-phone .modal-overlay > .modal:is(.nw-link-picker-modal, :has(> .ss-fn-body)) > .modal-body,
body.is-phone .nw-refpick:is(.nw-linkdb, #nw-tpl-modal > .nw-refpick) > .nw-refpick-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.is-phone .modal-overlay > .modal .nw-link-picker-results,
body.is-phone .modal-overlay > .modal .ss-fn-list,
body.is-phone .nw-refpick .nw-linkdb-list,
body.is-phone #nw-tpl-modal .nw-refpick-note-results {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
}

/* ═══ Notes tag tree ═════════════════════════════════════════════════════════
   Sidebar of nested tags (#a/b/c) beside the notes; the breadcrumb stands in for it
   on a phone or when it is hidden. See "Notes tag tree" in monitor.js. */
.notes-layout {
    display: flex;
    align-items: flex-start;
}
.notes-main { flex: 1 1 auto; min-width: 0; }
.notes-tree {
    flex: 0 0 var(--nt-w, 220px);
    width: var(--nt-w, 220px);
    box-sizing: border-box;
    /* Stays in view while the notes scroll past. */
    position: sticky;
    top: 48px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 8px 6px 12px 0;
    font-size: 12px;
}
.notes-tree-resizer {
    flex: 0 0 7px;
    align-self: stretch;
    cursor: col-resize;
    margin-right: 10px;
    border-right: 1px solid var(--color-border-default);
    touch-action: none;
}
.notes-tree-resizer:hover { border-right-color: var(--color-border-focus); }
.notes-layout.nt-hidden > .notes-tree,
.notes-layout.nt-hidden > .notes-tree-resizer { display: none; }

.nt-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 4px 6px 6px;
}
.nt-row {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-left: calc(var(--d, 0) * 14px);
    border-radius: var(--r-sm);
}
.nt-row:hover { background: var(--color-bg-row-hover); }
.nt-row.sel { background: var(--color-accent-tint-soft); }
.nt-row.sel .nt-name { color: var(--color-accent); font-weight: 600; }
.nt-caret {
    flex: 0 0 18px;
    width: 18px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 10px;
}
.nt-caret:disabled { cursor: default; }
.nt-name {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    padding: 4px 2px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nt-hash { color: var(--color-text-muted); margin-right: 1px; }
.nt-count {
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--color-text-muted);
    padding: 0 6px 0 4px;
    font-variant-numeric: tabular-nums;
}
.nt-all { margin-bottom: 2px; }
.nt-row.nt-untagged { margin-bottom: 4px; }   /* the inbox, then the tags */
.nt-untagged .nt-name, .nt-chip.nt-untagged { color: var(--color-text-muted); }

/* Section labels inside a branch: the parent path is quieter than the child's name. */
.notes-tag-prefix { color: var(--color-text-muted); font-weight: 400; }

/* Breadcrumb + child chips: hidden while the sidebar shows. */
.notes-crumbs { display: none; padding-top: 8px; }
.notes-layout.nt-hidden .notes-crumbs { display: block; }
.nt-crumbs-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.nt-path {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.nt-path::-webkit-scrollbar { display: none; }
.nt-crumb {
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    padding: 4px 4px;
    font-size: 13px;
    white-space: nowrap;
}
.nt-crumb.cur { color: var(--color-text-primary); font-weight: 600; cursor: default; }
.nt-sep { color: var(--color-text-muted); }
.nt-chips {
    display: flex;
    gap: 6px;
    padding: 8px 0 2px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.nt-chips::-webkit-scrollbar { display: none; }
.nt-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 4px 4px 10px;
    border-radius: var(--r-xl);
    border: 1px solid var(--color-border-default);
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-size: 12px;
    cursor: pointer;
}
.nt-chip:hover { border-color: var(--color-border-focus); }

/* Phone: no sidebar — the breadcrumb and chips are the tree, and "Tags" opens it whole. */
body.is-phone .notes-tree:not(.nt-in-modal),
body.is-phone .notes-tree-resizer { display: none; }
body.is-phone .notes-crumbs { display: block; }
/* In the full-screen dialog the tree is the whole page, not a sticky sidebar. */
.notes-tree.nt-in-modal {
    position: static;
    /* The sidebar's flex-basis is its WIDTH; in the dialog's column it would be a height. */
    flex: 1 0 auto;
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 8px 12px 16px;
    font-size: 14px;
}
.nt-in-modal .nt-name { font-size: 14px; padding: 8px 4px; }
.nt-in-modal .nt-count { font-size: 12px; }
.nt-in-modal .nt-caret { flex-basis: 28px; width: 28px; font-size: 12px; }
@media (pointer: coarse) {
    .nt-name { padding: 7px 4px; }
    .nt-crumb { padding: 6px 6px; }
    .nt-chip { padding: 6px 6px 6px 12px; font-size: 13px; }
}

/* ── Tag tools: Tidy button, autocomplete, Tidy dialog ─────────────────────── */
.nt-head { display: flex; align-items: center; justify-content: space-between; }
.nt-tidy {
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
    padding: 2px 4px;
}
.nt-tidy:hover { text-decoration: underline; }

.tag-ac {
    position: fixed;
    z-index: 1200500;            /* above dialogs too: the old note form is a dialog */
    max-height: 260px;
    overflow-y: auto;
    background: var(--color-bg-card-elevated);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--r-md);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    padding: 3px;
    display: flex;
    flex-direction: column;
}
.tag-ac-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--r-sm);
    color: var(--color-text-primary);
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}
.tag-ac-item.on, .tag-ac-item:hover { background: var(--color-accent-tint-soft); }
.tag-ac-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-ac-path b { color: var(--color-accent); font-weight: 600; }
.tag-ac-more { color: var(--color-text-muted); }
.tag-ac-count { color: var(--color-text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .tag-ac-item { padding: 9px 10px; font-size: 14px; } }

.tag-tidy-body { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.tag-tidy-intro { margin: 0 0 4px; font-size: 12px; }
.tag-tidy-row {
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tag-tidy-what { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.9; cursor: pointer; }
.tag-tidy-what input { margin-top: 6px; }
.tag-tidy-tag {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    padding: 1px 5px;
    font-size: 12px;
}
.tag-tidy-n { color: var(--color-text-muted); font-size: 11px; margin: 0 6px 0 2px; }
.tag-tidy-target { font-size: 12px; padding: 2px 4px; }
.tag-tidy-notes { font-size: 12px; color: var(--color-text-muted); margin-left: 24px; }
.tag-tidy-notes summary { cursor: pointer; }
.tag-tidy-notes ul { margin: 4px 0 0; padding-left: 18px; }
.tag-tidy-arch { font-size: 10px; text-transform: uppercase; opacity: 0.7; }
.tag-tidy-sum { font-size: 12px; color: var(--color-text-muted); }
body.is-phone .tag-tidy-body { max-height: none; overflow: visible; }

/* ── Manage tags & symbols ─────────────────────────────────────────────────── */
.tag-mgr-body { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; overflow: hidden; }
/* A fixed-height dialog: tabs, suggestions, search and the Move bar stay put, the tag list
   scrolls in the middle, and Pending keeps its own (shorter) scroll below it — so the
   dialog works the same with 30 tags or 3,000. */
.modal.tag-mgr {
    display: flex;
    flex-direction: column;
    height: min(86vh, 820px);
    overflow: hidden;
}
.tag-mgr > .modal-header, .tag-mgr > .modal-footer { flex: 0 0 auto; }
.tag-mgr-body > * { flex: 0 0 auto; }
.tag-mgr-body > .tag-mgr-list {
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-md);
    padding: 2px;
}
.tag-mgr-body > .tag-mgr-sugg { max-height: 22vh; overflow-y: auto; }
.tag-mgr-body > .tag-mgr-pending { max-height: 28vh; overflow-y: auto; }
.tag-mgr-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border-default); }
.tag-mgr-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}
.tag-mgr-tab.on { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
.tag-mgr-h { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin-bottom: 4px; }
.tag-mgr-sugg { border: 1px dashed var(--color-border-strong); border-radius: var(--r-md); padding: 8px 10px; }
.tag-mgr-sugg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; line-height: 1.9; }
.tag-mgr-tools { display: flex; gap: 8px; align-items: center; }
.tag-mgr-q { flex: 1 1 auto; min-width: 0; font-size: 12px; padding: 5px 8px; }
.tag-mgr-bulk {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--r-md);
    background: var(--color-accent-tint-soft); font-size: 12px;
}
.tag-mgr-move { display: inline-flex; align-items: center; gap: 6px; }
.tag-mgr-input { font-size: 12px; padding: 4px 7px; min-width: 0; }
.tag-mgr-move .tag-mgr-input { width: 160px; }
.tag-mgr-list { display: flex; flex-direction: column; }
.tag-mgr-row {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 4px 3px calc(var(--d, 0) * 16px + 4px);
    border-radius: var(--r-sm); font-size: 13px;
}
.tag-mgr-row:hover { background: var(--color-bg-row-hover); }
.tag-mgr-row.gone .tag-mgr-name { text-decoration: line-through; color: var(--color-text-muted); }
.tag-mgr-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-mgr-badge { font-size: 11px; color: var(--color-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag-mgr-badge.del { color: var(--color-status-danger); }
.tag-mgr-acts { margin-left: auto; display: flex; gap: 4px; flex: 0 0 auto; visibility: hidden; }
.tag-mgr-row:hover .tag-mgr-acts, .tag-mgr-row:focus-within .tag-mgr-acts { visibility: visible; }
@media (hover: none) { .tag-mgr-acts { visibility: visible; } }
.tag-mgr-edit { flex-wrap: wrap; background: var(--color-bg-row-hover); padding-top: 6px; padding-bottom: 6px; }
.tag-mgr-edit .tag-mgr-input { flex: 1 1 200px; }
.tag-mgr-hint { flex-basis: 100%; font-size: 11px; color: var(--color-text-muted); }
.tag-mgr-pending { border-top: 1px solid var(--color-border-default); padding-top: 8px; }
.tag-mgr-ops { margin: 0 0 6px; padding-left: 18px; font-size: 12px; }
.tag-mgr-ops li { margin: 2px 0; }
.tag-mgr-ops code { font-size: 11px; }
.tag-mgr-undo { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: 0 4px; }
.tag-mgr-undo:hover { color: var(--color-status-danger); }
.tag-mgr-preview { list-style: none; padding-left: 0; }
.tag-mgr-preview li { display: flex; flex-direction: column; padding: 3px 0; border-bottom: 1px solid var(--color-border-default); }
.tag-mgr-pv-title { color: var(--color-text-primary); }
.tag-mgr-pv { font-size: 11px; }
.tag-mgr-pv s { opacity: 0.6; }
/* Phone: the same layout at full screen — the list scrolls, everything else stays put. */
body.is-phone .modal-overlay > .modal.tag-mgr { overflow: hidden; }
body.is-phone .modal-overlay > .modal.tag-mgr > .tag-mgr-body { flex: 1 1 auto; min-height: 0; }

/* ── Expand / collapse chevron (CHEVRON_SVG in monitor.js) ───────────────────
   Points right when closed and turns down when its holder has `.open`: the tag tree,
   the tag sections in the Notes list, and a note window's Linked sections. */
.chev { display: block; flex: 0 0 auto; transition: transform 0.15s ease; }
.open > .chev { transform: rotate(90deg); }
.nt-caret { display: inline-flex; align-items: center; justify-content: center; color: var(--color-status-info); }
.nw-links-toggle { color: var(--color-status-info); }
.nt-caret:hover:not(:disabled), .nw-links-toggle:hover { color: var(--color-text-primary); }
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }

/* "+ Add" in a tag section's header: a new note with that section's tag filled in. */
.notes-tag-add {
    flex: 0 0 auto;
    padding: 1px 8px;
    font-size: 11px;
    line-height: 1.5;
    opacity: 0.75;
}
.notes-tag-section-header:hover .notes-tag-add, .notes-tag-add:focus-visible { opacity: 1; }

/* "+" on a tag tree row: a new note with that tag. Shown on hover (or keyboard focus) so
   the tree stays quiet; always shown where there is no hover. */
.nt-add {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--color-border-default);
    border-radius: var(--r-sm);
    background: var(--color-bg-secondary);
    color: var(--color-accent);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    visibility: hidden;
}
.nt-row:hover .nt-add, .nt-add:focus-visible { visibility: visible; }
.nt-add:hover { border-color: var(--color-border-focus); }
@media (hover: none) { .nt-add { visibility: visible; width: 28px; height: 28px; font-size: 16px; } }

/* ── uiAlert / uiConfirm / uiPrompt (in-page stand-ins for the browser's dialogs) ──
   Above every other dialog (a confirm can be raised from the order ticket, itself at
   1100010), below toasts. On a phone they stay a card, like the delete confirmations. */
.modal-overlay.ui-dlg-overlay { z-index: 1150000; }
/* Shown at once (only the opacity fades), so its field can take focus straight away. */
.modal-overlay.ui-dlg-overlay.active { transition: opacity 0.15s ease; }
.ui-dlg { max-width: 440px; }
.ui-dlg-body { display: flex; flex-direction: column; gap: 12px; }
.ui-dlg-msg {
    white-space: pre-wrap;          /* the messages break lines with newlines */
    overflow-wrap: anywhere;
    color: var(--color-text-primary);
    font-size: 13px;
    line-height: 1.5;
    max-height: 50vh;
    overflow-y: auto;
}
.ui-dlg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 9px;
    font-size: 13px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-input);
    border-radius: var(--r-sm);
}
textarea.ui-dlg-input { font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 12px; resize: vertical; }
.ui-dlg-input:focus { outline: none; border-color: var(--color-border-focus); }

/* ═══════════════════════════════════════════════════════════════════════════
   Tasks (Docs/TASKS_DESIGN.md) — section, note pane, pop-out, detail, picker Repeat row
   ═══════════════════════════════════════════════════════════════════════════ */
.tk-wrap { display: flex; gap: 12px; min-height: 240px; }
.tk-rail { flex: 0 0 200px; display: flex; flex-direction: column; gap: 2px; padding-right: 10px; border-right: 1px solid var(--color-border-default); }
.tk-wrap.tk-norail .tk-rail { display: none; }
.tk-rail-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin: 10px 0 2px; display: flex; align-items: center; gap: 6px; }
.tk-rail-title:first-child { margin-top: 0; }
.tk-rail-add { border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); border-radius: var(--r-sm); cursor: pointer; font-size: 11px; line-height: 1; padding: 1px 5px; }
.tk-rail-item { display: flex; align-items: center; gap: 6px; text-align: left; width: 100%; padding: 4px 8px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--color-text-secondary); cursor: pointer; font-size: 12.5px; }
.tk-rail-item:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); color: var(--color-text-primary); }
.tk-rail-item.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); font-weight: 600; }
.tk-rail-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tk-rail-n { margin-left: auto; font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
.tk-rail-edit { opacity: 0; font-size: 11px; padding: 0 2px; }
.tk-rail-item:hover .tk-rail-edit { opacity: .7; }
.tk-rail-none { font-size: 12px; color: var(--color-text-muted); padding: 4px 8px; }
.tk-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tk-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-quick { flex: 1 1 260px; min-width: 180px; padding: 6px 10px; border: 1px dashed var(--color-border-strong); border-radius: var(--r-lg); background: var(--color-bg-input, var(--color-bg-primary)); color: var(--color-text-primary); font-size: 13px; }
.tk-quick:focus { border-style: solid; border-color: var(--color-accent); outline: none; }
.tk-search { width: 160px; font-size: 12px; }
.tk-sel { width: auto; font-size: 12px; }
.tk-count { font-size: 11px; color: var(--color-text-muted); margin-left: auto; }
.tk-list { display: flex; flex-direction: column; gap: 10px; }
.tk-group-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 2px 4px; display: flex; gap: 6px; align-items: center; }
.tk-group-overdue .tk-group-head { color: var(--color-status-danger); }
.tk-group-n { font-weight: 400; opacity: .7; }
.tk-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-lg); cursor: pointer; border: 1px solid transparent; transition: background .12s ease, opacity .4s ease; }
.tk-row:hover { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.tk-row.tk-row-open { background: color-mix(in srgb, var(--color-accent) 12%, transparent); border-color: color-mix(in srgb, var(--color-accent) 35%, transparent); }
.tk-row.tk-done .tk-title { text-decoration: line-through; color: var(--color-text-muted); }
.tk-row.tk-fade { opacity: 0; }
.tk-check { width: 16px; height: 16px; accent-color: var(--color-accent); cursor: pointer; flex-shrink: 0; }
.tk-title { flex: 1 1 auto; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tk-prio { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: var(--r-sm); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tk-prio-high { background: color-mix(in srgb, var(--color-status-danger) 18%, transparent); color: var(--color-status-danger); }
.tk-prio-medium { background: color-mix(in srgb, var(--color-warning, #d97706) 20%, transparent); color: var(--color-warning, #d97706); }
.tk-prio-low { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); }
.tk-tag { font-size: 10.5px; padding: 1px 7px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--tag-c, var(--color-border-strong)) 18%, transparent); color: var(--color-text-secondary); border: 1px solid color-mix(in srgb, var(--tag-c, var(--color-border-strong)) 45%, transparent); white-space: nowrap; cursor: pointer; }
.tk-tag-note { border-style: dashed; }
.tk-note { font-size: 11px; color: var(--color-text-secondary); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tk-note:hover { color: var(--color-accent); }
.tk-repeat { font-size: 12px; color: var(--color-text-muted); }
.tk-due { font-size: 11.5px; color: var(--color-text-secondary); white-space: nowrap; cursor: pointer; padding: 1px 6px; border-radius: var(--r-md); }
.tk-due:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.tk-due-today { color: var(--color-accent); font-weight: 600; }
.tk-due-over { color: var(--color-status-danger); font-weight: 600; }
.tk-empty { color: var(--color-text-muted); font-size: 12.5px; padding: 8px 4px; }
/* Note card badge */
.note-card-task-badge { font-size: 10px; padding: 1px 6px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); font-weight: 600; white-space: nowrap; }
.note-card-task-badge .tk-badge-over { color: var(--color-status-danger); }
/* Detail panel */
.tk-d-head { display: flex; align-items: center; gap: 8px; }
.tk-d-title { flex: 1; font-size: 15px; font-weight: 600; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--color-text-primary); padding: 2px 0; }
.tk-d-title:focus { outline: none; border-bottom-color: var(--color-accent); }
.tk-d-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-d-l { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); width: 52px; flex-shrink: 0; }
.tk-d-due { font-size: 12.5px; }
.tk-d-repeat { font-size: 11px; color: var(--color-text-secondary); }
.tk-d-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.tk-d-prio { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.tk-pp { border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); border-radius: var(--r-md); font-size: 10.5px; font-weight: 700; padding: 2px 6px; cursor: pointer; }
.tk-pp.on, .tk-pp:hover { border-color: var(--color-accent); color: var(--color-accent); }
.tk-pp-high.on { background: color-mix(in srgb, var(--color-status-danger) 18%, transparent); color: var(--color-status-danger); border-color: var(--color-status-danger); }
.tk-pp-medium.on { background: color-mix(in srgb, var(--color-warning, #d97706) 20%, transparent); color: var(--color-warning, #d97706); border-color: var(--color-warning, #d97706); }
.tk-d-pnum { width: 52px; font-size: 11px; }
.tk-d-note { flex: 1; min-width: 120px; font-size: 12px; }
.tk-d-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tk-tagpick { border: 1px solid color-mix(in srgb, var(--tag-c, var(--color-border-strong)) 45%, transparent); background: transparent; color: var(--color-text-secondary); border-radius: var(--r-lg); font-size: 10.5px; padding: 1px 8px; cursor: pointer; }
.tk-tagpick.on { background: color-mix(in srgb, var(--tag-c, var(--color-border-strong)) 22%, transparent); color: var(--color-text-primary); font-weight: 600; }
.tk-tagpick-new { border-style: dashed; }
.tk-d-content { border: 1px solid var(--color-border-default); border-radius: var(--r-lg); min-height: 90px; max-height: 260px; overflow: auto; }
.tk-d-content .tiptap-prose { min-height: 70px; padding: 6px 8px; font-size: 12.5px; }
.tk-d-ta { width: 100%; min-height: 90px; border: 0; background: transparent; color: inherit; padding: 6px 8px; font: inherit; }
.tk-d-foot { display: flex; align-items: center; gap: 8px; }
.tk-d-meta { flex: 1; font-size: 10.5px; color: var(--color-text-muted); }
.tk-d-hist { border-top: 1px solid var(--color-border-default); padding-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.tk-h-title { font-weight: 700; text-transform: uppercase; font-size: 10px; color: var(--color-text-muted); margin-top: 4px; }
.tk-h-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-h-v { font-family: ui-monospace, monospace; color: var(--color-text-muted); }
.tk-h-type { font-weight: 600; }
.tk-h-complete { color: var(--color-status-success); }
.tk-h-delete { color: var(--color-status-danger); }
.tk-h-src, .tk-h-cols { color: var(--color-text-muted); font-size: 10px; }
/* Tag / note pickers */
.tk-tagdlg { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.tk-tagdlg label { display: flex; align-items: center; gap: 8px; }
.tk-tag-colors { display: flex; gap: 6px; }
.tk-np-search { width: 100%; margin-bottom: 8px; }
.tk-np-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.tk-np-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 4px; cursor: pointer; }
/* Note window pane + task-only window */
.nw-tk-pane { padding: 0; }
.nw-tk-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--color-border-default); }
.nw-tk-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-secondary); }
.nw-tk-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 10px; }
.nw-tk-body .tk-rail { flex-basis: 150px; }
.nw-tk-btn.active { background: var(--color-accent); color: #fff; }
.note-window.nw-taskonly .nw-title-row,
.note-window.nw-taskonly .nw-props,
.note-window.nw-taskonly .nw-editor-pane,
.note-window.nw-taskonly .nw-color-pick,
.note-window.nw-taskonly .nw-flag-btn,
.note-window.nw-taskonly .nw-db-btn,
.note-window.nw-taskonly .nw-ai-btn,
.note-window.nw-taskonly .nw-graph-btn,
.note-window.nw-taskonly .nw-hist-btn,
.note-window.nw-taskonly .nw-tk-btn,
.note-window.nw-taskonly .nw-ch-pane,
.note-window.nw-taskonly .nw-graph-pane,
.note-window.nw-taskonly .nw-history-drawer,
.note-window.nw-taskonly .nw-footer { display: none !important; }
.note-window.nw-taskonly .nw-tk-pane { display: flex !important; flex: 1 1 auto !important; min-width: 0; border-left: 0; }
.note-window.nw-taskonly .nw-tk-bar .btn[title^="Open these"], .note-window.nw-taskonly .nw-bd-pop { display: none; }
/* Date picker: Repeat row */
.nw-dp-pop.nw-dp-wide { width: 360px; }
.nw-dp-repeat { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--color-border-default); font-size: 12px; }
.nw-dp-repeat-row { display: flex; align-items: center; gap: 6px; }
.nw-dp-repeat-row > span { color: var(--color-text-secondary); }
.nw-dp-repeat select { width: auto; font-size: 12px; }
.nw-dp-custom { display: flex; flex-direction: column; gap: 5px; padding: 6px 8px; border: 1px dashed var(--color-border-default); border-radius: var(--r-md); font-size: 11.5px; }
.nw-dp-custom input[type=number] { width: 56px; font-size: 11.5px; }
.nw-dp-custom label { display: inline-flex; align-items: center; gap: 4px; }
.nw-dp-days { display: flex; gap: 3px; }
.nw-dp-dayb { width: 30px; height: 24px; border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); border-radius: var(--r-md); font-size: 10.5px; cursor: pointer; }
.nw-dp-dayb.on { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.nw-dp-month { display: flex; flex-direction: column; gap: 4px; }
.nw-dp-ends { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-dp-repeat-preview { font-size: 11px; color: var(--color-text-secondary); min-height: 14px; }
@media (max-width: 767px) {
    .tk-wrap { flex-direction: column; }
    .tk-rail { flex-basis: auto; width: auto !important; align-self: stretch; flex-direction: row; flex-wrap: wrap; gap: 6px 18px; padding: 8px 10px 10px; }
    .tk-rail-top { width: 100%; order: -1; margin: 0; }
    .tk-rail-sec { flex: 1 1 150px; min-width: 140px; }
    .tk-rail-sec + .tk-rail-sec .tk-rail-title { margin-top: 0; }
    .tk-rail-title { width: 100%; }
    /* Phones: one line per task, like the desktop list. The title keeps at least ~45% of the row and truncates;
       the chips (tags, assignees, note, due — whatever the ⚙ display settings show) sit right-aligned and the
       leftmost ones get clipped when there is no room, so the due date is always the one that stays visible. */
    .tk-row { flex-wrap: nowrap; }
    .tk-row .tk-title { flex: 1 1 45%; min-width: 90px; }
    .tk-meta { flex: 0 1 auto; min-width: 0; flex-wrap: nowrap; overflow: hidden; justify-content: flex-end; }
    .tk-meta .tk-due { white-space: nowrap; flex-shrink: 0; }
    .tk-meta .tk-note { max-width: 90px; }
}

/* ── Tasks Phase 2: view switcher, matrix panels, view editor ─────────────── */
.tk-switcher { margin-bottom: 2px; }
.tk-wrap-matrix .tk-rail-tag { opacity: .9; }
.tk-matrix { display: flex; flex-direction: column; }
.tk-mrow { display: grid; grid-template-columns: var(--tk-tracks, minmax(0, 1fr) 10px minmax(0, 1fr)); align-items: stretch; min-height: 0; }
.tk-mrow-rest { grid-template-columns: minmax(0, 1fr); }
.tk-mrow-fixed .tk-panel { height: 100%; min-height: 0; }
.tk-mrow-fixed .tk-panel-body { flex: 1 1 auto; min-height: 0; max-height: none; }
.tk-mdiv { position: relative; flex-shrink: 0; }
.tk-mdiv::after { content: ''; position: absolute; border-radius: 2px; background: var(--color-border-default); opacity: .55; transition: opacity .12s ease, background .12s ease; }
.tk-mdiv-v { width: 10px; cursor: col-resize; }
.tk-mdiv-v::after { left: 4px; right: 4px; top: 14px; bottom: 14px; }
.tk-mdiv-h { height: 10px; cursor: row-resize; }
.tk-mdiv-h::after { top: 4px; bottom: 4px; left: 14px; right: 14px; }
.tk-mdiv:hover::after, body.tk-resizing .tk-mdiv::after { opacity: 1; background: var(--color-accent); }
body.tk-resizing { user-select: none; cursor: inherit; }
.tk-matrix.tk-narrow .tk-mdiv-v { display: none; }
.tk-panel { border: 0; border-left: 4px solid var(--panel-c); border-radius: var(--r-lg); background: var(--color-bg-card, var(--color-bg-primary)); display: flex; flex-direction: column; min-height: 120px; transition: box-shadow .12s ease, background .12s ease; }
.tk-panel.tk-panel-over { box-shadow: 0 0 0 2px var(--panel-c) inset; background: color-mix(in srgb, var(--panel-c) 8%, var(--color-bg-card, var(--color-bg-primary))); }
.tk-panel-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; cursor: pointer; user-select: none; }
.tk-panel-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--panel-c); flex-shrink: 0; }
.tk-panel-title { font-weight: 700; font-size: 12.5px; color: var(--color-text-primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-panel-n { font-size: 11px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.tk-panel-chev { font-size: 11px; color: var(--color-text-muted); }
.tk-panel-body { display: flex; flex-direction: column; gap: 6px; padding: 0 6px 6px; max-height: 60vh; overflow: auto; }
.tk-panel-collapsed .tk-panel-body, .tk-panel-collapsed .tk-panel-add { display: none; }
.tk-panel-empty { font-size: 11.5px; color: var(--color-text-muted); padding: 10px 8px 14px; text-align: center; border: 1px dashed var(--color-border-default); border-radius: var(--r-lg); margin: 2px 4px; }
.tk-panel-add { flex: 0 0 auto; margin: 0 8px 8px; font-size: 12px; padding: 4px 8px; min-width: 0; }
.tk-panel-rest { opacity: .85; }
.tk-row-compact { padding: 4px 6px; }
.tk-row-compact .tk-title { font-size: 12.5px; }
.tk-row-compact .tk-note { max-width: 110px; }
.tk-row.tk-dragging { opacity: .4; }
.tk-row[draggable=true] { cursor: grab; }
.tk-row[draggable=true]:active { cursor: grabbing; }
/* View editor */
.tk-ve-modal { width: min(920px, 96vw); display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; }
.tk-ve-modal > .modal-header, .tk-ve-modal > .modal-footer { flex: 0 0 auto; }
.tk-ve-body { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.tk-ve-panel { border-left: 4px solid var(--panel-c); }
.tk-ve-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tk-ve-title { flex: 1; min-width: 140px; font-weight: 600; }
.tk-ve-val { width: auto; min-width: 120px; }
.tk-ve-drop { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.tk-ve-drop label { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-secondary); }
.tk-ve-drop input[type=text] { width: 120px; }
.tk-ve-drop select { width: auto; }
@media (max-width: 767px) {
    .tk-matrix { grid-template-columns: 1fr; }
    .tk-panel-body { max-height: none; }
    .tk-ve-modal { width: 100vw; }
}

/* ── Task detail as a floating window (movable / resizable, like the row editors) ── */
.tk-detail-win { min-width: 360px; min-height: 320px; display: flex; flex-direction: column; }
.tk-detail-win .row-ed-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-detail-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; font-size: 12.5px; }
.tk-detail-body .tk-d-content { flex: 1 1 auto; min-height: 90px; max-height: none; }
.tk-detail-body .tk-d-content .tiptap-prose { min-height: 100%; }
.tk-detail-win.tk-detail-sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100vw !important; height: 85vh !important; max-height: 85vh; border-radius: var(--r-xl) var(--r-xl) 0 0; resize: none; }
.tk-detail-win.tk-detail-sheet .row-ed-titlebar { cursor: default; }
.nw-tk-pane { flex: 0 0 420px; }
.note-window.nw-taskonly .nw-tk-pane { flex: 1 1 auto !important; }

/* Tasks pane divider: a wider grab zone than the 4px line (the line stays 4px). */

/* ── Tasks polish: responsive matrix, rail drawer, dashboard-style fields, tag picker ── */
/* (matrix tracks are per-row now; see .tk-mrow) */
.tk-rail { position: relative; }
.tk-rail-top { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: 2px; }
.tk-wrap { position: relative; overflow: visible; }
.tk-wrap.tk-norail .tk-rail.tk-rail-drawer { display: flex; position: absolute; left: 0; top: 0; z-index: 5; width: 220px; min-height: 240px; max-height: min(520px, 80vh); flex-direction: column; flex-wrap: nowrap; padding: 8px 10px; background: var(--color-bg-card, var(--color-bg-secondary)); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: 0 10px 28px rgba(0,0,0,.3); overflow: auto; }
.tk-wrap.tk-norail .tk-main { width: 100%; }
/* Fields in the task window / toolbars look like the rest of the dashboard's fields (.nw-props-grid). */
.tk-detail-body select, .tk-detail-body input[type="text"], .tk-detail-body input[type="number"], .tk-detail-body textarea.tk-d-title,
.tk-toolbar select, .tk-toolbar input[type="text"], .tk-ve-body select, .tk-ve-body input[type="text"], .tk-ve-body input[type="number"],
.tk-tagdlg input[type="text"], .tk-np-search, .tk-panel-add {
    padding: 4px 6px; background: var(--color-bg-note-window-input, var(--color-bg-input)); border: 1px solid var(--color-border-default);
    color: var(--color-text-bright, var(--color-text-primary)); border-radius: var(--r-sm); font-size: 12px; outline: none; font-family: inherit;
}
.tk-detail-body select:focus, .tk-detail-body input:focus, .tk-detail-body textarea.tk-d-title:focus, .tk-toolbar select:focus, .tk-toolbar input:focus,
.tk-ve-body select:focus, .tk-ve-body input:focus, .tk-panel-add:focus { border-color: var(--color-accent); }
.tk-detail-body .tk-d-title { font-size: 15px; font-weight: 600; resize: none; overflow: hidden; line-height: 1.3; white-space: pre-wrap; word-break: break-word; width: 100%; }
.tk-d-pnum { width: 56px; }
.tk-tagpick.on { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.tk-tagpick-x { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 12px; line-height: 1; padding: 0 2px; opacity: .7; }
.tk-tagpick-x:hover { opacity: 1; color: var(--color-status-danger); }
.tk-tagpop { position: fixed; width: 230px; max-height: 320px; overflow: auto; padding: 6px; background: var(--color-bg-secondary); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: 0 10px 28px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.tk-tagpop-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: var(--r-md); cursor: pointer; }
.tk-tagpop-row:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.tk-tagpop-note { font-size: 9px; color: var(--color-text-muted); text-transform: uppercase; margin-left: auto; }
.tk-tagpop-none { color: var(--color-text-muted); cursor: default; }
.tk-tagpop-new { margin-top: 4px; align-self: flex-start; }

/* =============================================================================
   STYLE D · ROUNDED PILL — component layer (2026-10-18)
   Pill buttons / tabs / chips, 10px inputs, 14px cards, 16px modals, Manrope.
   Every color comes from the Tier 2 tokens, so Dark and Light both apply.
   ============================================================================= */

/* Buttons --------------------------------------------------------------- */
.btn {
    border-radius: var(--r-pill);
    padding: 7px 14px;
    font-weight: 600;
    line-height: 1.3;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 9px;  font-size: 11px; }
.btn-secondary {
    background-color: var(--color-bg-button-secondary);
    border: 1px solid var(--color-border-default);
}
.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-bg-button-secondary-hover);
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
}
.btn-danger-outline { border: 1px solid var(--color-status-danger); background: transparent; }
.btn-danger-outline:hover:not(:disabled) { background: var(--color-status-danger); color: var(--palette-white); }
.btn:focus-visible, .nw-btn:focus-visible, .theme-toggle-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus-ring-accent); }
.nw-btn { border-radius: var(--r-pill); padding: 2px 9px; font-weight: 500; }
.modal-close { border-radius: var(--r-pill); width: 28px; height: 28px; }

/* Page tabs (the strip at the top of every tab page) ------------------- */
.tabs-bar { padding: 0 10px; gap: 6px; }
.tabs-strip { align-items: center; gap: 4px; }
.tabs-strip li.tab {
    top: 0;
    height: auto;
    align-self: center;
    padding: 4px 13px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
}
.tabs-strip li.tab:hover { background: var(--color-bg-button-secondary-hover); }
.tabs-strip li.tab.active {
    color: var(--color-text-on-accent);
    background: var(--color-accent);
    border-color: transparent;
}
.tabs-strip li.tab.active .tab-close { color: var(--color-text-on-accent); opacity: .75; }
.tabs-strip li.tab.active .tab-close:hover { opacity: 1; background: rgba(0,0,0,.18); }
.tabs-strip li.tab .tab-close { border-radius: var(--r-pill); }
.tabs-strip li.tab.drop-target { box-shadow: 0 0 0 2px var(--color-accent); }

/* Segmented controls (Theme: Dark | Light etc.) --------------------------- */
.theme-toggle-group { border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.theme-toggle-btn { border-radius: var(--r-pill); padding: 5px 14px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.theme-toggle-btn + .theme-toggle-btn { border-left: 0; }

/* Text-like fields ------------------------------------------------------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([class*="ss-"]),
select:not([class*="ss-"]),
textarea:not([class*="ss-"]) {
    border-radius: var(--r-md);
    font-family: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([class*="ss-"]):focus-visible,
select:not([class*="ss-"]):focus-visible,
textarea:not([class*="ss-"]):focus-visible {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-focus-ring-accent);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-accent); }

/* Surfaces --------------------------------------------------------------- */
.card { border-radius: var(--r-lg); }
.modal { border-radius: var(--r-xl); }
.modal-header { padding: 14px 20px 10px; border-bottom: 0; }
.modal-footer { border-top: 0; padding: 8px 20px 16px; }
.collapsible-header { border-radius: var(--r-md); }

/* Counts, badges, chips, tags → pills ----------------------------------- */
.section-count, .portfolio-section-count, .status-badge, .alert-count, .news-count, .sysmsgs-count, .wl-list-count, .tk-count,
.notes-filter-count, .notes-tag-count, .nw-db-count, .nw-db-tab-count, .nw-links-count, .nw-token-counter,
.acp-badge, .acp-tag-badge, .au-badge, .au-tag, .earnings-badge, .earnings-next-badge, .earnings-time-badge, .fut-dir-badge,
.memory-source-badge, .analyst-rating-badge, .price-source-badge, .order-status-badge, .opt-itm-badge, .opt-otm-badge,
.rg-badge, .rg-active-pill, .sdw-trigger-badge, .strat-badge, .strat-ev-badge, .strat-role-badge, .strat-symbol-badge,
.note-card-ch-badge, .note-card-db-badge, .note-card-func-tag, .note-card-link-badge, .note-card-task-badge,
.comms-chip, .comms-ai-tagpill, .comms-ai-grouptag, .dbp-chip, .ht-prefix-chip, .kit-pill, .nt-chip, .nw-db-chip, .nw-db-group-chip,
.nw-db-hidden-tag, .nw-db-relchip, .nw-db-ro-tag, .nw-dp-chip, .nw-history-badge, .nw-linked-chip, .nw-links-chip, .nw-props-chip,
.nw-props-summary-tag, .nw-refby-chip, .sdw-compare-chip, .ss-live-chip, .symbol-note-symbols-tag, .tag-mgr-badge, .tag-tidy-tag,
.tk-prio, .tk-tag, .tk-tagpick, .tk-tagpick-new {
    border-radius: var(--r-pill) !important;
}
.section-count { padding: 2px 9px; }
.status-badge { padding: 2px 8px; letter-spacing: .04em; }

/* Numbers line up in every table and card value ------------------------- */
td, th, .card-value, .card-value-small { font-variant-numeric: tabular-nums; }
th { font-weight: 600; }

/* ── Anchored pop menus (database bar: ☰ picker, + Add, ⋯ tools) ──────────── */
.nw-popmenu {
    position: fixed; min-width: 200px; max-width: 320px; max-height: 60vh; overflow: auto;
    padding: 6px; background: var(--color-bg-modal); border: 1px solid var(--color-border-default);
    border-radius: var(--r-lg); box-shadow: var(--shadow-dropdown); display: flex; flex-direction: column; gap: 2px; font-size: 12.5px;
}
.nw-popmenu-list { display: flex; flex-direction: column; gap: 2px; }
.nw-popmenu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 10px;
    border: 0; background: transparent; color: var(--color-text-primary); border-radius: var(--r-md); cursor: pointer; font: inherit;
}
.nw-popmenu-item:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nw-popmenu-item.on { color: var(--color-accent); font-weight: 600; background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.nw-popmenu-item.nw-popmenu-danger { color: var(--color-status-danger); }
.nw-popmenu-item.nw-popmenu-danger:hover { background: color-mix(in srgb, var(--color-status-danger) 12%, transparent); }
.nw-popmenu-ic { width: 18px; text-align: center; flex-shrink: 0; opacity: .9; }
.nw-popmenu-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-popmenu-head { padding: 4px 10px 6px; font-size: 11px; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-popmenu-sep { height: 1px; background: var(--color-border-default); margin: 4px 6px; }
.nw-popmenu-empty { padding: 8px 10px; color: var(--color-text-muted); }
.nw-popmenu-filter { margin: 2px 2px 6px; padding: 5px 9px; font-size: 12px; }

/* ── Assignees ─────────────────────────────────────────────────────────────── */
.tk-asg { font-size: 10.5px; padding: 1px 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-text-primary) 8%, transparent); color: var(--color-text-secondary); border: 1px solid var(--color-border-default); white-space: nowrap; cursor: pointer; }
.tk-asg.on { border-color: var(--color-accent); color: var(--color-accent); }

/* ── Databases section workspace (an inline database window) ──────────────── */
.dbp-mode-group { margin-right: 6px; }
.dbp-ws { width: 100%; }
.note-window.nw-inline { position: static; width: 100% !important; min-width: 0; height: 72vh; min-height: 420px; max-height: 92vh; resize: vertical; overflow: hidden; box-shadow: none; border-top-width: 1px; }
.note-window.nw-inline .nw-titlebar { display: none; }
.note-window.nw-inline .nw-footer { display: none !important; }
.note-window.nw-inline.nw-dbonly .nw-db-tabs { display: flex !important; }

/* ── Tasks on several notes ─────────────────────────────────────────────────── */
.tk-note-more { font-weight: 600; max-width: none; }
.tk-notechip { display: inline-flex; align-items: center; gap: 3px; }
.tk-notechip-t { cursor: pointer; }
.tk-notechip-t:hover { text-decoration: underline; }
.tk-notepop { width: 290px; }
.tk-notepop-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
/* ── Title wrapping: only the title wraps; the details stay on the right (wrapping among themselves if they must) ── */
.tk-matrix.tk-wrap-titles .tk-row, .tk-list.tk-wrap-titles .tk-row { flex-wrap: nowrap; align-items: flex-start; }
.tk-matrix.tk-wrap-titles .tk-row .tk-title, .tk-list.tk-wrap-titles .tk-row .tk-title { white-space: normal; overflow: visible; text-overflow: clip; word-break: break-word; flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.tk-matrix.tk-wrap-titles .tk-row .tk-meta, .tk-list.tk-wrap-titles .tk-row .tk-meta { flex: 0 0 auto; max-width: 70%; flex-wrap: nowrap; justify-content: flex-end; margin-left: auto; overflow: hidden; margin-top: 1px; }
.tk-matrix.tk-wrap-titles .tk-row .tk-title, .tk-list.tk-wrap-titles .tk-row .tk-title { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.tk-wrap-titles .tk-row .tk-check, .tk-wrap-titles .tk-row .tk-selbox, .tk-wrap-titles .tk-row .tk-prio { margin-top: 2px; }

/* ── Tasks: display settings + multi-select ────────────────────────────────── */
.tk-list.tk-compact .tk-row { padding: 2px 6px; gap: 6px; }
.tk-list.tk-compact .tk-row .tk-title { font-size: 12.5px; }
.tk-list.tk-compact .tk-group-head { margin-top: 6px; }
.nw-btn.tk-on { border-color: var(--color-accent); color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.tk-bulk { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; margin: 0 0 6px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg-secondary)); border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent); font-size: 12px; }
.tk-bulk-n { font-weight: 700; color: var(--color-accent); font-variant-numeric: tabular-nums; }
.tk-bulk-sep { width: 1px; height: 18px; background: var(--color-border-default); margin: 0 2px; }
.tk-selbox { accent-color: var(--color-accent); }
.tk-selecting .tk-row { cursor: pointer; }
.tk-row-selected, .tk-selecting .tk-row-selected:hover { background: color-mix(in srgb, var(--color-accent) 16%, transparent); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); }
.nw-popmenu-check { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: var(--r-md); cursor: pointer; }
.nw-popmenu-check:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.nw-popmenu-check select { margin-left: auto; max-width: 180px; font-size: 12px; padding: 3px 6px; }
.nw-popmenu-tall { max-height: 70vh; }
.nw-popmenu-wide { min-width: 300px; max-width: 360px; }

/* ── Tasks: collapsible headers with the dashboard caret ───────────────────── */
.tk-caret { display: inline-flex; align-items: center; color: var(--color-text-muted); transition: transform .2s ease; flex-shrink: 0; }
.tk-caret:not(.open) { transform: rotate(-90deg); }
.tk-caret svg { width: 12px; height: 12px; }
.tk-group-head { cursor: pointer; user-select: none; border-radius: var(--r-md); }
.tk-group-head:hover { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.tk-group-collapsed > .tk-row { display: none; }
.tk-rail-title { cursor: pointer; user-select: none; }
.tk-rail-sec + .tk-rail-sec .tk-rail-title { margin-top: 10px; }
.tk-rail-collapsed .tk-rail-body { display: none; }
.tk-panel-chev { display: inline-flex; }

/* ── Matrix: 'fit content' row sizing ─────────────────────────────────────── */
.tk-matrix-auto .tk-panel { min-height: 0; }
.tk-matrix-auto .tk-panel-body { max-height: none; overflow: visible; }
.tk-mgap { height: 10px; flex-shrink: 0; }
.tk-ve-rows { display: flex; flex-direction: column; gap: 4px; }

/* ── Task view editor: layout that holds at every width ────────────────────── */
.tk-ve-modal .nw-dbe-grid { grid-template-columns: 120px minmax(200px, 1fr); }
.tk-ve-modal .nw-dbe-grid > .nw-dbe-lbl { white-space: normal; }
.tk-ve-modal .nw-se-fc-dynl, .tk-ve-modal .tk-ve-rows label { white-space: normal; align-items: flex-start; line-height: 1.35; }
.tk-ve-modal .nw-se-fc-dynl input, .tk-ve-modal .tk-ve-rows label input { margin-top: 2px; flex-shrink: 0; }
.tk-ve-sizes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-ve-panel-head { flex-wrap: wrap; }
.tk-ve-panel-head .tk-ve-title { min-width: 0; }
.tk-ve-modal .nw-se-flt-cond { min-width: 0; }
.tk-ve-modal .nw-se-flt-cond > * { min-width: 0; }
@media (max-width: 767px) {
    .tk-ve-modal { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
    .tk-ve-modal .nw-dbe-grid { grid-template-columns: minmax(0, 1fr); gap: 3px 0; }
    .tk-ve-modal .nw-dbe-grid > .nw-dbe-lbl { margin-top: 10px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }
    .tk-ve-modal .nw-dbe-grid > .nw-dbe-lbl:first-child { margin-top: 0; }
    .tk-ve-modal .nw-se-flt-cond { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 4px; }
    .tk-ve-modal .nw-se-flt-cond > .nw-se-iconbtn { justify-self: end; }
    .tk-ve-modal .nw-se-flt-cond > .tk-ve-val { grid-column: 1; }
    .tk-ve-modal .tk-ve-panel-head .tk-ve-title { flex: 1 1 100%; }
    .tk-ve-modal .tk-ve-panel-head .ss-swatches { flex-wrap: wrap; }
    .tk-ve-modal .tk-ve-drop label { flex: 1 1 45%; }
    .tk-ve-modal .tk-ve-drop label input[type=text], .tk-ve-modal .tk-ve-drop label select { flex: 1 1 auto; min-width: 0; width: auto; }
}
.tk-group-head-none { font-style: italic; opacity: .8; }

/* ── Task reminders ─────────────────────────────────────────────────────────── */
.tk-bell { font-size: 11px; opacity: .8; }
.tk-remchip-fired { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-status-warning, #c98a1a) 45%, transparent); }
.tk-dim { opacity: .45; }
.toast.tk-remcard { width: min(580px, calc(100vw - 32px)); max-width: none; padding: 14px 16px; border-left: 4px solid var(--color-status-warning, #c98a1a); display: flex; flex-direction: column; gap: 8px; font-family: var(--font-ui); }
.tk-remcard-t { font-weight: 700; font-size: 15px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
.tk-remcard-b { font-size: 12.5px; color: var(--color-text-secondary); white-space: normal; }
.tk-remcard-d { display: flex; flex-direction: column; gap: 6px; }
.tk-remcard-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tk-remcard-chips:empty { display: none; }
.tk-remcard-asg { font-size: 11px; padding: 1px 8px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); color: var(--color-text-secondary); }
.tk-remcard-x { font-size: 12.5px; line-height: 1.45; color: var(--color-text-primary); white-space: normal; overflow-wrap: anywhere; max-height: 7.3em; overflow: hidden; }
.tk-remcard-x[hidden] { display: none; }
.tk-chip, .tk-rem-chip { font: inherit; font-size: 12px; padding: 3px 10px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-secondary); color: var(--color-text-primary); cursor: pointer; white-space: nowrap; line-height: 1.3; }
.tk-chip:hover, .tk-rem-chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
.tk-chip.on, .tk-rem-chip.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); border-color: var(--color-accent); color: var(--color-accent); font-weight: 600; }
.tk-rem-menu .nw-popmenu-label { display: flex; flex-direction: column; line-height: 1.2; }
.tk-rem-when { font-size: 10.5px; color: var(--color-text-muted); font-weight: 400; }
.tk-rem-details[hidden] { display: none; }
.tk-remcard-cu, .tk-remcard-rs { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: var(--r-md); background: var(--color-bg-secondary); }
.tk-remcard-cu[hidden], .tk-remcard-rs[hidden] { display: none; }
.tk-remcard-cu-g { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.tk-remcard-cu-g label { min-width: 34px; color: var(--color-text-muted); font-size: 11px; font-weight: 600; }
.tk-remcard-cu-g input[type=number] { width: 64px; }
.tk-remcard-cu-g select { width: auto; }
.tk-remcard-cu-g input, .tk-remcard-cu-g select { font-size: 12px; padding: 3px 6px; }
.tk-remcard-a { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tk-remcard-a .tk-rem-dismiss { margin-left: auto; }
body.is-phone .toast.tk-remcard { width: calc(100vw - 24px); }
.sn-cfg-row input[type=time] { width: auto; }

/* ── Files section ─────────────────────────────────────────────────────────── */
.fp-wrap { display: flex; gap: 14px; min-height: 320px; }
.fp-tree { flex: 0 0 220px; border-right: 1px solid var(--color-border-default); padding-right: 10px; font-size: 12.5px; }
.fp-tree-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); margin: 0 0 4px 8px; }
.fp-tree-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--r-md); cursor: pointer; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-tree-item:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); color: var(--color-text-primary); }
.fp-tree-item.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); font-weight: 600; }
.fp-tree-n { margin-left: auto; font-size: 10.5px; opacity: .7; font-variant-numeric: tabular-nums; }
.fp-tree-foot { margin-top: 12px; font-size: 10.5px; color: var(--color-text-muted); word-break: break-all; }
.fp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fp-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fp-crumbs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; font-size: 13px; flex-wrap: wrap; }
.fp-crumb { cursor: pointer; padding: 2px 8px; border-radius: var(--r-pill); color: var(--color-text-secondary); }
.fp-crumb:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.fp-crumb.on { color: var(--color-text-primary); font-weight: 600; cursor: default; }
.fp-crumb-sep { color: var(--color-text-muted); }
.fp-search { width: 180px; }
.fp-view { padding: 2px; }
.fp-drop-hint { font-size: 11.5px; color: var(--color-text-muted); border: 1px dashed var(--color-border-default); border-radius: var(--r-md); padding: 6px 10px; text-align: center; }
#files-container.fp-dropping .fp-drop-hint { border-color: var(--color-accent); color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.fp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fp-card { position: relative; background: var(--color-bg-card); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fp-card:hover { border-color: color-mix(in srgb, var(--color-accent) 50%, transparent); }
.fp-card-thumb { height: 110px; display: flex; align-items: center; justify-content: center; background: var(--color-bg-secondary); border-radius: var(--r-md); overflow: hidden; }
.fp-card-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fp-card-ic { font-size: 40px; }
.fp-card-folder .fp-card-thumb { height: 70px; }
.fp-card-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-card-meta { font-size: 11px; color: var(--color-text-muted); }
.fp-card-more { position: absolute; top: 6px; right: 6px; opacity: 0; }
.fp-card:hover .fp-card-more { opacity: 1; }
.fp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fp-table th { text-align: left; padding: 6px 8px; font-size: 11px; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border-default); }
.fp-table td { padding: 5px 8px; border-bottom: 1px solid var(--color-border-divider, var(--color-border-default)); vertical-align: middle; }
.fp-row { cursor: pointer; }
.fp-row:hover td { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.fp-row-ic img { width: 32px; height: 32px; object-fit: cover; border-radius: var(--r-sm); }
.fp-row-path { font-size: 10.5px; color: var(--color-text-muted); }
.fp-num { text-align: right; font-variant-numeric: tabular-nums; }
.fp-att { font-size: 10px; padding: 0 6px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 14%, transparent); color: var(--color-accent); }
.fp-progress { max-width: 320px; }
.fp-progress-t { font-weight: 600; }
.fp-progress-n { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-progress-bar { height: 6px; border-radius: 3px; background: var(--color-border-default); overflow: hidden; margin-top: 6px; }
.fp-progress-bar span { display: block; height: 100%; width: 0; background: var(--color-accent); transition: width .2s ease; }
.fp-att-row { gap: 8px; }
.fp-att-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: var(--r-sm); flex-shrink: 0; }
.fp-att-row small { color: var(--color-text-muted); margin-left: 4px; }
.fp-chip a { color: inherit; text-decoration: none; }
.note-window.nw-dropping { outline: 2px dashed var(--color-accent); outline-offset: -4px; }
.tiptap-prose img.nw-img, .ProseMirror img.nw-img, .note-card img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.ProseMirror img.ProseMirror-selectednode { outline: 2px solid var(--color-accent); }
@media (max-width: 767px) {
    .fp-wrap { flex-direction: column; }
    .fp-tree { flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--color-border-default); padding: 0 0 8px; max-height: 160px; overflow: auto; }
    .fp-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ── Notes sections: "Tray" (chosen 2026-10-20) — a soft filled container, no border, cards sit inside ── */
#notes-grid > .notes-tag-section,
#notes-grid > .notes-tag-section:first-child,
#notes-grid > .notes-tag-section:last-child,
#notes-grid > .notes-tag-section:only-child {
    border: none; border-radius: var(--r-xl); background: var(--tray-inner); overflow: visible; margin: 0;
}
#notes-grid:has(> .notes-tag-section) { gap: 18px; padding: 8px 0 0; }
#notes-grid > .notes-tag-section > .notes-tag-section-header {
    background: transparent; border-left: none; padding: 12px 14px 6px; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--color-accent); border-radius: var(--r-xl) var(--r-xl) 0 0;
}
#notes-grid > .notes-tag-section > .notes-tag-section-header:hover { background: color-mix(in srgb, var(--color-accent) 5%, transparent); }
#notes-grid > .notes-tag-section > .notes-tag-section-header::before {
    content: ''; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-tint-soft);
}
#notes-grid > .notes-tag-section > .notes-tag-section-header .notes-tag-arrow { order: 10; margin-left: 2px; color: var(--color-text-muted); }
#notes-grid > .notes-tag-section > .notes-tag-section-header .notes-tag-count { order: 5; background: transparent; border-color: var(--color-border-default); }
#notes-grid > .notes-tag-section > .notes-tag-section-header .notes-tag-add { order: 6; }
#notes-grid > .notes-tag-section > .notes-tag-section-body { background: transparent; border-top: none; padding: 6px 14px 14px; }
/* A collapsed tray keeps its bottom padding so it still reads as a container. */
#notes-grid > .notes-tag-section:has(> .notes-tag-section-body[style*="none"]) > .notes-tag-section-header { padding-bottom: 12px; border-radius: var(--r-xl); }
#notes-grid > .notes-tag-section .notes-tag-empty {
    margin: 2px 0 0; padding: 16px; text-align: center; font-size: 12px; font-style: italic; color: var(--color-text-muted);
    border: 1.5px dashed var(--color-border-default); border-radius: var(--r-lg);
}
body.is-phone #notes-grid > .notes-tag-section > .notes-tag-section-header { padding: 10px 12px 4px; }
body.is-phone #notes-grid > .notes-tag-section > .notes-tag-section-body { padding: 4px 10px 12px; }

/* Task window: the due text opens the calendar — make it look like it */
.tk-d-due { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.tk-d-due:hover { color: var(--color-accent); }

/* ── Tray, continued: the Databases section and the left rails (Notes, Files, Tasks) ── */
#dbp-container { background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 12px 12px; margin-top: 10px; }
#dbp-container .note-window.nw-inline { border: none; background: transparent; border-radius: var(--r-lg); }
#dbp-container .note-window.nw-inline .nw-body, #dbp-container .note-window.nw-inline .nw-db-pane { background: transparent; }
#dbp-container > .loading-text { margin: 6px 4px; }
#dbp-container .dbp-table th { border-bottom-color: var(--color-border-strong, var(--color-border-default)); }

.notes-layout > .notes-tree { background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 8px 12px 8px; }
.notes-tree-resizer { border-right-color: transparent; }
.notes-tree-resizer:hover { border-right-color: var(--color-border-focus); }
.notes-tree .nt-row:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.notes-tree .nt-row.sel { background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.fp-tree { background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 8px 12px; border-right: none; align-self: flex-start; }
.tk-rail { background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 8px 12px; border-right: none; align-self: flex-start; }
.tk-rail-item.on, .fp-tree-item.on { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* ── Tray, everywhere: every section's content sits in an outer tray; panels inside it (tag sections,
   the Databases workspace, the Notes/Files/Tasks rails) use the lighter inner tray. ── */
:root { --tray-bg: var(--color-bg-secondary); --tray-inner: color-mix(in srgb, var(--color-bg-card) 86%, #ffffff); }
:root[data-theme="light"] { --tray-inner: var(--color-bg-card); }
#main-content > section > .collapsible-content,
.sections-grid > section > .collapsible-content {
    background: var(--tray-bg); border-radius: var(--r-xl); padding: 12px 14px 14px; margin-top: 8px;
}
body.is-phone #main-content > section > .collapsible-content,
body.is-phone .sections-grid > section > .collapsible-content { padding: 10px 8px 12px; border-radius: var(--r-lg); }
#notes-grid:has(> .notes-tag-section) { padding-top: 0; }

/* ── Tray: Configuration tab panels and the Hashtable results ── */
#configuration .config-tabs { background: transparent; border: none; border-radius: 0; overflow: visible; }
#configuration .config-tab-buttons { background: transparent; border-bottom: none; gap: 6px; padding: 0 0 12px; flex-wrap: wrap; }
#configuration .config-tab-btn { border: 1px solid transparent; border-radius: var(--r-pill); padding: 6px 14px; font-weight: 600; }
#configuration .config-tab-btn:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); color: var(--color-text-primary); }
#configuration .config-tab-btn.active { background: var(--tray-inner); color: var(--color-accent); border-color: var(--color-border-default); border-bottom-color: var(--color-border-default); }
#configuration .config-tab-content { padding: 0; }
#configuration .config-tab-panel { display: none; flex-direction: column; gap: 12px; }
#configuration .config-tab-panel.active { display: flex; }
#configuration .config-section, #configuration .config-section:last-child { background: var(--tray-inner); border-radius: var(--r-xl); padding: 14px 16px 16px; margin: 0; border-bottom: none; }
#configuration .config-section > h4 { margin-top: 0; }
#hashtable-container:not(:empty) { background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 12px; }
body.is-phone #configuration .config-section { padding: 12px 10px; border-radius: var(--r-lg); }

/* ── Tray: Charts, Watchlists, Watchlist Alerts — inner trays instead of bordered cards ── */
#minute-charts .minute-chart-card, #watchlist .wl-list-card, #watchlist-alerts-container {
    background: var(--tray-inner); border: none; border-radius: var(--r-xl);
}
#watchlist-alerts-container { padding: 6px 8px; }

/* A collapsed section must hide every bit of its tray (the base rule only zeroes the top padding). */
#main-content > section > .collapsible-content.collapsed,
.sections-grid > section > .collapsible-content.collapsed {
    padding: 0 !important; margin-top: 0; border: none;
}

/* ── Tray: Main tab dashboard — the card grid is the outer tray, each card an inner tray; the ticker bar a tray too ── */
#dashboard .dashboard-cards { background: var(--tray-bg); border-radius: var(--r-xl); padding: 12px 14px 14px; }
#dashboard .dashboard-cards > .card { background: var(--tray-inner); border: none; border-radius: var(--r-xl); box-shadow: none; }
#dashboard #ticker-tape-bar { background: var(--tray-bg); border: none; border-radius: var(--r-xl); margin-top: 10px; }
body.is-phone #dashboard .dashboard-cards { padding: 10px 8px 12px; }

/* ── Tasks: saved filters ── */
.tk-filter-sel { max-width: 200px; }
.tk-rail-filter { font-weight: 500; }
.tk-ve-fsel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; }
.tk-ve-fsel select { width: auto; max-width: 260px; }
.tkf-sort-list { display: flex; flex-direction: column; gap: 6px; }
.tkf-sort-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.tkf-sort-row select { width: auto; }
.tkf-sort-n { color: var(--color-text-muted); font-variant-numeric: tabular-nums; min-width: 16px; }
.nw-dbe-addbar[hidden] { display: none; }
.tkf-sort-wrap { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.tkf-sort-wrap > .nw-dbe-lbl { padding-top: 4px; }
.tk-panel-flt { border: none; background: transparent; color: var(--color-text-muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 4px; opacity: .55; }
.tk-panel-head:hover .tk-panel-flt, .tk-panel-flt.on { opacity: 1; }
.tk-panel-flt.on { color: var(--color-accent); }

/* ── Resizable left rails (Tasks, Files); the Notes tree already has one ── */
.tk-rail { flex-basis: var(--tk-rail-w, 200px); width: var(--tk-rail-w, 200px); }
.fp-tree { flex: 0 0 var(--fp-tree-w, 220px); width: var(--fp-tree-w, 220px); }
.tk-rail-resizer, .fp-tree-resizer { flex: 0 0 8px; align-self: stretch; cursor: col-resize; margin: 0 -2px; border-radius: 4px; touch-action: none; }
.tk-rail-resizer:hover, .fp-tree-resizer:hover { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.tk-wrap.tk-norail .tk-rail-resizer, body.is-phone .tk-rail-resizer, body.is-phone .fp-tree-resizer { display: none; }
.tk-wrap { gap: 6px; }
/* nested groups (multi-level grouping) */
.tk-group .tk-group { margin-left: 14px; }
.tk-group-d1 > .tk-group-head { font-size: 10.5px; opacity: .9; }
.tk-group-d2 > .tk-group-head { font-size: 10px; opacity: .8; }

/* ── List grouping popover ── */
.tk-group-btn { text-align: left; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tk-group-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 8px 8px; }
.tk-group-levels { padding: 0 8px 8px; }
.tk-group-levels .tkf-sort-wrap > .nw-dbe-lbl { display: none; }

/* ── Calendar panels ── */
.tk-cal { display: flex; flex-direction: column; gap: 6px; font-size: 12px; padding: 2px 2px 4px; }
.tk-cal-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-cal-title { font-weight: 700; flex: 1 1 auto; min-width: 0; }
.tk-cal-modes { display: flex; gap: 4px; }
.tk-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.tk-cal-dow { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); text-align: center; }
.tk-cal-cell, .tk-cal-wcol, .tk-cal-dayv { border: 1px solid var(--color-border-default); border-radius: var(--r-md); background: var(--tray-inner); padding: 3px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-cal-cell { min-height: 72px; }
.tk-cal-cell.muted { opacity: .45; }
.tk-cal-cell.today, .tk-cal-wcol.today, .tk-cal-dayv.today { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-text-on-accent, #fff); }
.tk-cal-cell.today .tk-cal-day, .tk-cal-wcol.today .tk-cal-day { color: inherit; font-weight: 800; }
.tk-cal-cell.today .tk-cal-n, .tk-cal-wcol.today .tk-cal-n { background: color-mix(in srgb, var(--color-text-on-accent, #fff) 25%, transparent); color: inherit; }
.tk-cal-cell.today .tk-cal-chip, .tk-cal-wcol.today .tk-cal-chip { background: var(--tray-inner); color: var(--color-text-primary); }
.tk-cal-cell.today .tk-cal-chip.over { color: var(--color-status-danger); }
.tk-cal-cell.today .tk-cal-more { color: inherit; text-decoration: underline; }
.tk-cal-over { outline: 2px dashed var(--color-accent); outline-offset: -2px; }
.tk-cal-day { font-size: 10.5px; color: var(--color-text-muted); display: flex; align-items: center; gap: 4px; }
.tk-cal-n { margin-left: auto; font-size: 9.5px; font-weight: 700; color: var(--color-text-muted); background: color-mix(in srgb, var(--color-accent) 14%, transparent); border-radius: var(--r-pill); padding: 0 5px; }
.tk-cal-chip { --c: var(--color-border-strong); font-size: 10.5px; line-height: 1.3; padding: 1px 4px 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--color-text-primary); }
.tk-cal-chip:hover { background: color-mix(in srgb, var(--c) 26%, transparent); }
.tk-cal-chip.tk-cal-high { --c: var(--color-status-danger); }
.tk-cal-chip.tk-cal-medium { --c: var(--color-warning, #d97706); }
.tk-cal-chip.tk-cal-low { --c: var(--color-accent); }
.tk-cal-chip.over { color: var(--color-status-danger); }
.tk-cal-chip.done { text-decoration: line-through; opacity: .6; }
.tk-cal-time { color: var(--color-text-muted); margin-right: 3px; font-variant-numeric: tabular-nums; }
.tk-cal-more { font-size: 10px; color: var(--color-accent); cursor: pointer; }
.tk-cal-wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.tk-cal-wcol { min-height: 140px; }
.tk-cal-dayv { min-height: 80px; gap: 0; padding: 2px; }
.tk-cal-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tk-cal-jump { font: inherit; font-size: 11px; color: var(--color-text-secondary); background: var(--color-bg-secondary); border: 1px solid var(--color-border-default); border-radius: var(--r-pill); padding: 2px 9px; cursor: pointer; }
.tk-cal-jump:hover { color: var(--color-accent); border-color: var(--color-accent); }
.tk-cal-nodate { display: flex; flex-direction: column; gap: 2px; }
/* Small day cells still carry clickable chips: they shrink with the cell instead of disappearing. */
.tk-cal-cell { container-type: inline-size; }
@container (max-width: 110px) {
    .tk-cal-chip { font-size: 9.5px; padding: 0 3px; border-left-width: 2px; }
    .tk-cal-time { display: none; }
}
@container (max-width: 70px) {
    .tk-cal-chip { font-size: 8.5px; padding: 0 2px; }
    .tk-cal-day { font-size: 9.5px; }
}
body.is-phone .tk-cal-cell { min-height: 54px; padding: 2px; gap: 1px; }
body.is-phone .tk-cal-wk { grid-template-columns: 1fr !important; }

/* Year: twelve mini months; a day's tasks are thin colour bars you can click */
.tk-cal-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; }
.tk-cal-mini { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tk-cal-mini-h { font-size: 11.5px; font-weight: 700; color: var(--color-accent); cursor: pointer; padding-left: 2px; }
.tk-cal-mini-h:hover { text-decoration: underline; }
.tk-cal-mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.tk-cal-mini-dow { font-size: 8px; color: var(--color-text-muted); text-align: center; }
.tk-cal-mini-cell { min-height: 22px; border-radius: 3px; padding: 1px 2px 2px; display: flex; flex-direction: column; gap: 1px; cursor: pointer; background: var(--tray-inner); border: 1px solid transparent; min-width: 0; }
.tk-cal-mini-cell.muted { background: transparent; cursor: default; }
.tk-cal-mini-cell:not(.muted):hover { border-color: var(--color-accent); }
.tk-cal-mini-cell.today { background: var(--color-accent); color: var(--color-text-on-accent, #fff); }
.tk-cal-mini-n { font-size: 8.5px; line-height: 1; color: var(--color-text-muted); }
.tk-cal-mini-cell.has .tk-cal-mini-n { color: var(--color-text-primary); font-weight: 700; }
.tk-cal-mini-cell.today .tk-cal-mini-n { color: inherit; }
.tk-cal-mark { --c: var(--color-border-strong); display: block; height: 3px; border-radius: 2px; background: var(--c); }
.tk-cal-mark:hover { outline: 1px solid var(--color-text-primary); }
.tk-cal-mark.tk-cal-high { --c: var(--color-status-danger); }
.tk-cal-mark.tk-cal-medium { --c: var(--color-warning, #d97706); }
.tk-cal-mark.tk-cal-low { --c: var(--color-accent); }
.tk-cal-mini-cell.today .tk-cal-mark.tk-cal-low { --c: var(--color-text-on-accent, #fff); }
.tk-cal-mark.more { background: repeating-linear-gradient(90deg, var(--color-text-muted) 0 3px, transparent 3px 5px); }
.tk-cal-mini-cell.today .tk-cal-mini-cell { color: inherit; }
.tk-cal-over.tk-cal-mini-cell { outline: 2px dashed var(--color-accent); outline-offset: -1px; }

/* Agenda: days with tasks, as task rows */
.tk-cal-agenda { display: flex; flex-direction: column; gap: 8px; }
.tk-cal-ag-day { border: 1px solid var(--color-border-default); border-radius: var(--r-md); background: var(--tray-inner); padding: 4px 6px 6px; }
.tk-cal-ag-day.today { border-color: var(--color-accent); }
.tk-cal-ag-h { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-secondary); padding: 2px 4px 4px; }
.tk-cal-ag-day.today .tk-cal-ag-h { color: var(--color-accent); }
.tk-cal-ag-h .tk-cal-n { margin-left: 0; }

/* ── Group button + popover controls look like the rest of the toolbar ── */
.tk-group-btn { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: var(--r-md); border: 1px solid var(--color-border-input); background: var(--color-bg-input); color: var(--color-text-primary); cursor: pointer; }
.tk-group-btn:hover { border-color: var(--color-accent); }
.tk-group-menu .tkf-sort-row select, .tkf-sort-row select, .tk-cal-count, .tk-ve-span { font: inherit; font-size: 12px; padding: 3px 6px; border-radius: var(--r-md); border: 1px solid var(--color-border-input); background: var(--color-bg-input); color: var(--color-text-primary); }
.tk-ve-span { width: 56px; }
.tk-cal-count { width: auto; }
.tk-cal-sub { font-size: 12px; font-weight: 700; color: var(--color-text-secondary); margin-top: 6px; }
.tk-cal-weeks .tk-cal-cell { min-height: 64px; }

/* ── Task location ── */
.tk-d-loc { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.tk-loc-wrap { position: relative; flex: 1 1 260px; max-width: 420px; min-width: 0; }
.tk-d-locin { width: 100%; font: inherit; font-size: 12.5px; padding: 4px 8px; border-radius: var(--r-md); border: 1px solid var(--color-border-input); background: var(--color-bg-input); color: var(--color-text-primary); }
.tk-loc-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 20; display: none; flex-direction: column; background: var(--color-bg-modal, var(--color-bg-secondary)); border: 1px solid var(--color-border-default); border-radius: var(--r-md); box-shadow: var(--shadow-dropdown); max-height: 220px; overflow: auto; }
.tk-loc-suggest.open { display: flex; }
.tk-loc-item { padding: 5px 9px; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-loc-item:hover, .tk-loc-item.on { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.tk-loc-maps { text-decoration: none; white-space: nowrap; }
.tk-loc { text-decoration: none; font-size: 12px; line-height: 1; flex-shrink: 0; }

/* ── Periods (start → due) ── */
.tk-d-start { font-size: 12px; color: var(--color-text-muted); cursor: pointer; padding: 1px 8px; border-radius: var(--r-pill); border: 1px dashed var(--color-border-default); white-space: nowrap; }
.tk-d-start:hover { color: var(--color-accent); border-color: var(--color-accent); }
.tk-d-start.on { color: var(--color-text-secondary); border-style: solid; }
.tk-cal-chip.tk-cal-span-start { border-radius: 4px 0 0 4px; }
.tk-cal-chip.tk-cal-span-mid { border-radius: 0; border-left-width: 0; padding-left: 4px; opacity: .85; }
.tk-cal-chip.tk-cal-span-end { border-radius: 0 4px 4px 0; border-left-width: 0; padding-left: 4px; }
.tk-cal-chip.tk-cal-span-mid::before, .tk-cal-chip.tk-cal-span-end::before { content: '↔ '; opacity: .6; }

/* ── Period bars across month / week rows ── */
.tk-cal-rows { display: flex; flex-direction: column; gap: 3px; }
.tk-cal-row { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.tk-cal-lanes { flex: 0 0 auto; }
.tk-cal-span { --c: var(--color-border-strong); position: absolute; height: 15px; line-height: 15px; margin: 0 2px; box-sizing: border-box; padding: 0 5px; font-size: 10.5px; border-radius: 4px; background: color-mix(in srgb, var(--c) 24%, var(--tray-inner)); border-left: 3px solid var(--c); color: var(--color-text-primary); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; z-index: 2; }
.tk-cal-span:hover { background: color-mix(in srgb, var(--c) 40%, var(--tray-inner)); }
.tk-cal-span:not(.s) { border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0; padding-left: 4px; }
.tk-cal-span:not(.e) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tk-cal-span.tk-cal-high { --c: var(--color-status-danger); }
.tk-cal-span.tk-cal-medium { --c: var(--color-warning, #d97706); }
.tk-cal-span.tk-cal-low { --c: var(--color-accent); }
.tk-cal-span.over { color: var(--color-status-danger); }
.tk-d-arrow { color: var(--color-text-muted); font-size: 12px; }
.tk-d-spanlen { font-size: 11px; color: var(--color-text-muted); }

/* ── Note window side column: Tasks above Files ── */
.nw-side-col { display: flex; flex-direction: column; flex: 0 0 420px; min-width: 0; min-height: 0; }
.nw-side-col > .nw-tk-pane { flex: 1 1 50%; min-height: 0; }
.nw-side-col > .nw-fp-pane { flex: 1 1 auto; min-height: 0; padding: 0; }

.nw-fp-crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.nw-fp-crumb { background: none; border: none; color: var(--color-accent); cursor: pointer; font-size: 12px; padding: 1px 4px; border-radius: var(--r-sm); white-space: nowrap; }
.nw-fp-crumb.cur { color: var(--color-text-primary); font-weight: 600; cursor: default; }
.nw-fp-crumb:not(.cur):hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nw-fp-body { position: relative; display: flex; flex-direction: column; gap: 8px; }
.nw-fp-body.nw-dropping { outline: 2px dashed var(--color-accent); outline-offset: -4px; background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.nw-fp-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.nw-fp-grid .fp-card { padding: 6px; gap: 3px; }
.nw-fp-grid .fp-card-thumb { height: 78px; }
.nw-fp-grid .fp-card-folder .fp-card-thumb { height: 50px; }
.nw-fp-grid .fp-card-ic { font-size: 30px; }
.nw-fp-grid .fp-card-name { font-size: 11.5px; }
.nw-fp-grid .fp-card-meta { font-size: 10px; }
.nw-fp-grid .fp-card:hover .fp-card-more { opacity: 1; }
.nw-fp-hint { font-size: 11px; color: var(--color-text-muted); text-align: center; border: 1px dashed var(--color-border-default); border-radius: var(--r-md); padding: 6px; margin-top: auto; }
.nw-fp-empty { font-size: 12px; color: var(--color-text-muted); text-align: center; padding: 24px 10px; border: 1.5px dashed var(--color-border-default); border-radius: var(--r-lg); line-height: 1.5; }

/* ── Image lightbox ── */
.nw-lightbox { position: fixed; inset: 0; background: rgba(6, 10, 18, .82); display: flex; flex-direction: column; }
.nw-lightbox-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; font-size: 13px; }
.nw-lightbox-name { font-weight: 700; }
.nw-lightbox-meta { opacity: .7; font-size: 12px; }
.nw-lightbox-bar .nw-btn { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); text-decoration: none; }
.nw-lightbox-img { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 16px 16px; }
.nw-lightbox-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-md); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.nw-fp-pane .nw-tk-bar { flex-wrap: nowrap; }
.nw-fp-pane .nw-tk-bar .btn { white-space: nowrap; flex: 0 0 auto; }
.nw-fp-pane .nw-tk-bar .nw-fp-crumbs { flex: 1 1 auto; min-width: 40px; }
.nw-fp-pane .nw-tk-bar > span[style*="flex:1"] { display: none; }
.nw-fp-crumb { overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* ── Notes layouts: Snippets · List · Preview pane ── */
.notes-layout-select { max-width: 160px; }
#btn-notes-preview.active { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); border-color: var(--color-accent); }
.notes-body { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.notes-list-col { flex: 1 1 auto; min-width: 0; }
.notes-body.notes-split .notes-list-col { flex: 0 0 var(--notes-list-w, 420px); width: var(--notes-list-w, 420px); }
.notes-preview-resizer { display: none; flex: 0 0 8px; align-self: stretch; cursor: col-resize; border-radius: 4px; touch-action: none; }
.notes-body.notes-split .notes-preview-resizer { display: block; }
.notes-preview-resizer:hover { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.notes-preview { flex: 1 1 auto; min-width: 0; position: sticky; top: 48px; height: calc(100vh - 120px); display: flex; flex-direction: column; background: var(--tray-inner); border-radius: var(--r-xl); overflow: hidden; }
.notes-preview-empty { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--color-text-muted); font-size: 13px; text-align: center; padding: 20px; }
.notes-preview-empty small { font-size: 11.5px; }
.notes-preview.has-note .notes-preview-empty { display: none; }
#notes-preview-host { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#notes-preview-host .note-window.nw-inline { height: 100%; max-height: none; min-height: 0; resize: none; flex: 1 1 auto; border: none; border-radius: 0; background: transparent; }
#notes-preview-host .note-window.nw-inline .nw-titlebar { display: flex; }
#notes-preview-host .note-window.nw-inline .nw-close-btn { display: none; }
/* In split mode cards and snippets still flow into columns when the list column is wide enough */
.notes-body.notes-split .notes-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.notes-body.notes-split .notes-layout-snippets .notes-grid, .notes-body.notes-split #notes-grid.notes-layout-snippets > .notes-tag-section .notes-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* Snippets: compact cards */
.notes-layout-snippets .notes-grid, #notes-grid.notes-layout-snippets > .notes-tag-section .notes-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.note-snip { --note-color: var(--color-accent); position: relative; display: flex; flex-direction: column; gap: 4px; padding: 9px 10px 8px; background: var(--color-bg-card); border: 1px solid var(--color-border-default); border-left: 4px solid var(--note-color); border-radius: var(--r-lg); cursor: pointer; min-width: 0; }
.note-snip:hover { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); border-left-color: var(--note-color); }
.note-snip.selected, .note-row.selected, .note-card.selected { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.note-snip.archived, .note-row.archived { opacity: .55; }
.note-snip-top { display: flex; align-items: center; gap: 4px; min-height: 18px; }
.note-snip-title { font-size: 13px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-snip-text { font-size: 11.5px; line-height: 1.4; color: var(--color-text-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-snip-thumb { height: 86px; border-radius: var(--r-md); overflow: hidden; background: var(--color-bg-secondary); }
.note-snip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-snip-foot { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.note-snip .note-pin-icon, .note-row .note-pin-icon { opacity: 0; }
.note-snip:hover .note-pin-icon, .note-row:hover .note-pin-icon, .note-snip .note-pin-icon.on, .note-row .note-pin-icon.on { opacity: 1; }
.note-mini-tag { font-size: 10px; padding: 1px 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.note-mini-sym { background: var(--color-bg-secondary); color: var(--color-text-secondary); font-weight: 600; }
.note-mini-more { background: transparent; color: var(--color-text-muted); }
.note-row-date { margin-left: auto; font-size: 10.5px; color: var(--color-text-muted); white-space: nowrap; }
.note-row-edit { opacity: 0; font-size: 12px; }
.note-snip:hover .note-row-edit, .note-row:hover .note-row-edit { opacity: .8; }

/* List: dense rows */
.notes-layout-list .notes-grid, #notes-grid.notes-layout-list > .notes-tag-section .notes-grid { display: flex; flex-direction: column; gap: 3px; }
.note-row { --note-color: var(--color-accent); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: var(--r-md); border-left: 3px solid var(--note-color); background: var(--color-bg-card); cursor: pointer; min-width: 0; }
.note-row:hover { background: color-mix(in srgb, var(--color-accent) 7%, var(--color-bg-card)); }
.note-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.note-row-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.note-row-snip { font-size: 11.5px; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row-side { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; max-width: 42%; }
.note-row-thumb { flex: 0 0 44px; width: 44px; height: 34px; border-radius: var(--r-sm); overflow: hidden; background: var(--color-bg-secondary); }
.note-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
body.is-phone .note-row-side .note-mini-tag { display: none; }
body.is-phone .notes-preview, body.is-phone .notes-preview-resizer { display: none !important; }
body.is-phone .notes-body.notes-split .notes-list-col { flex: 1 1 auto; width: auto; }

/* Split mode: the list column clips to its width and everything inside it may shrink, so nothing runs under the preview */
.notes-body.notes-split .notes-list-col { overflow: hidden; min-width: 0; }
.notes-body.notes-split #notes-grid, .notes-body.notes-split #notes-grid > .notes-tag-section { min-width: 0; max-width: 100%; overflow: hidden; }
.notes-body.notes-split .notes-tag-section-header { min-width: 0; }
.notes-body.notes-split .notes-tag-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-body.notes-split .notes-grid { min-width: 0; }
.notes-body.notes-split .notes-grid > * { min-width: 0; max-width: 100%; }
.notes-body.notes-split .note-card, .notes-body.notes-split .note-snip, .notes-body.notes-split .note-row { box-sizing: border-box; }
.notes-preview { min-width: 320px; }

/* ── Toggle (details) blocks: no box, the app's chevron instead of a triangle ── */
.tiptap-editor-content .ProseMirror div[data-type="details"] { border: none; border-radius: 0; margin: 0.4em 0; }
.tiptap-editor-content .ProseMirror div[data-type="details"] > button { padding: 8px 4px 7px 2px; color: var(--color-text-muted); }
.tiptap-editor-content .ProseMirror div[data-type="details"] > button:hover { color: var(--color-accent); }
.tiptap-editor-content .ProseMirror div[data-type="details"] > button::before { content: ''; width: 14px; height: 14px; background: currentColor; -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; transform: none; }
.tiptap-editor-content .ProseMirror div[data-type="details"].is-open > button::before { transform: rotate(90deg); }
.tiptap-editor-content .ProseMirror div[data-type="details"] summary { padding: 7px 8px 7px 2px; }
.tiptap-editor-content .ProseMirror div[data-type="detailsContent"] { border-top: none; padding: 2px 8px 8px 2px; margin-left: 0; }

.note-content details, .about-content details { border: none; border-radius: 0; margin: 0.4em 0; overflow: visible; }
.note-content details summary, .about-content details summary { padding: 6px 8px 6px 2px; border-radius: var(--r-sm); }
.note-content details summary::before, .about-content details summary::before { content: ''; width: 14px; height: 14px; background: var(--color-text-muted); -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; font-size: 0; }
.note-content details summary:hover::before, .about-content details summary:hover::before { background: var(--color-accent); }
.note-content details[open] summary::before, .about-content details[open] summary::before { transform: rotate(90deg); }
.note-content details div[data-type="detailsContent"], .about-content details div[data-type="detailsContent"] { border-top: none; padding: 2px 8px 8px 22px; }

.note-card-content details summary::before { content: ''; width: 10px; height: 10px; display: inline-block; vertical-align: -1px; background: var(--color-accent); -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; margin-right: 4px; }
.note-card-content details[open] summary::before { content: ''; transform: rotate(90deg); }

/* Toggle headings: plain text (no colour, no bold) and the chevron centred on the heading line */
.tiptap-editor-content .ProseMirror div[data-type="details"] { align-items: flex-start; }
.tiptap-editor-content .ProseMirror div[data-type="details"] > button { height: 1.6em; padding: 0 4px 0 2px; margin-top: 7px; align-self: flex-start; }
.tiptap-editor-content .ProseMirror div[data-type="details"] summary { font-weight: 400; color: inherit; line-height: 1.6; padding: 7px 8px 7px 2px; }
.note-content details summary, .about-content details summary { font-weight: 400; color: inherit; line-height: 1.6; align-items: center; }
.note-content details summary::before, .about-content details summary::before { align-self: center; }
.note-card-content details summary { font-weight: 400; color: inherit; }

/* ── Toggle blocks: optional border / background per block (<details data-box data-shade>; set from the ⌄ toolbar menu) ── */
.tiptap-editor-content .ProseMirror div[data-type="details"][data-box], .note-content details[data-box], .about-content details[data-box], .note-card-content details[data-box] { border: 1px solid var(--color-border-strong); border-radius: var(--r-md); }
:root { --toggle-shade: var(--tray-inner); }
:root[data-theme="light"] { --toggle-shade: color-mix(in srgb, var(--color-text-primary) 5%, var(--color-bg-card)); }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-shade], .note-content details[data-shade], .about-content details[data-shade], .note-card-content details[data-shade] { background: var(--toggle-shade); border-radius: var(--r-md); }
.tiptap-editor-content .ProseMirror div[data-type="details"]:is([data-box], [data-shade]) { padding: 2px 8px 2px 4px; }
.note-content details:is([data-box], [data-shade]), .about-content details:is([data-box], [data-shade]) { padding: 2px 8px 2px 4px; }
.note-card-content details:is([data-box], [data-shade]) { padding: 1px 6px; }
.nw-popmenu-hint { padding: 4px 10px 2px; font-size: 11px; line-height: 1.4; color: var(--color-text-muted); max-width: 230px; }

/* ── Block drag handle (⋮⋮ in the editor's left gutter) ── */
.tiptap-editor-content.has-block-handle { position: relative; }
.tiptap-editor-content.has-block-handle .ProseMirror { padding-left: 26px; }
.pm-block-handle { position: absolute; z-index: 3; width: 16px; height: 18px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); color: var(--color-text-muted); opacity: .55; cursor: grab; user-select: none; -webkit-user-select: none; }
.pm-block-handle:hover { opacity: 1; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.pm-block-handle.dragging, .pm-block-handle:active { cursor: grabbing; }
.pm-block-handle[hidden] { display: none; }
.tiptap-editor-content .ProseMirror > .ProseMirror-selectednode { outline: 2px solid color-mix(in srgb, var(--color-accent) 55%, transparent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ── Task quick-add: + button (always on phones; on desktop once something is typed) ── */
.tk-quick-wrap { flex: 1 1 260px; min-width: 180px; display: flex; align-items: center; gap: 4px; }
.tk-quick-wrap .tk-quick { flex: 1 1 auto; min-width: 0; }
.tk-quick-go { flex: 0 0 auto; display: none; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: var(--r-pill); border: 1px solid var(--color-border-strong); background: var(--color-bg-secondary); color: var(--color-text-primary); font-size: 18px; line-height: 1; cursor: pointer; }
.tk-quick-go:hover { border-color: var(--color-accent); color: var(--color-accent); }
.tk-quick:not(:placeholder-shown) + .tk-quick-go, body.is-phone .tk-quick-go { display: inline-flex; }
body.is-phone .tk-quick-go { width: 34px; height: 34px; }

/* ── Toggle blocks: background from the note palette (data-shade="#hex" + --toggle-color) or the neutral tint ── */
.tiptap-editor-content .ProseMirror div[data-type="details"][data-shade]:not([data-shade="tint"]):not([data-shade=""]), .note-content details[data-shade]:not([data-shade="tint"]):not([data-shade=""]), .about-content details[data-shade]:not([data-shade="tint"]):not([data-shade=""]), .note-card-content details[data-shade]:not([data-shade="tint"]):not([data-shade=""]) { background: color-mix(in srgb, var(--toggle-color, var(--color-accent)) 24%, var(--color-bg-card)); }
:root[data-theme="light"] .tiptap-editor-content .ProseMirror div[data-type="details"][data-shade]:not([data-shade="tint"]):not([data-shade=""]), :root[data-theme="light"] .note-content details[data-shade]:not([data-shade="tint"]):not([data-shade=""]), :root[data-theme="light"] .about-content details[data-shade]:not([data-shade="tint"]):not([data-shade=""]) { background: color-mix(in srgb, var(--toggle-color, var(--color-accent)) 30%, var(--color-bg-card)); }
.nw-popmenu-sub { padding: 6px 10px 2px; font-size: 11px; color: var(--color-text-muted); }
.nw-toggle-swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 6px; }
.nw-toggle-swatches .nw-cp-swatch { width: 20px; height: 20px; }
.nw-toggle-swatches .nw-sw-none { background: transparent; border-color: var(--color-border-strong); position: relative; }
.nw-toggle-swatches .nw-sw-none::after { content: ''; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px; background: var(--color-border-strong); transform: rotate(-45deg); border-radius: 1px; }
.nw-toggle-swatches .nw-sw-tint { background: var(--toggle-shade); border-color: var(--color-border-strong); }
.nw-toggle-swatches .nw-cp-swatch.selected { border-color: var(--color-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 35%, transparent); }

/* ── Notes rail: Filters / Tags as collapsible tray-style sections ── */
.nt-sec { margin: 0 0 6px; }
.nt-sec-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 4px; border-radius: var(--r-lg); cursor: pointer; user-select: none; font-size: 13px; font-weight: 700; color: var(--color-accent); }
.nt-sec-head:hover { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.nt-sec-head::before { content: ''; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-tint-soft); }
.nt-sec-head .nt-sec-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-sec-head .notes-tag-count { flex: 0 0 auto; background: transparent; border-color: var(--color-border-default); }
.nt-sec-head .nt-sec-btn { flex: 0 0 auto; font-size: 10.5px; padding: 1px 8px; }
.nt-sec-head .notes-tag-arrow { order: 10; width: 14px; margin-left: 0; color: var(--color-text-muted); transition: transform .15s; }
.nt-sec.open > .nt-sec-head .notes-tag-arrow, .nt-sec.nt-sec-auto > .nt-sec-head .notes-tag-arrow { transform: rotate(90deg); }
.nt-sec-body { display: none; padding: 2px 0 0; }
.nt-sec.open > .nt-sec-body, .nt-sec.nt-sec-auto > .nt-sec-body { display: block; }
.notes-tree .nf-gap { display: none; }
/* The rail sits above the notes list at every width (monitor.js _notesRailPlace moves #notes-tree into
   .notes-list-col): as wide as the notes, never over the preview pane; sections start collapsed so the notes
   stay within reach, and an explicit open/close is remembered. */
.notes-list-col > .notes-tree { position: static; width: auto; flex: 0 0 auto; max-height: none; margin-bottom: 10px; background: var(--tray-inner); border-radius: var(--r-xl); padding: 10px 8px 12px 8px; box-sizing: border-box; }
.notes-layout.nt-stacked > .notes-tree-resizer { display: none; }
.notes-layout.nt-hidden .notes-tree { display: none; }
.notes-list-col > .notes-tree .nt-sec.nt-sec-auto > .nt-sec-body { display: none; }
.notes-list-col > .notes-tree .nt-sec.nt-sec-auto > .nt-sec-head .notes-tag-arrow { transform: none; }
.notes-list-col > .notes-tree .nt-sec { margin-bottom: 2px; }

/* ── Task kind (task | event | card) and card colour ── */
.tk-kindchip { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); color: var(--color-text-muted); white-space: nowrap; }
.tk-kind-event { color: #2563eb; border-color: color-mix(in srgb, #2563eb 45%, transparent); background: color-mix(in srgb, #2563eb 10%, transparent); }
.tk-kind-snippet { color: var(--color-accent); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.tk-pp-kind.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.tk-d-l2 { margin-left: 14px; }
.tk-d-swatches { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tk-d-swatches .nw-cp-swatch { width: 16px; height: 16px; }
.tk-d-swatches .nw-sw-none { background: transparent; border-color: var(--color-border-strong); position: relative; }
.tk-d-swatches .nw-sw-none::after { content: ''; position: absolute; left: 2px; right: 2px; top: 50%; height: 2px; background: var(--color-border-strong); transform: rotate(-45deg); }
.tk-d-swatches .nw-cp-swatch.selected { border-color: var(--color-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 35%, transparent); }

/* ── Matrix panel "Cards" view: Keep-style masonry (CSS columns; each card as tall as its content) ── */
.tk-cards { column-width: 210px; column-gap: 8px; padding: 2px 2px 4px; }
.tk-card { break-inside: avoid; display: inline-block; width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 8px 10px 7px; border-radius: var(--r-lg); background: var(--color-bg-card); border: 1px solid var(--color-border-default); cursor: pointer; vertical-align: top; transition: border-color .12s ease, box-shadow .12s ease; }
.tk-card-colored { background: color-mix(in srgb, var(--card-c) 22%, var(--color-bg-card)); border-color: color-mix(in srgb, var(--card-c) 45%, transparent); }
:root[data-theme="light"] .tk-card-colored { background: color-mix(in srgb, var(--card-c) 30%, var(--color-bg-card)); }
.tk-card:hover { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); }
.tk-card-open { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 50%, transparent); }
.tk-card.tk-done .tk-card-title { text-decoration: line-through; opacity: .6; }
.tk-card.tk-dragging { opacity: .4; }
.tk-card-head { display: flex; align-items: flex-start; gap: 6px; }
.tk-card-head .tk-check { margin-top: 2px; }
.tk-card-title { flex: 1 1 auto; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--color-text-primary); line-height: 1.35; overflow-wrap: anywhere; }
.tk-card-pin { flex: 0 0 auto; width: 20px; height: 20px; padding: 0; border: none; background: transparent; color: var(--color-text-muted); opacity: 0; cursor: pointer; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; }
.tk-card:hover .tk-card-pin { opacity: .6; }
.tk-card-pin.on { opacity: 1; color: var(--color-accent); }
.tk-card-pin:hover { opacity: 1; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
body.is-phone .tk-card-pin { opacity: .5; }
.tk-card-body { margin-top: 5px; font-size: 12px; line-height: 1.45; color: var(--color-text-secondary); display: -webkit-box; -webkit-line-clamp: 10; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tk-card-body > * { margin: 0 0 .35em; }
.tk-card-body img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.tk-card-body ul, .tk-card-body ol { padding-left: 18px; }
.tk-card-body details { margin: .2em 0; }
.tk-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; }
.tk-card-note { max-width: 100%; }
.tk-ve-kinds, .tk-ve-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.tk-ve-kinds label, .tk-ve-fields label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }

/* ── Cards section / note Cards pane (the task engine in cards mode) ── */
.tk-wrap-cards .tk-list > .tk-cards { column-width: 230px; padding: 4px 2px; }
#cards-container .tk-cards { column-width: 240px; }
.nw-side-col > .nw-cp-pane { flex: 1 1 50%; min-height: 0; }
.nw-split-container.split-vertical .nw-side-col > .nw-cp-resizer { width: auto; height: 6px; cursor: row-resize; }
.nw-cp-pane .tk-cards { column-width: 180px; }
.tk-pp-pin.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.tk-card-when { margin-left: auto; font-size: 10.5px; color: var(--color-text-muted); white-space: nowrap; }
.tk-ve-notes { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }
/* ── Archive ── */
.tk-card-arch { flex: 0 0 auto; width: 20px; height: 20px; padding: 0; border: none; background: transparent; color: var(--color-text-muted); opacity: 0; cursor: pointer; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.tk-card:hover .tk-card-arch, .tk-card-arch.on { opacity: .6; }
.tk-card-arch:hover { opacity: 1; color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
body.is-phone .tk-card-arch { opacity: .5; }
.tk-card-archived { opacity: .65; border-style: dashed; }
.tk-row-archived { opacity: .7; }
/* ── Database tabs: drag to reorder ── */
.nw-db-tab.nw-db-tab-sortable { touch-action: none; user-select: none; -webkit-user-select: none; }
.nw-db-tab.nw-db-tab-armed { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 50%, transparent); }
.nw-db-tab.nw-db-tab-dragging { opacity: .4; }
.nw-db-tab.nw-db-tab-ins-before { box-shadow: inset 3px 0 0 var(--color-accent); }
.nw-db-tab.nw-db-tab-ins-after { box-shadow: inset -3px 0 0 var(--color-accent); }
.nw-db-vtab.nw-db-tab-sortable { touch-action: none; user-select: none; -webkit-user-select: none; }
.nw-db-vtab.nw-db-tab-dragging { opacity: .4; }
.nw-db-vtab.nw-db-tab-ins-before { box-shadow: inset 3px 0 0 var(--color-accent); }
.nw-db-vtab.nw-db-tab-ins-after { box-shadow: inset -3px 0 0 var(--color-accent); }
.nw-db-vtab.nw-db-tab-armed { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 50%, transparent); }
/* ── Drag grips for vertical lists (view editor columns, matrix panels) ── */
.nw-grip { flex: 0 0 auto; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--color-text-muted); font-size: 14px; line-height: 1; padding: 0 4px; }
.nw-grip:hover { color: var(--color-accent); }
.nw-dragging { opacity: .4; }
.nw-ins-before { box-shadow: 0 -3px 0 0 var(--color-accent) !important; }
.nw-ins-after { box-shadow: 0 3px 0 0 var(--color-accent) !important; }

/* ── Editor blocks: callout · image figure · bookmark · embed · "/" menu · handle menu ── */
.nw-callout { display: flex; gap: 10px; padding: 10px 12px; margin: .5em 0; border-radius: var(--r-lg); background: color-mix(in srgb, var(--callout-c, var(--color-accent)) 14%, var(--color-bg-card)); border-left: 4px solid var(--callout-c, var(--color-accent)); }
.nw-callout-icon { flex: 0 0 auto; font-size: 18px; line-height: 1.3; background: transparent; border: none; padding: 0 2px; cursor: default; font-family: inherit; }
.ProseMirror .nw-callout-icon { cursor: pointer; border-radius: var(--r-sm); }
.ProseMirror .nw-callout-icon:hover { background: color-mix(in srgb, var(--callout-c, var(--color-accent)) 20%, transparent); }
.nw-callout-body { flex: 1 1 auto; min-width: 0; }
.nw-callout-body > :first-child { margin-top: 0; }
.nw-callout-body > :last-child { margin-bottom: 0; }
figure.nw-fig { margin: .6em 0; position: relative; display: table; max-width: 100%; }
figure.nw-fig[data-align="center"] { margin-left: auto; margin-right: auto; }
figure.nw-fig[data-align="right"] { margin-left: auto; margin-right: 0; }
figure.nw-fig[data-align="left"] { margin-right: auto; margin-left: 0; }
figure.nw-fig img { display: block; max-width: 100%; height: auto; border-radius: var(--r-md); }
figure.nw-fig figcaption { font-size: 11.5px; color: var(--color-text-muted); text-align: center; padding: 4px 2px 0; }
.nw-fig-grip { position: absolute; right: -5px; top: 50%; width: 9px; height: 40px; margin-top: -20px; border-radius: 5px; background: var(--color-accent); opacity: 0; cursor: ew-resize; touch-action: none; transition: opacity .12s; }
.ProseMirror figure.nw-fig:hover .nw-fig-grip, .ProseMirror figure.nw-fig.ProseMirror-selectednode .nw-fig-grip { opacity: .85; }
.ProseMirror figure.nw-fig.ProseMirror-selectednode { outline: 2px solid color-mix(in srgb, var(--color-accent) 55%, transparent); outline-offset: 2px; border-radius: var(--r-md); }
.nw-bookmark { display: flex; align-items: stretch; margin: .5em 0; border: 1px solid var(--color-border-default); border-radius: var(--r-lg); overflow: hidden; text-decoration: none; color: inherit; background: var(--color-bg-card); position: relative; }
a.nw-bookmark:hover { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); text-decoration: none; }
.nw-bm-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; }
.nw-bm-title { font-weight: 600; font-size: 13px; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-bm-desc { font-size: 12px; color: var(--color-text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nw-bm-site { font-size: 11px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-bm-img { flex: 0 0 160px; background-size: cover; background-position: center; min-height: 84px; }
.nw-bm-open { position: absolute; right: 6px; top: 4px; font-size: 12px; color: var(--color-text-muted); text-decoration: none; }
.nw-bm-open:hover { color: var(--color-accent); }
.ProseMirror .nw-bookmark.ProseMirror-selectednode { outline: 2px solid color-mix(in srgb, var(--color-accent) 55%, transparent); }
.nw-embed { position: relative; margin: .6em 0; aspect-ratio: 16 / 9; max-width: 720px; border-radius: var(--r-lg); overflow: hidden; background: #000; }
.nw-embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.ProseMirror .nw-embed-shield { position: absolute; inset: 0; }
.ProseMirror .nw-embed.ProseMirror-selectednode { outline: 2px solid var(--color-accent); }
.ProseMirror .nw-embed.ProseMirror-selectednode .nw-embed-shield { display: none; }
.nw-slash-menu { position: fixed; z-index: 100000; min-width: 230px; max-height: 320px; overflow: auto; padding: 6px; background: var(--color-bg-modal); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: var(--shadow-dropdown); font-size: 12.5px; }
.nw-slash-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--r-md); cursor: pointer; color: var(--color-text-primary); }
.nw-slash-item.on { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.nw-slash-ic { width: 24px; text-align: center; font-size: 11px; color: var(--color-text-muted); font-weight: 700; flex: 0 0 auto; }
.nw-slash-empty { padding: 6px 10px; color: var(--color-text-muted); font-size: 12px; }
.nw-popmenu-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 10px 6px; }
.nw-popmenu-gap { width: 8px; }
.nw-ico-swatch { width: 28px; height: 28px; border-radius: var(--r-md); border: 1px solid transparent; background: transparent; font-size: 16px; cursor: pointer; }
.nw-ico-swatch:hover, .nw-ico-swatch.on { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nw-turn-btn { min-width: 30px; height: 26px; padding: 0 6px; border-radius: var(--r-md); border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); font-size: 11px; font-weight: 700; cursor: pointer; }
.nw-turn-btn:hover, .nw-turn-btn.on { border-color: var(--color-accent); color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nw-block-menu, .nw-callout-menu { max-width: 340px; }
.pm-block-handle { cursor: grab; }
/* An empty toggle title shows a hint instead of a blank line */
.tiptap-editor-content .ProseMirror div[data-type="details"] summary:has(> br:only-child)::before { content: 'Toggle title'; color: var(--color-text-muted); pointer-events: none; }
/* ── Toggle headings (title styled as H1–H4) ── */
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading] { align-items: flex-start; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading] > button { margin-top: 7px; align-self: flex-start; }
/* the chevron stays on the title line: its box matches the title's line height */
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="1"] > button { height: 2.08em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="2"] > button { height: 1.76em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="3"] > button { height: 1.57em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="4"] > button { height: 1.6em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="1"] > div > summary, .note-content details[data-heading="1"] > summary, .about-content details[data-heading="1"] > summary { font-size: 1.6em; font-weight: 700; color: var(--color-text-bright); line-height: 1.3; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="2"] > div > summary, .note-content details[data-heading="2"] > summary, .about-content details[data-heading="2"] > summary { font-size: 1.3em; font-weight: 600; color: var(--color-text-bright); line-height: 1.35; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="3"] > div > summary, .note-content details[data-heading="3"] > summary, .about-content details[data-heading="3"] > summary { font-size: 1.12em; font-weight: 600; color: var(--color-text-bright); line-height: 1.4; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="4"] > div > summary, .note-content details[data-heading="4"] > summary, .about-content details[data-heading="4"] > summary { font-size: 1em; font-weight: 700; color: var(--color-text-bright); }
.tiptap-editor-content .ProseMirror h4 { font-size: 1em; font-weight: 700; margin: 0.55em 0 0.2em; color: var(--color-text-bright); }
/* ── Block handle menu: roomier controls ── */
.nw-block-menu { min-width: 300px; max-width: 360px; }
/* same button sizes as the rest of the site; only the glyphs inside are larger */
.nw-block-menu .nw-turn-btn, .nw-details-menu .nw-turn-btn { font-size: 13px; }
.nw-block-menu .nw-popmenu-ic { font-size: 17px; width: 24px; text-align: center; line-height: 1; }
.nw-block-menu .nw-ico-swatch, .nw-callout-menu .nw-ico-swatch { font-size: 18px; }
/* ── Masonry (JS-placed columns replace CSS multi-column once laid out) ── */
.tk-cards.tk-masonry { column-width: auto; column-count: auto; display: flex; align-items: flex-start; gap: 8px; }
.tk-cards.tk-masonry > .tk-cards-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tk-cards.tk-masonry .tk-card { display: block; width: auto; margin: 0; break-inside: auto; }
/* ── Date mention chips (@today …); Notion-exported <time>@…</time> gets the same look until it is re-saved as a chip ── */
time.nw-date, .note-content time, .about-content time, .note-card-content time, .tk-card-body time, .nw-db-card-fval time, .nw-db-cell time { display: inline-block; padding: 0 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-text-primary); font-size: .92em; line-height: 1.5; white-space: nowrap; }
.ProseMirror time.nw-date { cursor: pointer; }
.ProseMirror time.nw-date:hover { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.ProseMirror time.nw-date.ProseMirror-selectednode { outline: 2px solid color-mix(in srgb, var(--color-accent) 55%, transparent); }

/* ── Header overflow menu (⋯): right-hand controls of section headers, note titlebars, task toolbars ── */
.hdr-more { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.hdr-more-btn { line-height: 1; letter-spacing: 1px; }
.hdr-more > .hdr-more-panel { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 700; min-width: 220px; max-width: min(360px, 92vw); max-height: 70vh; overflow: auto; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; background: var(--color-bg-modal); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: var(--shadow-dropdown); cursor: default; text-transform: none; letter-spacing: normal; font-weight: 400; font-size: 12.5px; }
.hdr-more.open > .hdr-more-panel { display: flex; }
.hdr-more > .hdr-more-panel > * { flex: 0 0 auto; width: 100%; box-sizing: border-box; }
.hdr-more > .hdr-more-panel > .btn, .hdr-more > .hdr-more-panel > .nw-btn, .hdr-more > .hdr-more-panel > button { justify-content: flex-start; text-align: left; display: inline-flex; align-items: center; gap: 8px; }
.hdr-more > .hdr-more-panel > select { width: 100%; }
.hdr-more > .hdr-more-panel .notes-filter-panel { right: auto; left: 0; }
h2.collapsible-header .section-header-buttons.hdr-more { flex-wrap: nowrap; }
body.is-phone h2.collapsible-header .section-header-buttons.hdr-more { flex: 0 0 auto; overflow: visible; justify-content: flex-end; }
.nw-titlebar-btns.hdr-more { gap: 4px; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel { cursor: default; }
.tk-toolbar .tk-more { margin-left: auto; }
.tk-toolbar .tk-more > .hdr-more-panel { min-width: 240px; }
.tk-switcher .nw-db-vtools.hdr-more { margin-left: auto; }
/* Tasks pane scope: this note | all tasks */
.tk-scope-toggle { display: inline-flex; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); overflow: hidden; margin-left: 6px; }
.tk-scope-toggle button { border: none; background: transparent; color: var(--color-text-secondary); font-size: 10.5px; padding: 2px 8px; cursor: pointer; }
.tk-scope-toggle button.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent); font-weight: 600; }
.hdr-more-label { font-size: 12.5px; font-weight: 400; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-more > .hdr-more-panel > button.active .hdr-more-label, .hdr-more > .hdr-more-panel > button.on .hdr-more-label { color: inherit; }
.tk-new-btn { white-space: nowrap; }

/* ── 2026-10-26: tag / filter scope marks ─────────────────────────────────── */
.tk-rail-scopeic { font-size: 10px; opacity: .6; margin-left: 2px; }
.tk-tagdlg select, .tkf-ve-body #tkf-ve-scope { max-width: 100%; }

/* ── 2026-10-26: card layouts (list rows and table) ──────────────────────── */
.tk-layout.theme-toggle-group { display: inline-flex; width: auto; align-self: flex-start; }
.tk-layout .theme-toggle-btn { font-size: 11.5px; padding: 3px 9px; }
.tk-cardlist { display: flex; flex-direction: column; gap: 3px; padding: 2px; }
.tk-crow { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 6px; border-radius: var(--r-md); border: 1px solid var(--color-border-default); background: var(--color-bg-card); cursor: pointer; border-left-width: 4px; border-left-color: var(--color-border-default); min-width: 0; }
.tk-crow-colored { border-left-color: var(--card-c); background: color-mix(in srgb, var(--card-c) 10%, var(--color-bg-card)); }
.tk-crow:hover { background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg-card)); }
.tk-crow.tk-row-open { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 45%, transparent); }
.tk-crow-pinned .tk-card-pin { opacity: 1; }
.tk-crow .tk-card-pin, .tk-crow .tk-card-arch { flex: 0 0 auto; }
.tk-crow:hover .tk-card-pin, .tk-crow:hover .tk-card-arch { opacity: .8; }
.tk-crow-sp { width: 20px; flex: 0 0 auto; }
.tk-crow-main { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.tk-crow-title { font-size: 12.5px; font-weight: 600; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; max-width: 60%; }
.tk-crow-x { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.tk-crow-meta { display: inline-flex; align-items: center; gap: 4px; flex: 0 1 auto; flex-wrap: nowrap; overflow: hidden; }
.tk-crow .tk-card-when { margin-left: 0; }
.tk-wrap-titles .tk-crow-main { flex-wrap: wrap; }
.tk-wrap-titles .tk-crow-title, .tk-wrap-titles .tk-crow-x { white-space: normal; max-width: none; }
.tk-ctbl-wrap { overflow: auto; padding: 2px; }
.tk-ctbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tk-ctbl th { text-align: left; padding: 6px 8px; font-size: 11px; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border-default); white-space: nowrap; }
.tk-ctbl td { padding: 5px 8px; border-bottom: 1px solid var(--color-border-divider, var(--color-border-default)); vertical-align: middle; }
.tk-ctbl-row { cursor: pointer; }
.tk-ctbl-row:hover td { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.tk-ctbl-row.tk-row-open td { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.tk-ctbl-row.tk-card-archived td { opacity: .65; }
.tk-ctbl td.tk-ctbl-title { font-weight: 600; color: var(--color-text-primary); min-width: 160px; }
.tk-ctbl-c { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid color-mix(in srgb, var(--color-text-primary) 15%, transparent); vertical-align: middle; }
.tk-ctbl-x { color: var(--color-text-muted); font-size: 12px; display: inline-block; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tk-ctbl .tk-card-pin, .tk-ctbl .tk-card-arch { opacity: .7; }
.tk-ctbl .tk-card-when { margin-left: 0; }
.tk-ctbl td.tk-ctbl-act { width: 28px; text-align: right; }

/* ── 2026-10-26: files — views strip, tag rail, list layout, tag chips ───── */
.fp-switcher { margin-bottom: 4px; }
.fp-switcher .nw-db-vtools { margin-left: auto; }
.fp-tree-title2 { margin-top: 12px; }
.fp-tree-n { margin-left: auto; font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; padding-left: 6px; }
.fp-tag { display: inline-block; font-size: 10.5px; line-height: 1.5; padding: 0 7px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 10%, transparent); color: var(--color-text-secondary); cursor: pointer; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.fp-tag:hover { background: color-mix(in srgb, var(--color-accent) 20%, transparent); color: var(--color-text-primary); }
.fp-tag.on { background: color-mix(in srgb, var(--color-accent) 24%, transparent); color: var(--color-accent); font-weight: 600; }
.fp-tag-active { margin-left: 6px; }
.fp-card-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.fp-lrow-tags, .fp-tagwrap { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.fp-list { display: flex; flex-direction: column; gap: 2px; }
.fp-lrow { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: var(--r-md); cursor: pointer; min-width: 0; }
.fp-lrow:hover { background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.fp-lrow-ic { flex: 0 0 auto; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.fp-lrow-ic img { width: 28px; height: 28px; object-fit: cover; border-radius: var(--r-sm); }
.fp-lrow-name { flex: 1 1 auto; min-width: 0; font-size: 12.5px; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: baseline; gap: 8px; }
.fp-lrow-name .fp-row-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-lrow-tags { flex: 0 1 auto; max-width: 30%; overflow: hidden; }
.fp-lrow-meta { flex: 0 0 auto; font-size: 11px; color: var(--color-text-muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.fp-lrow .fp-card-more { position: static; opacity: 0; }
.fp-lrow:hover .fp-card-more { opacity: 1; }
.fp-lrow-folder .fp-lrow-name { font-weight: 600; }
.fp-table th.fp-col-tags, .fp-table td.fp-col-tags { max-width: 220px; }
@media (max-width: 720px) { .fp-lrow-meta { display: none; } .fp-lrow-tags { display: none; } .tk-crow-x { display: none; } }

/* ── 2026-10-26: task tag manager ──────────────────────────────────────── */
.tk-tagmgr { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tk-tagmgr th { text-align: left; font-size: 11px; color: var(--color-text-muted); padding: 4px 6px; border-bottom: 1px solid var(--color-border-default); }
.tk-tagmgr td { padding: 4px 6px; border-bottom: 1px solid var(--color-border-divider, var(--color-border-default)); vertical-align: middle; white-space: nowrap; }
.tk-tagmgr td:nth-child(2) { width: 38%; }
.tk-tagmgr-name { width: 100%; font-size: 12.5px; padding: 3px 6px; }
.tk-tagmgr-scope { max-width: 240px; font-size: 12px; padding: 3px 6px; }
.tk-tagmgr-n { text-align: right; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.tk-tagmgr-body { max-height: 60vh; overflow: auto; }
.tk-tagpop-foot { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.tk-tagpop-foot .tk-tagpop-new { margin: 0; }
.tag-mgr-task { padding-top: 8px; }
.tag-mgr-task-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.tag-mgr-task .tk-tagmgr-body { max-height: 50vh; }

/* ── 2026-10-26: note lookup, scope buttons, file tag picker, note Files pane views ── */
.tk-scope-row { display: flex; align-items: center; gap: 8px; }
.tk-scope-row > span:first-child { font-size: 12px; color: var(--color-text-secondary); min-width: 56px; }
.tk-scope-btn { border: 1px solid var(--color-border-default); background: var(--color-bg-card); color: var(--color-text-primary); border-radius: var(--r-md); padding: 4px 10px; font-size: 12px; cursor: pointer; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-scope-btn:hover { border-color: var(--color-accent); }
.tk-tagmgr .tk-scope-btn { width: 100%; max-width: 240px; }
.note-pick { position: fixed; z-index: 1200002; width: 300px; max-width: calc(100vw - 16px); background: var(--color-bg-card); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.note-pick-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.note-pick-q { width: 100%; box-sizing: border-box; font-size: 12.5px; padding: 5px 8px; }
.note-pick-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; }
.note-pick-h { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); padding: 6px 6px 2px; }
.note-pick-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--r-md); cursor: pointer; font-size: 12.5px; color: var(--color-text-primary); }
.note-pick-row:hover { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.note-pick-row[hidden], .note-pick-h[hidden], .note-pick-none[hidden] { display: none; }
.note-pick-none { font-size: 12px; color: var(--color-text-muted); padding: 6px; }
.note-pick-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--color-border-divider, var(--color-border-default)); padding-top: 6px; }
.note-pick-n { font-size: 11.5px; color: var(--color-text-muted); }
.tk-filetagpop { width: 300px; }
.tk-filetagpop .tk-notepop-list { max-height: 300px; overflow: auto; }
.tk-filetagpop .tk-tagpop-row[hidden] { display: none; }
.tk-filetag-create { align-self: flex-start; }
.nw-fp-views { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nw-fp-views .nw-db-vtabs { flex: 1 1 auto; min-width: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.nw-fp-lay.theme-toggle-group { display: inline-flex; width: auto; }
.nw-fp-lay .theme-toggle-btn { padding: 2px 7px; }
.nw-fp-filt { display: flex; gap: 4px; flex-wrap: wrap; }
.nw-fp-body .fp-list, .nw-fp-body .fp-table { font-size: 12px; }

/* ── 2026-10-26: one look for the Tasks / Cards / Files panes — the view band carries tabs, layout toggle, ⚙ and ⋯ ── */
.nw-db-switcher .nw-db-vtools.fp-vtools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.tk-layout-band.theme-toggle-group, .fp-lay-band.theme-toggle-group, .nw-fp-lay.theme-toggle-group { display: inline-flex; width: auto; flex: 0 0 auto; }
.tk-layout-band .theme-toggle-btn, .fp-lay-band .theme-toggle-btn, .nw-fp-lay .theme-toggle-btn { padding: 2px 8px; }
.tk-switcher .tk-layout-band { margin-left: auto; }
.tk-switcher .tk-layout-band + .nw-db-vtools.hdr-more { margin-left: 0; }
.nw-fp-views.nw-db-switcher { gap: 6px; }
.fp-tag-add { background: transparent; border: 1px dashed var(--color-border-default); color: var(--color-text-muted); }
.fp-tag-add:hover { border-color: var(--color-accent); color: var(--color-accent); background: transparent; }
.fp-table td.fp-col-tags { white-space: normal; min-width: 90px; }
.tk-switcher .tk-fields-band { flex: 0 0 auto; }

/* ── 2026-10-26: rails — pinned rails stay in view (sticky, own scroll), resize everywhere, wider drawer, scope icons; Files rail; task table ── */
.tk-wrap:not(.tk-norail) > .tk-rail { position: sticky; top: 4px; max-height: calc(var(--tk-sticky-h, 100vh) - 8px); overflow-y: auto; overscroll-behavior: contain; flex-shrink: 0; scrollbar-width: thin; box-sizing: border-box; }
.nw-tk-body .tk-wrap:not(.tk-norail) > .tk-rail { top: 0; max-height: calc(var(--tk-sticky-h, 100%) - 16px); }
.nw-tk-body .tk-rail { flex-basis: var(--tk-rail-w, 220px); }
.tk-wrap.tk-norail .tk-rail.tk-rail-drawer { width: max(260px, var(--tk-rail-w, 240px)); max-height: min(calc(var(--tk-sticky-h, 80vh) - 12px), 640px); }
.tk-rail-item { min-width: 0; }
.tk-rail-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-rail-item .tk-rail-scopeic { margin-left: auto; flex: 0 0 auto; font-size: 10px; opacity: .6; }
.tk-rail-item .tk-rail-scopeic + .tk-rail-n { margin-left: 4px; }
.tk-rail-n { min-width: 14px; text-align: right; flex: 0 0 auto; }
.tk-rail-edit { flex: 0 0 auto; }
.fp-rail .fp-tree-item { font-size: 12.5px; }
.fp-rail .fp-tree-foot { margin-top: 10px; padding: 0 8px; }
.fp-wrap.tk-wrap { gap: 6px; }
.fp-nwrap { min-height: 0; }
.fp-nmain { gap: 6px; }
.nw-fp-views .tk-rail-toggle { margin-right: 4px; }
.tk-group-collapsed > .tk-ctbl-wrap { display: none; }
.tk-ttbl .tk-ttbl-chk { width: 24px; text-align: center; }
.tk-ttbl-row.tk-done .tk-ctbl-title { text-decoration: line-through; opacity: .6; }
.tk-ttbl-row.tk-row-selected { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.tk-group .tk-ctbl-wrap { margin: 2px 0 8px; }
.tkf-for { display: inline-flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tkf-for label { display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; }
.tkf-for-fixed { font-size: 12.5px; }
.tk-ve-days { display: inline-flex; gap: 5px; align-items: center; }
.tk-ve-days input { width: 70px; }
@media (max-width: 767px) { .tk-wrap:not(.tk-norail) > .tk-rail { position: static; max-height: none; overflow: visible; } }

/* ── 2026-10-26: view editor columns — each column its own card, labelled properties ── */
.nw-db-ve-list, .nw-db-ve-cols { gap: 10px; }
.nw-db-ve-entry { background: var(--color-bg-card, var(--color-bg-primary)); border: 1px solid var(--color-border-default); border-left: 3px solid color-mix(in srgb, var(--color-accent) 55%, var(--color-border-default)); border-radius: var(--r-lg); padding: 8px 10px 10px; gap: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.nw-db-ve-entry:hover { border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); }
.nw-db-ve-entry-main .nw-db-ve-colname { font-size: 13px; }
.nw-db-ve-entry-fmt { padding: 8px 0 0 20px; border-top: 1px dashed var(--color-border-default); gap: 8px 12px; align-items: flex-end; }
.nw-db-ve-prop { display: inline-flex; flex-direction: column; gap: 3px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.nw-db-ve-prop > input, .nw-db-ve-prop > select { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; color: var(--color-text-primary); }

/* Sections holding a rail clip with overflow: clip (not hidden) so the pinned rail can stick while the page scrolls. */
section:has(.tk-wrap), .section:has(.tk-wrap), .collapsible-section:has(.tk-wrap) { overflow: clip; }

.tk-wrap:not(.tk-norail) > .tk-rail { top: var(--tk-sticky-top, 4px); max-height: calc(var(--tk-sticky-h, 100vh) - var(--tk-sticky-top, 4px) - 6px); }
.nw-tk-body .tk-wrap:not(.tk-norail) > .tk-rail { top: 0; max-height: calc(var(--tk-sticky-h, 100%) - 16px); }

/* Task table: fixed column widths so every group's table lines up */
.tk-ttbl { table-layout: fixed; width: 100%; }
.tk-ttbl .tk-ttbl-chk { width: 30px; }
.tk-ttbl th.tk-ctbl-priority { width: 72px; } .tk-ttbl th.tk-ctbl-due { width: 150px; } .tk-ttbl th.tk-ctbl-tags { width: 170px; }
.tk-ttbl th.tk-ctbl-assignees { width: 120px; } .tk-ttbl th.tk-ctbl-note { width: 170px; } .tk-ttbl th.tk-ctbl-repeat { width: 64px; } .tk-ttbl th.tk-ctbl-modified { width: 100px; }
.tk-ttbl td { overflow: hidden; text-overflow: ellipsis; }
.tk-ttbl td.tk-ctbl-title { white-space: normal; }

/* View columns set to "stays on one line" / "cut short with …": rich text and chip lists flatten to one line too
   (paragraphs joined with ·, no inner scroll box). ⤢ on the row still expands everything. */
.nw-db-td-oneline .nw-db-richtext { max-height: none; overflow: hidden; white-space: nowrap; padding-right: 0; }
.nw-db-td-oneline .nw-db-richtext * { display: inline !important; white-space: nowrap !important; margin: 0 !important; padding: 0 !important; }
.nw-db-td-oneline .nw-db-richtext br { display: none !important; }
.nw-db-td-oneline .nw-db-richtext > * + *::before { content: " · "; opacity: .55; }
.nw-db-td-oneline .nw-db-richtext img { max-height: 1.2em; vertical-align: middle; }
.nw-db-td-oneline .nw-db-chips { flex-wrap: nowrap; white-space: nowrap; }
.nw-db-td-cut .nw-db-richtext, .nw-db-td-cut .nw-db-chips { overflow: hidden; text-overflow: ellipsis; display: block; }
tr.nw-db-row-expanded td.nw-db-td-oneline { white-space: normal !important; max-width: none !important; overflow: visible !important; }
tr.nw-db-row-expanded td.nw-db-td-oneline .nw-db-richtext { white-space: normal; overflow: visible; }
tr.nw-db-row-expanded td.nw-db-td-oneline .nw-db-richtext * { display: revert !important; white-space: normal !important; margin: revert !important; padding: revert !important; }
tr.nw-db-row-expanded td.nw-db-td-oneline .nw-db-richtext br { display: revert !important; }
tr.nw-db-row-expanded td.nw-db-td-oneline .nw-db-richtext > * + *::before { content: none; }
tr.nw-db-row-expanded td.nw-db-td-oneline .nw-db-chips { flex-wrap: wrap; white-space: normal; }

/* ── 2026-10-27: collapsible note panes (chevron in each pane's header; .nw-pane-collapsed keeps only the header) ── */
.nw-pane-chev { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; padding: 2px; margin: 0 2px 0 0; cursor: pointer; border-radius: var(--r-sm); flex: 0 0 auto; }
.nw-pane-chev:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nw-pane-title { cursor: pointer; user-select: none; }
.nw-db-tabs > .nw-pane-chev, .notes-graph-toolbar > .nw-pane-chev, .nw-ch-bar > .nw-pane-chev { align-self: center; }
.nw-ed-bar { flex: 0 0 auto; }
.nw-ed-bar[hidden] { display: none !important; }
.note-window .nw-pane-collapsed > :not(.nw-pane-head) { display: none !important; }
/* Stacked panes give their space away; side-by-side ones keep their width and just show the header. */
.note-window .nw-ed-db-split:not(.db-split-vertical) > .nw-pane-collapsed.nw-pane-collapsed,
.note-window .nw-split-container.split-horizontal > .nw-pane-collapsed.nw-pane-collapsed,
.note-window .nw-side-col > .nw-pane-collapsed.nw-pane-collapsed,
body.is-phone .phone-full:not(.nw-dbonly) .nw-pane-collapsed.nw-pane-collapsed.nw-pane-collapsed { flex: 0 0 auto !important; min-height: 0 !important; height: auto !important; }
/* A divider next to a collapsed pane has nothing to resize. */

body.is-phone .phone-full:not(.nw-dbonly) > .nw-body > .nw-split-container.nw-any-collapsed { min-height: 0; }
body.is-phone .nw-pane-chev svg { width: 18px; height: 18px; }
body.is-phone .nw-pane-chev { padding: 6px; }
/* Properties use the same chevron (right when closed, down when open). */
.nw-props-summary::before {
    content: ""; width: 14px; height: 14px; flex: 0 0 14px; font-size: 0; background: var(--color-status-info);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
    transition: transform .15s ease;
}
details[open] > .nw-props-summary::before { content: ""; transform: rotate(90deg); }

/* Phone: Tasks, Cards and Files are documents too (natural height, no inner scroll), so the page scrolls past
   them to the next pane — an 80dvh frame that scrolled by itself trapped the thumb inside Tasks. */

/* Collapsed database: one title instead of the tab strip. */
.nw-db-coltitle { display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap; margin-right: 4px; }   /* always shown (2026-11-01) */
.note-window .nw-db-pane.nw-pane-collapsed > .nw-db-tabs > :not(.nw-pane-chev):not(.nw-db-coltitle) { display: none !important; }
.note-window .nw-db-pane.nw-pane-collapsed > .nw-db-tabs { justify-content: flex-start; }

/* Linked sections collapse like the other panes: just the header (no chip strip). */
.nw-links-sec.nw-links-collapsed { display: block; padding-right: 0; }
.nw-links-collapsed .nw-links-head { padding: 1px 10px 3px; }
.nw-links-collapsed .nw-links-spacer { display: block; }
.nw-links-sec.nw-links-collapsed > .nw-links-body { display: none !important; }
.nw-linked-label.nw-pane-title { cursor: pointer; user-select: none; }

/* Properties header matches the pane headers (Note, Tasks, Cards…): same chevron box and the same title type. */
.nw-props-summary { padding: 4px 8px; gap: 6px; min-height: 27px; box-sizing: border-box; }
.nw-props-summary::before { box-sizing: content-box; width: 14px; height: 14px; flex: 0 0 auto; padding: 2px; margin-right: 2px; -webkit-mask-size: 14px 14px; mask-size: 14px 14px; }
.nw-props-summary-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--color-text-secondary); }
/* The Databases section's panel (and database-only windows): collapsed, it is just its header. */
.note-window.nw-dbonly .nw-db-pane.nw-pane-collapsed { flex: 0 0 auto !important; min-height: 0 !important; }

/* The Databases section's panel shrinks to its header while its database is collapsed (its 72vh box is for the rows). */
.note-window.nw-inline.nw-dbonly:has(.nw-db-pane.nw-pane-collapsed) { height: auto !important; min-height: 0 !important; resize: none; }
.note-window.nw-inline.nw-dbonly:has(.nw-db-pane.nw-pane-collapsed) > .nw-body { flex: 0 0 auto; }
.note-window.nw-inline.nw-dbonly:has(.nw-db-pane.nw-pane-collapsed) .nw-split-container { flex: 0 0 auto; height: auto; }

/* Properties: a real pane chevron (so the phone's larger chevron applies too) instead of the drawn one. */
.nw-props-summary::before { content: none !important; display: none !important; }
details.nw-props[open] > .nw-props-summary .nw-props-chev .chev { transform: rotate(90deg); }
.nw-props-summary .nw-props-chev { pointer-events: none; }

/* ── Collapsed panes show only the chevron and the title (no scope toggles, ↗, ✕, crumbs, modes or + buttons) ── */
.note-window .nw-pane-collapsed > .nw-pane-head > :not(.nw-pane-chev):not(.nw-tk-title):not(.nw-db-coltitle):not(.nw-pane-coltitle) { display: none !important; }
.nw-pane-coltitle { display: none; }
.note-window .nw-pane-collapsed > .nw-pane-head > .nw-pane-coltitle { display: inline-flex; align-items: center; }
.note-window .nw-pane-collapsed > .nw-pane-head { flex-wrap: nowrap; }
.nw-links-sec.nw-links-collapsed .nw-links-head > :not(.nw-links-toggle):not(.nw-linked-label):not(.nw-links-count) { display: none !important; }
/* Linked headers look like the pane headers */
.nw-links-head { padding: 4px 8px; gap: 6px; min-height: 27px; box-sizing: border-box; }
.nw-links-collapsed .nw-links-head { padding: 4px 8px; }
.nw-links-head > .nw-links-toggle.nw-pane-chev { color: var(--color-status-info); padding: 2px; margin: 0 2px 0 0; }
body.is-phone .nw-links-head > .nw-links-toggle.nw-pane-chev { padding: 6px; }
.nw-linked-label.nw-tk-title { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--color-text-secondary); }
/* A note's database dropdown, named after the active database */
.nw-db-picker-btn { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.nw-db-picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; font-weight: 600; }
body.is-phone .nw-db-picker-name { max-width: 170px; }

/* ── 2026-10-27: skip this occurrence (repeating tasks) ── */
.tk-d-head .tk-d-skip { flex: 0 0 auto; white-space: nowrap; align-self: center; }
.tk-detail-body .tk-d-head .tk-d-title { min-width: 0; }
.tk-h-skip, .tk-h-skipped { color: var(--color-status-warning, #c98a1a); }

/* ── 2026-10-27: Linked / Linked From live in the editor pane (under the note + databases, not across the side column) ── */
.nw-editor-pane > .nw-links-dock { flex: 0 1 auto; min-height: 0; }
.nw-editor-pane > .nw-ed-db-split { flex: 1 1 0; }

/* ── 2026-10-27: a narrow desktop note window (e.g. the Notes preview) is ONE column ─────────────────────────────
   Below 760px the panes stop sitting side by side: the note + databases (+ Linked) on top, then the side column
   (Tasks / Cards / Files), AI channels and graph below — each sharing the window height (it still fits the window;
   collapse a pane to give its space away). Note and database stack too. Width dividers go; widths come back
   when the window is wide again. Phones have their own one-page layout. */

/* ── 2026-10-27: view tabs that do not fit on one line become one dropdown (_vtFit) ── */
.nw-db-vtab-dd { display: none; }
.nw-db-switcher.vt-compact > .nw-db-vtabs > .nw-db-vtab { display: none !important; }
.nw-db-switcher.vt-compact > .nw-db-vtabs > .nw-db-vtab-dd { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; white-space: nowrap; }
.nw-db-switcher.vt-compact > .nw-db-vtabs { flex-wrap: nowrap; }
.nw-db-vtab-dd .nw-db-picker-name { min-width: 0; }

/* ── 2026-10-27: database description capped (2 lines) and about text capped (4 lines) with more ▾ / less ▴ ── */
.nw-db-info-sum { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; min-width: 0; }
.nw-db-info-body:not(.more) { max-height: calc(1.55em * 4 + 12px); overflow: hidden; }
.nw-db-info-body.clamped { -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.nw-db-info-more { display: block; margin: -4px 0 6px 28px; padding: 1px 8px; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-accent); font-size: 11px; font-weight: 600; cursor: pointer; }
.nw-db-info-more:hover { border-color: var(--color-accent); }
.nw-db-info-more[hidden] { display: none; }
body.is-phone .nw-db-info > summary .nw-db-info-sum { display: inline; }

/* ── 2026-10-27: linked notes under each note in the Notes list (mini list · pill) ── */
.nl-dir { color: var(--color-accent); font-weight: 700; font-size: 11px; }
.nl-arch { width: 11px; height: 11px; flex: 0 0 auto; opacity: .8; }
.nl-pill { flex: 0 0 auto; padding: 1px 8px; border: 1px solid color-mix(in srgb, var(--color-accent) 40%, var(--color-border-default)); border-radius: var(--r-pill); background: transparent; color: var(--color-accent); font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.nl-pill:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nl-menu .nl-menu-h { display: flex; justify-content: space-between; gap: 10px; padding: 2px 10px 6px; font-size: 11px; font-weight: 600; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border-default); margin-bottom: 2px; }
.nl-menu .nl-menu-h span { font-weight: 400; }
.nl-menu .nl-mi .nl-dir { width: 12px; text-align: center; flex: 0 0 auto; }
.nl-menu .nl-mi .nw-popmenu-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-menu .nl-mi.archived { color: var(--color-text-muted); font-style: italic; }
.nl-mi-open { flex: 0 0 auto; border: 0; background: transparent; color: var(--color-text-muted); cursor: pointer; padding: 0 4px; border-radius: var(--r-sm); font-size: 12px; opacity: 0; }
.nl-mi:hover .nl-mi-open, body.is-phone .nl-mi-open { opacity: 1; }
.nl-mi-open:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nl-list { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; padding-top: 5px; border-top: 1px solid color-mix(in srgb, var(--color-border-default) 70%, transparent); min-width: 0; cursor: default; }
.note-card .nl-list { margin-top: -4px; }
.nl-head { display: flex; align-items: center; gap: 5px; padding: 0 4px 2px; font-size: 10.5px; font-weight: 600; color: var(--color-text-muted); }
.nl-head[role="button"] { cursor: pointer; }
.nl-head[role="button"]:hover { color: var(--color-accent); }
.nl-chev { margin-left: auto; }
.nl-row { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: var(--r-sm); font-size: 11.5px; line-height: 18px; color: var(--color-text-primary); cursor: pointer; min-width: 0; }
.nl-row:hover, .nl-row:focus-visible { background: color-mix(in srgb, var(--color-accent) 9%, transparent); outline: none; }
.nl-row-ic { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; min-width: 14px; }
.nl-row-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-row.archived { color: var(--color-text-muted); font-style: italic; }
.nl-row-acts { flex: 0 0 auto; display: inline-flex; gap: 2px; opacity: 0; }
.nl-row:hover .nl-row-acts, .nl-row:focus-within .nl-row-acts, body.is-phone .nl-row-acts { opacity: 1; }
.nl-row-btn { display: inline-flex; align-items: center; border: 0; background: transparent; color: var(--color-text-secondary); padding: 0 4px; border-radius: var(--r-sm); cursor: pointer; font: inherit; font-size: 12px; line-height: 18px; }
.nl-row-btn:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.nl-row-btn svg { width: 13px; height: 13px; }
.nl-more-row { padding-left: 24px; color: var(--color-accent); font-size: 11px; font-weight: 600; }

/* ── 2026-10-27: snippets wear the card styling — diagonal note-colour tint, the note-card shadow, and a tinted header
   band (pin/badges row + title) with a full-width divider, like .note-card-header::before. Sizes are unchanged. ── */
.note-snip {
    background-image: linear-gradient(135deg, color-mix(in srgb, var(--note-color, var(--color-accent)) 14%, transparent) 0%, transparent 70%);
    box-shadow: var(--shadow-note-card); overflow: hidden;
}
.note-snip-head { position: relative; display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; }
.note-snip-head::before {
    content: ''; position: absolute; top: -9px; left: -10px; right: -10px; bottom: 0; pointer-events: none;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--note-color, var(--color-accent)) 12%, transparent) 0%, transparent 100%);
    border-bottom: 1px solid color-mix(in srgb, var(--color-border-default) 60%, transparent);
}
.note-snip-head > * { position: relative; }
.note-snip-title { font-weight: 600; }

/* ── 2026-10-27 Boards phase 1: one-panel views read as a plain list / table / cards / calendar ── */
.tk-matrix-single > .tk-panel-single { border-left: 0; background: transparent; min-height: 0; border-radius: 0; }
.tk-matrix-single > .tk-panel-single > .tk-panel-body { max-height: none; overflow: visible; padding: 0; }
.tk-matrix-single > .tk-panel-single.tk-panel-over { box-shadow: 0 0 0 2px var(--color-accent) inset; }
.tk-ptbl .tk-ttbl-chk:empty { padding: 0; }
.tk-panel-head .tk-panel-flt + .tk-panel-flt { margin-left: -4px; }
.tk-ttbl.tk-ptbl { table-layout: auto; }
.tk-ptbl th { width: auto !important; }
.tk-ptbl td.tk-ctbl-title { min-width: 180px; white-space: normal; }
.tk-ptbl td:not(.tk-ctbl-title) { white-space: nowrap; }
.tk-ptbl td.tk-ctbl-notes .tk-note { max-width: 160px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

/* ── 2026-10-27 Boards phase 2: board panes in the note window, title-row board buttons, Boards ▾, dialogs ── */
.nw-bdbtns { display: contents; }
.nw-side-col > .nw-bd-pane { flex: 1 1 0; min-height: 0; }
.nw-bd-pane .tk-cards { column-width: 180px; }
.nw-bd-title { display: inline-flex; align-items: center; gap: 4px; }
.nw-bd-menu .nw-popmenu-item .bd-origin { margin-left: auto; font-size: 10.5px; color: var(--color-text-muted); }
.bd-choice-text { font-size: 13px; line-height: 1.5; margin: 0; }
.bd-mgr-list { display: flex; flex-direction: column; gap: 4px; }
.bd-mgr-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); font-size: 12.5px; }
.bd-mgr-row.bd-hidden { opacity: .6; }
.bd-mgr-name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-mgr-origin { font-size: 10.5px; color: var(--color-text-muted); white-space: nowrap; }
.bd-mgr-row .nw-se-move button { padding: 0 4px; }
.bd-edit-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; align-items: center; font-size: 12.5px; }
.bd-edit-grid input[type=text] { width: 100%; }
.bd-edit-grid .bd-icon-in { width: 60px; }
.bd-views { display: flex; flex-direction: column; gap: 2px; max-height: 40vh; overflow: auto; border: 1px solid var(--color-border-default); border-radius: var(--r-md); padding: 4px; }
.bd-view-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: var(--r-sm); font-size: 12.5px; }
.bd-view-row:hover { background: color-mix(in srgb, var(--color-accent) 7%, transparent); }
.bd-view-row .bd-view-name { flex: 1 1 auto; min-width: 0; }
.bd-view-row .bd-view-sub { font-size: 10.5px; color: var(--color-text-muted); }
.bd-view-row .nw-se-move button { padding: 0 4px; }
.hdr-more > .hdr-more-panel > .nw-bdbtns > .nw-btn { justify-content: flex-start; text-align: left; display: inline-flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; flex: 0 0 auto; }

/* ── 2026-10-28 Boards phase 3: the pane's scope chip ── */
.tk-scope-chip { margin-left: 6px; padding: 2px 9px; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: transparent; color: var(--color-text-secondary); font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: normal; }
.tk-scope-chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
.tk-scope-chip.tk-scope-own { color: var(--color-accent); border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.nw-bd-menu .bd-scope-note { font-weight: 400; text-transform: none; letter-spacing: normal; opacity: .8; margin-top: 4px; }
.nw-bd-menu .bd-tag-list { max-height: 34vh; overflow: auto; }

/* ── 2026-10-28 Boards phase 4: dashboard boards are sections ── */
.dash-bd-title { display: inline; }
#cards-container .tk-cards, .dash-board-section .tk-cards { column-width: 240px; }

/* ── 2026-10-28: view / panel settings as a floating window; per-panel fields ── */
.tk-float-win { position: fixed; display: flex; flex-direction: column; background: var(--color-bg-modal); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: var(--shadow-dropdown); resize: both; overflow: hidden; min-width: 360px; min-height: 240px; max-width: 100vw; max-height: 100vh; }
.tk-float-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--color-border-default); cursor: move; user-select: none; }
.tk-float-titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tk-float-titles h3 { margin: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-float-sub { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-float-head .btn { cursor: pointer; }
.tk-float-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px; }
.tk-float-foot { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--color-border-default); }
#tk-ve-win .nw-dbe-grid { grid-template-columns: 120px minmax(200px, 1fr); }
#tk-ve-win .nw-dbe-grid > .nw-dbe-lbl { white-space: normal; }
#tk-ve-win .nw-se-fc-dynl, #tk-ve-win .tk-ve-rows label { white-space: normal; align-items: flex-start; line-height: 1.35; }
body.is-phone .tk-float-win { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100dvh !important; border-radius: 0; resize: none; }
.tk-cal-chip .tk-cal-x { display: inline-flex; flex-wrap: wrap; gap: 2px; margin-left: 4px; vertical-align: middle; }
.tk-cal-chip .tk-cal-x > * { font-size: 9.5px; line-height: 1.3; padding: 0 4px; }

/* ── 2026-10-28: Board / View / Panel settings ── */
.tk-panel.tk-wrap-titles .tk-row { flex-wrap: nowrap; align-items: flex-start; }
.tk-panel.tk-wrap-titles .tk-row .tk-title { white-space: normal; overflow: visible; text-overflow: clip; word-break: break-word; flex: 1 1 auto; min-width: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.tk-panel.tk-wrap-titles .tk-row .tk-meta { flex: 0 0 auto; max-width: 70%; flex-wrap: nowrap; justify-content: flex-end; margin-left: auto; }
.tk-ve-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tk-ve-color { width: 30px; height: 24px; padding: 0; border: 1px solid var(--color-border-default); border-radius: var(--r-sm); background: none; cursor: pointer; }
.tk-ve-plist { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.tk-ve-prow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--color-border-default); border-left: 4px solid var(--panel-c); border-radius: var(--r-md); cursor: pointer; background: var(--color-bg-card); }
.tk-ve-prow:hover { border-color: var(--color-accent); border-left-color: var(--panel-c); background: color-mix(in srgb, var(--color-accent) 5%, var(--color-bg-card)); }
.tk-ve-prow .nw-grip { cursor: grab; }
.tk-ve-prow-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tk-ve-prow-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ve-prow-sub { font-size: 11px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ve-prow-go { color: var(--color-text-muted); font-size: 18px; }
.tk-sa-thumb { width: 46px; height: 30px; flex: 0 0 auto; color: var(--color-accent); }
.tk-ve-prow .tk-sa-thumb { width: 38px; height: 24px; opacity: .8; }
.tk-ve-showas-btn { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 6px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); background: var(--color-bg-card); color: var(--color-text-primary); font: inherit; font-size: 12.5px; cursor: pointer; }
.tk-ve-showas-btn:hover { border-color: var(--color-accent); }
.tk-sa-menu .tk-sa-item { gap: 10px; padding: 6px 10px; }
.tk-sa-txt { display: flex; flex-direction: column; line-height: 1.25; }
.tk-sa-txt b { font-weight: 600; } .tk-sa-txt span { font-size: 11px; color: var(--color-text-muted); }
.bd-edit-modal { width: min(460px, 96vw); }
.bd-icon-btn { padding: 3px 10px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); background: var(--color-bg-card); color: var(--color-text-primary); font-size: 15px; cursor: pointer; }
.bd-icon-grid { display: grid; grid-template-columns: repeat(8, 32px); gap: 4px; padding: 4px; }
.bd-icon-pick { width: 32px; height: 32px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font-size: 17px; cursor: pointer; }
.bd-icon-pick:hover, .bd-icon-pick.on { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.bd-vlist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.bd-vrow { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); background: var(--color-bg-card); font-size: 12.5px; }
.bd-vrow .nw-grip { cursor: grab; }
.bd-vrow .bd-view-name { flex: 1 1 auto; min-width: 0; }
.bd-vempty { padding: 4px 0; }
.bd-add-view { margin-right: 8px; }

/* ── 2026-10-28: one settings window (Board › View › Panel): as tall as its content, scrolls when it must ── */
#tk-ve-win { height: auto; min-height: 0; resize: horizontal; }
#tk-ve-win .tk-float-body { flex: 0 1 auto; }
#tk-ve-win .tk-float-head .btn { flex: 0 0 auto; }
.tk-ve-hint { font-size: 11px; color: var(--color-text-muted); }
.tk-ve-prow-ic { width: 20px; text-align: center; flex: 0 0 auto; }
.tk-ve-own { margin: 8px 0 2px; }
body.is-phone #tk-ve-win { height: 100dvh !important; max-height: 100dvh !important; }
#tk-ve-win .tk-ve-own { font-size: 11px; font-weight: 600; color: var(--color-text-muted); }

/* ── 2026-10-28: drag bars between stacked boards; board › view › panel background tints ── */

/* every background keeps only its hue: one light shade (Light) or one deep shade (Dark) for all colours */
:root { --tk-bg-l: 17%; --tk-pbg-l: 21%; --tk-bg-sf: 0.5; }
:root[data-theme="light"] { --tk-bg-l: 95%; --tk-pbg-l: 97.5%; --tk-bg-sf: 1; }
.tk-bg-on { background-color: hsl(from var(--tk-bg) h calc(s * var(--tk-bg-sf)) var(--tk-bg-l)); }
.tk-panel.tk-panel-bg { background-color: hsl(from var(--tk-pbg) h calc(s * var(--tk-bg-sf)) var(--tk-pbg-l)); }
.tk-bgshade { background-color: hsl(from var(--sw) h calc(s * var(--tk-bg-sf)) var(--tk-bg-l)) !important; }
.tk-ve-bg-panel .tk-bgshade { background-color: hsl(from var(--sw) h calc(s * var(--tk-bg-sf)) var(--tk-pbg-l)) !important; }
.tk-ve-bg .ss-swatches { flex-wrap: wrap; }
.tk-ve-bg .ss-swatch { width: 24px; height: 22px; border-radius: var(--r-sm); border: 2px solid hsl(from var(--sw) h s 72%); }
:root:not([data-theme="light"]) .tk-ve-bg .ss-swatch { border-color: hsl(from var(--sw) h s 42%); }
.tk-ve-bg .ss-swatch.ss-swatch-on { outline: 2px solid var(--color-text-primary); outline-offset: 1px; }
.tk-ve-bgprev.tk-bgshade { border-color: hsl(from var(--sw) h s 72%); color: var(--color-text-primary); }
.tk-bgsw-any { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; color: var(--color-text-secondary); }
.tk-bgsw-any > input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.tk-ve-bg { flex-wrap: wrap; gap: 6px; }
.tk-ve-bgprev { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 24px; flex: 0 0 auto; border: 1px solid var(--color-border-default); border-radius: var(--r-sm); font-size: 11px; color: var(--color-text-secondary); background-color: var(--color-bg-primary); }
.tk-ve-bgchip { font: inherit; font-size: 11px; padding: 2px 9px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); cursor: pointer; white-space: nowrap; }
.tk-ve-bgchip:hover { border-color: var(--color-accent); }
.tk-ve-bgchip.on { border-color: var(--color-accent); color: var(--color-accent); font-weight: 600; }

/* ── 2026-10-28: a reminder card is tinted with its task's priority colour (the H / M / L chip's, lighter) ── */
.toast.tk-remcard.tk-remcard-high { --rem-c: var(--color-status-danger); }
.toast.tk-remcard.tk-remcard-medium { --rem-c: var(--color-warning, #d97706); }
.toast.tk-remcard.tk-remcard-low { --rem-c: var(--color-accent); }
.toast.tk-remcard:is(.tk-remcard-high, .tk-remcard-medium, .tk-remcard-low) { background: color-mix(in srgb, var(--rem-c) 9%, var(--color-bg-card)); border-left-color: var(--rem-c); }

/* ── 2026-10-29: highlight, to-do lists, columns, callouts without an icon, Notion import panel ── */
mark { color: inherit; border-radius: 3px; padding: 0 1px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark:not([data-color]) { background: rgba(250, 204, 21, 0.35); }
.nw-hl-swatches .nw-cp-swatch { border: 1px solid var(--color-border-strong, var(--color-border)); }
ul[data-type="taskList"] { list-style: none; padding-left: 4px; }
ul[data-type="taskList"] li { display: flex; align-items: flex-start; gap: 8px; }
ul[data-type="taskList"] li > label { flex: 0 0 auto; margin-top: 2px; user-select: none; }
ul[data-type="taskList"] li > label input { cursor: pointer; accent-color: var(--color-accent); }
ul[data-type="taskList"] li > div { flex: 1 1 auto; min-width: 0; }
ul[data-type="taskList"] li > div > p { margin: 0; }
ul[data-type="taskList"] li[data-checked="true"] > div > p { color: var(--color-text-muted); text-decoration: line-through; }
.nw-cols, div[data-type="columns"] { display: flex; gap: 16px; margin: .5em 0; }
.nw-col, div[data-type="column"] { flex: 1 1 0; min-width: 0; }
.ProseMirror div[data-type="column"] { outline: 1px dashed transparent; border-radius: var(--r-sm); }
.ProseMirror div[data-type="columns"]:hover > div[data-type="column"] { outline-color: var(--color-border); }
@media (max-width: 640px) { .nw-cols, div[data-type="columns"] { flex-direction: column; gap: 4px; } }
.nw-callout-icon { align-self: flex-start; }
.nw-callout.nw-callout-noicon > .nw-callout-icon { display: none; }
.nw-callout.nw-callout-noicon { padding-left: 14px; }
.nw-ico-swatch.nw-ico-none { color: var(--color-text-muted); }
.ni-panel { position: fixed; right: 16px; bottom: 16px; z-index: 100000; width: min(420px, calc(100vw - 32px)); max-height: 50vh; overflow: auto; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--r-lg); box-shadow: 0 8px 28px rgba(0, 0, 0, .25); font-size: 12.5px; }
.ni-panel-head { padding: 8px 12px; font-weight: 700; border-bottom: 1px solid var(--color-border); }
.ni-panel-log { padding: 6px 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.ni-line.ni-ok { color: var(--color-status-success, #16a34a); }
.ni-line.ni-warn { color: var(--color-warning, #d97706); }
.ni-line.ni-err { color: var(--color-status-danger, #dc2626); }

/* ── 2026-10-31: every ⋯ menu item alike — one height, shape and font; an icon slot; on/off items carry a switch ── */
.hdr-more > .hdr-more-panel { overflow-x: hidden; }
.hdr-more > .hdr-more-panel .hdr-item.hdr-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; min-height: 34px; padding: 0 12px; box-sizing: border-box; margin: 0; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-text-primary); font: 500 13px/1 var(--font-ui); text-align: left; justify-content: flex-start; box-shadow: none; opacity: 1; cursor: pointer; text-transform: none; letter-spacing: normal; white-space: nowrap; }
.hdr-more > .hdr-more-panel .hdr-item.hdr-item:hover { background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg-card)); border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border-default)); }
.hdr-more > .hdr-more-panel .hdr-item.hdr-item:is(.active, .on) { background: var(--color-bg-card); border-color: var(--color-border-default); color: var(--color-text-primary); }
.hdr-more > .hdr-more-panel .hdr-item.hdr-item:disabled { opacity: .45; cursor: default; }
.hdr-more > .hdr-more-panel .hdr-item .hdr-ic { flex: 0 0 18px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; color: var(--color-text-secondary); }
.hdr-more > .hdr-more-panel .hdr-item svg.hdr-ic { width: 15px; height: 15px; flex-basis: 18px; padding: 0 1.5px; box-sizing: border-box; }
.hdr-more > .hdr-more-panel .hdr-item .hdr-more-label { font: inherit; color: inherit; overflow: hidden; text-overflow: ellipsis; }
.hdr-more > .hdr-more-panel .hdr-more-sel { cursor: default; padding-right: 6px; }
.hdr-more > .hdr-more-panel .hdr-more-sel > select { flex: 1 1 auto; min-width: 0; height: 30px; border: 0; background: transparent; color: inherit; font: inherit; padding: 0; margin: 0; box-shadow: none; cursor: pointer; outline: none; }
.hdr-more > .hdr-more-panel .hdr-sw { margin-left: auto; flex: 0 0 30px; width: 30px; height: 17px; border-radius: var(--r-pill); background: var(--color-border-strong, #9ca3af); position: relative; transition: background .15s; }
.hdr-more > .hdr-more-panel .hdr-sw::before { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.hdr-more > .hdr-more-panel .hdr-tog:is(.active, .on) > .hdr-sw { background: var(--color-accent); }
.hdr-more > .hdr-more-panel .hdr-tog:is(.active, .on) > .hdr-sw::before { transform: translateX(13px); }
/* Filters opens inside the menu (not as a clipped pop-over) */
.hdr-more > .hdr-more-panel .notes-filter-dropdown { width: 100%; }
.hdr-more > .hdr-more-panel .notes-filter-panel { position: static; width: 100%; box-sizing: border-box; min-width: 0; margin-top: 6px; box-shadow: none; background: var(--color-bg-secondary, var(--color-bg-card)); border-radius: var(--r-lg); }
.hdr-more > .hdr-more-panel .notes-filter-option { white-space: normal; }

/* ── On/off switches instead of checkboxes (selection, completion and pick-list boxes stay checkboxes) ── */
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input) {
    -webkit-appearance: none !important; appearance: none !important; width: 30px !important; height: 17px !important; flex: 0 0 30px; margin: 0; padding: 0; border: none; border-radius: var(--r-pill); background: var(--color-border-strong, #9ca3af); position: relative; cursor: pointer; vertical-align: middle; transition: background .15s; }
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input)::before {
    content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input):checked { background: var(--color-accent); }
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input):checked::before { transform: translateX(13px); }
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input):disabled { opacity: .45; cursor: default; }
input[type="checkbox"]:not(.tk-check, .tk-selbox, .tag-mgr-cb, [name="wlListNameCb"], .nw-db-ms-box, .nw-db-switch > input, .nw-db-td-bool input, ul[data-type="taskList"] input, .note-pick-row input, .tk-np-row input, .tk-tagpop-row input, .tk-notepop-list input, .notes-filter-section input):focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.tk-ve-sw { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; cursor: pointer; }

/* ── Reminder cards: Dismiss in the title row; the stack scrolls; compact on a phone ── */
.tk-remcard-top { display: flex; align-items: flex-start; gap: 10px; }
.tk-remcard-top .tk-remcard-t { flex: 1 1 auto; min-width: 0; }
.tk-remcard-top .tk-rem-dismiss { flex: 0 0 auto; margin-left: auto; }
.tk-remcard-a { gap: 5px; }
.toast-container:has(.tk-remcard) { max-height: calc(100vh - 80px); overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
body.is-phone .toast-container:has(.tk-remcard) { left: 8px; right: 8px; bottom: 8px; max-height: 55vh; max-height: 55dvh; gap: 6px; }
body.is-phone .toast.tk-remcard { width: auto; padding: 9px 11px; gap: 5px; }
body.is-phone .tk-remcard-t { font-size: 13.5px; }
body.is-phone .tk-remcard-b { font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
body.is-phone .tk-remcard-a .btn, body.is-phone .tk-remcard-a .nw-btn { padding: 3px 8px; font-size: 11.5px; }
body.is-phone .tk-remcard-x { max-height: 4.4em; }

/* ── Note cards: text on/off beside the task chip; linked notes carry their own task chip ── */
.note-body-tog { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 18px; padding: 0; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: transparent; color: var(--color-text-muted); cursor: pointer; flex: 0 0 auto; }
.note-body-tog svg { width: 12px; height: 12px; }
.note-body-tog.on { background: color-mix(in srgb, var(--color-accent) 16%, transparent); border-color: color-mix(in srgb, var(--color-accent) 50%, transparent); color: var(--color-accent); }
.note-body-tog:hover { border-color: var(--color-accent); }
.note-card.body-off > .note-card-content { display: none; }
.note-card.body-off > .nl-list { border-top: 0; margin-top: 0; padding-top: 0; }
.nl-row .nl-tk { flex: 0 0 auto; margin-left: auto; font-size: 9.5px; padding: 0 5px; }
.nl-row .nl-tk + .nl-row-acts { margin-left: 4px; }
.tk-badge-today { color: var(--color-warning, #d97706); }

/* ── Note window: Properties at the bottom, under Linked / Linked From ── */
.nw-editor-pane > .nw-props { margin: 6px 0 0; flex: 0 0 auto; }

.hdr-more > .hdr-more-panel .hdr-item.hdr-item:is(.active, .on) { background: var(--color-bg-card) !important; border-color: var(--color-border-default) !important; color: var(--color-text-primary) !important; }
.hdr-more > .hdr-more-panel .hdr-item.hdr-item:is(.active, .on):hover { background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg-card)) !important; }
.hdr-more > .hdr-more-panel .notes-filter-option { display: block; color: var(--color-text-primary); font-size: 12.5px; line-height: 1.5; }
.hdr-more > .hdr-more-panel .notes-filter-option input { margin-right: 8px; }
.nw-editor-pane > .nw-props { margin: 0; border-top: 1px dashed var(--color-border-default); }
.hdr-more > .hdr-more-panel .hdr-item.hdr-sub::after { content: '▾'; margin-left: auto; color: var(--color-text-muted); font-size: 11px; }

/* ── 2026-11-01: one column (narrow note window or preview) — the note and database panes, then the boards, then Linked,
   Linked From and Properties at the very bottom. The editor pane's box steps aside (display: contents) so its parts can be
   ordered among the boards; collapsed note + database panes take only their headers (no gap). ── */

/* 2026-11-01: a note card's header and footer open the note (preview) */
.note-card > .note-card-header, .note-card > .note-card-footer { cursor: pointer; }

/* ── 2026-11-01: note window section headers (Note, Databases, boards, Files, Channels, Graph, Linked, Linked From,
   Properties) share one header band — a faint tint of the text colour over the card, so it reads in Light and Dark —
   and each shows its count. The Linked dock's drag handle hides when its sections are all collapsed. ── */
.note-window { --nw-head-bg: color-mix(in srgb, var(--color-text-primary) 4.5%, var(--color-bg-card)); }
.note-window .nw-pane-head, .note-window .nw-db-tabs.nw-pane-head, .note-window .nw-links-head, .note-window .nw-props > .nw-props-summary { background: var(--nw-head-bg) !important; }
.note-window .nw-props { background: transparent !important; }
.note-window .nw-links-dock { background: transparent; }
.nw-head-n { margin-left: 2px; }

.note-window .nw-pane-collapsed.nw-pane-collapsed > .nw-pane-head.nw-pane-head > .nw-head-n.nw-head-n.nw-links-count { display: inline !important; }   /* the count stays when collapsed */

/* ── 2026-11-01: note window sections ruled alike. Each section (Note, Databases, every board, Files, Channels, Graph,
   Linked, Linked From, Properties) has ONE 1px line under it and none on top, so neighbours never double up; its header
   is 27px tall and draws its own line only while open (separating it from its content). ── */

.note-window .nw-links-dock { border-top: 0 !important; }
.note-window :is(.nw-pane-head, .nw-links-head, .nw-props-summary) { box-sizing: border-box; min-height: 27px; padding-top: 4px !important; padding-bottom: 4px !important; border-top: 0 !important; border-bottom: 1px solid var(--color-border-default) !important; }
.note-window :is(.nw-pane-collapsed > .nw-pane-head, .nw-links-collapsed > .nw-links-head, .nw-props:not([open]) > .nw-props-summary) { border-bottom: 0 !important; }
/* Stacked (one column), the side column's panes lose the left border that divides them from the note side by side. */

/* ── Board views / panels hidden on this note (e.g. "off on new notes"): the "N hidden here ▾" chip ── */
.tk-switcher .tk-hidden-here { border-style: dashed; color: var(--color-text-muted); background: transparent; }
.tk-switcher .tk-hidden-here:hover { color: var(--color-text-primary); border-color: var(--color-accent); }

/* ── Every toast (messages, upload progress, reminders) is one width: the reminder card's ── */
.toast-container > .toast, .toast-container > .toast.fp-progress { width: min(580px, calc(100vw - 32px)); max-width: none; box-sizing: border-box; overflow-wrap: anywhere; }
body.is-phone .toast-container { left: 8px; right: 8px; bottom: 8px; }
body.is-phone .toast-container > .toast { width: auto; }

/* ── 2026-11-02: a board in its own window (↗) fills the window instead of keeping the 420px side-column width ── */
.note-window.nw-taskonly .nw-split-container > .nw-side-col { flex: 1 1 auto !important; width: auto !important; max-width: none !important; }

/* ── 2026-11-02 one look for "a thing with a colour": matrix panels are the model — a flat tint of the colour, a
   4px colour edge on the left, var(--r-lg) corners, no gradient, no drop shadow, tight spacing.
   Note cards (Notes list), linked-note cards (note window) and cards (Cards panels) follow it. ── */
.note-card {
    background-image: none;
    background-color: color-mix(in srgb, var(--note-color, var(--color-accent)) 6%, var(--color-bg-card));
    border: 0; border-left: 4px solid var(--note-color, var(--color-accent));
    box-shadow: none; padding: 10px 12px; gap: 8px;
}
.note-card-header::before { background: none; top: -10px; left: -12px; right: -12px; }
.note-card.minimized .note-card-header::before { background: none; }
.note-snip { background-image: none; box-shadow: none; }
.note-snip-head::before { background: none; }
.notes-tag-section-body { padding: 8px 10px 10px; }
.notes-grid, .notes-body.notes-split .notes-grid { gap: 10px; }
.nw-links-cd { border: 0; border-left: 4px solid var(--note-color, var(--color-accent)); border-radius: var(--r-lg); background: color-mix(in srgb, var(--note-color, var(--color-accent)) 6%, var(--color-bg-card)); }
.nw-links-cd:hover { background: color-mix(in srgb, var(--note-color, var(--color-accent)) 12%, var(--color-bg-card)); }
.tk-card { border-left: 4px solid var(--color-border-strong, #9ca3af); }
.tk-card.tk-card-colored { border-left-color: var(--card-c); }

/* ── 2026-11-03 AI Chat pane: title · chat picker ▾ · + New · Link AI Chat… · ⋯ · ↗ ── */
.nw-ch-bar { align-items: center; }
.nw-ch-tabs { flex: 1 1 auto; align-items: center; flex-wrap: nowrap; }
.nw-ch-bar-tools { display: flex; align-items: center; gap: 4px; }
.nw-ch-picker { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.nw-ch-picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nw-ch-more { position: relative; }
.nw-ch-pane.nw-pane-collapsed .nw-ch-tabs, .nw-ch-pane.nw-pane-collapsed .nw-ch-bar-tools > :not(.nw-ch-pop) { display: none; }
.nw-chat-picker-foot { display: flex; justify-content: flex-end; }
/* AI Chat in its own window: only the chat pane */
.note-window.nw-taskonly.nw-chatonly .nw-ch-pane { display: flex !important; flex: 1 1 auto !important; min-width: 0; }
.note-window.nw-chatonly .nw-side-col, .note-window.nw-chatonly .nw-ch-pop { display: none !important; }

/* ── Movable dialogs (_dlgMovable): drag by the header, resize from the corner; the size doesn't follow the content ── */
.modal-overlay > .modal.dlg-movable { position: fixed; margin: 0; max-width: none; max-height: none; transform: none; resize: both; overflow: hidden; display: flex; flex-direction: column; min-width: 320px; min-height: 220px; }
.modal.dlg-movable > .modal-header { cursor: move; user-select: none; flex: 0 0 auto; }
.modal.dlg-movable > :not(.modal-header):not(.modal-body):not(.modal-footer) { flex: 0 0 auto; }
.modal.dlg-movable > .modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.modal.dlg-movable > .modal-footer { flex: 0 0 auto; }
.modal.dlg-movable.nw-link-picker-modal > .modal-body { display: flex; flex-direction: column; overflow: hidden; }
.modal.dlg-movable .nw-link-picker-results { flex: 1 1 auto; max-height: none; min-height: 0; }
body.is-phone .modal-overlay > .modal.dlg-movable { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; resize: none; border-radius: 0; }
.note-window .nw-ch-bar > .nw-pane-coltitle { display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap; margin-right: 4px; }   /* the AI Chat title shows open or collapsed, like Databases */
/* A board or AI Chat window has no note: the one-column layout (narrow window) must not bring the note area back */

/* ⋯ menu items that open a submenu (▾): the app's chevron (as on section headers), not a small text glyph */
.hdr-more > .hdr-more-panel .hdr-item.hdr-sub::after {
    content: ''; margin-left: auto; flex: 0 0 14px; width: 14px; height: 14px; font-size: 0; background-color: var(--color-text-secondary);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}

/* ── 2026-11-04 Note window panes as cards in columns (_nwLayApply; Docs/NOTE_LAYOUT_DESIGN.md phase 2) ──
   The old split wrappers stay in the DOM, hidden; the panes live in .nwl > .nwl-col. 6 px gaps between cards are the
   resize handles (.nwl-gv between columns, .nwl-gh between panes); ⠿ on a pane's header moves it. */
body .note-window.note-window .nw-split-container.nw-lay2 { flex-direction: row !important; }
body .note-window.note-window .nw-split-container.nw-lay2 > :not(.nwl) { display: none !important; }
.note-window .nwl { --nwl-gap: 6px; flex: 1 1 auto; display: flex; min-width: 0; min-height: 0; padding: var(--nwl-gap); box-sizing: border-box; background: color-mix(in srgb, var(--color-text-primary) 4%, var(--color-bg-card)); }
.note-window .nwl > .nwl-col { flex: var(--nwl-w, 1) 1 0; min-width: 220px; min-height: 0; display: flex; flex-direction: column; }
.note-window .nwl > .nwl-col[hidden] { display: none !important; }
body .note-window .nw-split-container .nwl > .nwl-col > .nwl-p {
    flex: var(--nwl-g, 1) 1 0 !important; min-height: 0 !important; min-width: 0 !important; max-height: none !important; width: auto !important; height: auto !important;
    margin: 0 !important; box-sizing: border-box; border: 1px solid var(--color-border-default) !important; border-radius: var(--r-lg) !important;
    background: var(--color-bg-card); overflow: hidden; display: flex; flex-direction: column; order: 0 !important;
}
body .note-window .nw-split-container .nwl > .nwl-col > .nwl-p[style*="display: none"], body .note-window .nw-split-container .nwl > .nwl-col > .nwl-p[style*="display:none"] { display: none !important; }
body .note-window .nw-split-container .nwl > .nwl-col > .nwl-p:is(.nw-pane-collapsed, .nw-links-collapsed, .nw-props) { flex: 0 0 auto !important; }
body .note-window .nw-split-container .nwl > .nwl-col > .nw-props.nwl-p { display: block; background: var(--color-bg-card); }
.note-window .nwl .nwl-p > :is(.nw-pane-head, .nw-links-head) { background: var(--nw-head-bg); }
.note-window .nwl .nwl-p:is(.nw-pane-collapsed) > .nw-pane-head, .note-window .nwl .nwl-p.nw-links-collapsed > .nw-links-head, .note-window .nwl details.nwl-p:not([open]) > .nw-props-summary { border-bottom: 0 !important; }
.note-window .nwl .nw-links-sec.nwl-p > .nw-links-body { height: auto !important; flex: 1 1 auto; min-height: 0; overflow: auto; }
.note-window .nwl .nwl-p.nw-links-collapsed > .nw-links-body { display: none; }
.note-window .nwl .nw-editor-area.nwl-p { overflow: hidden; }
.note-window .nwl .nw-editor-area.nwl-p > .nw-ed-bar[hidden] + * { border-top: 0; }
/* the gaps: resize handles */
.note-window .nwl .nwl-gv { flex: 0 0 var(--nwl-gap); cursor: col-resize; position: relative; touch-action: none; }
.note-window .nwl .nwl-gh { flex: 0 0 var(--nwl-gap); cursor: row-resize; position: relative; touch-action: none; }
.note-window .nwl :is(.nwl-gv, .nwl-gh)::after { content: ''; position: absolute; border-radius: var(--r-pill); background: transparent; transition: background .12s; }
.note-window .nwl .nwl-gv::after { top: 30%; bottom: 30%; left: 2px; width: 2px; }
.note-window .nwl .nwl-gh::after { left: 30%; right: 30%; top: 2px; height: 2px; }
.note-window .nwl :is(.nwl-gv, .nwl-gh):is(:hover, .on)::after { background: var(--color-accent); }
/* ⠿ grip on every pane header */
.nwl-grip { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 20px; padding: 0; margin: 0 2px 0 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--color-text-muted); font-size: 13px; line-height: 1; cursor: grab; touch-action: none; }
.nwl-grip:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
body.nwl-moving, body.nwl-moving * { cursor: grabbing !important; user-select: none !important; }
.note-window .nwl .nwl-p.nwl-dragging { opacity: .45; }
.nwl-ind { position: fixed; z-index: 1300000; background: var(--color-accent); border-radius: var(--r-pill); pointer-events: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 25%, transparent); }
.note-window .nw-props.nwl-p > .nw-props-summary { display: flex; align-items: center; }
/* One column (narrow window, phone): the column scrolls; each pane keeps a sensible height, the note the tallest */
.note-window .nwl.nwl-flat { overflow-y: auto; overscroll-behavior: contain; display: block; }
.note-window .nwl.nwl-flat > .nwl-col { min-width: 0; gap: var(--nwl-gap); }
body .note-window .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p { flex: 0 0 auto !important; height: min(460px, 70vh) !important; }
body .note-window .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nw-editor-area { height: min(620px, 75vh) !important; }
body .note-window .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p:is(.nw-links-sec) { height: 240px !important; }
body .note-window .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p:is(.nw-pane-collapsed, .nw-links-collapsed, .nw-props) { height: auto !important; }
body.is-phone .note-window .nwl { --nwl-gap: 5px; }
body.is-phone .note-window .nwl .nwl-grip { width: 26px; height: 26px; font-size: 15px; }
body .note-window .nw-split-container .nwl > .nwl-col > .nwl-p { align-items: stretch !important; }
.note-window .nwl .nwl-p :is(.nw-pane-head, .nw-links-head, .nw-props-summary) > .nwl-grip { display: inline-flex !important; }

/* ── 2026-11-04 Notes list in the pane style: tag sections are cards like the note window's panes (1 px border,
   --r-lg corners, a 27 px header band, 6 px gaps and padding), on the same flat tint as the window behind its panes ── */
.notes-body.notes-split > .notes-list-col { background: color-mix(in srgb, var(--color-text-primary) 4%, var(--color-bg-card)); padding: 6px; border-radius: var(--r-lg); box-sizing: border-box; }
.notes-list-col > .notes-tree { margin-bottom: 6px !important; padding: 4px 6px !important; border: 1px solid var(--color-border-default); border-radius: var(--r-lg) !important; background: var(--color-bg-card) !important; }
.notes-list-col #notes-grid:has(> .notes-tag-section) { gap: 6px !important; padding: 0 !important; }
.notes-list-col #notes-grid > .notes-tag-section { border: 1px solid var(--color-border-default) !important; border-radius: var(--r-lg) !important; box-shadow: none !important; background: var(--color-bg-card); }
.notes-list-col #notes-grid > .notes-tag-section > .notes-tag-section-header { min-height: 27px; box-sizing: border-box; padding: 4px 8px !important; gap: 8px !important; font-size: 12.5px !important; border-radius: 0 !important; background: color-mix(in srgb, var(--color-text-primary) 4.5%, var(--color-bg-card)) !important; }
.notes-list-col #notes-grid > .notes-tag-section > .notes-tag-section-header:hover { background: color-mix(in srgb, var(--color-accent) 7%, var(--color-bg-card)) !important; }
.notes-list-col #notes-grid > .notes-tag-section > .notes-tag-section-header::before { width: 7px; height: 7px; box-shadow: none; }
.notes-list-col #notes-grid > .notes-tag-section > .notes-tag-section-body { padding: 6px !important; border-top: 1px solid var(--color-border-default) !important; }
.notes-list-col .notes-tag-section-body .notes-grid { gap: 6px !important; }
.notes-list-col .note-card { padding: 8px 10px; gap: 6px; }
.notes-list-col .note-card-header::before { top: -8px; left: -10px; right: -10px; }
body .note-window.note-window .nw-split-container .nwl .nwl-col > .nwl-p > :is(.nw-pane-head, .nw-links-head, .nw-props-summary) > .nwl-grip { display: inline-flex !important; }

/* ── 2026-11-04 One background (--app-bg): the page, every section's tray and the area behind a note window's panes.
   Named choices (Configuration → Appearance → Background), each with a Light and a Dark value; none = the theme's own. ── */
:root { --app-bg: var(--palette-midnight-900); }
:root[data-theme="light"] { --app-bg: var(--palette-paper-alt); }
:root[data-app-bg="paper"] { --app-bg: #13141c; }   :root[data-theme="light"][data-app-bg="paper"] { --app-bg: #f6f7f9; }
:root[data-app-bg="stone"] { --app-bg: #1c1a17; }   :root[data-theme="light"][data-app-bg="stone"] { --app-bg: #f0eee9; }
:root[data-app-bg="sage"]  { --app-bg: #121b18; }   :root[data-theme="light"][data-app-bg="sage"]  { --app-bg: #e9f0ec; }
:root[data-app-bg="sky"]   { --app-bg: #111a2a; }   :root[data-theme="light"][data-app-bg="sky"]   { --app-bg: #e8eff7; }
:root, :root[data-theme] { --tray-bg: var(--app-bg); }
body { background-color: var(--app-bg) !important; }
.note-window .nwl { background: var(--app-bg) !important; }
/* the notes list sits straight on the background; 6 px from the preview's panes, like the gaps between columns */
.notes-body.notes-split { gap: 0 !important; }
.notes-body.notes-split > .notes-list-col { background: transparent !important; padding: 0 !important; }
.notes-body.notes-split .notes-preview-resizer { flex: 0 0 6px !important; }
.notes-body.notes-split .notes-preview .note-window .nwl { padding-left: 0; }
.app-bg-sw { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--color-border-default); vertical-align: -1px; background: var(--palette-midnight-900); }
:root[data-theme="light"] .app-bg-sw[data-sw="default"] { background: var(--palette-paper-alt); }
.app-bg-sw[data-sw="paper"] { background: #13141c; } :root[data-theme="light"] .app-bg-sw[data-sw="paper"] { background: #f6f7f9; }
.app-bg-sw[data-sw="stone"] { background: #1c1a17; } :root[data-theme="light"] .app-bg-sw[data-sw="stone"] { background: #f0eee9; }
.app-bg-sw[data-sw="sage"]  { background: #121b18; } :root[data-theme="light"] .app-bg-sw[data-sw="sage"]  { background: #e9f0ec; }
.app-bg-sw[data-sw="sky"]   { background: #111a2a; } :root[data-theme="light"] .app-bg-sw[data-sw="sky"]   { background: #e8eff7; }
.app-bg-group { flex-wrap: wrap; }

/* ── 2026-11-04 One header line: the title bar carries the editable title and its lock (no second title row) ── */
.note-window.nw-onehead .nw-title-label, .note-window.nw-onehead > .nw-body > .nw-title-row { display: none !important; }
.note-window.nw-onehead .nw-titlebar > .nw-title-input { flex: 1 1 auto; min-width: 60px; padding: 3px 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text-primary); background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); cursor: text; }
.note-window.nw-onehead .nw-titlebar > .nw-title-input:hover { border-color: var(--color-border-default); }
.note-window.nw-onehead .nw-titlebar > .nw-title-input:focus { border-color: var(--color-accent); background: var(--color-bg-card); outline: none; }
.note-window.nw-onehead .nw-titlebar > .nw-title-input[readonly] { cursor: default; border-color: transparent; background: transparent; }
.note-window.nw-onehead .nw-titlebar > .nw-title-lock-btn { flex: 0 0 auto; }
/* In the preview the header is a card like the panes under it, on the one background */
.notes-body.notes-split .notes-preview { background: transparent !important; border-radius: 0 !important; }
#notes-preview-host .note-window.nw-inline.nw-onehead { background: transparent !important; }
#notes-preview-host .note-window.nw-inline.nw-onehead .nw-titlebar { margin: 0 6px 0 0; border: 1px solid var(--color-border-default); border-radius: var(--r-lg); min-height: 32px; padding: 3px 6px 3px 10px; }
#notes-preview-host .note-window.nw-inline.nw-onehead .nwl { padding-top: 6px; }

/* ── The list / preview divider looks like the gaps between columns: no band, a short accent line on hover ── */
.notes-body.notes-split .notes-preview-resizer { background: transparent !important; position: relative; border-radius: 0; }
.notes-body.notes-split .notes-preview-resizer::after { content: ''; display: block; position: sticky; top: 35vh; height: 30vh; width: 2px; margin-left: 2px; border-radius: var(--r-pill); background: transparent; transition: background .12s; }
.notes-body.notes-split .notes-preview-resizer:hover::after, .notes-body.notes-split .notes-preview-resizer.active::after, body.win-rz-active .notes-preview-resizer::after { background: var(--color-accent); }

/* ── Graph and History are panes like the others ── */
.note-window .nw-graph-pane { display: flex; flex-direction: column; }
.note-window .nw-graph-pane > .nw-gph { flex: 1 1 auto; min-height: 0; position: relative; }
.note-window .nwl .nw-history-drawer.nwl-p { border-top: 0; background: var(--color-bg-card); }
.note-window .nwl .nw-history-drawer.nwl-p > .nw-history-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.note-window .nwl .nw-pane-collapsed > .nw-gph, .note-window .nwl .nw-pane-collapsed > .nw-history-body { display: none; }

/* ── 2026-11-04 Notes graph: 🔍 find box (opens left of the tool column) ── */
.notes-graph-find { position: absolute; top: 8px; right: 46px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; background: var(--color-bg-card); border: 1px solid var(--color-border-default); border-radius: var(--r-pill); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.notes-graph-find[hidden] { display: none; }
.notes-graph-find-input { width: 180px; border: 0; outline: none; background: transparent; color: var(--color-text-primary); font: inherit; font-size: 12.5px; padding: 3px 0; }
.notes-graph-find-n { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; padding-right: 6px; }
.notes-graph-3d-btn { font-size: 10.5px !important; font-weight: 700; letter-spacing: -.02em; }

/* ── 2026-11-04 Note covers and icons: a short cover band behind the window's one header line; icon before the title ── */
:root { --nw-cover-c1: #3b2f2f; --nw-cover-c2: #4a2c1a; --nw-cover-c3: #4a3c12; --nw-cover-c4: #1f3d2b; --nw-cover-c5: #133b3b; --nw-cover-c6: #16324f; --nw-cover-c7: #2a2a55; --nw-cover-c8: #3b2650; --nw-cover-c9: #4a2140; --nw-cover-c10: #4a1f2a; --nw-cover-c11: #2e3440; --nw-cover-c12: #333333; }
:root[data-theme="light"] { --nw-cover-c1: #f3e3d3; --nw-cover-c2: #fbe0c8; --nw-cover-c3: #fbf0c4; --nw-cover-c4: #d7f0de; --nw-cover-c5: #cdeeee; --nw-cover-c6: #d6e6fb; --nw-cover-c7: #dcdcfb; --nw-cover-c8: #ead9f7; --nw-cover-c9: #f7d7ec; --nw-cover-c10: #f9d6dc; --nw-cover-c11: #e2e8f0; --nw-cover-c12: #ececec; }
.note-window.nw-onehead .nw-titlebar { position: relative; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover { min-height: 84px; align-items: flex-end; padding-bottom: 7px; background: var(--nw-cover-bg) !important; background-size: cover !important; background-position: center var(--nw-cover-pos, 50%) !important; background-repeat: no-repeat !important; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > :is(.nw-title-input, .nw-title-lock-btn, .nw-titlebar-btns, .nw-color-pick, .nw-note-icon, .nw-head-adds) { background: color-mix(in srgb, var(--color-bg-card) 84%, transparent) !important; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-radius: var(--r-pill); }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-title-input { flex: 0 1 auto; field-sizing: content; min-width: 140px; max-width: 70%; border-color: transparent; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns { padding: 1px 3px; }
.nw-note-icon { flex: 0 0 auto; border: 0; background: transparent; padding: 0 3px; margin: 0; font-size: 18px; line-height: 1.2; cursor: pointer; border-radius: var(--r-sm); }
.nw-note-icon:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nw-titlebar.nw-has-cover > .nw-note-icon { font-size: 26px; padding: 1px 6px; }
.nw-head-adds { display: none; flex: 0 0 auto; gap: 4px; }
.note-window.nw-onehead .nw-titlebar:hover > .nw-head-adds { display: inline-flex; }
.nw-head-adds > button { border: 1px solid transparent; background: transparent; color: var(--color-text-muted); font: inherit; font-size: 11.5px; padding: 2px 8px; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap; }
.nw-head-adds > button:hover { color: var(--color-text-primary); border-color: var(--color-border-default); background: var(--color-bg-card); }
.nw-head-adds > button[hidden] { display: none; }
.nw-cover-ctl { position: absolute; top: 6px; left: 10px; display: inline-flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .15s; }
.nw-cover-ctl[hidden] { display: none; }
.note-window.nw-onehead .nw-titlebar:hover > .nw-cover-ctl { opacity: 1; }
.nw-cover-btn, .nw-cover-credit { font-size: 11px; padding: 2px 9px; border-radius: var(--r-pill); border: 0; cursor: pointer; color: var(--color-text-primary); background: color-mix(in srgb, var(--color-bg-card) 84%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); text-decoration: none; }
.nw-cover-credit[hidden] { display: none; }
.nw-cover-credit:hover { text-decoration: underline; }
.nw-titlebar.nw-cover-repos { cursor: ns-resize !important; outline: 2px dashed var(--color-accent); outline-offset: -3px; }
.nw-cover-repos-bar { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); display: inline-flex; gap: 6px; align-items: center; padding: 3px 4px 3px 12px; font-size: 11.5px; border-radius: var(--r-pill); background: var(--color-bg-card); border: 1px solid var(--color-border-default); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); cursor: default; }
.nw-cover-repos-bar > button { font: inherit; font-size: 11.5px; padding: 2px 10px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-card); color: var(--color-text-primary); cursor: pointer; }
.nw-cover-repos-bar > button[data-a="save"] { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.note-card-icon { margin-right: 5px; }
/* the cover picker */
.cvp-tabs { display: flex; align-items: center; gap: 4px; padding: 0 16px 6px; border-bottom: 1px solid var(--color-border-default); }
.cvp-tab { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: transparent; color: var(--color-text-secondary); border-bottom: 2px solid transparent; cursor: pointer; }
.cvp-tab.active { color: var(--color-text-primary); border-bottom-color: var(--color-accent); font-weight: 600; }
.cvp-body { padding: 12px 16px 16px; }
.cvp-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-secondary); margin: 6px 0 8px; }
.cvp-note { font-size: 11.5px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--color-text-muted); }
.cvp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 12px; }
.cvp-tile { height: 52px; border: 1px solid var(--color-border-default); border-radius: var(--r-md); cursor: pointer; padding: 0; }
.cvp-tile:hover, .cvp-img:hover { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.cvp-imgs { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.cvp-img { position: relative; height: 96px; padding: 0; border: 0; border-radius: var(--r-md); overflow: hidden; cursor: pointer; background: var(--color-bg-secondary); }
.cvp-img > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cvp-img > span { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: 10.5px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cvp-img.busy { opacity: .5; pointer-events: none; }
.cvp-search { display: flex; gap: 6px; margin-bottom: 8px; }
.cvp-search > input { flex: 1 1 auto; padding: 6px 10px; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-input, var(--color-bg-card)); color: var(--color-text-primary); font: inherit; font-size: 13px; }
.cvp-src { font-size: 11.5px; color: var(--color-text-muted); margin: 0 0 8px; }
.cvp-more { display: flex; justify-content: center; }
.cvp-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 160px; border: 2px dashed var(--color-border-default); border-radius: var(--r-lg); cursor: pointer; color: var(--color-text-secondary); font-size: 13px; }
.cvp-drop.over, .cvp-drop:hover { border-color: var(--color-accent); color: var(--color-text-primary); }
.cvp-drop.busy { opacity: .6; pointer-events: none; }
/* the icon picker */
.nw-icon-menu { width: 320px; }
.nw-icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 240px; overflow-y: auto; margin: 6px 0; }
.nw-icon-cell { font-size: 20px; line-height: 1; padding: 5px 0; border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; }
.nw-icon-cell:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.nw-icon-cell[hidden] { display: none; }
.nw-icon-foot { display: flex; gap: 6px; align-items: center; }
.nw-icon-own { width: 120px; padding: 3px 8px; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-text-primary); font: inherit; font-size: 12px; }
body .note-window.note-window.nw-onehead .nw-titlebar.nw-has-cover { min-height: 84px !important; align-items: flex-end !important; padding-bottom: 7px !important; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-head-adds + .nw-titlebar-btns, .note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns { margin-left: auto; }
.nl-row-t .note-card-icon { margin-right: 4px; }
body .note-window.note-window.nw-onehead .nw-titlebar.nw-has-cover { min-height: var(--nw-cover-h, 84px) !important; }
.nw-cover-rz { position: absolute; left: 0; right: 0; bottom: -3px; height: 7px; cursor: row-resize; z-index: 2; }
.nw-cover-rz[hidden] { display: none; }
.nw-cover-rz::after { content: ''; position: absolute; left: 35%; right: 35%; top: 2px; height: 3px; border-radius: var(--r-pill); background: transparent; transition: background .12s; }
.nw-cover-rz:hover::after, body.win-rz-active .nw-cover-rz::after { background: var(--color-accent); }

/* ── 2026-11-04 header tidy: the ⋯ menu draws above the panes; icon and title one height; note choices live in ⋯ ── */
.note-window.nw-onehead .nw-titlebar { z-index: 6; }
.note-window.nw-onehead .nw-titlebar > .nw-color-pick { display: none !important; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: color-mix(in srgb, var(--color-bg-card) 92%, transparent) !important; }
.note-window.nw-onehead .nw-titlebar > .nw-title-input { height: 28px; box-sizing: border-box; line-height: 20px; }
.note-window.nw-onehead .nw-titlebar > .nw-note-icon, .note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-note-icon { height: 28px; min-width: 28px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; font-size: 16px; line-height: 1; }
.note-window.nw-onehead .nw-titlebar > .nw-note-icon[hidden] { display: none; }
.note-window.nw-onehead .nw-cover-ctl { top: auto; bottom: 8px; left: auto; right: 10px; }
.hdr-more > .hdr-more-panel > [hidden] { display: none !important; }
.nw-color-menu-grid { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 4px 2px; }
.nw-color-menu-grid .nw-cp-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--color-border-default); cursor: pointer; padding: 0; }
.nw-color-menu-grid .nw-cp-swatch.selected { outline: 2px solid var(--color-accent); outline-offset: 2px; }
/* the photo credit sits top-right on the cover, clear of the ⋯ menu (which draws above it anyway) */
.note-window.nw-onehead .nw-cover-ctl { top: 6px !important; bottom: auto !important; right: 10px !important; left: auto !important; z-index: 1; }
.note-window.nw-onehead .nw-titlebar-btns { position: relative; z-index: 3; }
.note-row-title .note-card-icon { margin-right: 4px; }
/* the note's cover as a slim strip across the top of its card */
.note-card > .note-card-cover { flex: 0 0 auto; height: 38px; margin: -10px -12px 0; background: var(--cc) center var(--cp, 50%) / cover no-repeat; border-bottom: 1px solid var(--color-border-default); }
.notes-list-col .note-card > .note-card-cover { margin: -8px -10px 0; }
.note-card.minimized > .note-card-cover { display: none; }
/* a small thumbnail of the cover on linked (child) rows */
.nl-row > .nl-row-cover { flex: 0 0 auto; width: 26px; height: 16px; margin-right: 6px; border-radius: var(--r-sm); background: var(--cc) center var(--cp, 50%) / cover no-repeat; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-border-default) 70%, transparent); }
/* Group: None — the notes as one list (no tag sections) */
.notes-flat-grid { grid-column: 1 / -1; }

/* ── 2026-11-04 notes list: auto-hide (desktop + preview) ── */
.notes-list-strip { display: none; }
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden { gap: 6px !important; }
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden > .notes-list-strip { display: block; flex: 0 0 14px; align-self: stretch; min-height: 160px; cursor: pointer; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-text-primary) 6%, transparent); transition: background .12s; }
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden > .notes-list-strip:hover, body:not(.is-phone) .notes-body.notes-list-peek > .notes-list-strip { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.notes-list-strip > span { position: sticky; top: 45vh; display: block; text-align: center; font-size: 14px; line-height: 1; padding: 8px 0; color: var(--color-text-secondary); }
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden > .notes-preview-resizer { display: none !important; }
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden > .notes-list-col {
    position: fixed; z-index: 950; left: -10000px; top: 0; height: 60vh; width: var(--notes-list-w, 420px) !important; flex: none !important;
    overflow-y: auto; overflow-x: hidden; box-sizing: border-box; padding: 8px !important;
    background: var(--app-bg, var(--color-bg-card)) !important; border: 1px solid var(--color-border-default); border-radius: var(--r-lg);
    box-shadow: 0 14px 36px rgba(0, 0, 0, .28); opacity: 0; transform: translateX(-14px); pointer-events: none; transition: opacity .14s ease, transform .14s ease;
}
body:not(.is-phone) .notes-body.notes-split.notes-list-hidden.notes-list-peek > .notes-list-col { opacity: 1; transform: none; pointer-events: auto; }
.notes-list-dock { display: none; }
body:not(.is-phone) .notes-body.notes-list-hidden.notes-list-peek .notes-list-dock { display: block; width: 100%; margin: 0 0 6px; padding: 4px 8px; font: inherit; font-size: 12px; text-align: center; cursor: pointer; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-text-primary); }
.notes-list-dock:hover { border-color: var(--color-accent); color: var(--color-accent); }
#btn-notes-listhide[disabled] { opacity: .45; }

/* ── notes list: narrow widths (down to 96 px) — the cards go compact as the column shrinks ── */
.notes-body.notes-split > .notes-list-col { container: notes-list / inline-size; }
.notes-body.notes-split .notes-list-col .notes-grid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)) !important; }
@container notes-list (max-width: 250px) {
    .note-card-actions, .note-body-tog, .note-card-db-badge, .nl-row-acts, .notes-tag-add, .nt-sec-btn, .nt-add { display: none !important; }
    .note-card-content, .note-row-snip { display: none !important; }
    .nl-row-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .note-card-title { overflow-wrap: anywhere; }
    .notes-tag-section-header { gap: 4px !important; padding: 4px 6px !important; }
}
@container notes-list (max-width: 175px) {
    .note-card-header-top, .note-card-footer, .nt-count, .notes-tag-count, .nl-row-ic, .nl-tk { display: none !important; }
    .note-card { padding: 6px 7px !important; gap: 4px !important; }
    .note-card > .note-card-cover { height: 24px !important; margin: -6px -7px 0 !important; }
    .note-card-title { font-size: 12px !important; line-height: 1.25 !important; }
    .nl-row { font-size: 11px !important; padding-left: 2px !important; padding-right: 2px !important; }
    .nl-row > .nl-row-cover { width: 18px; height: 12px; margin-right: 4px; }
    .nl-more-row { font-size: 10.5px !important; }
    .note-row-title { font-size: 12px !important; }
}
@container notes-list (max-width: 125px) {
    .nl-list, .notes-tree .nt-sec-head .notes-tag-arrow { display: none !important; }
    .note-card-title .note-card-icon { display: block; margin: 0 0 2px !important; }
}

/* ── the notes list's own toolbar (above Filters / Tags): + New note · Auto-hide / Keep open ── */
.notes-list-col > .notes-list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; }
.notes-list-bar > .btn { border-radius: var(--r-pill); }
.notes-list-bar > .notes-new-btn { font-weight: 600; }
.notes-list-bar > .notes-autohide-btn { margin-left: auto; }
.notes-list-bar > .notes-autohide-btn.active { color: var(--color-accent); border-color: var(--color-accent); }
.notes-list-bar > [hidden] { display: none !important; }
.note-action-btn.note-new-linked-btn { width: auto !important; padding: 0 7px !important; font-size: 11px; font-weight: 600; white-space: nowrap; }
@container notes-list (max-width: 175px) { .notes-list-bar > .btn { padding-left: 6px; padding-right: 6px; font-size: 11px; } }
/* list toolbar: the sidebar toggle sits first (left), + New note beside it, room for more after */
.notes-list-bar > .notes-autohide-btn { margin-left: 0 !important; width: 28px; height: 26px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; }
.notes-list-bar > .notes-autohide-btn.active { background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-card)); }
/* the first note sits the usual card gap (10 px) under Filters / Tags — no extra grid padding */
.notes-list-col #notes-grid, .notes-list-col #notes-grid > .notes-flat-grid { padding-top: 0 !important; }
.notes-list-col:has(.notes-flat-grid) > .notes-tree { margin-bottom: 10px !important; }
/* Manual order: drag a note to a new place (desktop) */
#notes-grid.notes-manual .notes-grid > [draggable="true"] { cursor: grab; }
#notes-grid.nd-active .notes-grid > [data-note-guid] { transition: box-shadow .08s; }
#notes-grid .notes-grid > .nd-dragging { opacity: .45; }
#notes-grid .notes-grid > .nd-before { box-shadow: 0 -3px 0 0 var(--color-accent); }
#notes-grid .notes-grid > .nd-after { box-shadow: 0 3px 0 0 var(--color-accent); }

/* ── Note History: who replaced each version (phase 3, 2026-11-04) ── */
.nw-history-item-who { grid-column: 1 / -1; font-size: 10px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nw-history-item-who::before { content: 'by '; }
.nw-history-item-who.is-bot { color: var(--color-accent); }

/* ── 2026-11-04 cover menu pill: one even rim. The holder had 3px side / 1px top padding round the button's own border;
   now the button alone carries the backdrop, so its border is the only edge. ── */
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns { padding: 0 !important; background: transparent !important; gap: 4px; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns > .nw-btn { background: color-mix(in srgb, var(--color-bg-card) 92%, transparent) !important; }
.note-window.nw-onehead .nw-titlebar.nw-has-cover > .nw-titlebar-btns > .nw-btn:hover { background: var(--color-bg-card) !important; }

/* ── 2026-11-04 task / card / event window (t_308866f588) · Style D ──
   One control height (--tk-h) throughout; fields in When / Details / Links sections; a kind badge, note crumb and ⋯ in the
   title bar; the line under the title shows what matters for the kind; a coloured item gets the matrix-panel edge and a
   card the flat tint. Tokens only, so Dark and Light both work. */
#tk-detail { --tk-h: 26px; --tk-l-w: 70px; --tk-kc: var(--color-accent); }
#tk-detail.tk-d-is-event { --tk-kc: var(--color-status-info, #3b82f6); }
#tk-detail.tk-d-is-snippet { --tk-kc: var(--color-text-secondary); }
#tk-detail.tk-d-is-snippet.tk-d-colored { --tk-kc: color-mix(in srgb, var(--tk-c) 55%, var(--color-text-primary)); }   /* pastel card colours stay readable */
#tk-detail.tk-d-colored::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tk-c); border-radius: var(--r-xl) 0 0 var(--r-xl); z-index: 3; pointer-events: none; }
#tk-detail.tk-d-is-snippet.tk-d-colored { background: color-mix(in srgb, var(--tk-c) 14%, var(--color-bg-card)); }
#tk-detail.tk-d-is-snippet.tk-d-colored > .row-ed-titlebar { background: color-mix(in srgb, var(--tk-c) 24%, var(--color-bg-card)); }
/* title bar */
#tk-detail > .row-ed-titlebar { gap: 6px; }
#tk-detail .row-ed-title { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.tk-d-kb { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 10px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; color: var(--tk-kc); background: color-mix(in srgb, var(--tk-kc) 13%, transparent); border: 1px solid color-mix(in srgb, var(--tk-kc) 35%, transparent); }
.tk-d-crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; background: transparent; padding: 2px 6px; border-radius: var(--r-pill); font: inherit; font-size: 12.5px; font-weight: 600; color: var(--color-text-secondary); cursor: pointer; }
.tk-d-crumb::before { content: 'in '; font-weight: 400; color: var(--color-text-muted); }
.tk-d-crumb:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
#tk-detail .tk-d-tbmore { flex: 0 0 auto; }
#tk-detail .tk-d-tbmore > .hdr-more-panel { min-width: 210px; }
#tk-detail .hdr-more-panel .hdr-item.tk-d-mi-danger, #tk-detail .hdr-more-panel .hdr-item.tk-d-mi-danger .hdr-ic { color: var(--color-status-danger); }
/* body */
#tk-detail .tk-detail-body { container: tkwin / inline-size; gap: 10px; padding: 12px 14px 10px; }
#tk-detail .tk-d-head { align-items: flex-start; gap: 10px; }
#tk-detail .tk-d-head .tk-check { width: 18px; height: 18px; margin-top: 6px; }
#tk-detail .tk-detail-body textarea.tk-d-title { font-size: 18px; font-weight: 700; line-height: 1.3; padding: 3px 7px; margin-left: -7px; background: transparent; border: 1px solid transparent; border-radius: var(--r-md); }
#tk-detail .tk-detail-body textarea.tk-d-title:hover { border-color: var(--color-border-default); }
#tk-detail .tk-detail-body textarea.tk-d-title:focus { border-color: var(--color-accent); background: var(--color-bg-note-window-input, var(--color-bg-input)); }
#tk-detail.tk-d-is-snippet .tk-detail-body textarea.tk-d-title { margin-left: -7px; }
#tk-detail.tk-d-done .tk-detail-body textarea.tk-d-title { text-decoration: line-through; color: var(--color-text-muted); }
#tk-detail .tk-d-head .tk-d-skip { margin-top: 3px; }
/* the line under the title */
.tk-d-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tk-d-hp { box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-card); color: var(--color-text-primary); font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
button.tk-d-hp { cursor: pointer; }
button.tk-d-hp:hover { border-color: var(--color-accent); }
.tk-d-hp-sub { font-weight: 500; font-size: 11.5px; opacity: .85; }
.tk-d-hp-due.is-over { color: var(--color-status-danger); border-color: color-mix(in srgb, var(--color-status-danger) 45%, transparent); background: color-mix(in srgb, var(--color-status-danger) 10%, var(--color-bg-card)); }
.tk-d-hp-due.is-today { color: var(--color-accent); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); background: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg-card)); }
.tk-d-hp-due.is-soon { border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-border-default)); }
.tk-d-hp-due.is-none { color: var(--color-text-muted); border-style: dashed; font-weight: 500; background: transparent; }
.tk-d-hp-prio.is-high { color: var(--color-status-danger); border-color: color-mix(in srgb, var(--color-status-danger) 40%, transparent); background: color-mix(in srgb, var(--color-status-danger) 8%, var(--color-bg-card)); }
.tk-d-hp-prio.is-medium { color: var(--color-warning, #d97706); border-color: color-mix(in srgb, var(--color-warning, #d97706) 40%, transparent); background: color-mix(in srgb, var(--color-warning, #d97706) 8%, var(--color-bg-card)); }
.tk-d-hp-prio.is-low { color: var(--color-status-info, #3b82f6); border-color: color-mix(in srgb, var(--color-status-info, #3b82f6) 35%, transparent); }
.tk-d-hp-rep { font-weight: 500; color: var(--color-text-secondary); }
.tk-d-hp-done { color: var(--color-status-success, #16a34a); border-color: color-mix(in srgb, var(--color-status-success, #16a34a) 40%, transparent); }
/* event: a calendar block and the span */
.tk-d-ev { flex: 1 1 260px; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--tk-kc) 30%, var(--color-border-default)); background: color-mix(in srgb, var(--tk-kc) 7%, var(--color-bg-card)); color: var(--color-text-primary); font: inherit; text-align: left; cursor: pointer; }
.tk-d-ev:hover { border-color: var(--tk-kc); }
.tk-d-ev.is-past { opacity: .75; }
.tk-d-cal { flex: 0 0 46px; display: flex; flex-direction: column; align-items: stretch; text-align: center; border-radius: var(--r-md); overflow: hidden; background: var(--color-bg-card); border: 1px solid color-mix(in srgb, var(--tk-kc) 40%, var(--color-border-default)); }
.tk-d-cal-m { font-size: 10px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--tk-kc); padding: 2px 0; }
.tk-d-cal-d { font-size: 20px; font-weight: 800; line-height: 1.15; padding: 2px 0 3px; color: var(--color-text-primary); }
.tk-d-when { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-d-when-1 { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tk-d-when-2 { font-size: 12px; color: var(--color-text-secondary); }
.tk-d-when-2 b { color: var(--tk-kc); font-weight: 700; }
.tk-d-ev.is-past .tk-d-when-2 b { color: var(--color-text-muted); }
/* sections and rows */
.tk-d-sec { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--color-bg-card) 72%, transparent); border: 1px solid color-mix(in srgb, var(--color-border-default) 70%, transparent); }
.tk-d-sec-h { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }
#tk-detail .tk-d-row { display: grid; grid-template-columns: var(--tk-l-w) minmax(0, 1fr); align-items: center; column-gap: 10px; min-height: var(--tk-h); }
#tk-detail .tk-d-l { width: auto; font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--color-text-secondary); }
#tk-detail .tk-d-v { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: 0; }
#tk-detail .tk-d-seg { display: inline-flex; flex-wrap: wrap; gap: 3px; }
#tk-detail .tk-d-loc { flex: 1 1 auto; }
/* one height and shape for every control */
#tk-detail :is(.tk-pp, .tk-tagpick, .nw-dp-chip, .tk-d-start, .tk-d-due, .tk-loc-maps) { box-sizing: border-box; height: var(--tk-h); min-height: var(--tk-h); display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; line-height: 1; white-space: nowrap; margin: 0; }
#tk-detail .tk-pp { font-weight: 600; padding: 0 9px; background: var(--color-bg-card); }
#tk-detail .tk-pp.on { background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-card)); }
#tk-detail .tk-pp-high.on { background: color-mix(in srgb, var(--color-status-danger) 16%, var(--color-bg-card)); }
#tk-detail .tk-pp-medium.on { background: color-mix(in srgb, var(--color-warning, #d97706) 18%, var(--color-bg-card)); }
#tk-detail .tk-tagpick.on { padding-right: 5px; }
#tk-detail .tk-tagpick-new { color: var(--color-text-muted); }
#tk-detail .tk-tagpick-new:hover { color: var(--color-accent); border-color: var(--color-accent); }
#tk-detail .tk-d-due { text-decoration: none; border: 1px solid var(--color-border-default); background: var(--color-bg-card); font-weight: 600; color: var(--color-text-primary); cursor: pointer; }
#tk-detail .tk-d-due:hover { border-color: var(--color-accent); color: var(--color-accent); }
#tk-detail .tk-d-due.tk-due-over { color: var(--color-status-danger); border-color: color-mix(in srgb, var(--color-status-danger) 45%, transparent); }
#tk-detail .tk-detail-body :is(input.tk-d-pnum, input.tk-d-locin) { box-sizing: border-box; height: var(--tk-h); padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; }
#tk-detail .tk-detail-body input.tk-d-pnum { width: 58px; text-align: center; }
#tk-detail .tk-d-swatches { gap: 5px; }
#tk-detail .tk-d-swatches .nw-cp-swatch { width: 20px; height: 20px; }
/* the body pane */
#tk-detail .tk-d-content { flex: 1 0 auto; min-height: 150px; background: var(--color-bg-card); border: 1px solid color-mix(in srgb, var(--color-border-default) 85%, transparent); border-radius: var(--r-lg); overflow: visible; }
#tk-detail.tk-d-is-snippet .tk-d-content { min-height: 200px; }
#tk-detail .tk-d-foot { justify-content: flex-end; }
#tk-detail .tk-d-meta { flex: 0 1 auto; text-align: right; font-size: 11px; }
#tk-detail .tk-d-hist { border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--color-border-default) 70%, transparent); background: color-mix(in srgb, var(--color-bg-card) 72%, transparent); padding: 8px 10px; }
/* narrow windows and the phone sheet: labels go above their controls */
@container tkwin (max-width: 430px) {
    #tk-detail .tk-d-row { grid-template-columns: minmax(0, 1fr); row-gap: 3px; }
    #tk-detail .tk-d-l { font-size: 10.5px; }
    .tk-d-ev { flex-basis: 100%; }
}
#tk-detail.tk-detail-sheet { --tk-h: 30px; }
#tk-detail.tk-detail-sheet .tk-detail-body { padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
#tk-detail .tk-d-tbmore > .hdr-more-btn { box-sizing: border-box; height: 22px; min-width: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
#tk-detail.tk-d-is-snippet.tk-d-colored .tk-d-content { background: color-mix(in srgb, var(--tk-c) 6%, var(--color-bg-card)); }

/* ── Cards vs tasks: tag families, captured-from chip, panel filter (2026-11-05) ── */
.tk-src { --src-c: var(--color-accent); display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 8px; border-radius: var(--r-pill); font-size: 11px; line-height: 1; text-decoration: none; white-space: nowrap; color: var(--color-text-secondary); background: color-mix(in srgb, var(--src-c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--src-c) 32%, transparent); }
.tk-src:hover { color: var(--color-text-primary); background: color-mix(in srgb, var(--src-c) 20%, transparent); }
.tk-src-ic { font-size: 10px; color: var(--src-c); }
.tk-src-email { --src-c: #2563eb; } .tk-src-youtube { --src-c: #dc2626; } .tk-src-x { --src-c: #64748b; } .tk-src-web { --src-c: #0e7490; }
.tk-tag-fam { font-size: 10px; opacity: .55; margin-left: 3px; flex: 0 0 auto; }
.tk-row-cardmark { flex: 0 0 auto; width: 16px; text-align: center; font-size: 12px; color: var(--color-text-muted); }
.tk-tagpop-head { order: -1; padding: 2px 6px 4px; font-size: 11px; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.tk-tag-for-fixed { font-size: 12.5px; }
.tk-ve-filter .tk-ve-fsel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-ve-fsel-l { font-size: 12px; color: var(--color-text-secondary); }
.tk-ve-fdesc { margin: 8px 0 0; padding: 6px 10px; font-size: 12px; color: var(--color-text-secondary); border-radius: var(--r-md); background: color-mix(in srgb, var(--color-accent) 8%, transparent); border-left: 3px solid var(--color-accent); }
.tk-ve-own-h { margin: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--color-text-primary); }
.tk-ve-own-h .nw-dbe-card-sub { font-weight: 400; margin-left: 4px; }
.tk-ve-ownsort { margin-bottom: 6px; }
.tk-ve-days { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-secondary); }
.tk-ve-days input { width: 72px; }
.nw-popmenu-note { padding: 4px 10px 2px; max-width: 340px; font-size: 11.5px; color: var(--color-text-muted); }
.tk-ctbl-source { white-space: nowrap; }

/* ── Link property in the item window (2026-11-05) ── */
#tk-detail .tk-d-link { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
#tk-detail .tk-d-url { flex: 1 1 auto; min-width: 0; height: var(--tk-h); padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-input); color: var(--color-text-primary); font-size: 12.5px; }
#tk-detail .tk-d-url:focus { outline: none; border-color: var(--color-border-focus); }
#tk-detail .tk-d-link .tk-src { height: var(--tk-h); flex: 0 0 auto; }

/* ── Card categories (2026-11-05) ── */
.tk-cat { --cat-c: #6b7280; display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; color: color-mix(in srgb, var(--cat-c) 70%, var(--color-text-primary)); background: color-mix(in srgb, var(--cat-c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--cat-c) 35%, transparent); }
.tk-cat-ic { font-size: 10px; }
#tk-detail .tk-pp-cat.on { background: color-mix(in srgb, var(--cat-c, var(--color-accent)) 18%, transparent); border-color: var(--cat-c, var(--color-accent)); color: var(--color-text-primary); }
.tk-catmgr td input[type=text] { width: 100%; }
.tk-catmgr .tk-catmgr-ic { width: 48px; text-align: center; }
.tk-catmgr input[type=color] { width: 36px; height: 26px; padding: 0; border: none; background: none; }
.tk-catmgr-del td { opacity: .45; text-decoration: line-through; }
.tk-cgroup > .tk-group-head { margin-top: 6px; }

/* ── Links board: start.me-style tiles (2026-11-05) ── */
.tk-links { display: flex; flex-direction: column; gap: 10px; padding: 2px 0 8px; }
.tk-lsec { border-radius: var(--r-lg); padding: 4px 6px 8px; transition: background-color .12s; }
.tk-lsec-over { background: color-mix(in srgb, var(--color-accent) 10%, transparent); outline: 2px dashed color-mix(in srgb, var(--color-accent) 55%, transparent); outline-offset: -2px; }
.tk-lsec-h { display: flex; align-items: center; gap: 6px; padding: 4px 4px 6px; font-weight: 700; font-size: 12.5px; color: var(--color-text-primary); cursor: pointer; user-select: none; }
.tk-lsec-h .tk-group-n { font-weight: 500; }
.tk-ltiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.tk-ltile { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 30px 8px 10px; border-radius: var(--r-md); border: 1px solid var(--color-border-default); background: var(--color-bg-card); color: var(--color-text-primary); text-decoration: none; cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.tk-ltile:hover { border-color: var(--color-accent); box-shadow: 0 2px 10px rgba(0,0,0,.12); transform: translateY(-1px); }
.tk-ltile-open { border-color: var(--color-accent); }
.tk-lfav { position: relative; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 7px; overflow: hidden; display: grid; place-items: center; background: var(--lf-c); }
.tk-lfav-l { color: #fff; font-weight: 700; font-size: 14px; }
.tk-lfav img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; box-sizing: border-box; }
.tk-ltxt { display: flex; flex-direction: column; min-width: 0; }
.tk-ltitle { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ldom, .tk-ldesc { font-size: 11px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ldesc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tk-ledit { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: none; border-radius: var(--r-pill); background: transparent; color: var(--color-text-muted); font-size: 12px; cursor: pointer; opacity: 0; transition: opacity .12s; }
.tk-ltile:hover .tk-ledit, .tk-ledit:focus-visible { opacity: 1; }
.tk-ledit:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); color: var(--color-text-primary); }
.tk-ladd { min-height: 46px; border: 1px dashed var(--color-border-strong); border-radius: var(--r-md); background: transparent; color: var(--color-text-muted); font-size: 12px; cursor: pointer; }
.tk-ladd:hover { border-color: var(--color-accent); color: var(--color-text-primary); }
.tk-ladd-in { min-height: 46px; padding: 0 10px; border: 1px solid var(--color-border-focus); border-radius: var(--r-md); background: var(--color-bg-input); color: var(--color-text-primary); font-size: 12.5px; }
@media (hover: none) { .tk-ledit { opacity: .8; } }

/* ── Card looks per category (2026-11-05) ── */
.tk-card-fmt .tk-fbody { font-size: 12px; color: var(--color-text-secondary); line-height: 1.4; margin-top: 2px; }
.tk-fyt { position: relative; margin: -2px -2px 8px; border-radius: var(--r-md); overflow: hidden; aspect-ratio: 16 / 9; background: #000; cursor: pointer; }
.tk-fyt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tk-fyt iframe { width: 100%; height: 100%; border: 0; display: block; }
.tk-fyt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(220, 38, 38, .92); color: #fff; font-size: 15px; box-shadow: 0 2px 8px rgba(0,0,0,.35); transition: transform .12s; }
.tk-fyt:hover .tk-fyt-play { transform: translate(-50%, -50%) scale(1.08); }
.tk-fyt-len { position: absolute; right: 6px; bottom: 6px; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.78); color: #fff; font-size: 11px; font-weight: 600; }
.tk-fyt-ch { color: var(--color-text-muted); }
.tk-fem, .tk-fx { display: flex; flex-direction: column; gap: 6px; }
.tk-fem-h, .tk-fx-h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-fav-l { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--lf-c); color: #fff; font-size: 12px; font-weight: 700; }
.tk-fem-from { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; font-size: 12.5px; line-height: 1.2; }
.tk-fem-from b, .tk-fem-from small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-fem-from small { font-size: 11px; color: var(--color-text-muted); }
.tk-fem-date { flex: 0 0 auto; font-size: 11px; color: var(--color-text-muted); }
.tk-fem-snip { font-size: 12px; line-height: 1.45; color: var(--color-text-secondary); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tk-fopen { align-self: flex-start; font-size: 11.5px; font-weight: 600; color: var(--color-accent); text-decoration: none; }
.tk-fopen:hover { text-decoration: underline; }
.tk-fx-logo { margin-left: auto; font-size: 13px; color: var(--color-text-muted); }
.tk-fx-text { font-size: 13px; line-height: 1.45; color: var(--color-text-primary); white-space: normal; overflow-wrap: anywhere; }
.tk-fx-img { width: 100%; border-radius: var(--r-md); display: block; }
.tk-card-head-bare { min-height: 0; margin-bottom: -2px; }
.tk-card-head-bare .tk-card-title { display: none; }
.tk-card-head-bare { justify-content: flex-end; }
.tk-flink { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; text-decoration: none; color: var(--color-text-secondary); font-size: 12px; }
.tk-flink .tk-lfav { flex-basis: 22px; width: 22px; height: 22px; border-radius: 6px; }
.tk-flink:hover .tk-ldom { color: var(--color-accent); }

/* ── Phone pass (2026-11-05): one page that scrolls, finger-sized controls ── */
/* 1. Note window. The one-column note layout (.nwl-flat, 2026-11-04) gave every section a fixed height (editor
      min(620px,75vh), others min(460px,70vh), Linked 240px), so the note text was cut to one screen and Tasks / Cards
      scrolled inside their own boxes inside the scrolling note. Back to the phone rule: DOCUMENTS (note text, database
      tables, task and card boards, Linked, Files, Properties) take their natural height and the note scrolls as one
      page; VIEWPORTS (spreadsheet grid, AI / Channels, graph) keep a frame. Collapsing a section still shrinks it. */
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p { height: auto !important; max-height: none !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nw-editor-area { min-height: 30dvh; overflow: visible !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nwl.nwl-flat .nw-editor-area > .nw-editor-el { height: auto !important; max-height: none !important; overflow: visible !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nw-graph-pane:not(.nw-pane-collapsed) { height: 65dvh !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nw-ch-pane:not(.nw-pane-collapsed) { height: 75dvh !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nw-db-pane:has(.ss-scroll):not(.nw-pane-collapsed) { height: 75dvh !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nwl.nwl-flat :is(.nw-tk-body, .nw-links-body, .nw-props-body, .nw-fp-body) { height: auto !important; max-height: none !important; overflow-y: visible !important; }
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nwl.nwl-flat .nw-db-pane:not(:has(.ss-scroll)) .nw-db-viewbody { overflow-y: visible !important; }
/* The cover is a header, not a third of the screen: at most 96px on a phone. */
body.is-phone .note-window.note-window.nw-onehead.phone-full .nw-titlebar.nw-has-cover { min-height: min(var(--nw-cover-h, 84px), 96px) !important; max-height: 112px; }

/* 2. Task and card boards on a phone: panels one per row at their natural height (no box scrolling inside a box). */
body.is-phone .tk-mrow { grid-template-columns: minmax(0, 1fr) !important; row-gap: 10px; }
body.is-phone .tk-mrow > .tk-mdiv-v { display: none !important; }
body.is-phone .tk-mrow-fixed .tk-panel, body.is-phone .tk-panel { height: auto !important; }
body.is-phone .tk-panel-body, body.is-phone .tk-mrow-fixed .tk-panel-body { max-height: none !important; overflow: visible !important; }
body.is-phone .tk-matrix > .tk-mdiv-h { display: none !important; }

/* 3. A task row: the title gets the whole first line; its chips (priority, tags, note, due…) wrap onto a second. */
body.is-phone .tk-row { flex-wrap: wrap; row-gap: 3px; min-height: 40px; padding: 7px 8px; }
body.is-phone .tk-row > .tk-title { flex: 1 1 calc(100% - 80px); min-width: 0; white-space: normal; overflow-wrap: anywhere; }
body.is-phone .tk-row > .tk-meta { flex: 1 1 100%; max-width: none !important; flex-wrap: wrap; justify-content: flex-start; padding-left: 28px; row-gap: 4px; }
body.is-phone .tk-row .tk-check, body.is-phone .tk-row .tk-selbox { width: 20px; height: 20px; flex: 0 0 20px; }

/* 4. Finger-sized controls (about 36px; 44px where it is cheap). */
body.is-phone :is(.nl-row-btn, .note-pin-icon, .note-body-tog, .nf-crumb-x, .tk-tagpick-x, .tk-card-pin, .tk-card-arch, .tk-ledit, .nw-se-iconbtn) { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
body.is-phone .tabs-add-btn { min-width: 40px; min-height: 36px; }
body.is-phone .nl-row { min-height: 40px; align-items: center; }
body.is-phone :is(.btn-xs, .nw-btn.btn-xs, .nt-chip, .nt-crumb) { min-height: 34px; }
body.is-phone :is(.tk-pp, .tk-tagpick, .nw-dp-chip) { min-height: 34px; }
body.is-phone .nw-popmenu-item { min-height: 44px; }
body.is-phone .tk-ledit { opacity: .85; }
body.is-phone .tk-ltile { min-height: 52px; }

/* Phone: long sections stop at about one screen with "Show all" (see _phCapSync). */
body.is-phone .note-window.phone-full:not(.nw-dbonly) .nw-split-container .nwl.nwl-flat > .nwl-col > .nw-ph-capped.nw-ph-capped.nw-ph-capped { max-height: var(--ph-cap, 115dvh) !important; overflow: clip !important; position: relative; }
body.is-phone .note-window.phone-full .nwl.nwl-flat > .nwl-col > .nwl-p:has(> .nw-ph-more) { position: relative; padding-bottom: 46px; }
body.is-phone .nw-ph-more { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border-top: 1px solid var(--color-border-default); background: linear-gradient(to bottom, color-mix(in srgb, var(--color-bg-card) 70%, transparent), var(--color-bg-card) 45%); z-index: 3; }
html body.is-phone .nw-ph-more > button { min-height: 36px; padding: 0 12px; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-accent); font-size: 13px; font-weight: 700; cursor: pointer; }
html body.is-phone .nw-ph-more > button[data-a="more"] { background: color-mix(in srgb, var(--color-accent) 12%, var(--color-bg-card)); border-color: color-mix(in srgb, var(--color-accent) 40%, transparent); }
body.is-phone .nw-ph-more > .nw-ph-pct { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; }

body.is-phone .note-window.phone-full .nwl.nwl-flat > .nwl-col > .nw-ph-capped > * { flex-shrink: 0 !important; }   /* a capped section clips; its content keeps its full height */

/* Phone: database row buttons, section-header buttons and the note title get finger-sized too. */
body.is-phone :is(.nw-db-rowbtn, .nw-row-act, .tk-panel-head button, .nw-pane-head button, .nw-links-head button) { min-width: 34px; min-height: 34px; }
body.is-phone .btn:not(.btn-lg) { min-height: 34px; }
body.is-phone .note-window .nw-title-input { min-height: 34px; }

/* Phone: the editor's formatting buttons, linked-note ×, chips and the small text boxes. */
body.is-phone .tiptap-toolbar :is(.tt-btn, select) { min-width: 36px; min-height: 36px; }
body.is-phone :is(.nw-linked-chip-x, .tk-chip) { min-width: 32px; min-height: 32px; }
body.is-phone :is(.tk-quick, .nw-symbols, .tk-search, .tk-sel) { min-height: 36px; }
body.is-phone .tk-row .tk-check { width: 22px; height: 22px; flex-basis: 22px; }

/* ── Touch pass (2026-11-05 b) ── */
/* 1. Desktop, one column (window under 760px): a bar under each section sets its height (nwlFlatDown, saved per note). */
body:not(.is-phone) .note-window .nw-split-container .nwl.nwl-flat > .nwl-col > .nwl-p.nwl-fh-set:not(.nw-pane-collapsed):not(.nw-links-collapsed):not(.nw-props) { height: var(--nwl-fh) !important; max-height: none !important; }
.note-window .nwl.nwl-flat > .nwl-col > .nwl-gf { flex: 0 0 12px; margin: -9px 0; z-index: 2; }
.note-window .nwl.nwl-flat > .nwl-col > .nwl-gf::after { left: calc(50% - 22px); right: calc(50% - 22px); top: 4px; height: 4px; background: color-mix(in srgb, var(--color-text-primary) 16%, transparent); }
.note-window .nwl.nwl-flat > .nwl-col > .nwl-gf:is(:hover, .on)::after { left: 30%; right: 30%; background: var(--color-accent); }
.note-window .nwl.nwl-flat > .nwl-col > :is(.nw-pane-collapsed, .nw-links-collapsed) + .nwl-gf { visibility: hidden; pointer-events: none; }

/* 2. Phone on a real touch screen. The touch floor `@media (pointer: coarse) button:not(…)` (specificity 0,4,1) outranked
      every phone size rule above, so on an actual phone each button stayed 28px (a desktop popup at phone width, which is
      not touch, didn't show it). These rules start with `html body.is-phone` so they win. About 38–40px for buttons and
      text boxes, 22px check boxes; colour swatches and icon grids stay small squares. */
html body.is-phone button:not(.ss-sw):not(.nw-cp-swatch):not(.ss-swatch):not(.nw-color-swatch-btn):not(.nw-ico-swatch):not(.bd-icon-pick) { min-height: 38px; min-width: 38px; }
html body.is-phone :is(.nw-ico-swatch, .bd-icon-pick) { min-width: 34px; min-height: 34px; }
html body.is-phone .bd-icon-grid { grid-template-columns: repeat(8, 34px); }
html body.is-phone :is(select, textarea, input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="email"], input[type="url"], input[type="time"], input:not([type])):not(.ss-edit) { min-height: 40px; }
html body.is-phone textarea { min-height: 64px; }
html body.is-phone input[type="checkbox"]:not(.tk-check) { min-width: 22px; min-height: 22px; }
html body.is-phone .tk-row .tk-check, html body.is-phone .tk-check { width: 24px; height: 24px; flex: 0 0 24px; }
html body.is-phone .tabs-strip li.tab { min-height: 36px; display: inline-flex; align-items: center; }
html body.is-phone .nw-popmenu-item, html body.is-phone .tabs-context-menu button { min-height: 46px; }
html body.is-phone .nw-db-rowbtn { min-width: 40px; min-height: 40px; }
html body.is-phone .note-window .nw-cover-credit { padding: 8px 6px; }

/* Phone: finger scrolling in a note (2026-11-05 c) */
/* On a desktop the one-column container (.nwl-flat) is the note's scroll box, and `overscroll-behavior: contain` keeps
   a scroll inside it. On a phone it grows to the note's full height and the window body (.nw-body) scrolls instead —
   but Chrome still treats an overflow:auto box as a scroll container, and `contain` stopped every finger drag that
   started on the note from reaching .nw-body: nothing moved (the wheel and scrollbar still worked, which hid it). */
html body.is-phone .note-window .nwl.nwl-flat { overflow: visible !important; overscroll-behavior: auto !important; }

/* Phone: panels and database tables scroll inside (2026-11-05 d) */
/* Joey: the page scrolls, but the inside of panels doesn't. A board panel scrolls inside a box of at most 60% of the
   screen (a one-panel list / table / cards view 70%), a database table inside 70% with its header row pinned. Each box
   is shorter than the screen, so a finger outside it (headers, gaps, the other sections) still scrolls the page, and at
   the end of a box the next drag carries on to the page (overscroll-behavior auto). Replaces the 2026-11-05 natural-
   height panels; Show more (_phCapSync) now only kicks in for a board with many panels. */
/* 2026-11-13 Joey reversed this: no box inside a panel — every task / card is shown and the page scrolls (collapse a panel or the section to shorten it). */
html body.is-phone .tk-panel > .tk-panel-body, html body.is-phone .tk-mrow-fixed .tk-panel > .tk-panel-body { max-height: none !important; overflow: visible !important; }
html body.is-phone .tk-matrix-single > .tk-panel-single > .tk-panel-body { max-height: none !important; overflow: visible !important; padding: 0 2px 2px; }
html body.is-phone .note-window.phone-full:not(.nw-dbonly) .nwl.nwl-flat .nw-db-pane:not(:has(.ss-scroll)) .nw-db-viewbody,
html body.is-phone .phone-full:not(.nw-dbonly) .nw-db-pane:not(:has(.ss-scroll)) .nw-db-viewbody { max-height: 70dvh; overflow: auto !important; overscroll-behavior: auto; }

/* ── Add buttons instead of quick-add boxes (2026-11-06) ── */
.tk-addbtn { display: block; width: calc(100% - 16px); min-height: 34px; margin: 4px 8px 8px; padding: 0 10px; border: 1px dashed var(--color-border-strong); border-radius: var(--r-md); background: transparent; color: var(--color-text-muted); font-size: 12px; text-align: left; cursor: pointer; }
.tk-addbtn:hover { border-color: var(--color-accent); color: var(--color-text-primary); background: color-mix(in srgb, var(--color-accent) 6%, transparent); }
.tk-gadd { width: 100%; margin: 6px 0 10px; }
.tk-panel > .tk-panel-add.tk-addbtn { flex: 0 0 auto; }
.tk-toolbar .tk-new-btn { white-space: nowrap; }

/* ── Board toolbar (2026-11-06 b) ── */
/* The search box is as tall as the buttons beside it; the item count sits at the right, just before ⋯. */
.tk-toolbar .tk-search { height: 23px; padding-top: 0; padding-bottom: 0; }
.tk-toolbar .tk-count { margin-left: auto; }
.tk-toolbar .tk-count + .tk-more { margin-left: 0; }
html body.is-phone .tk-toolbar .tk-search { height: auto; }
.tk-ve-groups .tk-ve-grp-add { align-self: flex-start; }
.tk-ve-groups .tkf-sort-n { min-width: 30px; color: var(--color-text-muted); }

/* ── Formula columns (2026-11-06) ── */
.nw-db-struct-expr { flex: 1 1 260px; min-width: 200px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; }
.nw-db-struct-fxins, .nw-db-struct-rtype { width: auto; }
.nw-db-struct-dec { width: 86px; }
.nw-db-fx-err { color: var(--color-negative, #dc2626); font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; cursor: help; }
/* A formula's settings take the row's full width; computed columns have no default. */
.nw-se-row > .nw-se-cfg:has(.nw-db-struct-expr) { grid-column: 2 / -1; flex-wrap: wrap; }
.nw-se-row > .nw-se-cfg .nw-db-struct-expr { flex: 1 1 360px; }
.nw-se-row:has(.nw-db-struct-expr) > .nw-se-extra { display: none; }
.nw-se-row > .nw-se-cfg input.nw-db-struct-dec { flex: 0 0 100px; width: 100px !important; }

/* ── Due-date lock + spreadsheet formula cells (2026-11-07) ── */
.tk-due.tk-due-locked { cursor: default; }
.tk-pp.tk-d-lock.on { background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-card)); border-color: color-mix(in srgb, var(--color-accent) 45%, transparent); color: var(--color-text-primary); }

/* ── Sheet tabs (2026-11-07) ── */
.ss-sheetbar { display: flex; align-items: stretch; flex: 0 0 auto; min-height: 26px; background: var(--color-bg-secondary); border-top: 1px solid var(--color-border-default); font-size: 12px; user-select: none; }
.ss-sheettabs { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ss-sheettabs::-webkit-scrollbar { display: none; }
.ss-sheettab { flex: 0 0 auto; padding: 3px 16px; border: 0; border-right: 1px solid var(--color-border-default); background: transparent; color: var(--color-text-secondary); white-space: nowrap; cursor: pointer; touch-action: pan-x; }
.ss-sheettab:hover { background: color-mix(in srgb, var(--color-text-primary) 5%, transparent); color: var(--color-text-primary); }
.ss-sheettab.active { background: var(--color-bg-card); color: var(--color-text-primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--color-accent); }
.ss-sheettab.nw-db-tab-dragging { opacity: .6; }
.ss-sheettab.nw-db-tab-ins-before { box-shadow: inset 2px 0 0 var(--color-accent); }
.ss-sheettab.nw-db-tab-ins-after { box-shadow: inset -2px 0 0 var(--color-accent); }
.ss-sheetadd { flex: 0 0 auto; width: 30px; border: 0; background: transparent; color: var(--color-text-secondary); font-size: 15px; cursor: pointer; }
.ss-sheetadd:hover { color: var(--color-accent); }

/* ── Account & sign-in (2026-11-07) ── */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; padding: 10px 0; }
.acct-card { border: 1px solid var(--color-border-default); border-radius: var(--r-lg); padding: 12px 14px; background: var(--color-bg-card); display: flex; flex-direction: column; gap: 8px; }
.acct-card h4 { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.acct-user { display: flex; align-items: center; gap: 10px; }
.acct-user img, .acct-avatar { width: 36px; height: 36px; border-radius: 50%; flex: 0 0 36px; }
.acct-avatar { display: inline-flex; align-items: center; justify-content: center; background: var(--color-accent); color: #fff; font-weight: 700; }
.acct-user small { display: block; color: var(--color-text-muted); font-size: 11.5px; }
.acct-note { margin: 0; color: var(--color-text-muted); font-size: 12px; }
.acct-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.acct-table th, .acct-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--color-border-default); }
.acct-table tr.acct-current td { font-weight: 600; }
.acct-kv { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--color-text-muted); }
.acct-kv code { font-size: 12px; color: var(--color-text-primary); user-select: all; word-break: break-all; }
.acct-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.acct-ok, .acct-warn { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: var(--r-pill); }
.acct-ok { background: color-mix(in srgb, #16a34a 16%, transparent); color: #16a34a; }
.acct-warn { background: color-mix(in srgb, #d97706 16%, transparent); color: #d97706; }
.acct-wide { grid-column: 1 / -1; }
.acct-table tr.acct-off td { opacity: .5; }
.acct-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct-newkey { margin-top: 6px; padding: 10px; border: 1px solid color-mix(in srgb, var(--color-accent) 45%, transparent); border-radius: var(--r-md); background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg-card)); font-size: 12px; }
.acct-newkey-row { display: flex; gap: 6px; margin-top: 6px; }
.acct-newkey-row input { flex: 1 1 auto; font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; }

/* ── 2026-11-07 Edge to edge (default). Like a desktop app: no gutter round the window — the tab bar and every section
   run to the window's edges, sections sit flush and are divided by a hairline; content keeps a small inner padding.
   Configuration ▸ Appearance ▸ Layout ▸ Spaced (data-layout="spaced" on <html>) brings the old gutters back. ── */
:root:not([data-layout="spaced"]) #main-content { padding: 0; }
:root:not([data-layout="spaced"]) .tabs-bar { margin: 0; }
:root:not([data-layout="spaced"]) #main-content > section,
:root:not([data-layout="spaced"]) .sections-grid > section { margin: 0 !important; border-radius: 0; border-bottom: 1px solid var(--color-border-default); }
:root:not([data-layout="spaced"]) #main-content > section > h2.collapsible-header,
:root:not([data-layout="spaced"]) .sections-grid > section > h2.collapsible-header { margin: 0 !important; padding: 10px 12px 0 !important; border-radius: 0; }
:root:not([data-layout="spaced"]) #main-content > section > h2.collapsible-header:has(+ .collapsible-content.collapsed),
:root:not([data-layout="spaced"]) .sections-grid > section > h2.collapsible-header:has(+ .collapsible-content.collapsed) { padding-bottom: 10px !important; }
:root:not([data-layout="spaced"]) #main-content > section > .collapsible-content,
:root:not([data-layout="spaced"]) .sections-grid > section > .collapsible-content { border-radius: 0; margin-top: 0; padding: 8px 12px 12px; }
:root:not([data-layout="spaced"]) body.is-phone #main-content > section > .collapsible-content,
:root:not([data-layout="spaced"]) body.is-phone .sections-grid > section > .collapsible-content { border-radius: 0; padding: 6px 8px 10px; }
:root:not([data-layout="spaced"]) body.is-phone #main-content > section > h2.collapsible-header,
:root:not([data-layout="spaced"]) body.is-phone .sections-grid > section > h2.collapsible-header { padding: 8px 8px 0 !important; }
:root:not([data-layout="spaced"]) #dashboard .dashboard-cards { border-radius: 0; padding: 8px 12px 10px; }
:root:not([data-layout="spaced"]) .notes-preview { top: 40px; height: calc(100vh - 88px); }

/* ── 2026-11-07 Section names in the tab bar (default; Appearance ▸ Section names ▸ On the page = data-sechdr="page"
   restores the header rows). The section headers stay in the DOM (they hold the collapse state and handlers) but are
   hidden; the bar lists the names (_secRender). Collapsed sections leave the page unless data-seccol="show". ── */
.tabs-secs { display: flex; align-items: center; gap: 6px; position: relative; flex: 0 1 auto; min-width: 0; height: 100%; padding: 0 4px 0 10px; }
.tabs-secs[hidden] { display: none; }
:root:not([data-sechdr="page"]) .tabs-bar { overflow: visible; }
.tabs-secs-acts { display: flex; align-items: center; gap: 6px; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--color-border-default); flex: 0 0 auto; }
.tabs-secs-acts[hidden] { display: none; }
.tabs-secs-acts .section-header-buttons { display: inline-flex; align-items: center; gap: 6px; flex-wrap: nowrap; margin: 0; }
.tabs-secs-acts .section-header-buttons .btn { font-size: 12px; padding: 3px 10px; }
.tabs-secs-acts .section-tab-picker { max-width: 120px; }
.tabs-secs-acts .hdr-more > .hdr-more-panel { top: calc(100% + 8px); }
.tabs-secs-list { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; height: 100%; }
.tsec-chip { display: inline-flex; align-items: center; height: 26px; border-radius: var(--r-pill); color: var(--color-accent); white-space: nowrap; flex: 0 0 auto; }
.tsec-chip.col { color: var(--color-text-muted, var(--color-text-secondary)); }
.tsec-chip button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; height: 26px; display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-pill); }
.tsec-cv { width: 22px; justify-content: center; padding: 0; font-size: 14px; line-height: 1; }
.tsec-nm { padding: 0 8px 0 2px; font-size: 13px; font-weight: 600; }
.tsec-chip button:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.tsec-n { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 14%, transparent); color: var(--color-accent); }
.tsec-chip.col .tsec-n { background: color-mix(in srgb, var(--color-text-secondary) 12%, transparent); color: inherit; }
.tsec-title { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--color-accent); white-space: nowrap; padding: 0 6px; }
.tabs-secs-ind { position: absolute; bottom: 0; height: 3px; background: var(--color-accent); border-radius: 0; pointer-events: none; transition: left .18s ease, width .18s ease; display: none; }
.tabs-secs-menu { display: none; background: none; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); color: var(--color-accent); font: inherit; font-size: 12px; font-weight: 600; height: 26px; padding: 0 10px; cursor: pointer; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.tabs-secs.compact .tabs-secs-menu { display: inline-flex; align-items: center; }
.tabs-secs.compact .tabs-secs-list { display: none; }
.tabs-secs.compact.open .tabs-secs-list { display: flex; flex-direction: column; align-items: stretch; position: absolute; right: 0; top: calc(100% + 4px); height: auto; overflow: visible; z-index: 700; min-width: 220px; padding: 6px; gap: 2px; background: var(--color-bg-modal); border: 1px solid var(--color-border-default); border-radius: var(--r-lg); box-shadow: var(--shadow-dropdown); }
.tabs-secs.compact.open .tsec-chip, .tabs-secs.compact.open .tsec-chip button { height: 34px; }
.tabs-secs.compact.open .tsec-nm { flex: 1; justify-content: flex-start; }
.tabs-secs.compact.open .tsec-chip.cur { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
/* the page */
:root:not([data-sechdr="page"]) #main-content > section > h2.collapsible-header,
:root:not([data-sechdr="page"]) .sections-grid > section > h2.collapsible-header { display: none !important; }
:root:not([data-sechdr="page"]) #main-content > section,
:root:not([data-sechdr="page"]) .sections-grid > section { overflow: clip; overflow-clip-margin: 14px; position: relative; scroll-margin-top: 44px; }
:root:not([data-sechdr="page"]):not([data-seccol="show"]) #main-content > section:has(> h2.collapsible-header.collapsed),
:root:not([data-sechdr="page"]):not([data-seccol="show"]) .sections-grid > section:has(> h2.collapsible-header.collapsed) { display: none !important; }
:root:not([data-sechdr="page"])[data-seccol="show"] #main-content > section > h2.collapsible-header.collapsed,
:root:not([data-sechdr="page"])[data-seccol="show"] .sections-grid > section > h2.collapsible-header.collapsed { display: flex !important; align-items: center; gap: 6px; height: 26px; margin: 0 !important; padding: 0 12px !important; font-size: 12.5px; cursor: pointer; }
:root:not([data-sechdr="page"])[data-seccol="show"] section > h2.collapsible-header.collapsed .section-header-buttons { display: none; }
:root:not([data-sechdr="page"]) #main-content > section > .collapsible-content,
:root:not([data-sechdr="page"]) .sections-grid > section > .collapsible-content { padding-top: 12px; }
.sec-dl { display: none; }
:root:not([data-sechdr="page"]) #main-content > section:not(:has(> h2.collapsible-header.collapsed)) > .sec-dl,
:root:not([data-sechdr="page"]) .sections-grid > section:not(:has(> h2.collapsible-header.collapsed)) > .sec-dl { display: inline-flex; align-items: center; position: absolute; top: -9px; left: 10px; z-index: 5; height: 18px; padding: 0 8px; font: inherit; font-size: 11px; font-weight: 600; line-height: 1; color: var(--color-text-secondary); background: var(--app-bg, var(--color-bg-page)); border: 1px solid var(--color-border-default); border-radius: var(--r-pill); cursor: pointer; }
:root:not([data-sechdr="page"]) #main-content > section.sec-first > .sec-dl,
:root:not([data-sechdr="page"]) .sections-grid > section.sec-first > .sec-dl { display: none !important; }
:root:not([data-sechdr="page"]) .sec-dl:hover { color: var(--color-accent); border-color: var(--color-accent); }
.tabs-secs-empty { order: 0; padding: 40px 16px; text-align: center; color: var(--color-text-secondary); font-size: 13px; }
.tabs-secs-empty[hidden] { display: none; }
.tabs-secs-empty > div { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ── 2026-11-07 round 4 ── */
/* Chevron: the same SVG as the section headers; points right when collapsed. */
.tsec-ic { flex-shrink: 0; transition: transform .2s ease; }
.tsec-chip.col .tsec-ic, .tsec-exp .tsec-ic { transform: rotate(-90deg); }
.tsec-cv { width: 22px; }
.sec-dl .tsec-ic { width: 10px; height: 10px; margin-right: 4px; }
.tsec-exp { display: inline-flex; align-items: center; gap: 6px; }
/* 1. Tasks / Cards rail flush with the tab bar and the window's left edge, full height, like a desktop sidebar. */
:root:not([data-layout="spaced"]) body:not(.is-phone) :is(#main-content, .sections-grid) > section > .collapsible-content:has(> .tk-bg-on > .tk-wrap:not(.tk-norail), > .tk-wrap:not(.tk-norail)) { padding: 0 !important; }
@media (min-width: 768px) {
  :root:not([data-layout="spaced"]) body:not(.is-phone) :is(#main-content, .sections-grid) > section > .collapsible-content > .tk-bg-on > .tk-wrap:not(.tk-norail) > .tk-rail,
  :root:not([data-layout="spaced"]) body:not(.is-phone) :is(#main-content, .sections-grid) > section > .collapsible-content > .tk-wrap:not(.tk-norail) > .tk-rail {
      border-radius: 0; top: var(--tabs-bar-height, 36px); height: calc(100vh - var(--tabs-bar-height, 36px) - 36px); max-height: none; align-self: flex-start;
      border-right: 1px solid var(--color-border-default); padding: 10px 8px 12px; }
  :root:not([data-layout="spaced"]) body:not(.is-phone) :is(#main-content, .sections-grid) > section > .collapsible-content > .tk-bg-on > .tk-wrap:not(.tk-norail) > .tk-main,
  :root:not([data-layout="spaced"]) body:not(.is-phone) :is(#main-content, .sections-grid) > section > .collapsible-content > .tk-wrap:not(.tk-norail) > .tk-main { padding: 10px 12px 12px 4px; min-width: 0; }
}
/* 3. Notes: the list and the preview both start right under the tab bar; the preview stays pinned there while the list scrolls. */
:root:not([data-sechdr="page"]) #main-content > #notes > .collapsible-content { padding-top: 6px; }
:root:not([data-layout="spaced"]) .notes-preview { top: var(--tabs-bar-height, 36px); height: calc(100vh - var(--tabs-bar-height, 36px) - 42px); }
/* 4. A narrow task panel or list (a matrix quadrant, a note's Tasks pane): the title gets the whole first line and the
   chips (tags, assignee, note, due) move to a second line, instead of squeezing the title into a one-letter column. */
.tk-list, .tk-panel-body { container: tkrows / inline-size; }
@container tkrows (max-width: 480px) {
  .tk-row { flex-wrap: wrap !important; row-gap: 3px; }
  .tk-row > .tk-title { flex: 1 1 calc(100% - 80px) !important; min-width: 0 !important; }
  .tk-row > .tk-meta { flex: 1 1 100% !important; max-width: none !important; flex-wrap: wrap; justify-content: flex-start; padding-left: 26px; row-gap: 4px; }
}

/* ── 2026-11-07 round 5 ── */
/* Pane actions: ⤢ focus / ↗ own window, on every section header of a note (also when the section is collapsed). */
.nw-pane-acts { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; margin: 0 2px; }
.nw-pane-act { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 4px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--color-text-secondary); font-size: 13px; line-height: 1; cursor: pointer; }
.nw-pane-act:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.nw-pane-act.on { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.nw-pane-act[hidden] { display: none !important; }
.note-window .nw-pane-collapsed.nw-pane-collapsed > .nw-pane-head.nw-pane-head > .nw-pane-acts.nw-pane-acts.nw-pane-acts { display: inline-flex !important; }
/* 2026-11-09: Focus shows on collapsed sections too (it opens them) */
.note-window .nw-links-head > .nw-pane-acts { order: 99; }
.note-window .nw-props-summary > .nw-pane-acts { margin-left: auto; }
/* the ↗ in the pane actions replaces the older ones in a note's layout */
.note-window .nwl .nw-bd-pop, .note-window .nwl .nw-ch-pop { display: none !important; }
body.is-phone .nw-pane-floatbtn { display: none !important; }
/* ⤢ focus: the focused pane takes the whole layout; the rest are only hidden, so ⤡ restores everything as it was. */
.note-window .nwl.nwl-focus > .nwl-gv, .note-window .nwl.nwl-focus .nwl-gh { display: none !important; }
.note-window .nwl.nwl-focus > .nwl-col:not(:has(> .nwl-focused)) { display: none !important; }
/* 2026-11-16: the focused pane's column is the only one left, but it kept its saved width weight (--nwl-w). A flex-grow
   below 1 takes only that fraction of the free space, so a pane in a right column (weight 0.85: Graph, AI Chat, boards,
   Files) filled 85% of the window. The lone column always grows 1. */
.note-window .nwl.nwl-focus > .nwl-col:has(> .nwl-focused) { flex: 1 1 0 !important; }
body .note-window .nw-split-container .nwl.nwl-focus > .nwl-col > .nwl-p:not(.nwl-focused) { display: none !important; }
body .note-window .nw-split-container .nwl.nwl-focus > .nwl-col > .nwl-p.nwl-focused { flex: 1 1 0 !important; }
.note-window .nwl.nwl-flat.nwl-focus > .nwl-col:has(> .nwl-focused) { height: 100%; }
body .note-window .nw-split-container .nwl.nwl-flat.nwl-focus > .nwl-col > .nwl-p.nwl-focused { height: 100% !important; flex: 1 1 auto !important; }
.note-window .nwl.nwl-focus .nwl-focused > .nw-links-body { height: auto !important; flex: 1 1 auto; }
/* ↗ own window: the pane floats above the page (same pane, same note), dragged by its header, resized from the corner. */
body .note-window .nw-split-container .nwl > .nwl-p.nwl-float {
    position: fixed !important; left: var(--fl-x, 80px); top: var(--fl-y, 90px); width: var(--fl-w, 600px) !important; height: var(--fl-h, 520px) !important;
    max-width: calc(100vw - 8px); max-height: calc(100vh - 8px); min-width: 260px; min-height: 120px; z-index: 60; margin: 0 !important;
    display: flex !important; flex-direction: column; resize: both; overflow: hidden; box-sizing: border-box;
    background: var(--color-bg-card); border: 1px solid var(--color-border-strong, var(--color-border-default)) !important; border-top: 3px solid var(--nw-color, var(--color-accent)) !important;
    border-radius: var(--r-lg) !important; box-shadow: var(--shadow-note-window, 0 12px 40px rgba(0,0,0,.28));
}
body .note-window .nw-split-container .nwl > .nwl-p.nwl-float[style*="display: none"] { display: none !important; }
.note-window .nwl > .nwl-float > :is(.nw-pane-head, .nw-links-head, .nw-props-summary) { cursor: move; flex: 0 0 auto; }
.note-window .nwl > .nwl-float > :is(.nw-pane-head, .nw-links-head, .nw-props-summary) > :is(.nwl-grip, .nw-pane-chev) { display: none !important; }
.note-window .nwl > .nwl-float > .nw-ed-bar[hidden] { display: flex !important; }
.note-window .nwl > .nwl-float.nw-links-sec > .nw-links-body { height: auto !important; flex: 1 1 auto; min-height: 0; overflow: auto; display: block; }
.note-window .nwl > details.nwl-float > .nw-props-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.note-window .nwl > .nw-editor-area.nwl-float > :not(.nw-ed-bar) { min-height: 0; }

/* Sheet tabs: upside-down tabs hanging from the sheet, Excel style — the active one is the sheet's own colour and joins it. */
.ss-sheetbar { align-items: flex-start; min-height: 30px; padding: 0 6px 4px; border-top: 1px solid var(--color-border-strong, var(--color-border-default)); }
.ss-sheettabs { gap: 2px; padding-bottom: 2px; align-items: flex-start; }
.ss-sheettab {
    margin-top: -1px; padding: 4px 16px 5px; border: 1px solid var(--color-border-default); border-top: 0; border-radius: 0 0 8px 8px;
    background: color-mix(in srgb, var(--color-text-primary) 5%, var(--color-bg-secondary)); color: var(--color-text-secondary); line-height: 1.3;
}
.ss-sheettab:hover { background: color-mix(in srgb, var(--color-text-primary) 9%, var(--color-bg-secondary)); }
.ss-sheettab.active {
    background: var(--color-bg-primary); color: var(--color-text-primary); font-weight: 600; position: relative; z-index: 1;
    border-color: var(--color-border-strong, var(--color-border-default)); border-top: 1px solid var(--color-bg-primary);
    box-shadow: inset 0 -2px 0 var(--color-accent), 0 2px 4px rgba(0,0,0,.08);
}
.ss-sheettab.nw-db-tab-ins-before { box-shadow: inset 2px 0 0 var(--color-accent); }
.ss-sheettab.nw-db-tab-ins-after { box-shadow: inset -2px 0 0 var(--color-accent); }
.ss-sheetadd { align-self: flex-start; height: 26px; margin-top: 1px; border-radius: 0 0 8px 8px; }
.ss-sheetadd:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nw-pane-acts { margin-left: auto; }
.note-window .nw-links-sec.nw-links-collapsed.nw-links-collapsed .nw-links-head.nw-links-head > .nw-pane-acts.nw-pane-acts { display: inline-flex !important; }

/* ── 2026-11-08 build with ai ── */
.nw-dbai-modal .modal-body { display: flex; flex-direction: column; gap: 10px; }
.nw-dbai-lead { margin: 0; color: var(--color-text-secondary); font-size: 13px; line-height: 1.45; }
.nw-dbai-text { width: 100%; box-sizing: border-box; min-height: 110px; resize: vertical; padding: 10px 12px; font: inherit; font-size: 14px;
    border: 1px solid var(--color-border-default); border-radius: var(--r-md, 10px); background: var(--color-bg-primary); color: var(--color-text-primary); }
.nw-dbai-text:focus { outline: none; border-color: var(--color-accent, #7c4dff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent, #7c4dff) 20%, transparent); }
.nw-dbai-ex { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-secondary); }
.nw-dbai-chip { border: 1px solid var(--color-border-default); background: var(--color-bg-secondary); color: var(--color-text-primary);
    border-radius: var(--r-pill, 999px); padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.nw-dbai-chip:hover { border-color: var(--color-accent, #7c4dff); }
.nw-dbai-botl { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-secondary); }
.nw-dbai-botl select { flex: 1; min-width: 0; }

/* 2026-11-08 totals row: a footer under database tables (click a cell to choose) + per-group subtotals */
.nw-db-table tfoot td.nw-db-total-td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding: 4px 8px;
    white-space: nowrap;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    background: var(--color-bg-secondary);
    border-top: 2px solid var(--color-border-default);
}
.nw-db-table tfoot td.nw-db-total-td.has { font-weight: 600; }
.nw-db-table tfoot td.nw-db-total-td:hover { background: var(--color-accent-tint-soft, var(--color-bg-tertiary)); }
.nw-db-table tfoot td.nw-db-total-actions { cursor: default; }
.nw-db-table tfoot td.nw-db-total-actions:hover { background: var(--color-bg-secondary); }
.nw-db-total-lbl {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    margin-right: 3px;
}
.nw-db-total-add { font-size: 11px; font-weight: 400; color: var(--color-text-secondary); opacity: 0; transition: opacity .12s; }
.nw-db-table:hover .nw-db-total-add, .nw-db-total-td:focus-within .nw-db-total-add { opacity: .75; }
.nw-db-tfoot:not(.has) td.nw-db-total-td { border-top-width: 1px; padding-top: 2px; padding-bottom: 2px; }
.nw-db-total-err { color: var(--color-danger, #ef4444); font-weight: 600; }
tr.nw-db-subtotal-tr > td {
    padding: 3px 8px 5px;
    white-space: nowrap;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px solid var(--color-border-default);
    background: color-mix(in srgb, hsl(var(--grp-h, 211) 70% 50%) 5%, var(--color-bg-primary));
}
@media (hover: none) { .nw-db-total-add { opacity: .6; } }

/* 2026-11-08 files column: cell thumbnails, row-form editor, library picker */
.nw-db-files { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nw-db-file { display: inline-flex; align-items: center; gap: 4px; max-width: 180px; padding: 2px 6px 2px 2px; font: inherit; font-size: 11px; color: var(--color-text-primary);
    background: var(--color-bg-secondary); border: 1px solid var(--color-border-default); border-radius: var(--r-md); cursor: pointer; }
.nw-db-file.img { padding: 0; border-radius: var(--r-sm); overflow: hidden; }
.nw-db-file:hover { border-color: var(--color-accent); }
.nw-db-file.gone { opacity: .55; }
.nw-db-file-th { width: 32px; height: 32px; object-fit: cover; display: block; border-radius: var(--r-sm); }
.nw-db-file:not(.img) .nw-db-file-th { width: 18px; height: 18px; }
.nw-db-file-ic { display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.nw-db-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-db-file-more { font-size: 11px; color: var(--color-text-secondary); padding: 0 3px; }
.nw-db-files-edit { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px dashed var(--color-border-default); border-radius: var(--r-md); outline: none; }
.nw-db-files-edit:focus-within, .nw-db-files-edit:focus { border-color: var(--color-accent); }
.nw-db-files-edit.drag { border-style: solid; border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.nw-db-files-list { display: flex; flex-wrap: wrap; gap: 6px; }
.nw-db-files-list:empty { display: none; }
.nw-db-files-item { position: relative; display: inline-flex; }
.nw-db-files-open { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 84px; padding: 4px; font: inherit; font-size: 11px; color: var(--color-text-primary);
    background: var(--color-bg-secondary); border: 1px solid var(--color-border-default); border-radius: var(--r-md); cursor: pointer; }
.nw-db-files-open:hover { border-color: var(--color-accent); }
.nw-db-files-th { width: 72px; height: 56px; object-fit: cover; border-radius: var(--r-sm); font-size: 26px; }
.nw-db-files-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.nw-db-files-x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0; line-height: 16px; font-size: 13px; border-radius: 50%;
    border: 1px solid var(--color-border-default); background: var(--color-bg-primary); color: var(--color-text-secondary); cursor: pointer; }
.nw-db-files-x:hover { color: var(--color-danger, #ef4444); border-color: var(--color-danger, #ef4444); }
.nw-db-files-act { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nw-db-files-hint { font-size: 11px; color: var(--color-text-secondary); }
.nw-dbfp-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 10, 18, .45); padding: 16px; }
.nw-dbfp { display: flex; flex-direction: column; width: min(560px, 100%); max-height: min(640px, 90vh); background: var(--color-bg-primary); color: var(--color-text-primary);
    border: 1px solid var(--color-border-default); border-radius: var(--r-xl); box-shadow: 0 18px 48px rgba(0, 0, 0, .35); overflow: hidden; }
.nw-dbfp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--color-border-default); }
.nw-dbfp-bar { display: flex; gap: 8px; padding: 8px 12px; }
.nw-dbfp-q { flex: 1; min-width: 0; }
.nw-dbfp-list { flex: 1; overflow: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.nw-dbfp-item { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 5px 8px;
    font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: var(--r-md); cursor: pointer; }
.nw-dbfp-item:hover { background: var(--color-bg-secondary); }
.nw-dbfp-item.on { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.nw-dbfp-th { grid-row: 1 / 3; width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-sm); font-size: 22px; }
.nw-dbfp-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-dbfp-meta { font-size: 11px; color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 2026-11-09 — the schema-filter bar shares the view switcher's line (tabs · Filter · + View / Edit view). One line:
   when it is full the view tabs give way to their dropdown (_vtFit), and the filter select shortens. */
.nw-db-switcher > .nw-db-fbar { padding: 0; border-bottom: 0; background: transparent; flex: 0 1 auto; min-width: 0; gap: 10px; flex-wrap: nowrap; }
.nw-db-switcher > .nw-db-fbar label { min-width: 0; white-space: nowrap; }
.nw-db-switcher > .nw-db-fbar select { min-width: 90px; max-width: 220px; text-overflow: ellipsis; }
.nw-db-switcher > .nw-db-fbar .nw-db-fbar-dyn input { width: 120px; }

/* 2026-11-09 — Linked / Linked From show each note's cover like the Notes list: a band across a card, a small
   thumbnail before the title in a list row or chip. */
.nw-links-cd.has-cover { overflow: hidden; }
.nw-links-cd > .nw-links-cd-cover { flex: 0 0 auto; height: 34px; margin: -6px -8px 2px; background: var(--cc) center var(--cp, 50%) / cover no-repeat; border-bottom: 1px solid var(--color-border-default); }
.nw-links-li-title > .nw-links-cover,
.nw-linked-chip > .nw-links-cover { display: inline-block; vertical-align: -3px; width: 24px; height: 15px; margin-right: 6px; border-radius: var(--r-sm); background: var(--cc) center var(--cp, 50%) / cover no-repeat; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-border-default) 70%, transparent); }
.nw-linked-chip > .nw-links-cover { width: 18px; height: 12px; margin: 0 2px 0 -4px; vertical-align: middle; flex: 0 0 auto; }
/* 2026-11-09 — task window: linked cards (Links ▸ Cards), chips in the card's colour. */
.tk-cardchip { display: inline-flex; align-items: center; gap: 3px; }
/* 2026-11-09 — every picker popover's filter hides rows with the hidden attribute; .tk-tagpop-row's display:flex was
   overriding it (only the file-tag picker had the rule), so "+ card" and "+ note" never narrowed. */
.tk-tagpop-row[hidden] { display: none !important; }

/* ── Compact text (2026-11-09, Joey): no forced space above or below paragraphs or plain toggles — lines sit like
   Notion's. A toggle with a border or background keeps a little room inside and around it. Headings and lists keep
   their own spacing. Editor and rendered notes match. ── */
.tiptap-editor-content .ProseMirror > * + * { margin-top: 0; }
.tiptap-editor-content .ProseMirror p { margin: 0; }
.tiptap-editor-content .ProseMirror div[data-type="details"] { margin: 0; }
.tiptap-editor-content .ProseMirror div[data-type="details"] > div > summary { padding: 0 8px 0 2px; line-height: 1.65; }
.tiptap-editor-content .ProseMirror div[data-type="details"] > button, .tiptap-editor-content .ProseMirror div[data-type="details"][data-heading] > button { font-size: inherit; height: 1.65em; margin-top: 0; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="1"] > button { height: 2.08em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="2"] > button { height: 1.76em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="3"] > button { height: 1.57em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="4"] > button { height: 1.6em; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="1"] > div > summary { line-height: 1.3; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="2"] > div > summary { line-height: 1.35; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="3"] > div > summary { line-height: 1.4; }
.tiptap-editor-content .ProseMirror div[data-type="details"][data-heading="4"] > div > summary { line-height: 1.6; }
.tiptap-editor-content .ProseMirror div[data-type="detailsContent"] { padding: 0 8px 0 2px; }
.tiptap-editor-content .ProseMirror div[data-type="details"]:is([data-box], [data-shade]) { margin: 0.3em 0; }
.tiptap-editor-content .ProseMirror div[data-type="details"]:is([data-box], [data-shade]) > div > summary { padding-top: 3px; padding-bottom: 3px; }
.tiptap-editor-content .ProseMirror div[data-type="details"]:is([data-box], [data-shade]) > button { margin-top: 3px; }
.tiptap-editor-content .ProseMirror div[data-type="details"]:is([data-box], [data-shade]) > div > div[data-type="detailsContent"] { padding-bottom: 4px; }
.note-content p, .about-content p, .note-card-content p { margin: 0; }
.note-content details, .about-content details { margin: 0; }
.note-content details > summary, .about-content details > summary { padding-top: 0; padding-bottom: 0; line-height: 1.65; }
.note-content details > div[data-type="detailsContent"], .about-content details > div[data-type="detailsContent"] { padding-top: 0; padding-bottom: 0; }
.note-content details:is([data-box], [data-shade]), .about-content details:is([data-box], [data-shade]) { margin: 0.3em 0; }
.note-content details:is([data-box], [data-shade]) > summary, .about-content details:is([data-box], [data-shade]) > summary { padding-top: 3px; padding-bottom: 3px; }
.note-content details:is([data-box], [data-shade]) > div[data-type="detailsContent"], .about-content details:is([data-box], [data-shade]) > div[data-type="detailsContent"] { padding-bottom: 4px; }
/* ── Hidden sections (Note, Linked, Linked From, Properties — ⋯ switches / ✕), 2026-11-09 ── */
body .note-window .nwl-hidden.nwl-hidden { display: none !important; }
.nw-pane-acts > .nw-pane-hide { font-size: 12px; }
/* ── Note ⋯ menu: section switches under one "Sections" row, a compact two-column grid (2026-11-09) ── */
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs-btn { user-select: none; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs-btn > .nw-secs-n { margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--color-text-muted); }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs-btn > .nw-secs-chev { flex: 0 0 auto; font-size: 11px; color: var(--color-text-secondary); transition: transform .15s; }
.nw-titlebar-btns.hdr-more.nw-secs-open > .hdr-more-panel > .nw-secs-btn[data-g="sec"] > .nw-secs-chev,
.nw-titlebar-btns.hdr-more.nw-bds-open > .hdr-more-panel > .nw-secs-btn[data-g="bd"] > .nw-secs-chev { transform: rotate(180deg); }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin: -2px 0 2px; }
.nw-titlebar-btns.hdr-more.nw-secs-open > .hdr-more-panel > .nw-secs[data-g="sec"],
.nw-titlebar-btns.hdr-more.nw-bds-open > .hdr-more-panel > .nw-secs[data-g="bd"] { display: grid; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs > .nw-bdbtns { display: contents; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-item.hdr-item { height: 28px; min-height: 28px; padding: 0 6px 0 8px; gap: 6px; font-size: 12px; border-radius: var(--r-md); min-width: 0; width: auto; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-item .hdr-ic { flex-basis: 15px; width: 15px; font-size: 12.5px; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-item .hdr-more-label { flex: 1 1 auto; min-width: 0; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-sw { flex: 0 0 24px; width: 24px; height: 14px; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-sw::before { top: 2px; left: 2px; width: 10px; height: 10px; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs .hdr-tog:is(.active, .on) > .hdr-sw::before { transform: translateX(10px); }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs > .nw-bd-menu-btn { display: none !important; }   /* its switching is the grid above; New / Manage are the two rows below */
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs > .nw-secs-new { order: 1000; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs > .nw-secs-mgr { order: 1001; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-secs > .nw-secs-act.hdr-item { margin-top: 2px; border-style: dashed; color: var(--color-text-secondary); }
/* ⋯ menu group labels: Note · Appearance · Layout (2026-11-09) */
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-menu-head { padding: 6px 6px 0; font: 600 10.5px/1.2 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-menu-head:first-child { padding-top: 0; }
.nw-titlebar-btns.hdr-more > .hdr-more-panel > .nw-menu-head:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--color-border-default); padding-top: 9px; }

/* ── Database boards (2026-11-10): a board pane holding a database-only window (Docs/DATABASE_BOARDS_PLAN.md) ── */
.nw-bd-pane > .nw-tk-body.nw-bd-dbbody { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.note-window .note-window.nw-inline.nw-dbboard { position: static !important; flex: 1 1 auto !important; width: 100% !important; min-width: 0 !important; height: auto !important; min-height: 0 !important; max-height: none !important; resize: none !important; border: none !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; z-index: auto !important; }
.note-window .note-window.nw-dbboard .nw-titlebar, .note-window .note-window.nw-dbboard .nw-footer, .note-window .note-window.nw-dbboard .nw-remote-banner { display: none !important; }
.note-window .note-window.nw-dbboard > .nw-body, .note-window .note-window.nw-dbboard .nw-db-pane { background: transparent !important; }
.note-window .note-window.nw-dbboard.nw-dbb-lockdb .nw-db-tabs { display: none !important; }
.note-window .note-window.nw-dbboard .nw-db-tabs { border-top: 0; }
/* Database board dialog (phase 3) */
.bd-db-modal .bd-db-icons { margin-top: 6px; max-width: 360px; }
.bd-db-modal .bd-db-locks { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.bd-db-modal .bd-db-off { opacity: .55; }
.bd-db-modal select { max-width: 100%; }
.bd-db-modal .tk-ve-inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* ⋯ menu Boards / Sections rows (phase 4) are for note windows: a database, board or chat window has none of them */
:is(.note-window.nw-dbonly, .note-window.nw-taskonly) .nw-titlebar-btns.hdr-more > .hdr-more-panel > :is(.nw-secs-btn, .nw-secs, .nw-menu-head) { display: none !important; }
/* Task ↔ card link chips on boards (2026-11-11) */
.tk-linkchip { cursor: pointer; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-linkchip.tk-linkchip-c { box-shadow: inset 3px 0 0 var(--lc); }
.tk-linkchip-done, .tk-tagpick.tk-linkchip-done .tk-notechip-t { text-decoration: line-through; opacity: .7; }
.tk-linkchip-more { font-weight: 600; }
/* Files on tasks and cards (2026-11-11) */
.tk-filechip { cursor: pointer; font-weight: 600; }
.tk-tagpop.tk-filepick { width: min(460px, calc(100vw - 32px)); }
.tk-tagpop.tk-filepick .tk-notepop-list { max-height: min(420px, 60vh); }

/* ── @ links (refMention chips) and the grouped @ menu (2026-11-11, links phase 3) ── */
.nw-slash-menu { max-width: min(420px, calc(100vw - 16px)); }
.nw-slash-group { padding: 6px 8px 2px; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); }
.nw-slash-group:first-child { padding-top: 2px; }
.nw-slash-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-slash-sub { margin-left: auto; padding-left: 10px; max-width: 45%; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--color-text-muted); }
.nw-ref { display: inline; padding: 0 6px 0 4px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 11%, transparent); border: 1px solid color-mix(in srgb, var(--color-accent) 24%, transparent); color: var(--color-text-primary); font-weight: 500; cursor: pointer; text-decoration: none; white-space: normal; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.nw-ref::before { content: '📄'; margin-right: 3px; font-size: .88em; }
.nw-ref[data-kind="task"]::before { content: '✓'; color: var(--color-accent); font-weight: 700; }
.nw-ref[data-kind="task"][data-ik="event"]::before { content: '📅'; font-weight: 400; }
.nw-ref[data-kind="card"]::before { content: '▣'; color: var(--color-accent); }
.nw-ref[data-kind="file"]::before { content: '📎'; }
.nw-ref[data-kind="row"]::before { content: '▦'; color: var(--color-accent); }
.nw-ref:hover { background: color-mix(in srgb, var(--color-accent) 20%, transparent); }
.nw-ref.nw-ref-done { color: var(--color-text-secondary); text-decoration: line-through; text-decoration-color: var(--color-text-muted); }
.nw-ref.nw-ref-gone { color: var(--color-text-muted); background: transparent; border-style: dashed; border-color: var(--color-border-default); text-decoration: line-through; }
.nw-ref.nw-ref-gone::before { content: '✕'; color: var(--color-text-muted); font-weight: 400; }
.nw-ref.ProseMirror-selectednode { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.tk-mentionchip .tk-notechip-t { cursor: pointer; }

/* ── Sub-note tree in the Notes list (2026-11-11, links phase 4) ── */
.st-head { display: flex; align-items: center; gap: 5px; padding: 0 4px 2px; font-size: 10.5px; font-weight: 600; color: var(--color-text-muted); cursor: pointer; user-select: none; }
.st-head:hover, .st-head:focus-visible { color: var(--color-accent); outline: none; }
.st-chev { display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-muted); flex-shrink: 0; }
.st-chev .chev { width: 12px; height: 12px; }   /* the dashboard chevron (CHEVRON_SVG): .open > .chev turns it down */
.st-chev-btn { flex: 0 0 18px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; }
.st-chev-btn:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.st-chev-btn:hover .st-chev { color: var(--color-accent); }
.st-chev-sp { flex: 0 0 18px; width: 18px; }
.st-row { gap: 4px; }
.st-row .st-ind { flex: 0 0 auto; width: calc(var(--st-d, 0) * 14px); }
.st-loop { flex: 0 0 auto; font-size: 11px; color: var(--color-text-muted); }
.st-match .nl-row-t, .note-row.st-match .note-row-title { color: var(--color-accent); }
.st-from { padding: 3px 4px 0; font-size: 10.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-from-n { cursor: pointer; }
.st-from-n:hover, .st-from-n:focus-visible { color: var(--color-accent); text-decoration: underline; outline: none; }
.st-from-more { color: var(--color-text-muted); }
.note-row .st-chev-btn, .note-row .st-chev-sp { margin-right: -4px; }
.note-row.st-sub { margin-left: calc(min(var(--st-d, 1), 6) * 14px); background: color-mix(in srgb, var(--color-bg-card) 82%, transparent); }
.note-row.st-sub .note-row-date, .note-row.st-sub .note-mini-tag, .note-row.st-sub .note-row-thumb { display: none; }
.note-row.st-sub .note-row-side { max-width: 30%; }
.note-row.st-sub .note-row-snip { display: none; }
.note-card.st-context, .note-row.st-context { opacity: .62; }
.note-card.st-context:hover, .note-row.st-context:hover { opacity: .9; }
.st-allrow { display: flex; gap: 6px; padding-top: 2px; padding-bottom: 4px; }
body.is-phone .note-row.st-sub { margin-left: calc(min(var(--st-d, 1), 4) * 10px); }

/* ══ 2026-11-13 Phone pass 2 (Joey): less clutter — one ⋯ per toolbar (_phFoldScan), a dropdown tab bar, sections run
   their full length (only a database table scrolls in its own box), bigger icons, reminders can be put away.
   Phone rules start with `html body.is-phone` so they beat the touch floor; nothing here changes a desktop except the
   "Bigger icons" and "Reminders" blocks, which are for both. ══ */

/* ⋯ fold buttons: phone only */
.ph-fold-host { display: none !important; }
html body.is-phone .ph-fold-host { display: inline-flex !important; flex: 0 0 auto; margin-left: auto; align-items: center; }
html body.is-phone .ph-fold-btn { min-width: 42px; min-height: 38px; padding: 0 10px; font-size: 20px; line-height: 1; letter-spacing: 1px; border-radius: var(--r-pill); border: 1px solid var(--color-border-default); background: var(--color-bg-card); color: var(--color-text-primary); cursor: pointer; }
.ph-fold.hdr-more { position: fixed; top: 0; left: 0; width: 0; height: 0; display: block; }
.ph-fold > .hdr-more-panel { position: fixed; min-width: 250px; max-width: calc(100vw - 16px); }
.ph-fold .ph-fold-head { padding: 8px 6px 0; font: 600 10.5px/1.2 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.ph-fold .ph-fold-note { padding: 2px 6px 2px; font-size: 12px; color: var(--color-text-muted); white-space: normal; }
.ph-fold-check { margin-left: auto; padding-left: 8px; color: var(--color-accent); font-weight: 700; }
.ph-fold .hdr-item.ph-radio.on { border-color: var(--color-accent); color: var(--color-accent); font-weight: 600; }
.ph-fold .hdr-item.ph-danger { color: var(--color-status-danger); }
html body.is-phone .ph-fold > .hdr-more-panel .hdr-item.hdr-item { height: 42px; min-height: 42px; font-size: 14px; }
html body.is-phone .ph-fold > .hdr-more-panel .hdr-more-sel > select { height: 38px; min-height: 0; font-size: 14px; }
html body.is-phone :is(.hdr-more-btn, .tk-panel-flt) { font-size: 18px; }

/* Tasks / Cards boards: + New and Search on one row, everything else in ⋯ */
html body.is-phone .tk-main:has(> .tk-toolbar) > .tk-switcher,
html body.is-phone .tk-main > .tk-toolbar > :is(.tk-rail-toggle, .tk-more, .tk-count) { display: none !important; }
html body.is-phone .tk-main > .tk-toolbar { flex-wrap: nowrap; gap: 6px; }
html body.is-phone .tk-main > .tk-toolbar > .tk-search { flex: 1 1 auto; min-width: 0; width: auto; }
html body.is-phone .tk-main > .tk-toolbar > .tk-new-btn { flex: 0 0 auto; }
html body.is-phone .tk-main > .tk-toolbar > .ph-fold-host { margin-left: 0; }
/* Files: the view tab stays, the rest in ⋯ */
html body.is-phone .tk-main > .nw-fp-views > .nw-db-vtabs > .tk-rail-toggle,
html body.is-phone .tk-main > .nw-fp-views > .nw-db-vtools { display: none !important; }
html body.is-phone .tk-main > .nw-fp-views { flex-wrap: nowrap; align-items: center; }
/* A database: its view, Filter and search stay; the header's tools, the row buttons and the view tools are in ⋯ */
html body.is-phone .nw-db-pane > .nw-db-tabs > .nw-db-tabtools,
html body.is-phone .nw-db-pane .nw-db-toolbar > :is(.nw-db-toolbar-left, .nw-db-toolbar-right),
html body.is-phone .nw-db-pane .nw-db-switcher:not(.tk-switcher):not(.nw-fp-views) > .nw-db-vtools { display: none !important; }
html body.is-phone .nw-db-pane .nw-db-toolbar { overflow: visible; }
html body.is-phone .nw-db-pane .nw-db-toolbar > .nw-db-filter { flex: 1 1 auto; min-width: 0; width: 100%; }
html body.is-phone .nw-db-pane > .nw-db-tabs > .ph-fold-host { order: 5; }
/* Section headers in a note window: chevron, grip, title (and any crumbs) stay; their buttons are in ⋯ */
html body.is-phone .note-window :is(.nw-pane-head, .nw-links-head):not(.nw-db-tabs) > button:not(.nw-pane-chev):not(.nwl-grip):not(.nw-links-toggle):not(.ph-fold-btn),
html body.is-phone .note-window :is(.nw-pane-head, .nw-links-head):not(.nw-db-tabs) > .nw-pane-acts { display: none !important; }

/* Note window: the desktop's grouped ⋯ menu (Note · Appearance · Layout, with switches) on a phone too */
html body.is-phone .phone-full > .nw-titlebar .nw-titlebar-btns.hdr-more > .hdr-more-btn { display: inline-flex !important; align-items: center; justify-content: center; min-width: 40px; min-height: 36px; font-size: 20px; }
html body.is-phone .phone-full > .nw-titlebar .nw-titlebar-btns.hdr-more > .hdr-more-panel { min-width: 260px; }
html body.is-phone .phone-full > .nw-titlebar .nw-titlebar-btns.hdr-more > .hdr-more-panel .hdr-item.hdr-item { height: 42px; min-height: 42px; font-size: 14px; }

/* The tab bar: ☰ Tab ▾ · Section ▾ · ⋯ */
.ph-tabs-btn { display: none; }
html body.is-phone #tabs-strip, html body.is-phone #tabs-add-btn { display: none !important; }
html body.is-phone .ph-tabs-btn { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 46vw; min-height: 34px; margin: auto 0; padding: 0 12px; border: 1px solid var(--color-accent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--color-accent) 14%, var(--color-bg-card)); color: var(--color-accent); font: 700 14px/1 var(--font-ui); cursor: pointer; }
html body.is-phone .ph-tabs-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html body.is-phone .ph-tabs-ic, html body.is-phone .ph-tabs-dd { flex: 0 0 auto; font-size: 13px; }
html body.is-phone .tabs-bar { align-items: center; gap: 6px; padding: 0 8px; }
html body.is-phone .tabs-secs { flex: 1 1 auto; justify-content: flex-end; padding: 0; gap: 6px; }
html body.is-phone .tabs-secs .tabs-secs-menu { order: 1; flex: 0 1 auto; min-width: 0; max-width: none; height: 34px; padding: 0 12px; font-size: 13.5px; border-color: var(--color-border-strong); color: var(--color-text-primary); background: var(--color-bg-card); }
html body.is-phone .tabs-secs .tabs-secs-acts { order: 2; border-right: 0; padding-right: 0; margin-right: 0; }
html body.is-phone .tabs-secs .tabs-secs-ind { display: none !important; }
html body.is-phone .tabs-secs .tsec-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
html body.is-phone .tabs-secs.compact.open .tabs-secs-list { right: 0; min-width: 240px; max-width: calc(100vw - 16px); }
html body.is-phone .tabs-secs.compact.open .tsec-chip, html body.is-phone .tabs-secs.compact.open .tsec-chip button { height: 42px; }
html body.is-phone .ph-tabs-menu .nw-popmenu-item { font-size: 15px; }

/* Notes list header: one row — Showing <tag> ▾ · Filter <name> × · + New */
html body.is-phone .notes-list-bar { display: none !important; }
.nt-ph-bar { display: flex; align-items: center; gap: 6px; padding: 2px 0 6px; min-width: 0; }
.nt-ph-pick, .nt-ph-filter { display: inline-flex; align-items: center; gap: 6px; min-width: 0; min-height: 38px; padding: 0 12px; border: 1px solid var(--color-border-strong); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-text-primary); font: 600 14px/1.1 var(--font-ui); }
.nt-ph-pick { flex: 1 1 auto; cursor: pointer; text-align: left; }
.nt-ph-filter { flex: 0 1 auto; padding-right: 2px; border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg-card)); }
.nt-ph-k { flex: 0 0 auto; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.nt-ph-v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-ph-dd { margin-left: auto; flex: 0 0 auto; color: var(--color-text-secondary); }
.nt-ph-filter .nf-crumb-x { flex: 0 0 auto; }
html body.is-phone .nt-ph-new { flex: 0 0 auto; min-height: 38px; padding: 0 14px; font-size: 14px; }

/* Note cards: a big title to tap; the card's buttons are behind one ⋯ (no hover on a touch screen) */
.note-card-more { display: none !important; }
html body.is-phone .note-card-actions { visibility: visible; }
html body.is-phone .note-card-actions:has(> .note-card-more) > :not(.note-card-more) { display: none !important; }
html body.is-phone .note-card-more { display: inline-flex !important; min-width: 40px; min-height: 36px; font-size: 20px; line-height: 1; color: var(--color-text-secondary); border-radius: var(--r-pill); }
html body.is-phone .note-card-title { font-size: 16px; line-height: 1.3; min-height: 46px; display: flex; align-items: center; padding: 6px 2px; margin: 2px 0 2px; cursor: pointer; }
html body.is-phone .note-card .note-card-header { padding-bottom: 8px; }
html body.is-phone .note-card .note-card-header-top { gap: 8px; }

/* Sections run their full length and the page scrolls (only a database table scrolls inside its own box). */
html body.is-phone .nw-ph-more { display: none !important; }

/* ── Bigger small icons (Joey 2026-11-13: "too small for both mobile and on the desktop") — both ── */
.tk-panel-head .tk-panel-flt { font-size: 16px; opacity: .7; padding: 2px 6px; line-height: 1; }
.tk-panel-head:hover .tk-panel-flt, .tk-panel-head .tk-panel-flt.on { opacity: 1; }
.tk-panel-head .tk-panel-n { font-size: 12.5px; }
.tk-panel-head .tk-caret svg { width: 16px; height: 16px; }
.tk-panel-head .tk-panel-dot { width: 10px; height: 10px; }
.note-action-btn svg { width: 16px; height: 16px; }
.note-pin-icon { width: 24px; height: 24px; }
.note-pin-icon svg { width: 16px; height: 16px; }
.note-body-tog { width: 26px; height: 22px; }
.note-body-tog svg { width: 15px; height: 15px; }
.tk-caret svg { width: 14px; height: 14px; }
html body.is-phone .tk-panel-head .tk-panel-flt { font-size: 19px; min-width: 38px; min-height: 38px; }
html body.is-phone .tk-panel-head .tk-panel-n { font-size: 13.5px; }
html body.is-phone .tk-panel-head .tk-caret svg { width: 20px; height: 20px; }
html body.is-phone .tk-panel-head .tk-panel-title { font-size: 15px; }
html body.is-phone .note-pin-icon { width: 36px; height: 36px; }
html body.is-phone .note-pin-icon svg { width: 18px; height: 18px; }
html body.is-phone .note-body-tog { width: 38px; height: 34px; }
html body.is-phone .note-body-tog svg { width: 18px; height: 18px; }
html body.is-phone .tk-caret svg { width: 18px; height: 18px; }

/* ── Reminders can be put away (both) ── */
.toast-dock { position: sticky; top: 0; z-index: 1; width: min(580px, calc(100vw - 32px)); box-sizing: border-box; display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 6px 8px 6px 12px; border-radius: var(--r-lg); background: var(--color-bg-modal); border: 1px solid var(--color-border-default); box-shadow: var(--shadow-dropdown); font: 600 13px/1.2 var(--font-ui); color: var(--color-text-primary); pointer-events: auto; }
.toast-dock .toast-dock-hide { flex: 0 0 auto; }
body.toasts-hidden .toast-container > :is(.tk-remcard, .toast-dock) { display: none !important; }
.toast-pill { position: fixed; right: 12px; bottom: 52px; z-index: 100001; display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--color-accent); background: var(--color-bg-modal); color: var(--color-text-primary); font: 700 14px/1 var(--font-ui); box-shadow: var(--shadow-dropdown); cursor: pointer; }
.toast-pill.toast-pill-new { animation: toastPillPulse 1.2s ease 2; }
@keyframes toastPillPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); background: color-mix(in srgb, var(--color-accent) 22%, var(--color-bg-modal)); } }
html body.is-phone .toast-dock { width: auto; padding: 6px 8px 6px 12px; font-size: 14px; }
html body.is-phone .toast-pill { bottom: 48px; right: 10px; }

/* 2026-11-13 b: the label sits above its value, so both fit; a taller tab bar on a phone */
.nt-ph-pick, .nt-ph-filter { display: inline-grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 6px; row-gap: 1px; align-content: center; min-height: 44px; padding: 3px 12px; }
.nt-ph-pick > .nt-ph-k, .nt-ph-filter > .nt-ph-k { grid-column: 1; grid-row: 1; font-size: 10px; line-height: 1.1; }
.nt-ph-pick > .nt-ph-v, .nt-ph-filter > .nt-ph-v { grid-column: 1; grid-row: 2; font-size: 14px; line-height: 1.2; }
.nt-ph-pick > .nt-ph-dd { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.nt-ph-filter > .nf-crumb-x { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.nt-ph-filter { padding-right: 4px; max-width: 42%; }
html body.is-phone .nt-ph-new { min-height: 44px; }
body.is-phone { --tabs-bar-height: 50px; }
html body.is-phone .ph-tabs-btn, html body.is-phone .tabs-secs .tabs-secs-menu { height: 38px; min-height: 38px; }

/* 2026-11-13 c: a database header on a phone — row 1: ⌄ ⠿ Databases ☰ N … ⋯ ; row 2: the database tabs */
html body.is-phone .nw-db-pane > .nw-db-tabs > .nw-head-n { display: none !important; }
html body.is-phone .nw-db-pane > .nw-db-tabs > .ph-fold-host { order: 1; margin-left: auto; }
html body.is-phone .nw-db-pane > .nw-db-tabs > .nw-db-tablist { order: 2; }
html body.is-phone .nw-db-pane .nw-db-toolbar { width: 100%; box-sizing: border-box; }
html body.is-phone .nw-db-pane .nw-db-toolbar > .nw-db-filter { flex: 1 1 100% !important; max-width: none !important; }

.ph-fold > .hdr-more-panel { box-sizing: border-box; width: max-content; max-width: calc(100vw - 16px); }
.ph-fold > .hdr-more-panel .hdr-item { min-width: 0; }
.ph-fold > .hdr-more-panel .hdr-more-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══ 2026-11-15 Owner-only parts and the Dashboard / Active Alerts as ordinary sections ══ */
/* Owner-only (html[data-owner] is set from /api/auth/me): investing sections, the Account / API Control / API Usage /
   Site admin configuration tabs. Presentation only — the server must refuse the data too. */
html:not([data-owner="1"]) [data-owner-only] { display: none !important; }
/* The Dashboard's content sits in a collapsible wrapper; the card grid stays the tray (no second tray around it). */
#main-content > #dashboard > .collapsible-content { background: transparent; padding: 0; margin-top: 0; border-radius: 0; }
#main-content > #dashboard > .collapsible-content.collapsed { padding: 0 !important; }
#dashboard > .collapsible-content > .dashboard-body { padding-top: 0; }
:root[data-sechdr="page"] #dashboard > .collapsible-content > .dashboard-body { padding-top: 10px; }
/* Active Alerts keeps its alert colours: the section is the banner, its content has no tray of its own. */
#main-content > #active-alerts-container { position: relative; }
#main-content > #active-alerts-container > .collapsible-content { background: transparent; padding: 0; margin-top: 0; border-radius: 0; }
#active-alerts-container > h2.collapsible-header { color: var(--color-status-danger); }
/* A tab with nothing for you (all its sections owner-only) is hidden; the strip's own display rule would override [hidden]. */
.tabs-strip li.tab[hidden] { display: none !important; }

/* ── Workspace pill (Step 2e phase 7): shown only to someone with more than one workspace ── */
.ws-pill { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 220px; height: 28px; margin: auto 6px auto 0; padding: 0 10px; border: 1px solid var(--color-border-strong); border-radius: var(--r-pill); background: var(--color-bg-card); color: var(--color-text-primary); font: 600 12.5px/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.ws-pill:hover { border-color: var(--color-accent); }
.ws-pill-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-pill-ic { color: var(--color-accent); }
html body.is-phone .ws-pill { height: 38px; max-width: 28vw; padding: 0 10px; font-size: 13px; margin: auto 0; }

/* ── Sharing a workspace (Step 2g, phase 8): invitations, the Members panel ── */
.acct-invites { display: flex; flex-direction: column; gap: 6px; }
.acct-invite { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--r-md); border-left: 4px solid var(--color-accent); background: color-mix(in srgb, var(--color-accent) 9%, var(--color-bg-card)); font-size: 12.5px; }
.acct-actions { white-space: nowrap; }
.acct-actions .btn + .btn, .acct-head-actions .btn + .btn { margin-left: 4px; }
.acct-head-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.acct-sub { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--color-border-default); }
.acct-sub h5 { margin: 0; font-size: 12.5px; }
.acct-input { flex: 1 1 200px; min-width: 0; height: 28px; padding: 0 10px; border: 1px solid var(--color-border-strong); border-radius: var(--r-md); background: var(--color-bg-input, var(--color-bg-card)); color: var(--color-text-primary); font-size: 12.5px; }
.acct-select { height: 28px; padding: 0 6px; border: 1px solid var(--color-border-strong); border-radius: var(--r-md); background: var(--color-bg-input, var(--color-bg-card)); color: var(--color-text-primary); font-size: 12px; }
.acct-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-text-secondary, var(--color-text-primary)); }
.acct-sub code { font-size: 11.5px; word-break: break-all; user-select: all; }
html body.is-phone .acct-input, html body.is-phone .acct-select { height: 38px; font-size: 14px; }
html body.is-phone .acct-head-actions { margin-left: 0; flex-wrap: wrap; }
html body.is-phone #acct-ws-manage h4 { flex-wrap: wrap; }

/* ── Sub-notes: ⠿ drag to another note, ＋ new sub-note (2026-11-16) ── */
.st-grip { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 14px; margin-right: 2px; color: var(--color-text-muted); opacity: 0; cursor: grab; font-size: 12px; line-height: 1; user-select: none; }
.st-row:hover > .st-grip, .note-row:hover > .st-grip, .st-grip:focus-visible { opacity: .7; }
.st-grip:hover { opacity: 1; color: var(--color-accent); }
.st-grip:active { cursor: grabbing; }
html body.is-phone .st-grip { display: none; }
.st-head .st-add { margin-left: auto; }
.st-head { display: flex; align-items: center; }
.st-add { font-weight: 700; color: var(--color-accent); }
.note-card-actions .note-new-linked-btn.st-add { visibility: visible; padding: 0 6px !important; font-size: 14px; }
.note-row .note-row-add { opacity: .55; }
.note-row:hover .note-row-add { opacity: 1; }
.st-drop-on { outline: 2px dashed var(--color-accent); outline-offset: -2px; background: color-mix(in srgb, var(--color-accent) 10%, transparent) !important; border-radius: var(--r-md); }
.st-drag-src { opacity: .45; }
.st-flash { animation: st-flash 1.6s ease-out; }
@keyframes st-flash { 0%, 30% { background: color-mix(in srgb, var(--color-accent) 22%, transparent); } 100% { background: transparent; } }

/* ── Search everything (2026-11-16): the box beside + New note and the results window ── */
.notes-list-bar > .gs-box { flex: 1 1 160px; min-width: 120px; display: flex; align-items: center; height: 26px; border: 1px solid var(--color-border-strong); border-radius: var(--r-pill); background: var(--color-bg-card); overflow: hidden; }
.gs-box:focus-within { border-color: var(--color-accent); }
.gs-box input { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--color-text-primary); font: 12.5px var(--font-ui); padding: 0 4px 0 10px; }
.gs-box button { flex: 0 0 auto; height: 100%; border: 0; background: transparent; cursor: pointer; padding: 0 7px; font-size: 13px; color: var(--color-text-secondary); }
.gs-box button:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.gs-box .gs-box-saved { border-left: 1px solid var(--color-border-default); }
html body.is-phone .notes-list-bar > .gs-box { height: 38px; flex-basis: 100%; order: 5; }
html body.is-phone .gs-box input { font-size: 15px; }
.gs-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.gs-overlay .gs-modal { pointer-events: auto; position: fixed; display: flex; flex-direction: column; max-width: calc(100vw - 16px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.gs-modal:not(.dlg-movable) { left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, calc(100vw - 16px)); height: 80vh; }
html body.is-phone .gs-overlay .gs-modal { inset: 0; width: 100vw !important; height: 100% !important; max-width: none; transform: none; border-radius: 0; }
.gs-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.gs-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gs-bar input { flex: 1 1 200px; min-width: 0; height: 30px; padding: 0 12px; border: 1px solid var(--color-border-strong); border-radius: var(--r-pill); background: var(--color-bg-input, var(--color-bg-card)); color: var(--color-text-primary); font-size: 13px; }
.gs-adv-btn.gs-adv-on { color: var(--color-accent); border-color: var(--color-accent); }
.gs-adv { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); border-left: 4px solid var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg-card)); font-size: 12.5px; }
.gs-adv[hidden] { display: none; }
.gs-adv-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gs-adv-l { font-weight: 600; color: var(--color-text-secondary); min-width: 64px; }
.gs-adv-sp { flex: 1 1 auto; }
.gs-adv select, .gs-adv input[type=date], .gs-adv input[data-gs=scopeTag] { height: 26px; border: 1px solid var(--color-border-strong); border-radius: var(--r-md); background: var(--color-bg-card); color: var(--color-text-primary); font-size: 12px; padding: 0 6px; max-width: 240px; }
.gs-types { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.gs-chk { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; cursor: pointer; }
.gs-hint { color: var(--color-text-muted); font-size: 11.5px; }
.gs-sw-l { font-size: 12.5px; }
.gs-results { flex: 1 1 auto; min-height: 0; overflow: auto; padding-right: 2px; }
.gs-sum { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--color-text-secondary); margin: 2px 2px 8px; }
.gs-took { margin-left: auto; font-size: 11px; color: var(--color-text-muted); }
.gs-empty { color: var(--color-text-muted); font-size: 12.5px; padding: 10px 4px; }
.gs-group { margin-bottom: 10px; }
.gs-ghead { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; padding: 4px 2px; cursor: pointer; position: sticky; top: 0; background: var(--color-bg-card); z-index: 1; }
.gs-count { font-weight: 600; font-size: 11px; color: var(--color-text-muted); background: color-mix(in srgb, var(--color-accent) 10%, transparent); border-radius: var(--r-pill); padding: 0 7px; }
.gs-item { display: flex; gap: 8px; padding: 6px 8px; border-radius: var(--r-md); cursor: pointer; }
.gs-item:hover, .gs-item:focus-visible { background: color-mix(in srgb, var(--color-accent) 8%, transparent); outline: none; }
.gs-ic { flex: 0 0 18px; text-align: center; font-size: 13px; line-height: 18px; }
.gs-main { flex: 1 1 auto; min-width: 0; }
.gs-title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-meta { font-size: 11.5px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-snip { font-size: 12px; color: var(--color-text-secondary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gs-item mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.gs-col { font-weight: 600; }
.gs-st { font-weight: 600; text-transform: capitalize; }
.gs-st-done { color: #16a34a; }
.gs-more { font-size: 11.5px; color: var(--color-text-muted); padding: 2px 8px 0 34px; }
.gs-saved-item { display: flex; align-items: center; }
.gs-saved-item > .nw-popmenu-item { flex: 1 1 auto; min-width: 0; }
.gs-saved-x { flex: 0 0 auto; border: 0; background: transparent; color: var(--color-text-muted); cursor: pointer; padding: 0 8px; }
.gs-saved-x:hover { color: #dc2626; }

/* ── Disclosure chevrons (2026-11-17): <details> summaries draw the dashboard chevron (CHEVRON_SVG's shape) instead of ▸ ── */
.nw-db-form-sectitle::before, .nw-db-info > summary::before, .wl-plp-summary::before {
    display: inline-block; flex: 0 0 12px; width: 12px; height: 12px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 6 15 12 9 18'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 0.15s ease;
}
@media (prefers-reduced-motion: reduce) { .nw-db-form-sectitle::before, .nw-db-info > summary::before, .wl-plp-summary::before { transition: none; } }

/* ── Sections menu (2026-11-17): every tab with 2+ sections shows one "Name ▾" button; its menu is a standard pop menu
   with a show / hide switch per section (hiding, not collapsing). ── */
.tabs-secs-menu:hover { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.tsec-pop { min-width: 230px; }
.tsec-mrow { display: flex; align-items: center; gap: 6px; padding-right: 6px; border-radius: var(--r-md); }
.tsec-mrow > .nw-popmenu-item { flex: 1 1 auto; min-width: 0; }
.tsec-mrow.off > .nw-popmenu-item { color: var(--color-text-muted); }
.tsec-mrow.off .tsec-n { background: color-mix(in srgb, var(--color-text-secondary) 12%, transparent); color: inherit; }
.tsec-sw { flex: 0 0 auto; align-self: center; }
.tsec-sw .nw-db-switch-track { width: 30px; height: 16px; }
.tsec-sw .nw-db-switch-thumb { top: 2px; left: 2px; width: 12px; height: 12px; }
.tsec-sw input:checked + .nw-db-switch-track .nw-db-switch-thumb { left: 16px; }
.sec-dl-x { margin-left: 5px; font-size: 9px; opacity: .6; }
.sec-dl:hover .sec-dl-x { opacity: 1; }
html body.is-phone .tsec-pop .nw-popmenu-item { padding: 10px 12px; font-size: 14px; }

/* ── Sections menu, note-menu look (2026-11-17): the same pill rows, icon slot, switch and heading as a note's ⋯ menu ── */
.tsec-menu { position: fixed; width: 0; height: 0; }
.tsec-menu > .hdr-more-panel { min-width: 240px; }
.tsec-menu > .hdr-more-panel > .nw-menu-head { padding: 2px 6px 0; font: 600 10.5px/1.2 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.tsec-menu > .hdr-more-panel .hdr-item.hdr-item.tsec-cur.tsec-cur { border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-border-default)) !important; }
.tsec-menu .hdr-item.tsec-off .hdr-more-label, .tsec-menu .hdr-item.tsec-off .hdr-ic { color: var(--color-text-muted); }
.tsec-mn { margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--color-text-muted); }
.tsec-swhit { display: inline-flex; align-items: center; padding: 6px 0 6px 8px; margin: -6px 0; cursor: pointer; }
.tsec-menu .hdr-more-label + .tsec-swhit { margin-left: auto; }
.tsec-menu .hdr-tog.on .tsec-swhit > .hdr-sw { background: var(--color-accent); }
.tsec-menu .hdr-tog.on .tsec-swhit > .hdr-sw::before { transform: translateX(13px); }
.tsec-menu .tsec-swhit > .hdr-sw { margin-left: 0; }
html body.is-phone .tsec-menu > .hdr-more-panel { max-width: calc(100vw - 16px); }

/* ── Tab bar controls look alike (2026-11-17): tabs, the section buttons (⋯, + Task…), the sections menu (Name ▾) and +
   are all 24px pills with the same 12px theme font and the same 1px border; no underline under the sections menu. ── */
.tabs-secs-ind { display: none !important; }
html body:not(.is-phone) #tabs-bar :is(.tab, .tabs-secs-menu, .tabs-add-btn, .tabs-secs-acts > .section-header-buttons > :is(.btn, .hdr-more-btn, select)) {
    height: 24px; min-height: 24px; box-sizing: border-box; font: 600 12px/1 var(--font-ui); border-radius: var(--r-pill);
    display: inline-flex; align-items: center; justify-content: center; margin-top: 0; margin-bottom: 0;
}
html body:not(.is-phone) #tabs-bar :is(.tabs-secs-menu, .tabs-add-btn, .tabs-secs-acts > .section-header-buttons > :is(.btn, .hdr-more-btn)) {
    border: 1px solid var(--color-border-default); background: var(--color-bg-button-secondary);
}
html body:not(.is-phone) #tabs-bar :is(.tabs-secs-menu, .tabs-secs-acts > .section-header-buttons > :is(.btn, .hdr-more-btn)) { padding: 0 10px; }
#tabs-bar .tabs-secs:not(.compact) > .tabs-secs-menu { display: none !important; }
html body:not(.is-phone) #tabs-bar .tabs-add-btn { width: 24px; padding: 0; color: var(--color-text-primary); }
html body:not(.is-phone) #tabs-bar :is(.tabs-secs-menu, .tabs-add-btn):hover { border-color: var(--color-accent); }

/* ── Tab menu + profile (2026-11-17): the sections / section options / tab actions open from the selected tab (▾ on it);
   the bar's own Name ▾ and ⋯ are gone, ＋ follows the last tab and the profile button sits at the right end. ── */
#tabs-bar .tabs-secs { display: none !important; }
html body:not(.is-phone) #tabs-bar .tabs-strip { flex: 0 1 auto; }
.tabs-strip li.tab .tab-dd { display: none; font-size: 9px; line-height: 1; margin-left: -1px; opacity: .85; }
.tabs-strip li.tab.active .tab-dd { display: inline; }
html body:not(.is-phone) #tabs-bar li.tab.active { gap: 5px; }
.tsec-menu > .hdr-more-panel { left: 0; right: auto; top: 6px; }
.tsec-menu > .hdr-more-panel > .nw-menu-head ~ .nw-menu-head { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--color-border-default); }
.tsec-menu .tsec-none { padding: 4px 6px; color: var(--color-text-muted); font-size: 12px; }
.tsec-menu .hdr-item[disabled] { opacity: .45; cursor: default; }
.tabs-profile { margin-left: auto; flex: 0 0 auto; align-self: center; display: inline-flex; align-items: center; gap: 6px; height: 24px; max-width: 220px; padding: 0 9px 0 2px; box-sizing: border-box; border: 1px solid var(--color-border-default); border-radius: var(--r-pill); background: var(--color-bg-button-secondary); color: var(--color-text-primary); font: 600 12px/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.tabs-profile:hover, .tabs-profile[aria-expanded="true"] { border-color: var(--color-accent); }
.tprof-av { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.tprof-ini, .tprof-big.tprof-ini { display: inline-flex; align-items: center; justify-content: center; background: var(--color-accent); color: var(--color-text-on-accent); font-size: 10.5px; font-weight: 700; }
.tprof-ws { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tprof-dd { font-size: 9px; color: var(--color-text-muted); }
.tprof-menu > .hdr-more-panel { min-width: 260px; }
.tprof-who { display: flex; align-items: center; gap: 10px; padding: 4px 6px 6px; }
.tprof-who > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tprof-who b { font-size: 13px; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tprof-who small { font-size: 11.5px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tprof-big { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.tprof-big.tprof-ini { font-size: 15px; }
.tprof-check { margin-left: auto; color: var(--color-accent); font-weight: 700; }
html body.is-phone .tabs-profile { height: 38px; min-height: 38px; padding: 0 8px 0 4px; max-width: 34vw; margin: auto 0 auto auto; }
html body.is-phone .tprof-av { width: 28px; height: 28px; }
html body.is-phone .tprof-ws { display: none; }

/* Tab menu: drag a section row by its ⠿ grip to reorder (2026-11-17) */
.tsec-menu .tsec-grip { flex: 0 0 auto; margin: -6px -2px -6px -6px; padding: 6px 2px 6px 6px; color: var(--color-text-muted); font-size: 12px; line-height: 1; cursor: grab; touch-action: none; user-select: none; }
.tsec-menu .tsec-row:hover .tsec-grip { color: var(--color-text-secondary); }
.tsec-menu .tsec-row.tsec-dragging { border-color: var(--color-accent) !important; box-shadow: var(--shadow-dropdown); cursor: grabbing; }
.tsec-menu .tsec-row.tsec-dragging .tsec-grip { cursor: grabbing; }

/* Site admin ▸ Outgoing mail (2026-11-17) */
.site-mail-row { padding: 8px 0; border-top: 1px solid var(--color-border-default); }
.site-mail-row:first-of-type { border-top: 0; }
.site-mail-row .btn + .btn { margin-left: 6px; }
.acct-kv code + code { margin-left: 6px; }
