        :root {
            --app-h: 100vh;
            --app-w: 100vw;
            --compact-layout-max: 640px;
            --workspace-panel-width: 290px;
            /* Narrow viewports: match My Contexts / My Files width */
            --workspace-panel-width-narrow: min(290px, calc(100vw - 24px));
            --bg-paper: #e5dfcc;
            --bg-paper-lines-minor: rgba(95, 70, 50, 0.06);
            --bg-paper-lines-major: rgba(75, 55, 35, 0.11);
            --accent-blue: #2563eb;
            --accent-emerald: #059669;
            /* Mobile follow-up / composer accent (green family) */
            --accent-followup: #059669;
            --accent-followup-ring: rgba(5, 150, 105, 0.45);
            --accent-followup-soft: rgba(5, 150, 105, 0.14);
            --accent-followup-glow: rgba(5, 150, 105, 0.2);
            /* AI node sage-tinted surface (matches .chat-node-latest footer) — follow-up active fill is mixed lighter than this */
            --ai-node-accent-surface: color-mix(in srgb, var(--card-bg) 86%, var(--accent-emerald) 14%);
            --followup-pill-active-bg: color-mix(in srgb, #ffffff 72%, var(--ai-node-accent-surface) 28%);
            --followup-pill-active-border: rgba(5, 150, 105, 0.34);
            --followup-pill-active-ring: rgba(5, 150, 105, 0.12);
            /* Follow-up / bottom composer pill: fixed radius (does not grow with multi-line height). */
            --mobile-composer-pill-radius: 22px;
            --brain-border: rgba(5, 150, 105, 0.45);
            --brain-border-hover: rgba(5, 150, 105, 0.65);
            --brain-border-line: rgba(5, 150, 105, 0.55);
            --card-bg: #ece7d8;
            --card-border: rgba(80, 70, 55, 0.22);
            --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
            --text-primary: #1e293b;
            --text-secondary: #475569;
            --text-muted: #64748b;
        }

        @supports not (background: color-mix(in srgb, white, black)) {
            :root {
                --ai-node-accent-surface: #d8e8d4;
                --followup-pill-active-bg: #f0f7f3;
            }
        }

        html {
            /* Suppress mobile double-tap viewport zoom; map keeps custom pinch (canvas uses touch-action: none) */
            touch-action: manipulation;
            overflow: hidden;
            height: 100%;
        }

        body {
            margin: 0;
            overflow: hidden;
            height: 100%;
            min-height: 100%;
            min-height: -webkit-fill-available;
            background: var(--bg-paper);
            font-family: 'Inter', sans-serif;
            user-select: none;
            color: var(--text-primary);
            touch-action: manipulation;
        }

        /* Old Brown Graphing Paper Background (minor + major grid lines) */
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: var(--app-w, 100%);
            height: var(--app-h, 100%);
            background-image:
                linear-gradient(to right, var(--bg-paper-lines-minor) 1px, transparent 1px),
                linear-gradient(to bottom, var(--bg-paper-lines-minor) 1px, transparent 1px),
                linear-gradient(to right, var(--bg-paper-lines-major) 1px, transparent 1px),
                linear-gradient(to bottom, var(--bg-paper-lines-major) 1px, transparent 1px);
            background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
            z-index: -2;
            pointer-events: none;
        }

        /* Center focus: light above center, surrounding dimmed (warm parchment tint) */
        body::after {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: var(--app-w, 100%);
            height: var(--app-h, 100%);
            background: radial-gradient(
                ellipse 85% 75% at 50% 36%,
                transparent 0%,
                transparent 32%,
                rgba(68, 56, 46, 0.08) 50%,
                rgba(62, 50, 40, 0.18) 72%,
                rgba(55, 44, 35, 0.32) 100%
            );
            z-index: -1;
            pointer-events: none;
        }

        #canvas-container {
            position: absolute;
            top: 0;
            left: 0;
            width: var(--app-w, 100vw);
            height: var(--app-h, 100vh);
            cursor: grab;
            overflow: hidden;
            /* Lets one-finger drags reach JS (pan) instead of browser gestures on the empty map */
            touch-action: none;
        }

        #viewport {
            position: absolute;
            transform-origin: 0 0;
            will-change: transform;
            touch-action: none;
        }

        #connections-layer {
            position: absolute;
            top: 0;
            left: 0;
            pointer-events: none;
            overflow: visible;
        }

        /* Chat Box Styling - Paper Cards on Graph Paper */
        .chat-node {
            position: absolute;
            --chat-node-width: 480px;
            --chat-node-max-height-golden: calc(var(--chat-node-width) * 1.618);
            --chat-node-radius: 12px;
            width: var(--chat-node-width);
            max-height: min(var(--chat-node-max-height-golden), 80vh);
            background: var(--card-bg);
            border: 1px solid var(--brain-border);
            border-radius: var(--chat-node-radius);
            color: var(--text-primary);
            box-shadow: var(--card-shadow);
            pointer-events: auto;
            /* No browser pinch on cards; vertical scroll in .node-body-scroll uses pan-y */
            touch-action: none;
            transition: left 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
                top 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
                border-color 0.3s,
                box-shadow 0.35s ease,
                transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.4s ease,
                opacity 0.3s ease;
            cursor: default;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            opacity: 1;
        }

        /* Hide broken images in markdown */
        .markdown-content img:not([src]),
        .markdown-content img[src=""],
        .markdown-content img:not([src^="data:"]):not([src^="http"]) {
            display: none !important;
        }

        /* Allow editor-like left-drag text selection inside AI rendered content */
        .node-ai .markdown-content,
        .node-ai .markdown-content *,
        .node-ai .markdown-content pre,
        .node-ai .markdown-content code,
        .node-ai .markdown-content .katex,
        .node-ai .markdown-content .katex * {
            user-select: text;
            -webkit-user-select: text;
            cursor: text;
        }

        .node-ai .markdown-content .graph-container,
        .node-ai .markdown-content .graph-container *,
        .node-ai .markdown-content .canvas-wrapper,
        .node-ai .markdown-content .canvas-wrapper *,
        .node-ai .markdown-content img.execution-image {
            cursor: default;
            user-select: none;
            -webkit-user-select: none;
        }

        .chat-node:hover {
            /* Keep hover feedback but avoid scale-induced text shimmer while reading/scrolling. */
            transform: translateY(-1px);
            border-color: var(--brain-border-hover);
            box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.15);
        }

        /* Newest node — flat parchment + emerald tint (header, body, follow-up panel) */
        .chat-node.chat-node-latest .node-header,
        .chat-node.chat-node-latest .node-body,
        .chat-node.chat-node-latest .node-footer {
            background: color-mix(in srgb, var(--card-bg) 86%, var(--accent-emerald) 14%);
        }

        .chat-node.chat-node-latest .node-header {
            border-bottom: 2px solid var(--accent-emerald);
        }

        .chat-node.chat-node-latest .node-header .font-bold.uppercase {
            color: var(--accent-emerald);
            opacity: 0.88;
        }

        /* Minimized State */
        .chat-node.minimized {
            height: 54px !important;
            width: 220px;
        }

        .chat-node.minimized .node-body {
            display: none;
        }

        .chat-node.minimized > .node-header {
            border-radius: var(--chat-node-radius);
            border-bottom: none;
        }

        /* Hidden State (When ancestor is minimized) */
        .chat-node.hidden-branch {
            display: none !important;
            pointer-events: none;
        }

        /* Control Bar */
        .node-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 16px;
            background: rgba(248, 250, 252, 0.8);
            border-bottom: 1px solid var(--card-border);
            font-family: 'Outfit', sans-serif;
            position: relative;
            cursor: grab;
            user-select: none;
            border-radius: var(--chat-node-radius) var(--chat-node-radius) 0 0;
        }

        /* Match card radius so fills align with outer border (incl. when overflow is visible on touch) */
        .chat-node > .node-body:not(:has(.node-footer)) {
            border-radius: 0 0 var(--chat-node-radius) var(--chat-node-radius);
        }

        .chat-node > .node-body:has(.node-footer) .node-footer:last-child {
            border-radius: 0 0 var(--chat-node-radius) var(--chat-node-radius);
        }

        .node-header .control-btn,
        .node-header .link-toggle-btn {
            cursor: pointer;
        }

        .node-controls {
            display: flex;
            gap: 6px;
        }

        .control-btn {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
            background: rgba(100, 116, 139, 0.08);
            cursor: pointer;
            transition: all 0.2s;
            color: var(--text-muted);
        }

        .control-btn svg {
            width: 14px;
            height: 14px;
        }

        .control-btn:hover {
            color: var(--text-primary);
            background: rgba(100, 116, 139, 0.15);
            transform: scale(1.1);
        }

        .btn-minimize:hover {
            background: rgba(37, 99, 235, 0.15);
            color: var(--accent-blue);
        }

        .btn-destroy:hover {
            background: rgba(239, 68, 68, 0.15);
            color: #dc2626;
        }

        .node-body {
            padding: 20px;
            flex-grow: 1;
            min-height: 0;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .node-body-scroll {
            flex: 1 1 auto;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            touch-action: pan-y;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }

        .node-body-scroll::-webkit-scrollbar {
            width: 8px;
        }

        .node-body-scroll::-webkit-scrollbar-track {
            background: rgba(241, 245, 249, 0.8);
            border-radius: 9999px;
        }

        .node-body-scroll::-webkit-scrollbar-thumb {
            background: rgba(100, 116, 139, 0.4);
            border-radius: 9999px;
        }

        .node-body-scroll::-webkit-scrollbar-thumb:hover {
            background: rgba(100, 116, 139, 0.55);
        }

        .node-footer {
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--card-border);
            flex-shrink: 0;
        }

        .node-input-row {
            display: flex;
            align-items: flex-end;
            gap: 8px;
        }

        /* Viewport-fixed follow-up composer (mobile / coarse pointer): input lives outside transformed #viewport */
        .mobile-ai-followup-trigger {
            flex: 1;
            min-width: 0;
            margin-top: 0;
            background: rgba(248, 250, 252, 0.9);
            padding: 12px;
            border-radius: 10px;
            font-size: 16px;
            border: 1px solid var(--card-border);
            font-family: 'Inter', sans-serif;
            color: var(--text-muted);
            text-align: left;
            cursor: pointer;
            min-height: 48px;
            line-height: 1.5;
            transition: background 0.2s, border-color 0.2s;
        }

        .mobile-ai-followup-trigger:active {
            background: #fff;
            border-color: var(--accent-followup-ring);
        }

        .mobile-ai-followup-trigger.mobile-ai-followup-linked {
            border-color: var(--followup-pill-active-border);
            box-shadow: 0 0 0 6px var(--followup-pill-active-ring);
            background: var(--followup-pill-active-bg);
        }

        /* Mobile: composer target when pill removed — ring follows same radius as card */
        .chat-node.mobile-ai-composer-node-linked {
            box-shadow: var(--card-shadow), 0 0 0 6px var(--followup-pill-active-ring);
            border-radius: var(--chat-node-radius);
        }

        .chat-node.mobile-ai-composer-node-linked:hover {
            box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.15), 0 0 0 6px var(--followup-pill-active-ring);
        }

        @keyframes mobile-composer-attention {
            0%, 100% {
                box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.12);
            }

            50% {
                box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.12), 0 0 0 3px var(--accent-followup-glow);
            }
        }

        .mobile-ai-composer-sheet.mobile-ai-composer-attention {
            animation: mobile-composer-attention 0.85s ease-in-out 2;
        }

        .mobile-ai-composer-bar {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 8px;
        }

        /* Desktop AI node: same pill as mobile bottom composer (+, field, send) — no close button */
        .ai-inline-composer-bar {
            width: 100%;
        }

        /* In-node desktop follow-up: white at rest; emerald theme when the field is active (:focus-within) */
        .node-footer .ai-inline-composer-pill.mobile-ai-composer-pill {
            flex: 1;
            min-width: 0;
            align-items: center;
            background: #fff;
            border: 1px solid var(--card-border);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
            transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .node-footer .ai-inline-composer-pill.mobile-ai-composer-pill:focus-within {
            background: var(--followup-pill-active-bg);
            border-color: var(--followup-pill-active-border);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 2px var(--followup-pill-active-ring);
        }

        .node-footer .ai-inline-composer-pill .mobile-ai-composer-attach-plus {
            background: #fff;
            color: var(--text-primary);
            transition: background 0.2s ease, color 0.2s ease;
        }

        .node-footer .ai-inline-composer-pill:focus-within .mobile-ai-composer-attach-plus {
            background: transparent;
            color: var(--accent-emerald);
        }

        .node-footer .ai-inline-followup-ta.mobile-ai-composer-ta {
            min-height: 0;
            max-height: 120px;
            padding: 7px 10px;
            font-size: 0.9rem;
            line-height: 1.35;
            background: #fff;
            border-radius: 8px;
            border: none;
            resize: none;
            outline: none;
            box-shadow: none;
            transition: background 0.2s ease;
            box-sizing: border-box;
            overflow-x: hidden;
            overflow-y: auto;
        }

        .node-footer .ai-inline-composer-pill:focus-within .ai-inline-followup-ta.mobile-ai-composer-ta {
            /* Same tone as pill — no second green layer on top */
            background: transparent;
        }

        .node-footer .ai-inline-followup-ta.mobile-ai-composer-ta:focus {
            box-shadow: none;
            outline: none;
        }

        .node-footer .ai-inline-followup-ta.mobile-ai-composer-ta::placeholder {
            color: var(--text-muted);
        }

        .node-footer .ai-inline-composer-pill .mobile-ai-composer-send-icon {
            background: #fff;
            color: var(--accent-followup);
            box-shadow: inset 0 0 0 1px var(--card-border);
            transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
        }

        .node-footer .ai-inline-composer-pill:focus-within .mobile-ai-composer-send-icon {
            background: var(--accent-emerald);
            color: #fff;
            box-shadow: none;
        }

        .mobile-ai-composer-pill {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 6px;
            padding: 5px 10px 5px 6px;
            border-radius: var(--mobile-composer-pill-radius);
            border: 1px solid var(--card-border);
            background: #fff;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
            transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
            overflow: hidden;
        }

        .mobile-ai-composer-attach-plus {
            flex-shrink: 0;
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 50%;
            background: transparent;
            color: var(--text-primary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            touch-action: manipulation;
        }

        .mobile-ai-composer-attach-plus svg {
            width: 22px;
            height: 22px;
            stroke: currentColor;
            stroke-width: 2.2;
        }

        .mobile-ai-composer-pill .mobile-ai-composer-ta {
            flex: 1;
            min-width: 0;
            min-height: 0;
            max-height: 120px;
            padding: 8px 6px;
            align-self: center;
            line-height: 1.35;
            border: none;
            border-radius: 0;
            background: transparent;
            box-shadow: none;
            box-sizing: border-box;
            overflow-x: hidden;
            overflow-y: auto;
        }

        .mobile-ai-composer-pill .mobile-ai-composer-ta:focus {
            box-shadow: none;
            outline: none;
        }

        /* Bottom dock: same inactive (white pill) / active (lighter-than-node sage) as desktop — × close unchanged */
        #mobile-ai-composer .mobile-ai-composer-pill:focus-within {
            background: var(--followup-pill-active-bg);
            border-color: var(--followup-pill-active-border);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 2px var(--followup-pill-active-ring);
        }

        #mobile-ai-composer .mobile-ai-composer-pill .mobile-ai-composer-attach-plus {
            background: #fff;
            color: var(--text-primary);
            transition: background 0.2s ease, color 0.2s ease;
        }

        #mobile-ai-composer .mobile-ai-composer-pill:focus-within .mobile-ai-composer-attach-plus {
            background: transparent;
            color: var(--accent-emerald);
        }

        #mobile-ai-composer .mobile-ai-composer-pill:focus-within .mobile-ai-composer-send-icon {
            background: var(--accent-emerald);
            color: #fff;
            box-shadow: none;
        }

        .mobile-ai-composer-pill.mobile-ai-composer-target-active .mobile-ai-composer-ta {
            background: transparent;
            border-radius: 8px;
        }

        .mobile-ai-composer-send-icon {
            flex-shrink: 0;
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 50%;
            background: #fff;
            color: var(--accent-followup);
            box-shadow: inset 0 0 0 1px var(--card-border);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            touch-action: manipulation;
            transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
        }

        .mobile-ai-composer-send-icon svg {
            width: 20px;
            height: 20px;
            fill: currentColor;
        }

        .mobile-ai-composer-send-icon:active {
            background: rgba(5, 150, 105, 0.22);
            color: #047857;
        }

        .mobile-ai-composer-send-icon.mobile-ai-composer-mic-mode:not(.mobile-ai-composer-recording) {
            color: #0f766a;
        }

        .mobile-ai-composer-send-icon.mobile-ai-composer-recording {
            color: #b91c1c;
            box-shadow: inset 0 0 0 2px rgba(185, 28, 28, 0.35);
        }

        .mobile-ai-composer-send-icon.mobile-ai-composer-retry-mode {
            color: #b45309;
            box-shadow: inset 0 0 0 2px rgba(180, 83, 9, 0.35);
        }

        .mobile-ai-composer-mic-cancel {
            flex-shrink: 0;
            width: 32px;
            height: 32px;
            border: none;
            border-radius: 50%;
            background: #fff;
            color: #64748b;
            box-shadow: inset 0 0 0 1px var(--card-border);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            touch-action: manipulation;
            transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
        }

        .mobile-ai-composer-mic-cancel:active {
            background: rgba(148, 163, 184, 0.22);
            color: #475569;
        }

        #mobile-ai-composer .mobile-ai-composer-pill:focus-within .mobile-ai-composer-mic-cancel {
            background: #fff;
            color: #64748b;
        }

        /* Floating mic/send mirror (mobile AI composer) — above composer z-[600] */
        #mobile-ai-mic-float {
            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
        }

        #mobile-ai-mic-float .mobile-ai-composer-send-icon {
            touch-action: none;
            /* True see-through: avoid backdrop-filter on iOS — blur() composites as a frosty opaque layer over the map/nodes. */
            background: rgba(255, 255, 255, 0.5);
            /* Outer rings hint “floating / draggable”; inset ring replaces solid white fill edge */
            box-shadow:
                inset 0 0 0 1px rgba(148, 163, 184, 0.4),
                0 0 0 2px rgba(5, 150, 105, 0.5),
                0 0 0 5px rgba(5, 150, 105, 0.12),
                0 6px 18px rgba(15, 23, 42, 0.14);
        }

        #mobile-ai-mic-float .mobile-ai-composer-send-icon:active {
            background: rgba(255, 255, 255, 0.58);
        }

        #mobile-ai-mic-float .mobile-ai-composer-send-icon svg {
            filter: drop-shadow(0 0.5px 1px rgba(255, 255, 255, 0.85)) drop-shadow(0 1px 2px rgba(15, 23, 42, 0.2));
        }

        #mobile-ai-mic-float .mobile-ai-composer-send-icon.mobile-ai-composer-recording {
            box-shadow:
                inset 0 0 0 2px rgba(185, 28, 28, 0.4),
                0 0 0 2px rgba(220, 38, 38, 0.55),
                0 0 0 5px rgba(220, 38, 38, 0.12),
                0 6px 18px rgba(15, 23, 42, 0.12);
        }

        #mobile-ai-mic-float .mobile-ai-composer-send-icon.mobile-ai-composer-retry-mode {
            box-shadow:
                inset 0 0 0 2px rgba(180, 83, 9, 0.45),
                0 0 0 2px rgba(217, 119, 6, 0.55),
                0 0 0 5px rgba(217, 119, 6, 0.12),
                0 6px 18px rgba(15, 23, 42, 0.12);
        }

        #mobile-ai-mic-float .mobile-ai-composer-mic-cancel {
            touch-action: manipulation;
            background: rgba(255, 255, 255, 0.5);
            box-shadow:
                inset 0 0 0 1px rgba(148, 163, 184, 0.45),
                0 0 0 2px rgba(100, 116, 139, 0.35),
                0 4px 12px rgba(15, 23, 42, 0.12);
        }

        #mobile-ai-mic-float .mobile-ai-composer-mic-cancel:active {
            background: rgba(255, 255, 255, 0.62);
        }

        /* Keep Safari/iOS from selecting chrome text (e.g. ×) while long-pressing mic/send */
        #mobile-ai-composer .mobile-ai-composer-bar {
            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
        }

        #mobile-ai-composer .mobile-ai-composer-ta {
            -webkit-user-select: text;
            user-select: text;
        }

        #mobile-ai-composer .mobile-ai-composer-close-outside,
        #mobile-ai-composer .mobile-ai-composer-send-icon,
        #mobile-ai-composer .mobile-ai-composer-mic-cancel,
        #mobile-ai-composer .mobile-ai-composer-attach-plus {
            -webkit-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
        }

        .mobile-ai-composer-close-outside {
            flex-shrink: 0;
            width: 36px;
            height: 36px;
            border: none;
            border-radius: 10px;
            background: transparent;
            color: var(--text-muted);
            font-size: 1.35rem;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            touch-action: manipulation;
        }

        .mobile-ai-composer-close-outside:active {
            color: var(--text-primary);
        }

        #mobile-ai-composer {
            pointer-events: auto;
            touch-action: manipulation;
            /* bottom adjusted in JS from visualViewport so the sheet sits above the software keyboard */
            left: 0;
            right: 0;
        }

        #mobile-ai-composer.hidden {
            display: none !important;
        }

        .mobile-ai-composer-sheet {
            background: var(--card-bg);
            border-top: 1px solid var(--card-border);
            box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.12);
            padding: 10px 12px;
            padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
            max-height: min(46vh, 420px);
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .mobile-ai-composer-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-muted);
        }

        .mobile-ai-composer-close {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            border: 1px solid var(--card-border);
            background: rgba(248, 250, 252, 0.95);
            color: var(--text-secondary);
            font-size: 18px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .mobile-ai-composer-previews {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            max-height: 72px;
            overflow-y: auto;
        }

        .mobile-ai-composer-previews:empty {
            display: none;
        }

        .mobile-ai-composer-row {
            display: flex;
            align-items: flex-end;
            gap: 8px;
        }

        .mobile-ai-composer-ta {
            flex: 1;
            min-width: 0;
            min-height: 48px;
            max-height: 140px;
            padding: 10px 12px;
            border-radius: 10px;
            border: 1px solid var(--card-border);
            background: rgba(248, 250, 252, 0.95);
            font-family: 'Inter', sans-serif;
            font-size: 16px;
            line-height: 1.45;
            color: var(--text-primary);
            resize: none;
            outline: none;
            overflow-x: hidden;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }

        .mobile-ai-composer-ta::-webkit-scrollbar {
            width: 8px;
        }

        .mobile-ai-composer-ta::-webkit-scrollbar-track {
            background: rgba(241, 245, 249, 0.8);
            border-radius: 9999px;
        }

        .mobile-ai-composer-ta::-webkit-scrollbar-thumb {
            background: rgba(100, 116, 139, 0.4);
            border-radius: 9999px;
        }

        .mobile-ai-composer-ta::-webkit-scrollbar-thumb:hover {
            background: rgba(100, 116, 139, 0.55);
        }

        .mobile-ai-composer-attach-inactive .mobile-ai-composer-attach-plus {
            opacity: 0.38;
            cursor: not-allowed;
        }

        .mobile-ai-composer-ta:focus {
            border-color: var(--accent-followup-ring);
            box-shadow: 0 0 0 2px var(--accent-followup-soft);
        }

        /* Flyout for + attach (position set in JS to stay on-screen) */
        .cm-attach-flyout-menu {
            width: min(220px, calc(100vw - 20px));
            border-radius: 12px;
            border: 1px solid rgba(5, 150, 105, 0.22);
            background: #fff;
            box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
            z-index: 800;
            overflow: hidden;
        }

        /* AI node (mobile): one pill row matching bottom composer */
        .mobile-ai-followup-pill-row {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 4px;
            padding: 5px 8px 5px 6px;
            border-radius: var(--mobile-composer-pill-radius);
            border: 1px solid var(--card-border);
            background: #fff;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
            transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
            overflow: hidden;
        }

        .mobile-ai-followup-pill-row .mobile-ai-followup-trigger {
            flex: 1;
            min-width: 0;
            margin: 0;
            border: none;
            background: transparent;
            box-shadow: none;
            min-height: 36px;
            padding: 6px 6px 6px 4px;
            border-radius: max(8px, calc(var(--mobile-composer-pill-radius) - 4px));
        }

        .mobile-ai-followup-pill-row .mobile-ai-followup-trigger.mobile-ai-followup-linked {
            box-shadow: inset 0 0 0 2px var(--followup-pill-active-ring);
            background: var(--followup-pill-active-bg) !important;
        }

        .mobile-ai-followup-pill-row .attach-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border: none;
            background: transparent;
            color: var(--text-primary);
        }

        .mobile-ai-followup-pill-row .attach-btn:hover {
            background: var(--accent-followup-soft);
            color: var(--accent-followup);
            border: none;
        }

        .mobile-ai-followup-pill-row .attach-btn svg {
            width: 20px;
            height: 20px;
        }

        .mobile-ai-composer-send {
            flex-shrink: 0;
            height: 48px;
            padding: 0 14px;
            border-radius: 10px;
            border: none;
            background: var(--accent-emerald);
            color: #fff;
            font-weight: 600;
            font-size: 14px;
            cursor: pointer;
        }

        .mobile-ai-composer-send:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        /* Topic Pills Styling */
        .topic-pill:hover {
            display: none;
        }

        .node-textarea {
            width: 100%;
            margin-top: 0;
            background: rgba(248, 250, 252, 0.9);
            padding: 12px;
            border-radius: 10px;
            font-size: 0.9rem;
            border: 1px solid var(--card-border);
            font-family: 'Inter', sans-serif;
            color: var(--text-primary);
            resize: none;
            outline: none;
            transition: all 0.2s;
            line-height: 1.5;
            min-height: 48px;
            max-height: 200px;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }

        .node-textarea:focus {
            background: #fff;
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
        }

        .node-textarea::placeholder {
            color: var(--text-muted);
        }

        /* Touch / narrow: map-first gestures — no in-node scroll cap, no markdown selection; inputs stay editable */
        @media (max-width: 900px), (pointer: coarse) {
            .chat-node textarea.node-textarea,
            .chat-node textarea.user-content-textarea {
                font-size: 16px !important;
            }

            .chat-node {
                max-height: none;
                /* Match outer border-radius: visible inner fills were painting square lower corners */
                overflow: hidden;
            }

            .node-body {
                overflow: hidden;
                border-radius: 0 0 var(--chat-node-radius) var(--chat-node-radius);
            }

            .node-body-scroll {
                flex: 0 1 auto;
                min-height: auto;
                overflow: visible;
                touch-action: none;
            }

            .node-ai .markdown-content,
            .node-ai .markdown-content *,
            .node-ai .markdown-content pre,
            .node-ai .markdown-content code,
            .node-ai .markdown-content .katex,
            .node-ai .markdown-content .katex * {
                user-select: none;
                -webkit-user-select: none;
                cursor: default;
            }

            .node-ai .markdown-content .graph-container,
            .node-ai .markdown-content .graph-container *,
            .node-ai .markdown-content .canvas-wrapper,
            .node-ai .markdown-content .canvas-wrapper *,
            .node-ai .markdown-content img.execution-image {
                user-select: none;
                -webkit-user-select: none;
                cursor: default;
            }

            .node-user .user-hot-prompt-display,
            .node-user .user-prompt-readonly-mobile {
                user-select: none;
                -webkit-user-select: none;
                cursor: default;
                touch-action: none;
            }

            .chat-node textarea,
            .chat-node input[type="text"],
            .chat-node input[type="search"],
            .chat-node input[type="email"],
            .chat-node input[type="password"],
            .chat-node input[type="number"] {
                user-select: text;
                -webkit-user-select: text;
                cursor: text;
            }

            .node-user textarea.user-content-textarea {
                user-select: none !important;
                -webkit-user-select: none !important;
                cursor: default;
            }

            .chat-node .markdown-content pre {
                touch-action: none;
            }

            .node-textarea,
            .user-content-textarea {
                max-height: none;
                overflow-y: visible;
            }
        }

        .user-content-textarea {
            width: 100%;
            background: transparent;
            border: none;
            padding: 0;
            margin: 0;
            font-family: inherit;
            font-size: inherit;
            color: inherit;
            line-height: inherit;
            resize: none;
            outline: none;
            transition: opacity 0.2s;
            max-height: 280px;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }

        .user-content-textarea:focus {
            background: rgba(248, 250, 252, 0.5);
            border-radius: 4px;
        }

        .node-textarea::-webkit-scrollbar,
        .user-content-textarea::-webkit-scrollbar {
            width: 8px;
        }

        .node-textarea::-webkit-scrollbar-track,
        .user-content-textarea::-webkit-scrollbar-track {
            background: rgba(241, 245, 249, 0.8);
            border-radius: 9999px;
        }

        .node-textarea::-webkit-scrollbar-thumb,
        .user-content-textarea::-webkit-scrollbar-thumb {
            background: rgba(100, 116, 139, 0.4);
            border-radius: 9999px;
        }

        .node-textarea::-webkit-scrollbar-thumb:hover,
        .user-content-textarea::-webkit-scrollbar-thumb:hover {
            background: rgba(100, 116, 139, 0.55);
        }

        .chat-node .markdown-content {
            font-size: 0.95rem;
            line-height: 1.62;
            letter-spacing: 0.01em;
        }

        .chat-node .markdown-content a { color: var(--accent-blue); text-decoration: none; }
        .chat-node .markdown-content a:hover { text-decoration: underline; }
        .chat-node .markdown-content code { background: rgba(100, 116, 139, 0.12); padding: 0.2em 0.4em; border-radius: 4px; font-size: 0.9em; }
        .chat-node .markdown-content pre {
            background: #f8fafc;
            border: 1px solid var(--card-border);
            border-radius: 8px;
            padding: 12px;
            overflow-x: auto;
            touch-action: pan-x pan-y;
        }
        .chat-node .markdown-content pre code { background: none; padding: 0; }
        .chat-node .markdown-content blockquote { border-left: 4px solid var(--card-border); padding-left: 1em; margin: 1em 0; color: var(--text-secondary); }
        .chat-node .markdown-content h1, .chat-node .markdown-content h2, .chat-node .markdown-content h3 { color: var(--text-primary); font-weight: 600; margin: 1em 0 0.5em; }
        .chat-node .markdown-content table { border-collapse: collapse; width: 100%; }
        .chat-node .markdown-content th, .chat-node .markdown-content td { border: 1px solid var(--card-border); padding: 6px 10px; text-align: left; }
        .chat-node .markdown-content th { background: rgba(248, 250, 252, 0.9); font-weight: 600; }

        /* Connection Lines - Pencil-like (brain green theme) */
        .connection-path {
            stroke: var(--brain-border-line);
            stroke-width: 4;
            fill: none;
            opacity: 0.45;
            transition: d 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
        }

        .spinner {
            border: 2px solid rgba(37, 99, 235, 0.2);
            border-top: 2px solid var(--accent-blue);
            border-radius: 50%;
            width: 20px;
            height: 20px;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .loading-dots::after {
            content: '';
            animation: dots 1.5s infinite step-start;
        }

        @keyframes dots {
            0% {
                content: '';
            }

            25% {
                content: '.';
            }

            50% {
                content: '..';
            }

            75% {
                content: '...';
            }

            100% {
                content: '';
            }
        }

        #ui-layer {
            position: fixed;
            top: 24px;
            left: 24px;
            z-index: 100;
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: stretch;
            padding: 10px;
            border-radius: 12px;
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            box-shadow: var(--card-shadow);
            /* Block browser pinch-zoom on toolbar; taps still work; map uses its own pinch (#canvas-container) */
            touch-action: none;
        }

        .ui-btn {
            width: 40px;
            height: 40px;
            padding: 0;
            color: var(--text-secondary);
            border-radius: 10px;
            font-size: 0.95rem;
            border: 1px solid var(--card-border);
            background: rgba(248, 250, 252, 0.9);
            cursor: pointer;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
            transition: all 0.18s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .ui-btn:hover {
            border-color: var(--accent-blue);
            color: var(--accent-blue);
            background: rgba(37, 99, 235, 0.06);
            transform: translateY(-1px);
        }

        .ui-btn:active {
            transform: translateY(0);
        }

        .ui-zoom-btn {
            font-size: 1rem;
            font-weight: 700;
            line-height: 1;
        }

        .ui-btn svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
        }

        .ui-btn-save {
            color: var(--text-secondary);
            border-color: var(--card-border);
            background: rgba(248, 250, 252, 0.9);
        }

        .ui-btn-save:hover {
            color: var(--accent-blue);
            border-color: var(--accent-blue);
            background: rgba(37, 99, 235, 0.06);
        }

        .ui-btn-save.is-dirty {
            color: var(--accent-emerald);
            border-color: rgba(5, 150, 105, 0.4);
            background: rgba(5, 150, 105, 0.12);
        }

        .ui-btn-save.is-dirty:hover {
            color: #047857;
            border-color: rgba(5, 150, 105, 0.6);
            background: rgba(5, 150, 105, 0.2);
        }

        #ui-zoom-indicator {
            position: fixed;
            left: 50%;
            top: 76px;
            min-width: 56px;
            text-align: center;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-secondary);
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 9999px;
            padding: 6px 10px;
            opacity: 0;
            transform: translateX(-50%) translateY(4px);
            transition: opacity 0.2s ease, transform 0.2s ease;
            pointer-events: none;
            box-shadow: var(--card-shadow);
            z-index: 180;
        }

        #ui-zoom-indicator.visible {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        .cm-touch-like #ui-layer #ui-zoom-in,
        .cm-touch-like #ui-layer #ui-zoom-out {
            display: none !important;
        }

        /* Mobile / coarse: extra toolbar buttons, hide secondary column; center map under brain */
        .ui-toolbar-mobile-only {
            display: none !important;
        }

        #ui-center-map-under-brain {
            display: flex;
        }

        @media (max-width: 900px), (pointer: coarse) {
            :root {
                --mobile-chrome-top: max(4px, env(safe-area-inset-top, 0px));
                /* Match left icon strip: 26px controls + 8px vertical padding + 2px border */
                --mobile-toolbar-outer-h: 36px;
                --mobile-toolbar-inner-h: 26px;
            }

            .ui-toolbar-mobile-only {
                display: flex !important;
            }

            #ui-secondary-panel {
                display: none !important;
            }

            #ui-center-map-under-brain {
                display: flex !important;
            }

            /* Horizontal icon strip: shrink-wrap width (not full viewport), aligned with brain + profile */
            #ui-layer {
                top: var(--mobile-chrome-top);
                left: max(10px, env(safe-area-inset-left, 0px));
                width: fit-content;
                max-width: calc(100vw - 20px);
                height: var(--mobile-toolbar-outer-h);
                box-sizing: border-box;
                padding: 4px 8px;
                gap: 6px;
                border-radius: 10px;
                flex-direction: row;
                flex-wrap: nowrap;
                align-items: center;
                position: fixed;
            }

            #ui-layer .ui-btn {
                width: 26px;
                height: 26px;
                border-radius: 7px;
                flex-shrink: 0;
            }

            #ui-layer .ui-btn svg {
                width: 12px;
                height: 12px;
            }

            #brain-toggle-layer {
                top: var(--mobile-chrome-top);
                flex-direction: column;
                align-items: center;
                justify-content: flex-start;
                gap: 0;
            }

            #map-zoom-hud {
                top: calc(var(--mobile-chrome-top) + 38px + 2px);
            }

            #brain-toggle-layer .ui-btn-brain {
                width: 38px;
                height: 38px;
                border-radius: 8px;
            }

            #brain-toggle-layer .ui-btn-brain svg {
                width: 24px;
                height: 24px;
            }

            #brain-toggle-layer .ui-btn-brain:hover {
                border-color: rgba(5, 150, 105, 0.5);
                background: rgba(5, 150, 105, 0.08);
                color: var(--text-secondary);
            }

            .ui-center-crosshair-mobile {
                width: 28px;
                height: 28px;
                min-width: 28px;
                min-height: 28px;
                padding: 0;
                margin: -2px 0 0 0;
                border: none !important;
                background: transparent !important;
                box-shadow: none !important;
                border-radius: 0;
                color: var(--text-secondary);
                cursor: pointer;
                align-items: center;
                justify-content: center;
                touch-action: manipulation;
            }

            .ui-center-crosshair-mobile svg {
                width: 16px;
                height: 16px;
                stroke: currentColor;
                fill: none;
                stroke-width: 2;
                stroke-linecap: round;
            }

            .ui-center-crosshair-mobile:active {
                opacity: 0.65;
            }

            #ui-maps-toggle-mobile.active {
                color: var(--accent-emerald) !important;
                border-color: rgba(5, 150, 105, 0.45) !important;
                background: rgba(5, 150, 105, 0.12) !important;
            }

            /* Map icon: theme green, not default .ui-btn blue hover / iOS tap flash */
            #ui-layer #ui-maps-toggle-mobile {
                -webkit-tap-highlight-color: transparent;
            }

            #ui-layer #ui-maps-toggle-mobile:not(.active) {
                color: var(--text-secondary);
            }

            #ui-layer #ui-maps-toggle-mobile:not(.active):hover {
                color: var(--accent-emerald);
                border-color: rgba(5, 150, 105, 0.4);
                background: rgba(5, 150, 105, 0.1);
                transform: none;
            }

            #ui-layer #ui-maps-toggle-mobile:focus-visible {
                outline: 2px solid rgba(5, 150, 105, 0.45);
                outline-offset: 2px;
            }

            #user-profile-widget.profile-widget-root {
                top: var(--mobile-chrome-top) !important;
                margin-top: 0 !important;
                right: max(10px, env(safe-area-inset-right, 0px)) !important;
                width: auto !important;
                max-width: min(290px, calc(100vw - 148px)) !important;
                height: var(--mobile-toolbar-outer-h) !important;
                min-height: var(--mobile-toolbar-outer-h) !important;
                max-height: var(--mobile-toolbar-outer-h) !important;
                box-sizing: border-box !important;
                padding: 4px 8px !important;
                border-radius: 10px !important;
                background: var(--card-bg) !important;
                border: 1px solid var(--card-border) !important;
                box-shadow: var(--card-shadow) !important;
                display: flex !important;
                align-items: center !important;
                overflow: hidden !important;
            }

            #user-profile-widget .profile-widget-first-row {
                align-items: center !important;
                gap: 6px !important;
                flex: 1 1 auto !important;
                min-width: 0 !important;
                min-height: 0 !important;
                height: var(--mobile-toolbar-inner-h) !important;
                max-height: var(--mobile-toolbar-inner-h) !important;
            }

            #user-profile-widget .profile-widget-avatar,
            #user-profile-widget .profile-widget-user-text,
            #user-profile-widget .profile-widget-usage-desktop {
                display: none !important;
            }

            #user-profile-widget .profile-usage-compact {
                display: block !important;
                color: var(--text-secondary) !important;
                font-size: 10px !important;
                font-weight: 600 !important;
                line-height: var(--mobile-toolbar-inner-h) !important;
                white-space: nowrap !important;
                overflow: hidden !important;
                text-overflow: ellipsis !important;
            }

            #user-profile-widget .profile-widget-logout {
                flex-shrink: 0 !important;
                width: var(--mobile-toolbar-inner-h) !important;
                height: var(--mobile-toolbar-inner-h) !important;
                min-width: var(--mobile-toolbar-inner-h) !important;
                min-height: var(--mobile-toolbar-inner-h) !important;
                padding: 0 !important;
                border-radius: 7px !important;
                border-color: var(--card-border) !important;
                background: rgba(248, 250, 252, 0.65) !important;
                color: var(--text-secondary) !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
            }

            #user-profile-widget .profile-widget-logout svg {
                width: 12px !important;
                height: 12px !important;
            }

            #user-profile-widget .profile-widget-logout:hover {
                border-color: rgba(5, 150, 105, 0.4) !important;
                color: var(--accent-emerald) !important;
            }

            /* max-height always; top only while .maps-default-mobile-y so drag can set inline top */
            #right-panel-scroll.right-panel-maps-host {
                max-height: calc(100vh - env(safe-area-inset-top, 0px) - 3.5rem) !important;
            }

            #right-panel-scroll.right-panel-maps-host.maps-default-mobile-y {
                top: calc(env(safe-area-inset-top, 0px) + 2.85rem) !important;
            }

            /* Library card headers: compact on coarse / ≤900 */
            #workspace-card-drag-handle,
            #context-card-drag-handle,
            #documents-card-drag-handle,
            #groups-card-drag-handle {
                padding-left: 0.5rem !important;
                padding-right: 0.5rem !important;
                padding-top: 0.45rem !important;
                padding-bottom: 0.45rem !important;
            }

            #workspace-card-drag-handle h3.text-sm,
            #context-card-drag-handle h3.text-sm,
            #documents-card-drag-handle h3.text-sm,
            #groups-card-drag-handle h3.text-sm {
                min-width: 0;
                flex: 1 1 auto;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .library-card-header-actions {
                gap: 4px !important;
            }

            #workspace-card .library-card-icon-btn,
            #context-card .library-card-icon-btn,
            #documents-card .library-card-icon-btn,
            #groups-card .library-card-icon-btn {
                padding: 0.125rem !important;
            }

            #workspace-card .library-card-icon-btn svg,
            #context-card .library-card-icon-btn svg,
            #documents-card .library-card-icon-btn svg,
            #groups-card .library-card-icon-btn svg {
                width: 11px !important;
                height: 11px !important;
            }
        }

        #ui-secondary-panel {
            position: fixed;
            top: 92px;
            left: 24px;
            z-index: 100;
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: stretch;
            padding: 10px;
            border-radius: 12px;
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            box-shadow: var(--card-shadow);
            /* Same as #ui-layer: no browser pinch-zoom on icon column */
            touch-action: none;
        }

        .ui-btn-toggle.active {
            color: var(--accent-emerald);
            border-color: rgba(5, 150, 105, 0.4);
            background: rgba(5, 150, 105, 0.12);
        }

        .ui-btn-toggle.active:hover {
            color: #047857;
            border-color: rgba(5, 150, 105, 0.6);
            background: rgba(5, 150, 105, 0.2);
        }

        #ui-secondary-panel #ui-maps-toggle.active {
            color: var(--accent-emerald) !important;
            border-color: rgba(5, 150, 105, 0.45) !important;
            background: rgba(5, 150, 105, 0.12) !important;
        }

        #ui-secondary-panel .ui-btn-toggle:not(.active):hover {
            color: var(--accent-emerald);
            border-color: rgba(5, 150, 105, 0.4);
            background: rgba(5, 150, 105, 0.1);
        }

        .ui-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Brain toggle: top center, frontmost app chrome (tool setting across features). */
        #brain-toggle-layer {
            position: fixed;
            top: 24px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 12000;
            opacity: 0.7;
            transition: opacity 0.18s ease;
            display: flex;
            flex-direction: column;
            align-items: center;
            touch-action: none; /* no browser pinch-zoom on brain toggle */
        }

        /* Map zoom / center: fixed under brain, above chat nodes & map chrome; below app modals (z-500+). */
        #map-zoom-hud {
            position: fixed;
            left: 50%;
            transform: translateX(-50%);
            top: calc(24px + 58px + 2px);
            z-index: 120;
            flex-direction: row;
            align-items: center;
            justify-content: center;
            gap: 4px;
            opacity: 0.7;
            transition: opacity 0.18s ease;
            touch-action: none;
            pointer-events: auto;
        }

        #map-zoom-hud:not(.hidden) {
            display: flex;
        }

        #map-zoom-hud:hover {
            opacity: 0.95;
        }

        #map-zoom-hud .ui-zoom-under-brain,
        #map-zoom-hud .ui-center-crosshair-mobile {
            margin-top: 0;
        }

        /* Fixed overlays: block Safari page pinch (map keeps JS pinch under #canvas-container) */
        #user-profile-widget {
            touch-action: none;
        }

        #right-panel-scroll {
            touch-action: none;
            transition: none;
        }
        #right-panel-scroll.dragging {
            transition: none;
        }
        #right-panel-scroll.maps-panel-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #right-panel-scroll.maps-panel-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1),
                opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        /* Library side cards: My Maps, My Contexts, My Files — shared parchment + subtle chrome */
        #workspace-card,
        #context-card,
        #documents-card,
        #groups-card {
            touch-action: none;
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            box-shadow: var(--card-shadow);
        }

        #workspace-card-drag-handle,
        #context-card-drag-handle,
        #documents-card-drag-handle,
        #groups-card-drag-handle {
            background: var(--card-bg);
            border-bottom: 1px solid rgba(75, 55, 35, 0.12) !important;
        }

        #workspace-card-drag-handle:hover,
        #context-card-drag-handle:hover,
        #documents-card-drag-handle:hover,
        #groups-card-drag-handle:hover {
            background: rgba(255, 255, 255, 0.22);
        }

        #workspace-card-content,
        #context-card-content,
        #documents-card-content,
        #groups-card-content {
            background: var(--card-bg);
        }

        .library-card-title {
            color: #2d2819;
        }

        .library-card-header-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-shrink: 0;
        }

        .library-card-icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.2rem;
            border-radius: 0.375rem;
            border: 1px solid rgba(75, 55, 35, 0.14);
            color: #5c5142;
            background: transparent;
            cursor: pointer;
            transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        .library-card-icon-btn:hover {
            background: rgba(75, 55, 35, 0.06);
            color: #2d2819;
            border-color: rgba(75, 55, 35, 0.22);
        }

        .library-card-icon-btn:focus-visible {
            outline: 2px solid rgba(5, 150, 105, 0.4);
            outline-offset: 2px;
        }

        .library-card-icon-btn.library-card-icon-primary {
            border-color: rgba(5, 150, 105, 0.22);
            color: #047857;
        }

        .library-card-icon-btn.library-card-icon-primary:hover {
            background: rgba(5, 150, 105, 0.08);
            color: #065f46;
            border-color: rgba(5, 150, 105, 0.34);
        }

        #workspace-list-container .library-list-row,
        #context-list-container .library-list-row,
        #documents-list-container .library-list-row {
            border: 1px solid rgba(75, 55, 35, 0.14);
            background: rgba(255, 255, 255, 0.28);
        }

        #workspace-list-container .library-list-row:hover,
        #context-list-container .library-list-row:hover,
        #documents-list-container .library-list-row:hover {
            border-color: rgba(5, 150, 105, 0.3);
            background: rgba(5, 150, 105, 0.06);
        }

        .library-list-primary {
            color: #2d2819;
            font-weight: 500;
        }

        button.library-list-primary {
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            font: inherit;
            text-align: left;
        }

        button.library-list-primary:hover {
            color: #047857;
        }

        .library-list-meta {
            color: rgba(71, 85, 105, 0.88);
        }

        .library-list-actions-toggle {
            font-size: 11px;
            padding: 0.125rem 0.35rem;
            border-radius: 0.375rem;
            border: 1px solid rgba(75, 55, 35, 0.14);
            color: #5c5142;
            background: rgba(255, 255, 255, 0.35);
            cursor: pointer;
            transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
        }

        .library-list-actions-toggle:hover {
            border-color: rgba(5, 150, 105, 0.32);
            color: #047857;
            background: rgba(5, 150, 105, 0.07);
        }

        .library-actions-menu {
            border: 1px solid rgba(75, 55, 35, 0.18) !important;
            background: var(--card-bg) !important;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
        }

        .library-actions-menu .library-actions-item {
            color: #2d2819;
            font-size: 11px;
        }

        .library-actions-menu .library-actions-item:hover:not(:disabled) {
            background: rgba(75, 55, 35, 0.08);
        }

        .library-actions-menu .library-actions-item:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        .library-actions-menu .library-actions-item-muted {
            border-top: 1px solid rgba(75, 55, 35, 0.12);
        }

        .library-actions-menu .library-actions-item-danger {
            color: #b45309;
            border-top: 1px solid rgba(75, 55, 35, 0.12);
        }

        .library-actions-menu .library-actions-item-danger:hover:not(:disabled) {
            background: rgba(180, 83, 9, 0.1);
            color: #92400e;
        }

        .library-list-empty {
            color: rgba(92, 81, 66, 0.72);
        }

        #workspace-list-container,
        #context-list-container,
        #documents-list-container {
            touch-action: pan-y;
            scrollbar-width: thin;
            scrollbar-color: rgba(75, 55, 35, 0.35) rgba(236, 231, 216, 0.9);
        }

        #workspace-list-container::-webkit-scrollbar,
        #context-list-container::-webkit-scrollbar,
        #documents-list-container::-webkit-scrollbar {
            width: 8px;
        }

        #workspace-list-container::-webkit-scrollbar-track,
        #context-list-container::-webkit-scrollbar-track,
        #documents-list-container::-webkit-scrollbar-track {
            background: rgba(236, 231, 216, 0.85);
            border-radius: 999px;
        }

        #workspace-list-container::-webkit-scrollbar-thumb,
        #context-list-container::-webkit-scrollbar-thumb,
        #documents-list-container::-webkit-scrollbar-thumb {
            background: rgba(75, 55, 35, 0.28);
            border-radius: 999px;
        }

        #workspace-list-container::-webkit-scrollbar-thumb:hover,
        #context-list-container::-webkit-scrollbar-thumb:hover,
        #documents-list-container::-webkit-scrollbar-thumb:hover {
            background: rgba(75, 55, 35, 0.4);
        }

        /* My Maps floating panel: hidden until the map toolbar icon opens it (all viewports). */
        #right-panel-scroll.right-panel-maps-host:not(.my-maps-panel-visible) {
            display: none !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }

        #workspace-close-btn.workspace-close-my-maps {
            display: inline-flex !important;
            align-items: center;
            justify-content: center;
        }

        #context-card-panel,
        #documents-card-panel,
        #groups-card-panel {
            touch-action: none;
        }

        #context-card,
        #documents-card,
        #groups-card {
            touch-action: none;
        }

        #context-list-container,
        #documents-list-container,
        #groups-list-container {
            touch-action: pan-y;
        }

        #writepad-panel {
            touch-action: none;
        }

        #documents-panel,
        #visibility-panel {
            touch-action: none;
        }

        #login-overlay {
            touch-action: none;
        }

        #brain-toggle-layer:hover {
            opacity: 0.95;
        }

        .ui-btn-brain {
            width: 58px;
            height: 58px;
            padding: 0;
            border-radius: 12px;
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            cursor: pointer;
            box-shadow: var(--card-shadow);
            transition: all 0.18s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
        }

        .ui-btn-brain:hover {
            border-color: var(--accent-blue);
            background: rgba(37, 99, 235, 0.06);
            color: var(--text-secondary);
        }

        .ui-btn-brain.active {
            color: var(--accent-emerald);
            border-color: rgba(5, 150, 105, 0.4);
            background: rgba(5, 150, 105, 0.12);
        }

        .ui-btn-brain.active:hover {
            color: #047857;
            border-color: rgba(5, 150, 105, 0.6);
            background: rgba(5, 150, 105, 0.2);
        }

        .ui-btn-brain svg {
            width: 36px;
            height: 36px;
            stroke: currentColor;
        }

        .ui-center-crosshair-mobile {
            width: 32px;
            height: 32px;
            min-width: 32px;
            min-height: 32px;
            margin-top: 6px;
            padding: 0;
            border: none !important;
            background: transparent !important;
            box-shadow: none !important;
            border-radius: 0;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            touch-action: manipulation;
        }

        .ui-center-crosshair-mobile svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
        }

        .ui-center-crosshair-mobile:active {
            opacity: 0.65;
        }

        .ui-zoom-under-brain {
            width: 32px;
            height: 32px;
            min-width: 32px;
            min-height: 32px;
            margin-top: 6px;
            padding: 0;
            border: none !important;
            background: transparent !important;
            box-shadow: none !important;
            border-radius: 0;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            touch-action: manipulation;
            font-size: 1.05rem;
            font-weight: 700;
            line-height: 1;
        }

        .ui-zoom-under-brain:active {
            opacity: 0.65;
        }

        /* Spark layer: hidden by default, shows animated dash when active */
        .ui-btn-brain .brain-spark {
            opacity: 0;
            pointer-events: none;
        }

        .ui-btn-brain .brain-spark path {
            stroke-dasharray: 0.06 0.94;
            animation: none;
        }

        .ui-btn-brain.active .brain-spark {
            opacity: 1;
        }

        .ui-btn-brain.active .brain-spark path {
            stroke: white;
            stroke-width: 2.5;
            animation: brainStrokeFlow 2.5s linear infinite;
        }

        @keyframes brainStrokeFlow {
            from { stroke-dashoffset: 0; }
            to { stroke-dashoffset: 1; }
        }

        .global-ui-hint {
            position: fixed;
            z-index: 250;
            padding: 8px 12px;
            font-size: 0.75rem;
            color: var(--text-primary);
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 8px;
            box-shadow: var(--card-shadow);
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transform: translate(-50%, 0);
            transition: opacity 0.15s ease;
        }

        .global-ui-hint.visible {
            opacity: 1;
        }

        .global-ui-hint.hint-right {
            transform: translate(0, -50%);
        }

        /* Ensure contextual themed hints can appear over actions menus */
        #global-themed-hint {
            z-index: 6000;
        }

        /* KaTeX Textbook Display Overrides */
        .katex-display {
            margin: 1.25em 0 !important;
            font-size: 1.15em;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 8px 0;
        }

        .katex {
            font-size: 1.1em;
        }

        /* Graphing Styles */
        .graph-container {
            width: 100%;
            height: 220px;
            margin: 15px 0;
            background: rgba(248, 250, 252, 0.9);
            border-radius: 10px;
            overflow: hidden;
            border: 1px solid var(--card-border);
        }

        .graph-container svg {
            font-family: 'Inter', sans-serif;
        }

        .graph-container .grid line {
            stroke: rgba(100, 116, 139, 0.15) !important;
        }

        .graph-container .axis line,
        .graph-container .axis path {
            stroke: rgba(100, 116, 139, 0.4) !important;
        }

        .graph-container .axis text {
            fill: var(--text-secondary) !important;
            font-size: 10px;
        }

        /* Attachment Styles — AI Node Footer (send area) */
        .attachment-preview-container {
            display: flex;
            gap: 10px;
            overflow-x: auto;
            padding: 8px 0;
            margin-bottom: 5px;
        }

        .attachment-item {
            position: relative;
            width: 50px;
            height: 50px;
            border-radius: 8px;
            background: rgba(248, 250, 252, 0.9);
            border: 1px solid var(--card-border);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }

        .attachment-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .attachment-item .file-icon {
            font-size: 10px;
            font-weight: bold;
            opacity: 0.6;
        }

        .attachment-remove {
            position: absolute;
            top: 2px;
            right: 2px;
            width: 14px;
            height: 14px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: white;
            font-size: 8px;
            z-index: 10;
        }

        .attachment-controls {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 10px;
        }

        /* Draggable Context card panel */
        #context-card-panel {
            transition: none;
        }
        #context-card-panel.dragging {
            transition: none;
        }
        #context-card-panel.context-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #context-card-panel.context-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1),
                opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        /* Documents card panel (like My Contexts) */
        #documents-card-panel { transition: none; }
        #documents-card-panel.dragging { transition: none; }
        #documents-card-panel.documents-card-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #documents-card-panel.documents-card-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        #groups-card-panel { transition: none; }
        #groups-card-panel.dragging { transition: none; }
        #groups-card-panel.groups-card-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #groups-card-panel.groups-card-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        #writepad-panel {
            transition: none;
        }
        #writepad-panel.dragging { transition: none; }
        #writepad-panel.writepad-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #writepad-panel.writepad-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        #writepad-drag-handle:hover { background: rgba(241, 245, 249, 0.6); }
        .writepad-tool.active { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
        #writepad-zoom-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #2563eb; border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,0.1); cursor: pointer; }
        #writepad-zoom-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #2563eb; border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,0.1); cursor: pointer; }
        #writepad-panel { overflow: visible; }
        #writepad-canvas-wrap {
            overflow: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }
        #writepad-canvas-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
        #writepad-canvas-wrap::-webkit-scrollbar-track { background: rgba(241, 245, 249, 0.8); border-radius: 4px; }
        #writepad-canvas-wrap::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.4); border-radius: 4px; }
        #writepad-canvas-wrap::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); }
        #writepad-resize-handle {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 50%, rgba(148, 163, 184, 0.4) 50%);
        }
        #writepad-resize-handle:hover { background: linear-gradient(135deg, transparent 50%, rgba(100, 116, 139, 0.6) 50%); }

        /* Documents Canvas panel */
        #documents-panel { transition: none; }
        #documents-panel.dragging { transition: none; }
        #documents-panel.documents-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #documents-panel.documents-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        #documents-panel-title[contenteditable="true"] {
            user-select: text;
            -webkit-user-select: text;
            cursor: text;
        }
        #documents-drag-handle:hover { background: rgba(241, 245, 249, 0.6); }
        #visibility-panel { transition: none; }
        #visibility-panel.dragging { transition: none; }
        #visibility-panel.documents-collapse {
            transition: transform 0.68s ease-in, opacity 0.4s ease-in 0.28s;
        }
        #visibility-panel.documents-expand {
            transition: transform 0.68s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.4s ease-out;
            opacity: 1;
            transform: scale(1);
        }
        #visibility-drag-handle:hover { background: rgba(241, 245, 249, 0.6); }
        /* Responses table — old parched graphing paper aesthetic */
        #view-responses-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
        }
        /* Actions tray: breadcrumb-style bar next to close; wraps on desktop, horizontal scroll on mobile */
        #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: flex-end;
            gap: 0.35rem 0.5rem;
            min-width: 0;
            flex: 1 1 auto;
            padding: 6px 8px;
            border-radius: 8px;
            background: rgba(245, 242, 233, 0.6);
            border: 1px solid rgba(75, 55, 35, 0.22);
        }
        @media (min-width: 640px) {
            #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb > * {
                max-width: 100%;
            }
        }
        @media (max-width: 639px) {
            #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb {
                flex-wrap: nowrap;
                justify-content: flex-start;
                overflow-x: auto;
                overflow-y: hidden;
                -webkit-overflow-scrolling: touch;
                touch-action: pan-x;
                scrollbar-width: thin;
                overscroll-behavior-x: contain;
                padding-bottom: 10px;
                margin-bottom: -2px;
            }
            #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb > * {
                max-width: none;
                flex-shrink: 0;
            }
            #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb::-webkit-scrollbar {
                height: 5px;
            }
            #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb::-webkit-scrollbar-thumb {
                background: rgba(75, 55, 35, 0.38);
                border-radius: 4px;
            }
        }
        #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb > *:not(:last-child)::after {
            content: '\203A';
            margin-left: 0.4rem;
            color: rgba(75, 55, 35, 0.42);
            font-size: 0.65rem;
            font-weight: 600;
            pointer-events: none;
        }
        #view-responses-actions-breadcrumb.view-responses-actions-breadcrumb > .view-responses-attach-wrap::after {
            content: none;
        }
        /* Layer sits above modal content but pointer-events-none so only the menu captures clicks */
        #view-responses-attach-menu-layer {
            pointer-events: none;
        }
        #view-responses-attach-menu {
            position: absolute;
            z-index: 1;
        }
        #view-responses-table {
            background: #e5dfcc;
            background-image:
                linear-gradient(to right, rgba(95, 70, 50, 0.08) 1px, transparent 1px),
                linear-gradient(to bottom, rgba(95, 70, 50, 0.08) 1px, transparent 1px);
            background-size: 20px 24px;
        }
        #view-responses-table .tabulator-row.view-responses-row-invalid .tabulator-cell {
            background-color: rgba(248, 113, 113, 0.22) !important;
        }
        #view-responses-points-modal table.vr-points-grid tbody tr.vr-points-row-invalid td {
            background-color: rgba(248, 113, 113, 0.2);
        }
        #view-responses-points-stage {
            min-height: 168px;
            background: linear-gradient(180deg, #faf8f2 0%, #f0ebe0 100%);
            border-bottom: 1px solid rgba(75, 55, 35, 0.2);
        }
        #view-responses-points-idle .vr-points-icon-btn {
            width: 4.5rem;
            height: 4.5rem;
            border-radius: 1rem;
            border: 2px solid rgba(75, 55, 35, 0.35);
            background: #fff;
            color: #3d3529;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, border-color 0.15s, transform 0.1s;
        }
        #view-responses-points-idle .vr-points-icon-btn:hover {
            background: rgba(75, 55, 35, 0.08);
            border-color: rgba(75, 55, 35, 0.5);
        }
        #view-responses-points-idle .vr-points-icon-btn:active {
            transform: scale(0.97);
        }
        #view-responses-points-cam-video {
            width: 100%;
            max-height: 220px;
            object-fit: contain;
            background: #1a1814;
            border-radius: 0.5rem;
        }
        #view-responses-points-mic-bars {
            display: flex;
            align-items: flex-end;
            justify-content: center;
            gap: 3px;
            height: 72px;
            padding: 0.5rem;
        }
        #view-responses-points-mic-bars span {
            width: 6px;
            border-radius: 2px;
            background: rgba(34, 120, 80, 0.85);
            min-height: 4px;
            transition: height 0.05s ease-out;
        }

        /* Parchment dialogs (Start new map, Name workspace) — matches Responses shell */
        #new-map-unsaved-modal #new-map-unsaved-box,
        #prompt-modal #prompt-modal-box,
        #groups-editor-discard-modal #groups-editor-discard-box,
        #view-responses-discard-modal #view-responses-discard-box,
        #groups-delete-group-modal #groups-delete-group-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
        }

        #new-map-unsaved-modal .new-map-unsaved-body,
        #prompt-modal .prompt-modal-body,
        #groups-editor-discard-modal .new-map-unsaved-body,
        #view-responses-discard-modal .new-map-unsaved-body,
        #groups-delete-group-modal .new-map-unsaved-body {
            background-color: #ece7d8;
        }

        #new-map-unsaved-modal .new-map-unsaved-action-btn,
        #prompt-modal .prompt-modal-action-btn,
        #groups-editor-discard-modal .new-map-unsaved-action-btn,
        #view-responses-discard-modal .new-map-unsaved-action-btn,
        #groups-delete-group-modal .new-map-unsaved-action-btn {
            flex: 1 1 0;
            min-width: 0;
            font-size: 0.8125rem;
            font-weight: 600;
            line-height: 1.2;
            padding: 0.5rem 0.35rem;
            border-radius: 0.375rem;
            border: 1px solid rgba(75, 55, 35, 0.3);
            color: #5c5142;
            background: transparent;
            cursor: pointer;
            transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        #new-map-unsaved-modal .new-map-unsaved-action-btn:hover,
        #prompt-modal .prompt-modal-action-btn:hover,
        #groups-editor-discard-modal .new-map-unsaved-action-btn:hover,
        #view-responses-discard-modal .new-map-unsaved-action-btn:hover,
        #groups-delete-group-modal .new-map-unsaved-action-btn:hover {
            background: rgba(75, 55, 35, 0.1);
            color: #2d2819;
            border-color: rgba(75, 55, 35, 0.45);
        }

        #prompt-modal #prompt-input {
            width: 100%;
            box-sizing: border-box;
            padding: 0.65rem 0.75rem;
            border-radius: 0.5rem;
            border: 1px solid rgba(75, 55, 35, 0.35);
            background: #f5f2e9;
            color: #2d2819;
            font-size: 0.875rem;
            font-family: inherit;
            outline: none;
            transition: border-color 0.15s ease, box-shadow 0.15s ease;
        }

        #prompt-modal #prompt-input::placeholder {
            color: rgba(92, 81, 66, 0.55);
        }

        #prompt-modal #prompt-input:focus {
            border-color: rgba(5, 150, 105, 0.45);
            box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.12);
        }

        #groups-dummy-modal #groups-editor-shell {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
        }

        #groups-dummy-modal .groups-editor-body {
            background-color: #ece7d8;
        }

        #groups-dummy-modal .groups-editor-table-wrap {
            max-height: min(50vh, 320px);
            overflow: auto;
            border: 1px solid rgba(75, 55, 35, 0.2);
            border-radius: 0.5rem;
            background: rgba(255, 255, 255, 0.25);
        }

        #groups-dummy-modal .groups-editor-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.7rem;
        }

        #groups-dummy-modal .groups-editor-table th,
        #groups-dummy-modal .groups-editor-table td {
            border: 1px solid rgba(75, 55, 35, 0.18);
            padding: 0.35rem 0.4rem;
            text-align: left;
            vertical-align: middle;
        }

        #groups-dummy-modal .groups-editor-table th {
            background: rgba(75, 55, 35, 0.08);
            color: #2d2819;
            font-weight: 600;
            white-space: nowrap;
        }

        #groups-dummy-modal .groups-editor-table input {
            width: 100%;
            box-sizing: border-box;
            min-width: 4rem;
            padding: 0.3rem 0.35rem;
            border-radius: 0.35rem;
            border: 1px solid rgba(75, 55, 35, 0.3);
            background: #f5f2e9;
            color: #2d2819;
            font-size: 0.7rem;
            font-family: inherit;
            outline: none;
        }

        #groups-dummy-modal .groups-editor-table input:read-only {
            background: rgba(75, 55, 35, 0.06);
            color: #5c5142;
        }

        #groups-dummy-modal .groups-editor-table input:focus:not(:read-only) {
            border-color: rgba(5, 150, 105, 0.45);
            box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.15);
        }

        #groups-dummy-modal .groups-editor-name-input {
            width: 100%;
            max-width: 14rem;
            box-sizing: border-box;
            padding: 0.4rem 0.5rem;
            border-radius: 0.4rem;
            border: 1px solid rgba(75, 55, 35, 0.35);
            background: #f5f2e9;
            color: #2d2819;
            font-size: 0.8rem;
            font-family: inherit;
        }

        #groups-dummy-modal #groups-editor-save-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        #groups-batch-from-modal #groups-batch-from-box,
        #groups-batch-preview-modal #groups-batch-preview-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
        }

        #groups-batch-from-modal .groups-batch-from-footer {
            border-top: 1px solid rgba(75, 55, 35, 0.15);
        }

        #groups-batch-from-modal .groups-batch-from-action-btn {
            flex: 0 0 auto;
            min-width: 5.5rem;
            font-size: 0.8125rem;
            font-weight: 600;
            line-height: 1.2;
            padding: 0.45rem 1rem;
            border-radius: 0.375rem;
            border: 1px solid rgba(75, 55, 35, 0.3);
            color: #5c5142;
            background: rgba(255, 255, 255, 0.3);
            cursor: pointer;
            transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        #groups-batch-from-modal .groups-batch-from-action-btn:hover:not(:disabled) {
            background: rgba(75, 55, 35, 0.1);
            color: #2d2819;
            border-color: rgba(75, 55, 35, 0.45);
        }

        #groups-batch-from-modal #groups-batch-from-ok:not(:disabled) {
            background: rgba(16, 185, 129, 0.2);
            border-color: rgba(5, 150, 105, 0.5);
            color: #14532d;
        }

        #groups-batch-from-modal #groups-batch-from-ok:not(:disabled):hover {
            background: rgba(16, 185, 129, 0.32);
        }

        #groups-batch-from-modal #groups-batch-from-ok:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        #groups-batch-preview-modal .groups-batch-preview-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.72rem;
        }

        #groups-batch-preview-modal .groups-batch-preview-table th,
        #groups-batch-preview-modal .groups-batch-preview-table td {
            border: 1px solid rgba(75, 55, 35, 0.18);
            padding: 0.35rem 0.4rem;
            text-align: left;
        }

        #groups-batch-preview-modal .groups-batch-preview-table th {
            background: rgba(75, 55, 35, 0.08);
            color: #2d2819;
            font-weight: 600;
        }

        #groups-property-schema-modal #groups-property-schema-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
        }

        #groups-property-schema-modal .groups-property-schema-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.72rem;
        }

        #groups-property-schema-modal .groups-property-schema-table th,
        #groups-property-schema-modal .groups-property-schema-table td {
            border: 1px solid rgba(75, 55, 35, 0.18);
            padding: 0.35rem 0.4rem;
            text-align: left;
            vertical-align: middle;
        }

        #groups-property-schema-modal .groups-property-schema-table th {
            background: rgba(75, 55, 35, 0.08);
            color: #2d2819;
            font-weight: 600;
        }

        #groups-property-schema-modal .groups-prop-schema-footer .groups-prop-schema-action-btn {
            flex: 0 0 auto;
            min-width: 5rem;
            font-size: 0.8125rem;
            font-weight: 600;
            line-height: 1.2;
            padding: 0.45rem 1rem;
            border-radius: 0.375rem;
            border: 1px solid rgba(75, 55, 35, 0.3);
            color: #5c5142;
            background: rgba(255, 255, 255, 0.3);
            cursor: pointer;
            transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        #groups-property-schema-modal .groups-prop-schema-footer .groups-prop-schema-action-btn:hover:not(:disabled) {
            background: rgba(75, 55, 35, 0.1);
            color: #2d2819;
            border-color: rgba(75, 55, 35, 0.45);
        }

        #groups-property-schema-modal #groups-property-schema-apply:not(:disabled) {
            background: rgba(16, 185, 129, 0.2);
            border-color: rgba(5, 150, 105, 0.5);
            color: #14532d;
        }

        #groups-property-schema-modal #groups-property-schema-add-row:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        #groups-dummy-modal .prompt-modal-action-btn {
            flex: 0 0 auto;
            min-width: 4.5rem;
        }

        /* Documents Canvas — viewer submit / exit (parchment + blue accent, matches app dialogs) */
        #documents-viewer-submit-modal .documents-viewer-dialog-box,
        #documents-viewer-exit-confirm-modal .documents-viewer-dialog-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 4px 20px rgba(0, 0, 0, 0.15);
            border-color: rgba(75, 55, 35, 0.3) !important;
        }
        #documents-viewer-submit-modal #documents-viewer-submit-name {
            width: 100%;
            box-sizing: border-box;
            background: #f5f2e9 !important;
            border: 1px solid rgba(75, 55, 35, 0.35) !important;
            color: #2d2819 !important;
        }
        #documents-viewer-submit-modal #documents-viewer-submit-name::placeholder {
            color: rgba(92, 81, 66, 0.55) !important;
        }
        #documents-viewer-submit-modal #documents-viewer-submit-name:focus {
            border-color: rgba(37, 99, 235, 0.45) !important;
            box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12) !important;
            outline: none !important;
        }
        
        /* Parchment dialogs (Context Access, Context Edit) */
        #context-access-modal #context-access-box,
        #context-modal #context-modal-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            border-color: rgba(75, 55, 35, 0.28) !important;
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 6px 24px rgba(0, 0, 0, 0.16);
            color: #2d2819;
        }

        #context-access-title,
        #context-modal-title {
            color: #2d2819 !important;
        }

        #context-access-email,
        #context-name-input,
        #context-description-input,
        #context-file-input {
            background: #f5f2e9 !important;
            border-color: rgba(75, 55, 35, 0.28) !important;
            color: #2d2819 !important;
        }

        #context-access-email::placeholder,
        #context-name-input::placeholder,
        #context-description-input::placeholder {
            color: rgba(92, 81, 66, 0.62) !important;
        }

        #context-access-email:focus,
        #context-name-input:focus,
        #context-description-input:focus,
        #context-file-input:focus {
            border-color: rgba(5, 150, 105, 0.45) !important;
            box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.12) !important;
        }

        #context-private-input {
            accent-color: #5c5142;
        }

        #context-modal #context-modal-box .text-slate-600,
        #context-modal #context-modal-box .text-slate-500 {
            color: #6e5f4c !important;
        }

        #context-modal #context-modal-box .bg-slate-50 {
            background: rgba(245, 242, 233, 0.92) !important;
        }

        #context-modal #context-modal-box .border-slate-200 {
            border-color: rgba(75, 55, 35, 0.2) !important;
        }

        #context-access-list > div {
            background: rgba(245, 242, 233, 0.92) !important;
            border-color: rgba(75, 55, 35, 0.22) !important;
        }

        #context-access-list .text-slate-800 {
            color: #2d2819 !important;
        }

        #context-access-list .text-slate-500 {
            color: #6e5f4c !important;
        }

        #context-access-add,
        #context-save-btn {
            background: #5c5142 !important;
            color: #fff !important;
        }

        #context-access-add:hover,
        #context-save-btn:hover {
            background: #3d3529 !important;
        }

        #context-access-close,
        #context-cancel-btn {
            background: transparent !important;
            color: #5c5142 !important;
            border: 1px solid rgba(75, 55, 35, 0.3) !important;
        }

        #context-access-close:hover,
        #context-cancel-btn:hover {
            background: rgba(75, 55, 35, 0.1) !important;
            color: #2d2819 !important;
            border-color: rgba(75, 55, 35, 0.45) !important;
        }

        /* Parchment confirm dialog (Remove access / Transfer ownership, etc.) */
        #confirm-modal #confirm-modal-box {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
            border-color: rgba(75, 55, 35, 0.28) !important;
            box-shadow: inset 0 0 80px rgba(95, 70, 50, 0.04), 0 6px 24px rgba(0, 0, 0, 0.16);
        }

        #confirm-modal #confirm-title {
            color: #2d2819 !important;
        }

        #confirm-modal #confirm-msg {
            color: #5c5142 !important;
        }

        #confirm-modal #confirm-cancel {
            background: transparent !important;
            color: #5c5142 !important;
            border: 1px solid rgba(75, 55, 35, 0.3) !important;
        }

        #confirm-modal #confirm-cancel:hover {
            background: rgba(75, 55, 35, 0.1) !important;
            color: #2d2819 !important;
            border-color: rgba(75, 55, 35, 0.45) !important;
        }
        #view-responses-table .tabulator {
            background: transparent !important;
            font-family: 'Courier New', Courier, 'Lucida Console', monospace;
            font-size: 12px;
            color: #3d3529;
        }
        #view-responses-table .tabulator-header {
            background: linear-gradient(180deg, #d4cdb8 0%, #cdc5af 100%) !important;
            border-bottom: 2px solid rgba(75, 55, 35, 0.4) !important;
            box-shadow: 0 1px 3px rgba(75, 55, 35, 0.15);
        }
        #view-responses-table .tabulator-header .tabulator-col {
            white-space: normal;
            border-right: 1px solid rgba(75, 55, 35, 0.25) !important;
            color: #2d2819;
            font-weight: 600;
            /* Same parchment as frozen NAME/(%) /Points — scrollable #cols were default off-white */
            background: linear-gradient(180deg, #d8d1bc 0%, #d0c9b2 100%) !important;
        }
        #view-responses-table .tabulator-header .tabulator-col .tabulator-col-title {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        #view-responses-table .tabulator-tableHolder {
            background: transparent !important;
        }
        #view-responses-table .tabulator-row {
            background: rgba(245, 242, 233, 0.5) !important;
        }
        #view-responses-table .tabulator-row.tabulator-row-even {
            background: rgba(235, 230, 218, 0.4) !important;
        }
        #view-responses-table .tabulator-row:hover {
            background: rgba(220, 212, 195, 0.6) !important;
        }
        #view-responses-table .tabulator-cell {
            position: relative;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            border-right: 1px solid rgba(75, 55, 35, 0.18) !important;
            border-bottom: 1px solid rgba(75, 55, 35, 0.18) !important;
            padding: 4px 8px;
            line-height: 1.2;
            color: #3d3529;
        }
        /* Frozen NAME / (%) / Points: no opaque fill so row tint + graph paper match # columns */
        #view-responses-table .tabulator-cell.tabulator-frozen {
            background: transparent !important;
            box-shadow: 2px 0 4px rgba(75, 55, 35, 0.08);
        }
        #view-responses-table .tabulator-calcs-holder .tabulator-row .tabulator-cell {
            background: rgba(212, 205, 184, 0.9) !important;
            font-weight: 600;
            font-size: 11px;
        }
        /* Tabulator defaults: .tabulator-table is white; bottom calcs row is inline-block, so
           horizontal slack shows as a white strip. Keep table transparent and tint calc rows. */
        #view-responses-table .tabulator-tableholder .tabulator-table {
            background-color: transparent !important;
        }
        #view-responses-table .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs {
            background: rgba(212, 205, 184, 0.9) !important;
        }
        #view-responses-table .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs .tabulator-cell {
            background: rgba(212, 205, 184, 0.9) !important;
        }
        #view-responses-table .tabulator-footer .tabulator-calcs-holder {
            background: rgba(212, 205, 184, 0.95) !important;
            border-color: rgba(75, 55, 35, 0.22) !important;
        }
        #view-responses-table .tabulator-footer .tabulator-calcs-holder .tabulator-row {
            background: transparent !important;
        }
        #view-responses-table::-webkit-scrollbar,
        #view-responses-table .tabulator-tableHolder::-webkit-scrollbar { width: 10px; height: 10px; }
        #view-responses-table::-webkit-scrollbar-track,
        #view-responses-table .tabulator-tableHolder::-webkit-scrollbar-track { background: rgba(75, 55, 35, 0.08); border-radius: 4px; }
        #view-responses-table::-webkit-scrollbar-thumb,
        #view-responses-table .tabulator-tableHolder::-webkit-scrollbar-thumb { background: rgba(75, 55, 35, 0.3); border-radius: 4px; }
        #view-responses-table::-webkit-scrollbar-thumb:hover,
        #view-responses-table .tabulator-tableHolder::-webkit-scrollbar-thumb:hover { background: rgba(75, 55, 35, 0.45); }
        #view-responses-table .tabulator-cell .cell-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        #view-responses-table .tabulator-cell .cell-overlay { position: absolute; top: 2px; right: 6px; font-size: 10px; font-weight: 700; color: #166534; }
        #view-responses-table .tabulator-cell .cell-overlay.score-wrong { color: #b91c1c; }
        /* Responses statistics panel */
        #view-responses-stats-panel {
            background: linear-gradient(135deg, #e8e4d5 0%, #e0d9c4 50%, #ddd6c0 100%);
        }
        #view-responses-stats-panel .stats-inner-grid {
            background: #e5dfcc;
            background-image:
                linear-gradient(to right, rgba(95, 70, 50, 0.06) 1px, transparent 1px),
                linear-gradient(to bottom, rgba(95, 70, 50, 0.06) 1px, transparent 1px);
            background-size: 20px 24px;
        }
        #view-responses-stats-histogram .stats-box {
            flex-shrink: 0;
            min-height: 6px;
            border-radius: 2px;
            border: 1px solid rgba(75, 55, 35, 0.35);
            background: #cdc5af;
        }
        #view-responses-stats-histogram-scroll {
            scrollbar-width: thin;
            scrollbar-color: rgba(75, 55, 35, 0.35) rgba(75, 55, 35, 0.08);
        }
        #view-responses-stats-histogram-scroll::-webkit-scrollbar {
            height: 8px;
        }
        #view-responses-stats-histogram-scroll::-webkit-scrollbar-thumb {
            background: rgba(75, 55, 35, 0.35);
            border-radius: 4px;
        }
        #view-responses-stats-top-scroll {
            overflow-y: auto;
        }
        @media (min-width: 640px) {
            #view-responses-stats-top-scroll {
                overflow-x: hidden;
            }
            #view-responses-stats-top-table {
                min-width: 0;
                width: 100%;
            }
        }
        @media (max-width: 639.98px) {
            #view-responses-stats-top-scroll {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }
            #view-responses-stats-top-table {
                min-width: 300px;
                width: 100%;
            }
        }
        #view-responses-stats-top-table {
            box-sizing: border-box;
            line-height: calc(1.2 * 0.99);
        }
        #view-responses-stats-top-table thead th {
            padding-top: calc(0.375rem * 0.99);
            padding-bottom: calc(0.375rem * 0.99);
        }
        #view-responses-stats-top-table tbody td {
            padding-top: calc(0.25rem * 0.99);
            padding-bottom: calc(0.25rem * 0.99);
        }
        #view-responses-stats-top-table .stats-name-cell {
            width: auto;
            max-width: 0;
            overflow: hidden;
            vertical-align: middle;
        }
        #view-responses-stats-top-table .stats-name-cell .stats-name-text {
            display: block;
            width: 100%;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #view-responses-stats-histogram-inner {
            --stats-hist-col-min: 48px;
        }
        #view-responses-stats-histogram .stats-hist-col {
            flex: 1 1 0;
            min-width: var(--stats-hist-col-min, 48px);
        }
        #view-responses-stats-histogram-labels .stats-hist-axis-cell {
            flex: 1 1 0;
            min-width: var(--stats-hist-col-min, 48px);
            font-size: 8px;
            line-height: 1.2;
            color: #5c5142;
            text-align: center;
            white-space: nowrap;
            overflow: visible;
            padding: 2px 2px 0;
        }
        #view-responses-stats-histogram .stats-bin-count {
            flex-shrink: 0;
            min-height: 14px;
            height: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 9px;
            font-weight: 600;
            color: #3d3529;
        }
        #documents-canvas-wrap {
            position: relative;
            overflow: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(100, 116, 139, 0.5) rgba(241, 245, 249, 0.8);
        }
        #documents-canvas-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
        #documents-canvas-wrap::-webkit-scrollbar-track { background: rgba(241, 245, 249, 0.8); border-radius: 4px; }
        #documents-canvas-wrap::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.4); border-radius: 4px; }
        #documents-canvas-wrap::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); }
        #documents-resize-handle {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 50%, rgba(148, 163, 184, 0.4) 50%);
        }
        #documents-resize-handle:hover { background: linear-gradient(135deg, transparent 50%, rgba(100, 116, 139, 0.6) 50%); }

        /* Documents canvas pill-shaped input */
        .documents-input-pill {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            border-radius: 9999px;
            border: 1px solid #e2e8f0;
            background: white;
            min-height: 44px;
        }
        .documents-input-pill > .relative {
            flex: 0 0 36px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .documents-input-pill .documents-attach-btn {
            flex-shrink: 0;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #64748b;
            background: transparent;
            border: none;
            cursor: pointer;
            transition: color 0.2s, background 0.2s;
        }
        .documents-input-pill .documents-attach-btn:hover {
            color: #2563eb;
            background: rgba(37, 99, 235, 0.08);
        }
        .documents-input-pill #documents-instruction {
            flex: 1;
            min-width: 0;
            align-self: center;
            border: none;
            background: transparent;
            margin: 0;
            padding: 6px 8px 6px 0;
            font-size: 14px;
            line-height: 20px;
            min-height: 32px;
            max-height: 120px;
            resize: none;
            outline: none;
            text-align: left;
            box-sizing: border-box;
        }
        .documents-input-pill #documents-instruction::placeholder { color: #94a3b8; }
        .documents-input-pill .documents-submit-btn-wrap {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 36px;
        }
        .documents-input-pill .documents-submit-btn {
            padding: 8px 16px;
            border-radius: 9999px;
            font-size: 13px;
            font-weight: 500;
            background: #2563eb;
            color: white;
            border: none;
            cursor: pointer;
            transition: background 0.2s;
        }
        .documents-input-pill .documents-submit-btn:hover { background: #1d4ed8; }

        /* Narrow screens (≤640px): My Maps drawer (profile chrome lives in coarse / ≤900 rules) */
        @media (max-width: 640px) {
            #user-profile-widget.profile-widget-root {
                max-width: min(290px, calc(100vw - 24px));
            }
            #right-panel-scroll.right-panel-maps-host {
                right: 12px;
                width: var(--workspace-panel-width-narrow) !important;
                max-width: var(--workspace-panel-width-narrow);
                max-height: calc(100vh - 6rem);
                display: block;
                padding-right: 0;
            }

            #right-panel-scroll.right-panel-maps-host.maps-default-mobile-y {
                top: calc(env(safe-area-inset-top, 0px) + 2.85rem);
            }

            #context-card-panel,
            #documents-card-panel,
            #groups-card-panel {
                width: min(290px, calc(100vw - 24px)) !important;
                max-width: min(290px, calc(100vw - 24px));
            }

            #workspace-card {
                width: 100%;
                max-width: var(--workspace-panel-width-narrow);
            }
            .map-row-compact-narrow .map-row-title {
                font-size: 10px !important;
                line-height: 1.25;
            }
            .map-row-compact-narrow {
                padding-left: 0.35rem;
                padding-right: 0.35rem;
            }
            .map-row-compact-narrow .map-actions-toggle {
                font-size: 10px;
                padding: 0.1rem 0.35rem;
            }
        }
        @media (min-width: 641px) and (pointer: fine) {
            #user-profile-widget .profile-usage-compact {
                display: none !important;
            }
            #user-profile-widget .profile-widget-first-row {
                align-items: flex-start;
            }
        }

        /* Attachment Styles — User Node Display Strip */
        .user-attachment-strip {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            padding-bottom: 10px;
        }

        .user-attachment-strip:empty {
            display: none;
        }

        .user-attachment-strip.is-locked .remove-btn {
            display: none !important;
        }

        /* Image thumbnail chip */
        .user-att-img {
            position: relative;
            width: 64px;
            height: 64px;
            border-radius: 10px;
            overflow: hidden;
            border: 1px solid var(--card-border);
            flex-shrink: 0;
            cursor: default;
        }

        .user-att-img img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .user-att-img .user-att-x {
            position: absolute;
            top: 3px;
            right: 3px;
            width: 16px;
            height: 16px;
            background: rgba(0, 0, 0, 0.55);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: #fff;
            font-size: 9px;
            font-weight: bold;
            line-height: 1;
            z-index: 5;
            transition: background 0.15s;
        }

        .user-att-img .user-att-x:hover {
            background: #dc2626;
        }

        /* File chip */
        .user-att-file {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(248, 250, 252, 0.9);
            border: 1px solid var(--card-border);
            border-radius: 20px;
            padding: 4px 8px 4px 10px;
            font-size: 11px;
            color: var(--text-secondary);
            max-width: 180px;
            flex-shrink: 0;
        }

        .user-att-file .att-ext {
            background: rgba(37, 99, 235, 0.12);
            color: var(--accent-blue);
            font-size: 9px;
            font-weight: 700;
            padding: 2px 5px;
            border-radius: 4px;
            text-transform: uppercase;
            flex-shrink: 0;
        }

        .user-att-file .att-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex: 1;
        }

        .user-att-file .user-att-x {
            flex-shrink: 0;
            width: 14px;
            height: 14px;
            background: rgba(100, 116, 139, 0.15);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-muted);
            font-size: 9px;
            font-weight: bold;
            transition: background 0.15s, color 0.15s;
        }

        .user-att-file .user-att-x:hover {
            background: #dc2626;
            color: white;
        }

        .attach-btn {
            color: var(--text-muted);
            cursor: pointer;
            transition: color 0.2s, background 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 34px;
            height: 34px;
            border-radius: 10px;
            background: rgba(248, 250, 252, 0.9);
            border: 1px solid var(--card-border);
            flex-shrink: 0;
        }

        .attach-btn:hover {
            color: var(--accent-blue);
            background: rgba(37, 99, 235, 0.08);
            border-color: rgba(37, 99, 235, 0.3);
        }

        /* Context Link Toggle Styles - Inside Header */
        .link-toggle-btn {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 28px;
            height: 28px;
            background: rgba(100, 116, 139, 0.08);
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 10;
            color: var(--text-muted);
            transition: all 0.2s;
        }

        .link-toggle-btn:hover {
            background: rgba(100, 116, 139, 0.15);
            color: var(--text-primary);
        }

        .link-toggle-btn svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            transition: transform 0.2s;
            fill: none;
        }

        .link-toggle-btn.is-unlinked {
            color: #dc2626;
            background: rgba(239, 68, 68, 0.12);
        }

        .link-toggle-btn.is-unlinked:hover {
            background: rgba(239, 68, 68, 0.2);
            color: #b91c1c;
        }

        /* Severed / dashed line */
        .connection-path.is-unlinked {
            stroke-dasharray: 6, 6;
            opacity: 0.4;
            stroke: #dc2626;
        }


        .attach-btn svg {
            width: 18px;
            height: 18px;
        }

        /* Code Execution Styles */
        .execution-block {
            margin: 15px 0;
            border-radius: 10px;
            overflow: hidden;
            border: 1px solid var(--card-border);
        }

        .execution-header {
            background: rgba(248, 250, 252, 0.9);
            padding: 8px 12px;
            font-size: 10px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
            opacity: 0.8;
            color: var(--text-secondary);
            display: flex;
            justify-content: space-between;
        }

        .execution-code {
            background: #f8fafc;
            padding: 12px;
            font-family: 'Fira Code', 'Courier New', monospace;
            font-size: 12px;
            color: var(--text-primary);
            border-bottom: 1px solid var(--card-border);
        }

        .execution-result {
            background: #fff;
            padding: 12px;
            font-family: 'Fira Code', 'Courier New', monospace;
            font-size: 11px;
            color: var(--text-secondary);
            max-height: 200px;
            overflow-y: auto;
            white-space: pre-wrap;
            border-bottom: 1px solid var(--card-border);
        }

        .execution-image {
            width: 100%;
            border-radius: 0 0 10px 10px;
            display: block;
        }

        /* Canvas Styles */
        .canvas-wrapper {
            margin: 15px 0;
            border-radius: 10px;
            overflow: hidden;
            border: 1px solid var(--card-border);
            background: #fff;
            position: relative;
        }

        .canvas-header {
            background: rgba(248, 250, 252, 0.9);
            padding: 8px 12px;
            font-size: 10px;
            font-weight: bold;
            color: var(--text-secondary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--card-border);
        }

        .canvas-expand-btn {
            background: rgba(37, 99, 235, 0.12);
            color: var(--accent-blue);
            padding: 2px 8px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .canvas-expand-btn:hover {
            background: rgba(37, 99, 235, 0.2);
            color: #1d4ed8;
        }

        .canvas-iframe {
            width: 100%;
            height: 240px;
            border: none;
            display: block;
        }

        /* Fullscreen Overlay */
        #canvas-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.92);
            z-index: 10000;
            display: none;
            flex-direction: column;
        }

        #canvas-overlay.active {
            display: flex;
        }

        .overlay-header {
            padding: 15px 25px;
            background: var(--card-bg);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--card-border);
            color: var(--text-primary);
        }

        .close-overlay-btn {
            background: #dc2626;
            color: white;
            padding: 8px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: bold;
        }

        .overlay-content {
            flex: 1;
            width: 100%;
            height: 100%;
        }

        .overlay-iframe {
            width: 100%;
            height: 100%;
            border: none;
        }

        #revise-panel {
            touch-action: none;
        }
        #revise-panel.dragging { transition: none; }
        #revise-drag-handle:hover { background: rgba(241, 245, 249, 0.6); }
        #revise-resize-handle {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            background: linear-gradient(135deg, transparent 50%, rgba(148, 163, 184, 0.4) 50%);
        }
        #revise-resize-handle:hover { background: linear-gradient(135deg, transparent 50%, rgba(100, 116, 139, 0.6) 50%); }
        .revise-iframe {
            width: 100%;
            height: 100%;
            border: none;
        }

        #selection-rect {
            position: fixed;
            border: 2px solid #dc2626;
            background: rgba(239, 68, 68, 0.15);
            pointer-events: none;
            z-index: 1000;
            display: none;
        }

        .node-textarea.pasting {
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
        }

        /* Toast System */
        #toast-container {
            position: fixed;
            bottom: 30px;
            right: 30px;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 12px;
            pointer-events: none;
        }

        .toast {
            padding: 12px 24px;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 12px;
            color: var(--text-primary);
            font-size: 0.85rem;
            font-weight: 500;
            box-shadow: var(--card-shadow);
            transform: translateY(100px);
            opacity: 0;
            transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
            display: flex;
            align-items: center;
            gap: 10px;
            pointer-events: auto;
        }

        .toast.visible {
            transform: translateY(0);
            opacity: 1;
        }

        .toast-success {
            color: var(--accent-emerald);
        }

        .toast-error {
            color: #dc2626;
        }

        .toast-info {
            color: var(--accent-blue);
        }