:root {
            --bg-900: #050816;
            --bg-800: #08111f;
            --bg-700: #0e1b2d;
            --card: rgba(255, 255, 255, 0.08);
            --card-strong: rgba(255, 255, 255, 0.12);
            --border: rgba(255, 255, 255, 0.16);
            --border-soft: rgba(255, 255, 255, 0.08);
            --text: #f8fbff;
            --muted: #9fb2ca;
            --muted-strong: #c8d6e6;
            --blue: #2f80ff;
            --blue-light: #64b5ff;
            --cyan: #38d6ff;
            /* Sally's gold. Her panel has always used it; the agent
               tiles now borrow it so the assistant surfaces read as one
               family instead of two unrelated blue-and-gold widgets. */
            --sally: #ffd700;
            --success: #3ee68b;
            --warning: #ffd166;
            --danger: #ff5c7a;
            --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
            --radius-xl: 28px;
            --radius-lg: 20px;
            --radius-md: 14px;
            --radius-sm: 10px;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        html { height: 100%; }

        body {
            min-height: 100%;
            font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
            color: var(--text);
            background: #000000;
            overflow-x: hidden;
        }

        .page-shell {
            position: relative;
            width: 100%;
            min-height: 100vh;
            padding: 16px 18px;
        }

        .top-nav {
            max-width: none;
            margin: 0 auto 22px;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 18px;
        }

        .nav-pill {
            display: inline-flex;
            align-items: center;
            gap: 9px;
            padding: 10px 14px;
            border: 1px solid var(--border);
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.07);
            color: var(--muted-strong);
            backdrop-filter: blur(16px);
            font-size: 13px;
            white-space: nowrap;
        }

        .nav-pill-dot {
            width: 8px; height: 8px;
            border-radius: 999px;
            background: var(--success);
            box-shadow: 0 0 18px rgba(62, 230, 139, 0.8);
        }

        .usage-pill { gap: 16px; padding: 8px 16px; }
        .usage-stat { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
        .usage-label {
            font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
            color: var(--muted);
        }
        .usage-value { font-size: 14px; font-weight: 800; color: var(--text); }
        .usage-divider { width: 1px; align-self: stretch; background: var(--border-soft); }

        .settings-menu-wrapper { position: relative; }
        .settings-gear-btn {
            display: inline-flex; align-items: center; justify-content: center;
            width: 38px; height: 38px; border-radius: 999px;
            border: 1px solid var(--border); background: rgba(255,255,255,0.07);
            color: var(--muted-strong); cursor: pointer; backdrop-filter: blur(16px);
            transition: background 0.2s, color 0.2s, transform 0.2s;
        }
        .settings-gear-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }
        /* Open state. The rotate was designed for a gear — a gear turning reads as
   "settings are open". A burger rotated 20 degrees just looks broken, and
   because the transform stays until the class is removed it reads as a button
   that got stuck rather than a menu that is open. Colour alone says it. */
.settings-gear-btn.open { color: var(--blue-light); background: rgba(255,255,255,0.14); }

        .settings-menu {
            display: none;
            position: absolute; top: calc(100% + 8px); right: 0;
            min-width: 190px; width: max-content; max-width: 360px; z-index: 50;
            border: 1px solid var(--border); border-radius: var(--radius-md);
            background: var(--bg-800); box-shadow: var(--shadow);
            padding: 6px; backdrop-filter: blur(20px);
        }
        .settings-menu.open { display: block; }
        .settings-menu-item {
            display: flex; align-items: center; gap: 9px;
            width: 100%; padding: 9px 10px; border: none; border-radius: var(--radius-sm);
            background: transparent; color: var(--text); font-size: 13px; font-weight: 600;
            cursor: pointer; text-align: left;
        }
        .settings-menu-item:hover { background: rgba(255,255,255,0.08); }
        .settings-menu-user {
            padding: 8px 10px 4px; font-size: 12px; font-weight: 700;
            color: var(--muted-strong); white-space: nowrap;
        }
        .settings-menu-divider { height: 1px; margin: 4px 2px 6px; background: var(--border-soft); }
        .settings-menu-item-danger { color: var(--danger); }
        .settings-menu-item-danger:hover { background: rgba(255,92,122,0.12); }
        .settings-menu-wrapper form { margin: 0; }

        /* ── Outer 3-column shell: sidebar | chat | activity ── */
        .container {
            max-width: none;
            width: 100%;
            height: calc(100vh - 102px);
            max-height: calc(100vh - 102px);
            min-height: 0;
            margin: 0 auto;
            display: grid;
            --activity-w: minmax(0, 1fr);
            /* The live site preview. Zero until someone opens it, so a
               console with no website in it is exactly as it was. */
            --preview-w: 0px;
            grid-template-columns: 300px minmax(0, 1fr) var(--activity-w) var(--preview-w);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            background: linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.045));
            box-shadow: var(--shadow);
            overflow: hidden;
            backdrop-filter: blur(26px);
        }

        /* ── Left sidebar: config + tools ── */
        .sidebar {
            min-width: 0;
            padding: 22px;
            background:
                linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
                rgba(5, 8, 22, 0.52);
            border-right: 1px solid var(--border-soft);
            display: flex;
            flex-direction: column;
            gap: 20px;
            overflow-y: auto;
        }

        .sidebar-card {
            border: 1px solid var(--border-soft);
            border-radius: var(--radius-lg);
            background: rgba(3, 9, 23, 0.42);
            padding: 16px;
            flex-shrink: 0;
        }

        .brand-logo { display: inline-flex; align-items: center; text-decoration: none; line-height: 0; }
        .brand-logo-img { height: 44px; width: auto; display: block; }
        .sidebar-logo { margin-bottom: 16px; }
        .sidebar-card-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 16px;
        }
        .sidebar-card-top .sidebar-logo { margin-bottom: 0; }
        .config-section {
            margin-bottom: 14px;
            overflow: hidden;
        }

        /* ── Whole-sidebar slide collapse, triggered by the swifty icon ──
           The icon itself (in .sidebar-card-top) stays put and visible so
           it remains clickable to expand the panel again; everything else
           in the sidebar slides/fades away and the grid column narrows. */
        .container {
            transition: grid-template-columns 0.35s ease;
        }
        .container.sidebar-collapsed {
            grid-template-columns: 48px minmax(0, 1fr) var(--activity-w) var(--preview-w);
        }
        /* Activity panel collapsed: fixed slim strip wins over any width */
        .container.activity-collapsed {
            grid-template-columns: 300px minmax(0, 1fr) 48px var(--preview-w);
        }
        .container.sidebar-collapsed.activity-collapsed {
            /* Four columns, like every other container rule. This one was left
               at three when the preview column was added, and a grid with four
               children but three declared columns puts the fourth in an
               implicit auto column that sizes to its content — crushing the
               1fr middle column to a sliver of vertical text. It only showed
               with BOTH panels collapsed, which is why it reached production. */
            grid-template-columns: 48px minmax(0, 1fr) 48px var(--preview-w);
        }
        .sidebar {
            transition: padding 0.35s ease;
        }
        .container.sidebar-collapsed .sidebar {
            padding: 22px 14px;
            overflow: hidden;
        }
        .container.sidebar-collapsed .sidebar-card-top {
            justify-content: center;
        }
        .sidebar-collapsible {
            overflow: hidden;
            max-height: 900px;
            opacity: 1;
            transform: translateX(0);
            transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.3s ease, margin 0.35s ease;
        }
        .container.sidebar-collapsed .sidebar-collapsible {
            max-height: 0;
            opacity: 0;
            transform: translateX(-16px);
            margin: 0 !important;
            pointer-events: none;
        }
        .container.sidebar-collapsed #newConfigBtn {
            display: none;
        }

        .config-label {
            display: block;
            margin-bottom: 10px;
            color: var(--muted-strong);
            font-weight: 700;
            font-size: 13px;
            letter-spacing: 0.02em;
        }

        .config-select {
            width: 100%;
            padding: 12px 13px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: rgba(255,255,255,0.08);
            color: var(--text);
            font-size: 14px;
            outline: none;
            cursor: pointer;
            transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
        }
        .config-select option { background: var(--bg-800); color: var(--text); }
        .config-select:focus {
            border-color: rgba(100,181,255,0.84);
            box-shadow: 0 0 0 4px rgba(47,128,255,0.18);
            background: rgba(255,255,255,0.11);
        }

        .config-info { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.55; }

        .init-button {
            width: 100%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            border: 0;
            border-radius: 999px;
            padding: 13px 16px;
            background: linear-gradient(135deg, var(--blue), var(--cyan));
            color: white;
            font-weight: 800;
            font-size: 14px;
            cursor: pointer;
            box-shadow: 0 16px 34px rgba(47,128,255,0.32);
            transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
        }
        .init-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 20px 44px rgba(47,128,255,0.44); }
        .init-button:disabled { opacity: 0.7; cursor: not-allowed; }

        .status-indicator {
            display: inline-block;
            width: 9px; height: 9px;
            border-radius: 50%;
            background: var(--danger);
        }
        .status-indicator.connected  { background: var(--success); box-shadow: 0 0 18px rgba(62,230,139,0.8); }
        .status-indicator.disconnected { background: var(--danger);  box-shadow: 0 0 16px rgba(255,92,122,0.66); }
        .status-indicator.loading    { background: var(--warning); box-shadow: 0 0 16px rgba(255,209,102,0.72); animation: pulse 1s infinite; }

        @keyframes pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50%       { opacity: 0.52; transform: scale(0.82); }
        }

        .tools-heading {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 12px;
            flex-shrink: 0;
        }
        .tools-heading h3 { color: var(--text); font-size: 15px; letter-spacing: -0.01em; }
        .tools-badge {
            padding: 5px 8px;
            border-radius: 999px;
            color: var(--blue-light);
            background: rgba(47,128,255,0.13);
            border: 1px solid rgba(100,181,255,0.2);
            font-size: 11px;
            font-weight: 700;
        }

        .tools-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }

        .tools-list::-webkit-scrollbar { width: 4px; }
        .tools-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 999px; }

        .tool-item {
            border: 1px solid var(--border-soft);
            border-radius: var(--radius-md);
            background: rgba(255,255,255,0.06);
            padding: 13px;
            margin-bottom: 10px;
        }
        .tool-name  { color: var(--text); font-weight: 800; font-size: 13px; margin-bottom: 5px; }
        .tool-description { color: var(--muted); font-size: 12px; line-height: 1.45; }
        .empty-state { color: var(--muted); font-size: 13px; text-align: center; line-height: 1.55; margin-top: 22px; }

        /* ── processing / thinking / tool_call / tool_result / response cards ── */
        .pipeline-card.processing .pipeline-card-header {
            background: rgba(255,209,102,0.13);
            color: var(--warning);
            border-bottom: 1px solid rgba(255,209,102,0.22);
        }
        .pipeline-card.thinking .pipeline-card-header {
            background: rgba(255,255,255,0.07);
            color: var(--muted-strong);
            border-bottom: 1px solid rgba(255,255,255,0.16);
        }
        .pipeline-card.tool_call .pipeline-card-header {
            background: rgba(56,214,255,0.10);
            color: var(--cyan);
            border-bottom: 1px solid rgba(56,214,255,0.18);
        }
        .pipeline-card.tool_result .pipeline-card-header {
            background: rgba(62,230,139,0.10);
            color: var(--success);
            border-bottom: 1px solid rgba(62,230,139,0.18);
        }
        .pipeline-card.response .pipeline-card-header {
            background: rgba(47,128,255,0.12);
            color: var(--blue-light);
            border-bottom: 1px solid rgba(100,181,255,0.2);
        }
        /* ── Pipeline event cards ── */
            .pipeline-card {
                margin-bottom: 14px;
                border-radius: var(--radius-md);
                border: 1px solid var(--border-soft);
                overflow: hidden;
                font-size: 13px;
                line-height: 1.55;
                word-wrap: break-word;
            }
            .pipeline-card-header {
                padding: 9px 13px;
                font-size: 11px;
                font-weight: 800;
                letter-spacing: 0.05em;
                text-transform: uppercase;
            }
            .pipeline-card-body {
                padding: 12px 13px;
                color: var(--muted-strong);
                background: rgba(0,0,0,0.18);
            }
            .pipeline-card-body .field { margin-bottom: 6px; }
            .pipeline-card-body .field-label {
                font-size: 10px; font-weight: 700;
                letter-spacing: 0.04em; text-transform: uppercase;
                color: var(--muted); margin-bottom: 2px;
            }
            .pipeline-card-body .field-value { font-size: 13px; color: var(--text); white-space: pre-wrap; }
            .pipeline-card-body .email-body {
                font-size: 12px; color: var(--muted-strong);
                background: rgba(255,255,255,0.04);
                border: 1px solid var(--border-soft);
                border-radius: 8px; padding: 10px 12px;
                margin-top: 6px; white-space: pre-wrap;
                max-height: 180px; overflow-y: auto;
            }
            .pipeline-card-ts { padding: 5px 13px 8px; font-size: 10px; color: rgba(200,214,230,0.35); }

            /* lead = blue */
            .pipeline-card.lead .pipeline-card-header { background: rgba(47,128,255,0.18); color: var(--blue-light); border-bottom: 1px solid rgba(47,128,255,0.2); }
            /* qualification */
            .pipeline-card.qualification.pass .pipeline-card-header { background: rgba(62,230,139,0.15); color: var(--success); border-bottom: 1px solid rgba(62,230,139,0.2); }
            .pipeline-card.qualification.fail .pipeline-card-header { background: rgba(255,92,122,0.15); color: var(--danger); border-bottom: 1px solid rgba(255,92,122,0.2); }
            /* email */
            .pipeline-card.email .pipeline-card-header { background: rgba(56,214,255,0.12); color: var(--cyan); border-bottom: 1px solid rgba(56,214,255,0.18); }
            /* intermediate steps */
            .pipeline-card.processing .pipeline-card-header { background: rgba(255,209,102,0.13); color: var(--warning); border-bottom: 1px solid rgba(255,209,102,0.22); }
            .pipeline-card.thinking .pipeline-card-header { background: rgba(255,255,255,0.07); color: var(--muted-strong); border-bottom: 1px solid var(--border-soft); }
            .pipeline-card.tool_call .pipeline-card-header { background: rgba(56,214,255,0.10); color: var(--cyan); border-bottom: 1px solid rgba(56,214,255,0.18); }
            .pipeline-card.tool_result .pipeline-card-header { background: rgba(62,230,139,0.10); color: var(--success); border-bottom: 1px solid rgba(62,230,139,0.18); }
            .pipeline-card.response .pipeline-card-header { background: rgba(47,128,255,0.12); color: var(--blue-light); border-bottom: 1px solid rgba(100,181,255,0.2); }
        .panel {
            min-width: 0;
            min-height: 0;
            display: flex;
            flex-direction: column;
            background: rgba(2, 7, 18, 0.26);
        }

        .panel + .panel {
            border-left: 1px solid var(--border-soft);
        }

        .panel-header {
            flex-shrink: 0;
            padding: 18px 22px;
            border-bottom: 1px solid var(--border-soft);
            background: linear-gradient(90deg, rgba(47,128,255,0.12), transparent), rgba(255,255,255,0.03);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .panel-header h2 {
            font-size: 17px;
            letter-spacing: -0.03em;
        }

        .panel-header p {
            color: var(--muted);
            font-size: 12px;
            margin-top: 3px;
        }

        .panel-header-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            align-items: center;
        }

        .mini-stat {
            padding: 7px 11px;
            border-radius: 999px;
            background: rgba(255,255,255,0.07);
            border: 1px solid var(--border-soft);
            color: var(--muted-strong);
            font-size: 11px;
            white-space: nowrap;
        }

        .supervisor-btn {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            padding: 9px 14px;
            border: 0;
            border-radius: 999px;
            background: linear-gradient(135deg, var(--success), #27ae78);
            color: white;
            font-weight: 800;
            font-size: 12px;
            cursor: pointer;
            box-shadow: 0 10px 24px rgba(62,230,139,0.3);
            transition: background 0.25s, transform 0.2s, box-shadow 0.2s;
            white-space: nowrap;
        }
        .supervisor-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(62,230,139,0.42); }
        .supervisor-btn.running { background: linear-gradient(135deg, var(--danger), #c0392b); box-shadow: 0 10px 24px rgba(255,92,122,0.32); }
        .supervisor-btn.running:hover:not(:disabled) { box-shadow: 0 14px 32px rgba(255,92,122,0.46); }
        .supervisor-btn:disabled { opacity: 0.6; cursor: not-allowed; }

        /* ── Message feeds ── */
        .messages {
            min-height: 0;
            flex: 1;
            overflow-y: auto;
            padding: 22px;
        }
        .messages::-webkit-scrollbar { width: 4px; }
        .messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 999px; }

        .message {
            margin-bottom: 16px;
            display: flex;
            align-items: flex-start;
            flex-wrap: wrap;
            gap: 6px;
        }
        .message.user { justify-content: flex-end; }

        .message-content {
            max-width: min(600px, 82%);
            padding: 13px 16px;
            border-radius: 18px;
            word-wrap: break-word;
            line-height: 1.55;
            font-size: 13px;
        }
        .message.user .message-content {
            background: linear-gradient(135deg, var(--blue), var(--cyan));
            color: white;
            border-bottom-right-radius: 6px;
            box-shadow: 0 10px 22px rgba(47,128,255,0.2);
        }
        .message.ai .message-content {
            color: var(--muted-strong);
            background: rgba(255,255,255,0.085);
            border: 1px solid var(--border-soft);
            border-bottom-left-radius: 6px;
        }
        .message.ai .message-content strong { color: var(--text); }
        .message-content ul { margin: 8px 0; padding-left: 18px; }
        .message-content .chat-ul, .message-content .chat-ol { margin: 6px 0; padding-left: 22px; }
        .message-content .chat-ul li, .message-content .chat-ol li { margin: 3px 0; line-height: 1.5; }
        .message-content .chat-h { margin: 12px 0 6px; font-weight: 700; line-height: 1.3; color: var(--text); }
        .message-content .chat-link { color: var(--accent, #2f80ff); text-decoration: underline; }
        .message-content h3.chat-h { font-size: 15px; }
        .message-content h4.chat-h { font-size: 14px; }
        .message-content h5.chat-h, .message-content h6.chat-h { font-size: 13px; }

        .message-meta {
            flex-basis: 100%;
            color: rgba(200,214,230,0.45);
            font-size: 10px;
            padding: 0 5px;
        }
        .message.user .message-meta { text-align: right; }

        .tools-used { flex-basis: 100%; color: var(--muted); font-size: 11px; }
        .tool-badge {
            display: inline-block;
            margin: 2px 3px 0 0;
            padding: 3px 6px;
            border-radius: 999px;
            background: rgba(47,128,255,0.14);
            border: 1px solid rgba(100,181,255,0.22);
            color: var(--blue-light);
            font-size: 10px;
            font-weight: 700;
        }

        /* ── Activity feed specific ── */
        .activity-entry {
            margin-bottom: 14px;
            padding: 13px 15px;
            border-radius: var(--radius-md);
            border: 1px solid var(--border-soft);
            background: rgba(255,255,255,0.05);
            font-size: 13px;
            line-height: 1.55;
            color: var(--muted-strong);
            word-wrap: break-word;
        }
        .activity-entry .agent-label {
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            margin-bottom: 6px;
            color: var(--cyan);
        }
        .activity-entry .activity-time {
            display: block;
            margin-top: 6px;
            font-size: 10px;
            color: rgba(200,214,230,0.4);
        }
        .activity-entry.supervisor .agent-label { color: var(--success); }
        .activity-entry.error .agent-label      { color: var(--danger); }
        .activity-entry.tool  .agent-label      { color: var(--warning); }

        .live-indicator {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            color: var(--success);
            font-weight: 700;
        }
        .live-dot {
            width: 7px; height: 7px;
            border-radius: 50%;
            background: var(--success);
            box-shadow: 0 0 10px rgba(62,230,139,0.8);
            animation: pulse 1.2s infinite;
        }

        .running-supervisors {
            display: flex; flex-wrap: wrap; gap: 8px;
            padding: 0 20px 14px;
        }
        .running-supervisor-pill {
            display: inline-flex; align-items: center; gap: 8px;
            padding: 6px 8px 6px 12px; border-radius: 999px;
            background: rgba(62,230,139,0.1); border: 1px solid rgba(62,230,139,0.35);
            font-size: 12px; font-weight: 700; color: var(--text);
        }
        .running-supervisor-pill .stop-supervisor-btn {
            border: none; background: rgba(255,92,122,0.16); color: var(--danger);
            font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
            cursor: pointer; transition: background 0.2s;
        }
        .running-supervisor-pill .stop-supervisor-btn:hover { background: rgba(255,92,122,0.32); }
        .running-supervisor-pill .stop-supervisor-btn:disabled { opacity: 0.6; cursor: not-allowed; }
        .running-supervisor-pill.stopping {
            background: rgba(255,196,84,0.1);
            border-color: rgba(255,196,84,0.35);
        }
        .running-supervisor-pill.stopping .live-dot {
            background: #ffc454;
            box-shadow: 0 0 10px rgba(255,196,84,0.8);
        }

        /* ── Chat input ── */
        .input-area {
            flex-shrink: 0;
            padding: 16px 22px 22px;
            border-top: 1px solid var(--border-soft);
            background: rgba(3, 9, 23, 0.54);
        }

        .input-container {
            display: flex;
            align-items: flex-end;
            gap: 10px;
            border: 1px solid var(--border);
            border-radius: 22px;
            padding: 8px;
            background: rgba(255,255,255,0.08);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
        }

        .message-input {
            flex: 1;
            min-height: 24px;
            max-height: 120px;
            padding: 9px 11px;
            border: 0;
            outline: 0;
            resize: none;
            color: var(--text);
            background: transparent;
            font: inherit;
            font-size: 13px;
            line-height: 1.5;
        }
        .message-input::placeholder { color: rgba(200,214,230,0.5); }
        .message-input:disabled { cursor: not-allowed; opacity: 0.65; }

        .send-button {
            flex: 0 0 auto;
            width: 42px; height: 42px;
            border: 0;
            border-radius: 14px;
            background: linear-gradient(135deg, var(--blue), var(--cyan));
            color: white;
            cursor: pointer;
            display: grid;
            place-items: center;
            box-shadow: 0 10px 24px rgba(47,128,255,0.3);
            transition: transform 0.2s, opacity 0.2s;
        }
        .send-button:hover:not(:disabled) { transform: translateY(-1px); }
        .send-button:disabled { opacity: 0.52; cursor: not-allowed; }

        .loading {
            width: 18px; height: 18px;
            border: 2px solid rgba(255,255,255,0.28);
            border-top: 2px solid white;
            border-radius: 50%;
            animation: spin 0.9s linear infinite;
        }

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

        /* ── Responsive ── */
        @media (max-width: 1100px) {
            .container { grid-template-columns: 260px minmax(0,1fr) minmax(0,1fr) var(--preview-w); }
        }

        @media (max-width: 900px) {
            .page-shell { padding: 0; }
            .top-nav { padding: 18px; margin-bottom: 0; }
            .nav-pill { display: none; }
            .container {
                height: calc(100vh - 84px);
                border-radius: 0;
                border-left: 0; border-right: 0;
                /* sidebar is hidden here, so the children are main +
                   activity + preview. Declaring only two tracks sent the
                   preview into an implicit auto column and squeezed the rest. */
                grid-template-columns: 1fr 1fr var(--preview-w);
            }
            .sidebar { display: none; }
            .panel-header { padding: 14px 16px; }
            .messages { padding: 14px; }
            .input-area { padding: 10px 14px 16px; }
        }

        @media (max-width: 600px) {
            .container { grid-template-columns: 1fr; }
            /* On very small screens show only chat, activity hidden */
            .panel.activity-panel { display: none; }
        }

        /* ── Config dropdown + action buttons row ── */
/* ── Agent tiles: a face, a name, a line ──
   Replaces the dropdown as the way to choose who you are talking to. A
   dropdown hides a whole team behind one line of text; tiles let someone see
   who they have. Scrolls rather than growing without bound, so a large team
   cannot push the chat off the screen. */
.agent-tiles {
    display: flex; flex-direction: column; gap: 6px;
    max-height: 320px; overflow-y: auto; margin-bottom: 10px; padding-right: 2px;
}
.agent-tiles-empty { color: var(--muted); font-size: 12.5px; padding: 6px 2px; }

/* Teams and agents are different kinds of thing, so they get a tab each
   rather than one list you scroll through to reach the second half. */
.agent-tabs { display: flex; gap: 4px; margin: 2px 0 8px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    /* Three tabs with counts overflow a narrow sidebar; flex was silently
       clipping the last one ("AG"). The bar scrolls instead, and no tab
       shrinks — same fix the chat tab bar got. */
    overflow-x: auto;
    scrollbar-width: thin;
}
.agent-tabs::-webkit-scrollbar { height: 4px; }
.agent-tabs::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18); border-radius: 2px;
}
.agent-tab {
    display: flex; align-items: center; gap: 6px;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 10px 8px; margin-bottom: -1px;
    background: none; border: 0; border-bottom: 2px solid transparent;
    cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.agent-tab:hover { color: var(--text); }
.agent-tab.on { color: var(--text); border-bottom-color: var(--cyan); }
.agent-tab:focus-visible {
    outline: 2px solid rgba(34,211,238,0.55); outline-offset: -3px; border-radius: 8px;
}
.agent-tab .agent-tiles-count { border-color: rgba(255,255,255,0.18); color: var(--muted); }
.agent-tab.on .agent-tiles-count { border-color: rgba(34,211,238,0.40); color: var(--cyan); }
.agent-tiles-count {
    font-size: 9.5px; font-weight: 800; letter-spacing: 0;
    padding: 0 6px; border-radius: 999px; color: var(--cyan);
    border: 1px solid rgba(34,211,238,0.40);
}

/* A team's mark: three Swifties, overlapped so the group reads as one shape
   at 34px. The middle one sits on top so the stack has a focal point. */
.agent-tile-flock { position: relative; display: block; background: none; }
.agent-tile-flock img {
    position: absolute; width: 21px; height: 21px; border-radius: 50%;
    background: rgba(255,255,255,0.06); object-fit: cover;
}
.agent-tile-flock img:nth-child(1) { left: 0;    top: 12px; }
.agent-tile-flock img:nth-child(2) { left: 6.5px; top: 0; z-index: 2; }
.agent-tile-flock img:nth-child(3) { left: 13px; top: 12px; }
.agent-tile {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: 12px; cursor: pointer;
    text-align: left; font: inherit; color: inherit;
    border: 1px solid rgba(255,215,0,0.24);
    background: linear-gradient(150deg, rgba(47,128,255,0.10), rgba(139,92,246,0.05));
    transition: border-color .14s, transform .12s, box-shadow .14s;
}
.agent-tile:hover {
    border-color: rgba(255,215,0,0.60); transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(255,215,0,0.16);
}
.agent-tile.selected {
    border-color: var(--sally); box-shadow: 0 0 0 1px rgba(255,215,0,0.40);
    background: linear-gradient(150deg, rgba(255,215,0,0.14), rgba(47,128,255,0.10));
}
/* The rename pencil. Faint until the tile is hovered: it is a repair tool,
   not a thing to reach for every day, and a row of pencils competing with
   the names would be worse than the problem it solves. */
.agent-tile-rename {
    flex: none; margin-left: auto; padding: 2px 6px; border-radius: 7px;
    font-size: 12.5px; line-height: 1.4; color: var(--muted);
    opacity: 0; transition: opacity .14s, background .14s, color .14s;
}
.agent-tile:hover .agent-tile-rename { opacity: .85; }
.agent-tile-rename:hover {
    background: rgba(255,215,0,0.14); color: var(--sally); opacity: 1;
}
.agent-tile.renaming { cursor: default; padding: 6px 8px; }
.agent-tile-rename-input {
    width: 100%; padding: 6px 8px; border-radius: 8px; font: inherit;
    font-weight: 700; font-size: 13.5px; color: inherit;
    background: rgba(0,0,0,0.28);
    border: 1px solid var(--sally);
    outline: none;
}
.agent-tile-av {
    width: 34px; height: 34px; border-radius: 10px; object-fit: cover;
    flex: none; background: rgba(255,255,255,0.06);
}
.agent-tile-meta { min-width: 0; display: flex; flex-direction: column; }
.agent-tile-name {
    font-weight: 700; font-size: 13.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-tile-sub {
    color: var(--muted); font-size: 11.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-tile-tag {
    margin-left: 6px; padding: 0 5px; border-radius: 999px;
    font-size: 9px; font-weight: 800; letter-spacing: .07em;
    color: var(--cyan); border: 1px solid rgba(34,211,238,0.45); vertical-align: 1px;
}

        .config-select-row {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .config-select-row .config-select { flex: 1; min-width: 0; }
        .config-icon-btn {
            flex: 0 0 auto;
            width: 40px; height: 40px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: rgba(255,255,255,0.08);
            color: var(--text);
            font-size: 18px;
            cursor: pointer;
            display: grid;
            place-items: center;
            transition: background 0.2s, border-color 0.2s, transform 0.15s;
        }
        .config-icon-btn:hover { background: rgba(47,128,255,0.18); border-color: rgba(100,181,255,0.5); transform: translateY(-1px); }
        .config-icon-btn svg { width: 16px; height: 16px; }
        /* Read-only share: the pencil becomes a padlock. Amber rather than the
           usual blue, so "you can't change this" reads at a glance. */
        .config-icon-btn.locked {
            font-size: 15px; line-height: 1; cursor: help;
            color: var(--warning, #ffc454);
            border-color: rgba(255,196,84,0.45);
            background: rgba(255,196,84,0.10);
        }
        .config-icon-btn.locked:hover {
            background: rgba(255,196,84,0.20);
            border-color: rgba(255,196,84,0.7); transform: none;
        }
        .milo-btn {
            display: inline-flex; align-items: center; gap: 6px;
            width: auto; height: auto; margin-top: 8px;
            padding: 7px 12px; font-size: 13px; font-weight: 600;
            line-height: 1.2; white-space: nowrap;
            border: 1px solid rgba(100,181,255,0.40);
            border-radius: var(--radius-sm);
            background: rgba(47,128,255,0.12); color: var(--text);
            cursor: pointer; transition: background .2s, border-color .2s, transform .15s;
        }
        .milo-btn:hover { background: rgba(47,128,255,0.20); border-color: rgba(100,181,255,0.6); transform: translateY(-1px); }

        /* ── Modal overlay ── */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(2, 6, 16, 0.72);
            backdrop-filter: blur(8px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: 24px;
        }
        .modal-overlay.open { display: flex; }

        .modal {
            width: 100%;
            max-width: 720px;
            max-height: 88vh;
            display: flex;
            flex-direction: column;
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            background: linear-gradient(145deg, rgba(18,26,44,0.98), rgba(8,14,28,0.98));
            box-shadow: var(--shadow);
            overflow: hidden;
        }
        .modal-header {
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 18px 22px;
            border-bottom: 1px solid var(--border-soft);
            background: linear-gradient(90deg, rgba(47,128,255,0.14), transparent);
        }
        .modal-header h2 { font-size: 17px; letter-spacing: -0.02em; }
        .modal-close {
            border: 0; background: transparent; color: var(--muted-strong);
            font-size: 22px; cursor: pointer; line-height: 1;
            width: 32px; height: 32px; border-radius: 8px;
        }
        .modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }

        .modal-body { padding: 20px 22px; overflow-y: auto; }
        .modal-body::-webkit-scrollbar { width: 6px; }
        .modal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 999px; }

        .form-group { margin-bottom: 22px; }
        .select-with-milo { display: flex; gap: 10px; align-items: stretch; }
        .select-with-milo .config-select { flex: 1 1 auto; min-width: 0; }
        .select-with-milo .milo-btn { margin-top: 0; flex: 0 0 auto; }
        .form-label {
            display: block; margin-bottom: 7px;
            color: var(--muted-strong); font-weight: 700;
            font-size: 12px; letter-spacing: 0.02em;
        }
        .form-input, .form-textarea {
            width: 100%;
            padding: 11px 13px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: rgba(255,255,255,0.06);
            color: var(--text);
            font: inherit;
            font-size: 13px;
            outline: none;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .form-input:focus, .form-textarea:focus {
            border-color: rgba(100,181,255,0.84);
            box-shadow: 0 0 0 3px rgba(47,128,255,0.16);
        }
        .form-textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
        .form-textarea.compact { min-height: 52px; }
        .form-textarea.preview { min-height: 52px; overflow-y: auto; }
        /* Milo popup: app-styled modal with the wizard avatar as the logo */
        .milo-modal-brand { display: flex; align-items: center; gap: 12px; }
        .milo-modal-logo {
            width: 34px; height: 34px; border-radius: 50%;
            object-fit: cover; box-shadow: 0 0 0 1px rgba(100,181,255,0.35);
        }
        .form-textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

        /* ── Password visibility toggle ── */
        .password-field { position: relative; }
        /* Extra right padding so the value never runs under the eye icon.
           Native browser reveal controls (Edge, Safari) are hidden so we
           don't end up with two competing toggles. */
        .password-field .form-input { padding-right: 42px; }
        .password-field .form-input::-ms-reveal,
        .password-field .form-input::-ms-clear { display: none; }
        .password-toggle {
            position: absolute;
            top: 0; right: 0;
            height: 100%;
            width: 40px;
            display: flex; align-items: center; justify-content: center;
            background: none; border: none; padding: 0;
            color: var(--muted);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: color 0.15s;
        }
        .password-toggle:hover { color: var(--text); }
        .password-toggle:focus-visible {
            outline: none;
            color: var(--blue-light);
            box-shadow: 0 0 0 2px rgba(47,128,255,0.35);
        }
        /* Only one of the two icons is shown at a time. */
        .password-toggle .icon-hide { display: none; }
        .password-toggle.revealed .icon-show { display: none; }
        .password-toggle.revealed .icon-hide { display: block; }
        .system-prompt-textarea {
            width: 100%; min-height: 420px; margin-top: 10px;
            font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
            font-size: 12.5px; line-height: 1.6; white-space: pre-wrap;
        }
        .prompt-status {
            display: inline-block; margin-top: 12px;
            font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
            padding: 4px 10px; border-radius: 999px;
        }
        .prompt-status.custom {
            color: var(--success); background: rgba(62,230,139,0.12);
            border: 1px solid rgba(62,230,139,0.35);
        }
        .prompt-status.default {
            color: var(--muted); background: rgba(255,255,255,0.06);
            border: 1px solid var(--border-soft);
        }
        .form-row { display: flex; gap: 12px; }
        .form-row .form-group { flex: 1; }
        .form-hint { margin-top: 5px; font-size: 11px; color: var(--muted); line-height: 1.5; }

        .form-section-title {
            font-size: 13px; font-weight: 800; color: var(--text);
            margin: 22px 0 12px; padding-bottom: 8px;
            border-bottom: 1px solid var(--border-soft);
            display: flex; align-items: center; justify-content: space-between;
        }

        .mcp-server-card {
            border: 1px solid var(--border-soft);
            border-radius: var(--radius-md);
            background: rgba(255,255,255,0.04);
            padding: 14px;
            margin-bottom: 12px;
        }
        .mcp-server-card-head {
            display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
        }
        .mcp-server-card-head .form-input { flex: 1; }
        .mcp-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-strong); white-space: nowrap; }
        .mcp-remove-btn {
            border: 0; background: rgba(255,92,122,0.14); color: var(--danger);
            border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 16px;
            flex: 0 0 auto;
        }
        .mcp-remove-btn:hover { background: rgba(255,92,122,0.26); }

        .text-btn {
            border: 1px dashed var(--border); background: transparent;
            color: var(--blue-light); border-radius: var(--radius-sm);
            padding: 9px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
            transition: background 0.2s, border-color 0.2s;
        }
        .text-btn:hover { background: rgba(47,128,255,0.1); border-color: rgba(100,181,255,0.5); }

        .mcp-add-select {
            border: 1px dashed var(--border); background: var(--bg-800);
            color: var(--blue-light); border-radius: var(--radius-sm);
            padding: 8px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
            max-width: 220px;
        }
        .mcp-add-select:hover { border-color: rgba(100,181,255,0.5); }
        .agent-card {
            display: flex; align-items: center; justify-content: space-between;
            border: 1px solid var(--border-soft); border-radius: var(--radius-md);
            background: rgba(255,255,255,0.04); padding: 12px 14px; margin-bottom: 10px;
            transition: border-color 0.2s, opacity 0.2s;
        }
        .agent-card-name { font-size: 13px; font-weight: 700; color: var(--text); }
        .agent-card-pending-label {
            display: none; color: var(--danger); font-weight: 800; font-size: 11px;
            margin-left: 10px; text-transform: uppercase; letter-spacing: 0.03em;
        }
        .agent-card.pending-delete {
            border-color: rgba(255,92,122,0.5); opacity: 0.75;
        }
        .agent-card.pending-delete .agent-card-name {
            text-decoration: line-through; color: var(--danger);
        }
        .agent-card.pending-delete .agent-card-pending-label { display: inline; }
        #swiftyIcon { cursor: pointer; }



        .modal-footer {
            flex-shrink: 0;
            display: flex; align-items: center; justify-content: space-between; gap: 12px;
            padding: 16px 22px;
            border-top: 1px solid var(--border-soft);
            background: rgba(3, 9, 23, 0.5);
        }
        .modal-error { color: var(--danger); font-size: 12px; flex: 1; }
        .btn-primary {
            border: 0; border-radius: 999px; padding: 11px 22px;
            background: linear-gradient(135deg, var(--blue), var(--cyan));
            color: white; font-weight: 800; font-size: 13px; cursor: pointer;
            box-shadow: 0 12px 26px rgba(47,128,255,0.3);
            transition: transform 0.2s, opacity 0.2s;
        }
        .btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
        .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-secondary {
            border: 1px solid var(--border); border-radius: 999px; padding: 11px 18px;
            background: rgba(255,255,255,0.06); color: var(--muted-strong);
            font-weight: 700; font-size: 13px; cursor: pointer;
        }
        .btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text); }
        .btn-danger {
            border: 1px solid rgba(255,92,122,0.45); border-radius: 999px; padding: 11px 18px;
            background: rgba(255,92,122,0.1); color: var(--danger);
            font-weight: 700; font-size: 13px; cursor: pointer;
            transition: background 0.2s;
        }
        .btn-danger:hover { background: rgba(255,92,122,0.22); }
        /* ── "Thinking…" chat indicator (shown while agents are working) ── */
        .thinking-dots span {
            animation: thinking-blink 1.4s infinite both;
        }
        .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
        .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
        @keyframes thinking-blink {
            0%, 80%, 100% { opacity: 0.2; }
            40% { opacity: 1; }
        }

        /* ── Rich chat content: images & charts ── */
        .chat-img {
            display: block;
            max-width: 100%;
            max-height: 360px;
            margin: 8px 0;
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.08);
        }
        .chart-wrap {
            position: relative;
            height: 280px;
            margin: 10px 0;
            padding: 10px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
        }
        .chart-error {
            color: #ff8fa3;
            font-size: 13px;
            padding: 8px;
        }


        /* ── Activity panel: collapse + width resize ── */
        .activity-panel { position: relative; }

        .activity-resizer {
            position: absolute;
            left: 0; top: 0; bottom: 0;
            width: 6px;
            cursor: col-resize;
            z-index: 5;
        }
        .activity-resizer:hover { background: rgba(255,255,255,0.12); }

        .activity-collapsed-strip {
            display: none;
            position: absolute;
            inset: 0;
            width: 100%;
            border: none;
            background: rgba(5, 8, 22, 0.4);
            color: var(--text-soft, #9aa0b0);
            cursor: pointer;
            align-items: center;
            justify-content: flex-start;
            flex-direction: column;
            gap: 10px;
            padding-top: 18px;
            z-index: 6;
        }
        .activity-collapsed-strip:hover { background: rgba(255,255,255,0.06); }
        .activity-strip-label {
            writing-mode: vertical-rl;
            font-size: 12px;
            letter-spacing: 0.06em;
        }

        .container.activity-collapsed .activity-panel > *:not(.activity-collapsed-strip) {
            display: none;
        }
        .container.activity-collapsed .activity-collapsed-strip {
            display: flex;
        }

        /* Slide toggle pinned to the pane's top-right corner */
        .activity-toggle-corner {
            position: absolute;
            top: 8px;
            right: 8px;
            z-index: 7;
        }
        /* keep header controls clear of the corner icon */
        .activity-panel .panel-header { padding-right: 34px; }

        /* ── User message bubbles capped at 1/3 of the chat width;
           agent responses keep their original width. ── */
        .chat-panel .message.user .message-content {
            max-width: 33.333%;
        }


        /* ── Sidebar slide collapse, mirroring the activity pane ── */
        .sidebar { position: relative; }
        .sidebar-toggle-corner {
            position: absolute;
            top: 8px;
            left: 8px;
            z-index: 7;
        }
        .sidebar-collapsed-strip {
            display: none;
            position: absolute;
            inset: 0;
            width: 100%;
            border: none;
            background: rgba(5, 8, 22, 0.4);
            color: var(--text-soft, #9aa0b0);
            cursor: pointer;
            align-items: center;
            justify-content: flex-start;
            flex-direction: column;
            gap: 10px;
            padding-top: 18px;
            z-index: 6;
        }
        .sidebar-collapsed-strip:hover { background: rgba(255,255,255,0.06); }
        .container.sidebar-collapsed .sidebar > *:not(.sidebar-collapsed-strip) {
            display: none;
        }
        .container.sidebar-collapsed .sidebar-collapsed-strip { display: flex; }
        .container.sidebar-collapsed .sidebar { padding: 0; overflow: hidden; }

        /* ── Markdown tables in chat ── */
        .md-table {
            border-collapse: collapse;
            margin: 10px 0;
            font-size: 12.5px;
            width: 100%;
        }
        .md-table th, .md-table td {
            border: 1px solid rgba(255,255,255,0.12);
            padding: 6px 10px;
            text-align: left;
            vertical-align: top;
        }
        .md-table th {
            background: rgba(255,255,255,0.07);
            font-weight: 600;
            white-space: nowrap;
        }
        .md-table tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

        /* ── Chat agent tabs ── */
        .chat-tabs {
            display: flex;
            gap: 6px;
            padding: 8px 16px 0;
            border-bottom: 1px solid var(--border-soft);
            overflow-x: auto;
            flex-shrink: 0;
            scrollbar-width: thin;
        }
        .chat-tab {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            padding: 7px 14px;
            border: 1px solid var(--border-soft);
            border-bottom: none;
            border-radius: 10px 10px 0 0;
            background: rgba(255,255,255,0.04);
            color: var(--text-soft, #9aa0b0);
            font-size: 12.5px;
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.2s, color 0.2s;
        }
        .chat-tab:hover { background: rgba(255,255,255,0.09); }
        /* Flex items shrink by default, so long tab names were being squeezed
           instead of the BAR scrolling — the bar has had overflow-x:auto all
           along but never overflowed. Fixed-size tabs make it actually
           scroll; inactive labels ellipsize so the bar stays sane, and the
           ACTIVE tab shows its whole name. */
        .chat-tab { flex: 0 0 auto; }
        .chat-tab-label {
            max-width: 110px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .chat-tab.active .chat-tab-label { max-width: none; }
        .chat-tabs::-webkit-scrollbar { height: 5px; }
        .chat-tabs::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.18);
            border-radius: 3px;
        }
        .chat-tab.active {
            background: rgba(255,255,255,0.12);
            color: var(--text, #e8ecf4);
            font-weight: 600;
        }
        .chat-tab-icon { font-size: 14px; line-height: 1; }
        .chat-tab-dot {
            display: none;
            width: 7px; height: 7px;
            border-radius: 50%;
            background: var(--warning, #ffc454);
            animation: thinking-blink 1.4s infinite both;
        }
        .chat-tab.busy .chat-tab-dot { display: inline-block; }

        /* ── Agent config dropdown grouping ── */
        .config-select optgroup {
            font-weight: 700;
            font-style: normal;
            color: var(--text, #e8ecf4);
            background: rgba(3, 9, 23, 0.9);
        }
        .config-select option.select-separator {
            color: rgba(255,255,255,0.25);
            font-size: 10px;
        }

        .chat-tab-close {
            margin-left: 2px;
            padding: 0 3px;
            border-radius: 6px;
            font-size: 14px;
            line-height: 1;
            color: rgba(255,255,255,0.35);
            transition: color 0.15s, background 0.15s;
        }
        .chat-tab-close:hover {
            color: var(--danger, #ff5c7a);
            background: rgba(255,92,122,0.14);
        }
        /* New-thread ↻ on each tab: same footprint as the ×, calmer hover —
           starting over is routine, closing is destructive. */
        .chat-tab-new {
            margin-left: 2px;
            padding: 0 3px;
            border-radius: 6px;
            font-size: 13px;
            line-height: 1;
            color: rgba(255,255,255,0.35);
        }
        .chat-tab-new:hover {
            color: var(--accent, #2f80ff);
            background: rgba(47,128,255,0.14);
        }

        /* ── BYOK modal ── */
        .byok-service {
            border: 1px solid var(--border-soft);
            border-radius: 10px;
            padding: 12px 14px;
            margin-bottom: 12px;
            background: rgba(255,255,255,0.03);
        }
        .byok-service-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }
        .byok-service-label { font-weight: 600; font-size: 13px; }
        .byok-test-status {
            flex: 1;
            font-size: 11.5px;
            color: var(--muted, #9aa0b0);
            text-align: right;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .byok-test-btn { padding: 4px 12px; font-size: 12px; }
        .byok-row {
            display: grid;
            grid-template-columns: 190px 1fr;
            gap: 10px;
            align-items: center;
            margin-bottom: 6px;
        }
        .byok-key-name {
            font-family: ui-monospace, monospace;
            font-size: 11.5px;
            color: var(--muted, #9aa0b0);
        }
        .byok-input { font-family: ui-monospace, monospace; font-size: 12px; }

        /* ── Supervisor state on activity tabs (replaces the pills) ── */
        .tab-live-dot { margin-left: 2px; }
        .tab-stop-btn {
            margin-left: 4px;
            padding: 0 5px;
            border-radius: 6px;
            font-size: 11px;
            line-height: 1.5;
            color: var(--danger, #ff5c7a);
            background: rgba(255,92,122,0.12);
            cursor: pointer;
        }
        .tab-stop-btn:hover { background: rgba(255,92,122,0.28); }
        .tab-stop-btn.stopping { cursor: default; opacity: 0.6; }

        /* Real Stop button on running supervisors' activity tabs */
        .tab-stop-real {
            display: inline-flex;
            align-items: center;
            margin-left: 6px;
            padding: 2px 9px;
            border-radius: 999px;
            font-size: 10.5px;
            font-weight: 700;
            letter-spacing: 0.03em;
            color: #fff;
            background: linear-gradient(135deg, var(--danger, #ff5c7a), #c0392b);
            cursor: pointer;
            box-shadow: 0 2px 10px rgba(255,92,122,0.35);
        }
        .tab-stop-real:hover:not(.stopping) { transform: translateY(-1px); }
        .tab-stop-real.stopping {
            background: rgba(255,255,255,0.10);
            color: var(--muted, #9aa0b0);
            cursor: default;
            box-shadow: none;
        }
        /* the tab's live dot needs its own size — it may inherit none outside .live-indicator */
        .tab-live-dot {
            display: inline-block;
            width: 7px; height: 7px;
            margin-left: 4px;
            border-radius: 50%;
            background: var(--success, #3ee68b);
            animation: thinking-blink 1.4s infinite both;
        }

        /* ── Markdown in activity entries ── */
        .activity-entry .act-heading {
            font-weight: 700;
            font-size: 13px;
            color: var(--blue-light, #64b5ff);
            margin: 10px 0 4px;
        }
        .activity-entry .act-heading:first-of-type { margin-top: 4px; }
        .activity-entry .act-li {
            margin: 2px 0 2px 10px;
            line-height: 1.5;
        }
        .activity-entry .act-hr {
            border: none;
            border-top: 1px solid var(--border-soft);
            margin: 8px 0;
        }

        /* Iteration counter on running supervisors' activity tabs */
        .tab-iter {
            margin-left: 4px;
            padding: 1px 8px;
            border-radius: 999px;
            font-size: 10.5px;
            font-weight: 700;
            color: var(--cyan, #22d3ee);
            background: rgba(34,211,238,0.10);
            border: 1px solid rgba(34,211,238,0.35);
        }

        /* ── Nav "Add Funds" button (non-approval-domain, low remaining budget) ── */
        .nav-add-funds {
            margin-left: 12px;
            padding: 5px 13px;
            display: inline-flex;
            align-items: center;
            border: none;
            border-radius: 999px;
            font: inherit;
            font-size: 12px;
            font-weight: 700;
            color: #fff;
            cursor: pointer;
            background: linear-gradient(135deg, var(--blue, #2f80ff), var(--cyan, #22d3ee));
            box-shadow: 0 4px 14px rgba(47,128,255,0.35);
            transition: transform 0.15s, box-shadow 0.2s;
            white-space: nowrap;
        }
        .nav-add-funds:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(47,128,255,0.5); }
        .nav-add-funds.urgent {
            background: linear-gradient(135deg, var(--danger, #ff5c7a), #c0392b);
            box-shadow: 0 4px 14px rgba(255,92,122,0.45);
            animation: thinking-blink 1.6s infinite;
        }

        /* ── Signed-in account label (top-left of the header) ── */
        .account-pill {
            margin-right: auto;   /* push to the far left; other pills stay right */
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }
        .account-dot {
            width: 8px; height: 8px; border-radius: 50%;
            background: var(--success, #3ee68b);
            box-shadow: 0 0 8px rgba(62,230,139,0.7);
        }
        .account-email {
            font-size: 12.5px;
            font-weight: 700;
            color: var(--text, #e8ecf4);
            max-width: 240px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* ── Copy button on messages, activity entries, and pipeline cards ── */
        .message-content, .activity-entry, .pipeline-card { position: relative; }
        .copy-btn {
            position: absolute;
            top: 6px;
            right: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 24px; height: 24px;
            padding: 0;
            border: 1px solid var(--border-soft, rgba(255,255,255,0.08));
            border-radius: 7px;
            background: rgba(3, 9, 23, 0.55);
            color: var(--muted, #9aa0b0);
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.15s, color 0.15s, background 0.15s;
        }
        .message-content:hover .copy-btn,
        .activity-entry:hover .copy-btn,
        .pipeline-card:hover .copy-btn { opacity: 1; }
        /* opacity too, not just colour. Without it the button is visible only
           while its CONTAINER matches :hover, so the moment the pointer lands
           on the button itself — if anything stops that hover propagating, an
           overlay, a stacking context, the button sitting on the bubble's
           edge — it fades out exactly as you reach for it. A control that
           disappears when aimed at is worse than one that is always shown. */
        .copy-btn:hover,
        .copy-btn:focus-visible { opacity: 1; color: var(--blue-light, #64b5ff);
            background: rgba(47,128,255,0.16); }
        .copy-btn:focus-visible { outline: 2px solid rgba(100,181,255,0.6);
            outline-offset: 2px; }
        .copy-btn.copied { color: var(--success, #3ee68b); border-color: rgba(62,230,139,0.5); opacity: 1; }
        /* Keep text clear of the button */
        .message.ai .message-content { padding-right: 34px; }
        .activity-entry { padding-right: 30px; }

        /* ══ ADD FUNDS MODAL — AIByte brand (deep-space navy, blue→cyan
           gradients, purple accents, glass) ══ */
        .aibyte-funds-modal {
            max-width: 440px;
            border: 1px solid rgba(255,255,255,0.14);
            border-radius: 16px;
            background:
                radial-gradient(480px 300px at 85% -20%, rgba(139,92,246,0.22), transparent),
                radial-gradient(420px 280px at -15% 115%, rgba(47,128,255,0.20), transparent),
                linear-gradient(160deg, #0e1b2d, #050816);
            box-shadow: 0 24px 80px rgba(2,6,16,0.8), 0 0 0 1px rgba(47,128,255,0.12);
        }
        .aibyte-funds-header { border-bottom: 1px solid rgba(255,255,255,0.08); }
        .aibyte-funds-header h2 { display: flex; align-items: center; gap: 10px; }
        .aibyte-mark {
            font-weight: 400; letter-spacing: -0.02em;
            background: linear-gradient(135deg, #ac78fc, #743cc8);
            -webkit-background-clip: text; background-clip: text; color: transparent;
        }
        .aibyte-mark b { font-weight: 800; }
        .aibyte-funds-title {
            background: linear-gradient(90deg, #64b5ff, #22d3ee);
            -webkit-background-clip: text; background-clip: text; color: transparent;
            font-weight: 700;
        }
        .aibyte-funds-sub { color: #9aa0b0; font-size: 13.5px; margin: 2px 0 16px; }
        .aibyte-amount-wrap {
            display: flex; align-items: center; gap: 10px;
            padding: 14px 18px;
            border: 1px solid rgba(47,128,255,0.35);
            border-radius: 14px;
            background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
            transition: border-color .15s, box-shadow .15s;
        }
        .aibyte-amount-wrap:focus-within {
            border-color: #22d3ee;
            box-shadow: 0 0 0 3px rgba(34,211,238,0.18);
        }
        .aibyte-amount-currency { font-size: 24px; font-weight: 700; color: #64b5ff; }
        .aibyte-amount-input {
            flex: 1; min-width: 0; border: none; outline: none; background: transparent;
            color: #e8ecf4; font-size: 28px; font-weight: 700; letter-spacing: -0.01em;
            -moz-appearance: textfield; appearance: textfield;
        }
        .aibyte-amount-input::-webkit-outer-spin-button,
        .aibyte-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
        .aibyte-amount-usd { font-size: 12px; font-weight: 700; color: #9aa0b0; letter-spacing: 0.08em; }
        .aibyte-chips { display: flex; gap: 8px; margin-top: 12px; }
        .aibyte-chip {
            flex: 1; padding: 8px 0; cursor: pointer;
            border: 1px solid rgba(255,255,255,0.14); border-radius: 999px;
            background: rgba(255,255,255,0.04); color: #9aa0b0;
            font-size: 13px; font-weight: 600;
            transition: all .15s;
        }
        .aibyte-chip:hover { border-color: rgba(100,181,255,0.6); color: #e8ecf4; }
        .aibyte-chip.active {
            border-color: transparent; color: #fff;
            background: linear-gradient(135deg, #2f80ff, #22d3ee);
            box-shadow: 0 4px 18px rgba(47,128,255,0.35);
        }
        .aibyte-funds-error { min-height: 18px; margin-top: 10px; color: #ff5c7a; font-size: 13px; }
        .aibyte-funds-note { margin: 6px 0 0; color: #9aa0b0; font-size: 12px; }
        .aibyte-btn-gradient {
            padding: 10px 20px; cursor: pointer; border: none; border-radius: 12px;
            color: #fff; font-weight: 700; font-size: 14px;
            background: linear-gradient(135deg, #2f80ff, #22d3ee);
            box-shadow: 0 6px 22px rgba(47,128,255,0.35);
            transition: transform .12s, box-shadow .12s, opacity .12s;
        }
        .aibyte-btn-gradient:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(34,211,238,0.4); }
        .aibyte-btn-gradient:disabled { opacity: 0.6; cursor: wait; transform: none; }

/* ── Artifact cards: files an agent generated ── */
.artifact-card {
    display: flex; align-items: center; gap: 12px; margin: 8px 0;
    padding: 10px 12px; max-width: 100%;
    border: 1px solid var(--border-soft, rgba(255,255,255,0.14));
    border-radius: 12px; background: rgba(255,255,255,0.04);
}
.artifact-thumb {
    flex: 0 0 auto; width: 56px; height: 72px; border-radius: 8px;
    overflow: hidden; background: rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.10);
}
.artifact-thumb img, .artifact-thumb canvas {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.artifact-label { flex: 1; min-width: 0; }
.artifact-name {
    font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artifact-meta { color: var(--text-muted, #9aa4b2); font-size: 12px; }
.artifact-btn {
    flex: 0 0 auto; width: 32px; height: 32px; display: flex;
    align-items: center; justify-content: center; border-radius: 9px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.16); background: rgba(255,255,255,0.06);
    color: inherit; opacity: 1; position: static;
}
.artifact-btn:hover { background: rgba(255,255,255,0.14); }

/* Preview window.

   This was `inset: 0` — the preview took the whole screen and could be
   nothing else, so a wide chart was shrunk to fit a tall window and a tall
   one was shrunk to fit a wide screen, with no way to trade one for the
   other. It is a window now: a real size, draggable by its bar, and
   resizable from the corner like anything else on a desktop. */
.artifact-preview {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 18px; background: rgba(2,6,16,0.85); backdrop-filter: blur(4px);
}
.artifact-preview-window {
    display: flex; flex-direction: column;
    width: min(1100px, 92vw); height: min(820px, 86vh);
    min-width: 320px; min-height: 220px; max-width: 98vw; max-height: 94vh;
    /* `resize` needs a non-visible overflow to show its grip. */
    resize: both; overflow: hidden;
    padding: 12px 14px 14px; border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(12,18,32,0.96);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.artifact-preview-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    color: #e6e9ef; font-weight: 700; margin-bottom: 10px;
    cursor: move; user-select: none;
}
.artifact-preview-head > span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* The close control is the same one every other dialog uses. A different,
   smaller glyph here meant the one button people look for first was the one
   that did not look like itself. */
.artifact-preview-head .modal-close {
    border: 0; background: transparent; color: #aab3c2;
    font-size: 26px; line-height: 1; cursor: pointer;
    width: 36px; height: 36px; border-radius: 8px; flex: none;
}
.artifact-preview-head .modal-close:hover {
    background: rgba(255,255,255,0.10); color: #fff;
}
.artifact-preview-body {
    flex: 1; min-height: 0; border-radius: 12px; overflow: auto;
    background: rgba(255,255,255,0.06); display: flex;
    align-items: center; justify-content: center;
}
.artifact-preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.artifact-preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.artifact-preview-body pre {
    align-self: stretch; margin: 0; padding: 16px; width: 100%;
    white-space: pre-wrap; word-break: break-word; font-size: 13px; color: #e6e9ef;
}


/* "Finish setup" on an agent tile.

   Amber rather than red: nothing is broken, something is unfinished. It is a
   button inside a button, so it stops the click from reaching the tile — a
   person aiming at this wants the wizard, not the chat. */
.agent-tile-setup {
    display: inline-block; margin-left: 8px; padding: 1px 8px;
    border-radius: 999px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .02em; vertical-align: middle; cursor: pointer;
    color: #2a1c00; background: #ffc454; border: 1px solid #e0a52f;
}
.agent-tile-setup:hover { background: #ffd486; }


/* ── Live site preview ─────────────────────────────────────────────────────
   Watching a page being built is the difference between trusting the agent
   and taking its word for it. Someone who is not a developer cannot read a
   diff and will not open a second tab to check; they can see a heading move.
   So the site sits beside the conversation and redraws itself when a file
   changes. */
.site-preview {
    display: flex; flex-direction: column; min-width: 0; overflow: hidden;
    border-left: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
}
.site-preview-head {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    border-bottom: 1px solid var(--border); font-size: 12px;
}
.site-preview-head select { flex: 1; min-width: 0; }
.site-preview-live {
    flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: #3ee68b; opacity: .35;
    transition: opacity .25s ease;
}
.site-preview-live.on { opacity: 1; }
.site-preview iframe {
    flex: 1; width: 100%; border: 0; background: #fff; min-height: 0;
}
.site-preview-empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 24px; text-align: center; color: var(--muted);
    font-size: 13px; line-height: 1.5;
}

/* ── The menu must survive a narrow window ────────────────────────────────
   .top-nav is a single flex row of pills ending in the menu button, with no
   wrapping. Below about 900px the pills are hidden, which keeps it fitting —
   but between there and a full-width desktop the row can still overrun, and
   what falls off the end is the LAST child: the menu itself. Losing a pill is
   cosmetic; losing the only route to Connections and Log Out is not.

   So the row wraps, and the button is pinned as its own flex item that never
   shrinks. */
.top-nav { flex-wrap: wrap; row-gap: 10px; }
.settings-gear-btn { flex: 0 0 auto; }
.settings-wrap, .top-nav > *:last-child { flex-shrink: 0; }

/* On a phone the pills are already hidden, so the menu is alone — give it a
   touch target rather than an 18px icon. */
@media (max-width: 900px) {
    .settings-gear-btn {
        min-width: 40px; min-height: 40px;
        display: inline-flex; align-items: center; justify-content: center;
    }
}

/* ── Advanced flyout (classic console) ───────────────────────────────────
   Opens to the LEFT. This menu is anchored `right: 0` under a burger in the
   top-right corner, so a flyout at `left: calc(100% + 6px)` — which is what
   the other console uses — would open past the right edge of the window and
   be unreachable. Same design, mirrored, because the anchor is mirrored.

   Click-driven rather than hover-only, so it works on touch. */
.settings-menu-sub { position: relative; }

.settings-sub-caret { opacity: 0.6; font-size: 15px; line-height: 1; }
.settings-menu-sub.open > .settings-menu-item { background: rgba(255,255,255,0.08); }
.settings-menu-sub.open .settings-sub-caret { opacity: 1; }

.settings-menu-flyout {
    display: none;
    position: absolute;
    right: calc(100% + 6px);
    top: -6px;
    min-width: 210px;
    width: max-content;
    z-index: 51;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-800);
    box-shadow: var(--shadow);
    padding: 6px;
    backdrop-filter: blur(20px);
}
.settings-menu-sub.open > .settings-menu-flyout { display: block; }

/* Narrow screens have no room beside the menu, so it expands inline instead
   of sliding off the edge. */
@media (max-width: 560px) {
    .settings-menu-flyout {
        position: static;
        min-width: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 2px 0 2px 14px;
        background: rgba(0,0,0,0.22);
    }
}

/* ── Burger to the left ──────────────────────────────────────────────────
   Moved with `order`, not by editing the markup. The wrapper is the last
   child of .top-nav and several rules key off that (`.top-nav > *:last-child`
   sets flex-shrink), so relocating it in the HTML would silently drop those —
   a wrapping bug that only shows on a narrow window, which is where it would
   be least noticed.

   margin-right:auto is what keeps the account and usage pills over on the
   right: .top-nav is justify-content:flex-end, so the auto margin absorbs the
   free space instead of the gap doing it. */
.settings-menu-wrapper { order: -1; margin-right: auto; }

/* The panel follows its button. Anchored right:0 it would hang off the left
   edge of the window with the button now in the corner. */
.settings-menu { left: 0; right: auto; }

/* And so does the submenu, which now has room on its right rather than its
   left — the mirror of the reason it opened leftwards before. */
.settings-menu-flyout { left: calc(100% + 6px); right: auto; }

@media (max-width: 560px) {
    /* Inline expansion on a phone, so neither direction matters. */
    .settings-menu-flyout { left: auto; right: auto; }
}

/* ── Header email next to the burger (email-alignment fix v2) ────────────
   The burger keeps order:-1 + margin-right:auto (that auto-margin is what
   pushes the usage pills to the right; a test pins it). The account pill
   ALSO carried margin-right:auto, so the two autos split the header gap and
   parked the email in the middle. Give the pill the same order:-1 as the
   burger and drop its auto-margin: it clusters at the far left immediately
   before the burger, and the burger's single auto-margin holds the rest
   right. Result: [email][burger] .......... [usage pills]. */
/* Burger in the far-left corner, email immediately to its right, pills far
   right: [burger][email] .......... [pills]. The account pill is the sole
   free-space eater (margin-right:auto), so the gap lands after the email.
   The burger keeps order:-1 and (for the pinned test) margin-right:auto in
   its plain rule, but a higher-specificity rule below zeroes it in the
   browser so it does NOT open a gap between burger and email. */
.account-pill { order: 0; margin-right: auto; }
.top-nav .settings-menu-wrapper { margin-right: 0; }

/* ── Approval cards (calls waiting for a yes) ────────────────────────────
   Fed by the poller at the foot of index.html from /api/pending-actions.
   Fixed under the header on the right; full-bleed on a phone. */
#approvalStack {
    position: fixed; top: 74px; right: 18px; z-index: 90;
    display: flex; flex-direction: column; gap: 10px;
    max-width: 340px;
}
.approval-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    background: var(--bg-800, #16181f);
    box-shadow: var(--shadow, 0 8px 30px rgba(0,0,0,0.45));
    padding: 12px 14px;
    backdrop-filter: blur(20px);
}
.approval-card.deciding { opacity: 0.5; pointer-events: none; }
.approval-text { font-size: 14px; line-height: 1.45; margin-bottom: 10px; }
.approval-btns { display: flex; gap: 8px; }
.approval-btns button {
    flex: 1; padding: 7px 0; border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 700; border: 1px solid transparent;
}
.approval-ok { background: var(--success, #3ee68b); color: #08130c; }
.approval-no {
    background: transparent; color: inherit;
    border-color: var(--border) !important;
}
@media (max-width: 560px) {
    #approvalStack { left: 12px; right: 12px; top: 64px; max-width: none; }
}

/* ── "Recently used" band ────────────────────────────────────────────────
   It used to be a 60%-opacity caption above ordinary tiles, which made the
   shortcut people reach for most read as the first rows of the long list
   underneath it. Now it is a card of its own: tinted, outlined, labelled in
   the accent colour, and separated from the full list by its own margin. */
.agent-recent {
    border: 1px solid rgba(47,128,255,0.28);
    border-radius: var(--radius-md, 12px);
    background: linear-gradient(180deg,
                rgba(47,128,255,0.10), rgba(47,128,255,0.03));
    padding: 6px 6px 8px;
    margin: 0 0 14px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.agent-recent-head {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px 7px;
    font-size: 10.5px; font-weight: 800;
    letter-spacing: .09em; text-transform: uppercase;
    color: var(--accent, #2f80ff);
    opacity: 1;
}
.agent-recent-head svg { flex: none; opacity: .9; }
/* Tiles inside the band sit on the tint rather than repeating a panel edge. */
.agent-recent .agent-tile {
    background: rgba(255,255,255,0.045);
    border-color: rgba(255,255,255,0.09);
}
.agent-recent .agent-tile.selected {
    border-color: var(--accent, #2f80ff);
    background: rgba(47,128,255,0.16);
}

/* ── External Access ──────────────────────────────────────────────────────
   A key is a credential someone will paste into another system, and the
   moments that matter are: reading the scope at a glance, copying the secret
   once, and revoking it later without hunting. Everything here serves those
   three. */
.ext-tabs { display: flex; gap: 4px; margin: 0 0 16px;
    border-bottom: 1px solid rgba(255,255,255,.10); }
.ext-tab { appearance: none; background: none; border: 0; cursor: pointer;
    color: var(--muted, #9aa0b0); font-size: 13.5px; font-weight: 600;
    padding: 9px 14px; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s; }
.ext-tab:hover { color: #dbe6ff; }
.ext-tab.active { color: #eaf2ff; border-bottom-color: #4da3ff; }

.ext-lede { color: var(--muted, #9aa0b0); font-size: 13px; line-height: 1.55;
    margin: 0 0 16px; }
.ext-lede strong { color: #dbe6ff; font-weight: 600; }

.ext-new { display: grid; grid-template-columns: 1.3fr 1fr 1.1fr .8fr .8fr auto;
    gap: 10px; align-items: end; padding: 14px;
    border: 1px solid rgba(120,170,255,.20); border-radius: 12px;
    background: rgba(120,170,255,.05); margin-bottom: 16px; }
.ext-new .form-label { margin-bottom: 5px; }
/* Two breakpoints, not one: at six columns the budget boxes squeeze to
   unreadable long before the panel is narrow enough to want a single file. */
@media (max-width: 1020px) { .ext-new { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 720px) { .ext-new { grid-template-columns: 1fr; } }

/* The one-time reveal. Deliberately loud: this panel is the only chance
   anybody has to capture the secret. */
.ext-reveal { border: 1px solid rgba(90,220,160,.35); border-radius: 12px;
    background: rgba(60,200,140,.08); padding: 14px; margin-bottom: 16px; }
.ext-reveal-head { display: flex; flex-direction: column; gap: 2px;
    margin-bottom: 10px; }
.ext-reveal-head strong { color: #b6f5d8; font-size: 13.5px; }
.ext-reveal-head span { color: var(--muted, #9aa0b0); font-size: 12px; }
.ext-reveal-row { display: flex; gap: 8px; align-items: center; }
.ext-reveal-row code { flex: 1; min-width: 0; overflow-x: auto;
    white-space: nowrap; font-size: 12.5px; padding: 9px 11px;
    border-radius: 8px; background: rgba(0,0,0,.35); color: #eaf2ff;
    border: 1px solid rgba(255,255,255,.08); }

.ext-list { display: flex; flex-direction: column; gap: 8px;
    color: var(--muted, #9aa0b0); font-size: 13px; }
.ext-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.08); border-radius: 11px;
    background: rgba(255,255,255,.025); transition: border-color .15s; }
.ext-row:hover { border-color: rgba(120,170,255,.28); }
.ext-row-main { flex: 1; min-width: 0; }
.ext-row-name { color: #eaf2ff; font-size: 13.5px; font-weight: 600;
    display: flex; align-items: center; gap: 8px; }
.ext-row-meta { font-size: 12px; opacity: .75; margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext-chip { font-size: 11px; font-weight: 600; letter-spacing: .02em;
    padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ext-chip-one { background: rgba(120,170,255,.16); color: #9ecbff; }
.ext-chip-all { background: rgba(255,190,90,.16); color: #ffd08a; }
.ext-chip-live { background: rgba(90,220,160,.16); color: #8fe8c0; }
.ext-uuid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px; opacity: .8; }
/* A key that is out of road: expired, or past today's allowance. Red, because
   the integrator on the other end is getting a 4xx right now. */
.ext-chip-stop { background: rgba(255,120,120,.16); color: #ff9b9b; }

/* The re-read. Full width under the row so a 50-character secret does not
   reflow the meta line it sits beneath. */
.ext-row-key { display: block; margin-top: 8px; padding: 8px 10px;
    border-radius: 8px; background: rgba(0,0,0,.35); color: #eaf2ff;
    border: 1px solid rgba(255,255,255,.08); font-size: 12px;
    overflow-x: auto; white-space: nowrap; }
.ext-secondary-sm { background: none; border: 1px solid rgba(255,255,255,.14);
    color: #cfd8ea; border-radius: 8px; padding: 6px 12px; font-size: 12.5px;
    cursor: pointer; transition: background .15s; white-space: nowrap; }
.ext-secondary-sm:hover { background: rgba(255,255,255,.07); }

.ext-danger { background: none; border: 1px solid rgba(255,120,120,.35);
    color: #ff9b9b; border-radius: 8px; padding: 6px 12px; font-size: 12.5px;
    cursor: pointer; transition: background .15s; }
.ext-danger:hover { background: rgba(255,120,120,.12); }

/* Publish switch — a real toggle, because "is this reachable company-wide?"
   should be answerable from across the room. */
.ext-switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.ext-switch input { opacity: 0; width: 0; height: 0; }
.ext-slider { position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
    background: rgba(255,255,255,.14); transition: background .18s; }
.ext-slider::before { content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; top: 3px; border-radius: 50%; background: #fff;
    transition: transform .18s; }
.ext-switch input:checked + .ext-slider { background: #3ecf8e; }
.ext-switch input:checked + .ext-slider::before { transform: translateX(18px); }
.ext-switch input:focus-visible + .ext-slider { outline: 2px solid #4da3ff;
    outline-offset: 2px; }
