/* =====================================================================
   agent.css
   Styles for Agent.html (the workspace page). Loaded after the Tailwind CDN
   script, so these rules keep the same order they had when they were inline.
   Sections: theme + shell, sidebar, chat + messages, composer + modes,
   dialogs, activity timeline, diff viewer, refinement layer.
   ===================================================================== */
        :root {
            --agent-accent: var(--sg-accent);
            --agent-accent-light: var(--sg-accent-hover);
            --agent-border: var(--sg-line);
            --mode-accent: #4DA9EE;
            --mode-accent-rgb: 77,169,238;
        }

        body { min-height: 100vh; }

        /* ---------- Shell: a workbench, not floating cards ---------- */
        .agent-shell {
            min-height: calc(100dvh - 56px);
            transition: padding-top .38s cubic-bezier(.22, 1, .36, 1);
        }
        .workspace-grid {
            grid-template-columns: 288px minmax(0, 1fr);
            height: calc(100dvh - 56px);
            min-height: 520px;
            align-items: stretch;
            transition: height .42s cubic-bezier(.22, 1, .36, 1);
        }
        body.agent-nav-collapsed #agent-main { padding-top: 0; }
        body.agent-nav-collapsed .workspace-grid { height: 100dvh; }

        .agent-panel { background: transparent; border: 0; box-shadow: none; }
        .agent-panel-header {
            border-bottom: 1px solid var(--sg-line);
            background: transparent;
        }
        .history-panel {
            background: var(--sg-bg-soft);
            border-right: 1px solid var(--sg-line);
            border-radius: 0;
        }
        .history-panel .agent-panel-header { background: transparent; }
        .conversation-panel {
            background: transparent;
            border: 0;
            border-radius: 0;
            box-shadow: none;
        }
        .conversation-panel .agent-panel-header { background: transparent; }

        /* ---------- Buttons ---------- */
        .agent-button {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: .5rem;
            border: 1px solid var(--sg-line-strong);
            background: transparent;
            color: var(--sg-text);
            transition: background-color .15s ease, border-color .15s ease, color .15s ease;
        }
        .agent-button:hover { background: var(--sg-hover); border-color: var(--sg-text-3); }
        .agent-button-primary {
            color: var(--sg-on-accent);
            border-color: var(--sg-accent);
            background: var(--sg-accent);
        }
        .agent-button-primary:hover { background: var(--sg-accent-hover); border-color: var(--sg-accent-hover); }

        .chat-scroll::-webkit-scrollbar, .model-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
        .chat-scroll::-webkit-scrollbar-thumb, .model-scroll::-webkit-scrollbar-thumb { border-radius: 8px; background: var(--sg-line-strong); }
        .chat-scroll::-webkit-scrollbar-track, .model-scroll::-webkit-scrollbar-track { background: transparent; }

        /* ---------- Nav collapse control ---------- */
        .agent-nav-toggle {
            position: fixed;
            z-index: 60;
            top: .65rem;
            right: .75rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 30px;
            height: 28px;
            gap: 0;
            border: 1px solid var(--sg-line-strong);
            border-radius: var(--sg-radius-sm);
            padding: .3rem;
            color: var(--sg-text-2);
            background: var(--sg-panel);
            font-size: 11px;
            opacity: 0;
            transition: top .38s cubic-bezier(.22, 1, .36, 1), width .2s ease, gap .2s ease, opacity .2s ease, border-color .2s ease;
        }
        .agent-nav-toggle:hover, .agent-nav-toggle:focus-visible {
            opacity: 1; width: auto; gap: .4rem; padding: .4rem .6rem; border-color: var(--sg-accent);
        }
        .agent-nav-toggle span { max-width: 0; overflow: hidden; opacity: 0; white-space: nowrap; transition: max-width .2s ease, opacity .16s ease; }
        .agent-nav-toggle:hover span, .agent-nav-toggle:focus-visible span { max-width: 5rem; opacity: 1; }
        body:not(.agent-nav-collapsed) .agent-nav-toggle { top: 4rem; }

        site-nav > nav {
            transform-origin: top center;
            transition: transform .42s cubic-bezier(.22, 1, .36, 1), opacity .28s ease, visibility 0s linear 0s;
        }
        body.agent-nav-collapsed site-nav > nav {
            transform: translateY(-105%);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: transform .42s cubic-bezier(.22, 1, .36, 1), opacity .24s ease, visibility 0s linear .42s;
        }

        /* ---------- Sidebar ---------- */
        .sidebar-section-label { color: var(--sg-text-3); font-size: 11.5px; font-weight: 550; }
        .sidebar-group-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; text-align: left; transition: color .15s ease; }
        .sidebar-group-trigger:hover { color: var(--sg-text); }
        .sidebar-group-chevron { transition: transform .2s ease; }
        .sidebar-group-trigger[aria-expanded="false"] .sidebar-group-chevron { transform: rotate(-90deg); }
        .sidebar-group-content { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows .22s ease, opacity .18s ease; }
        .sidebar-group-content > div { overflow: hidden; min-height: 0; }
        .sidebar-group-content.collapsed { grid-template-rows: 0fr; opacity: 0; }
        .sidebar-scroll-area { scrollbar-gutter: stable; }
        .sidebar-project-button { min-height: 30px; transition: background-color .15s ease, color .15s ease; }
        .sidebar-new-chat {
            min-height: 38px;
            border-radius: var(--sg-radius-sm);
            background: var(--sg-accent);
            border-color: var(--sg-accent);
            color: var(--sg-on-accent) !important;
        }
        .sidebar-new-chat i { color: inherit !important; }
        .sidebar-new-chat:hover { background: var(--sg-accent-hover); border-color: var(--sg-accent-hover); }
        .sidebar-footer-control { border-top-color: var(--sg-line); }

        .chat-history-item { border: 1px solid transparent; transition: background-color .15s ease; position: relative; }
        .chat-history-item:hover { background: var(--sg-hover); }
        .chat-history-item.active { background: var(--sg-accent-soft); }
        .chat-history-item.active::before {
            content: "";
            position: absolute;
            left: 0; top: 7px; bottom: 7px;
            width: 2px;
            border-radius: 2px;
            background: var(--sg-accent);
        }
        .chat-management-button { opacity: 0; transition: opacity .15s ease, color .15s ease, background-color .15s ease; }
        .sidebar-chat-row:hover .chat-management-button, .chat-management-button:focus-visible { opacity: 1; }
        .chat-star-button { opacity: .55; transition: opacity .18s ease, color .18s ease; }
        .sidebar-chat-row:hover .chat-star-button, .chat-star-button:focus-visible { opacity: 1; }
        .sidebar-section { animation: sidebarSectionIn .3s ease-out both; }
        .sidebar-chat-row { animation: sidebarItemIn .22s ease-out both; }

        .sidebar-model-selector #model-dropdown-btn {
            width: 100%;
            justify-content: flex-start;
            border-color: var(--sg-line-strong);
            border-radius: var(--sg-radius-sm);
            background: var(--sg-field);
        }
        .sidebar-model-selector .model-menu {
            top: auto; right: auto; bottom: calc(100% + 8px); left: 0;
            width: min(320px, calc(100vw - 24px));
            transform-origin: bottom left;
        }
        .model-menu { animation: modelMenuIn .16s ease-out both; box-shadow: var(--sg-shadow); }
        .model-option { transition: background-color .15s ease, border-color .15s ease; }
        .model-option:hover, .model-option.selected { background: var(--sg-accent-soft); border-color: color-mix(in srgb, var(--sg-accent) 40%, transparent); }

        /* ---------- Composer ---------- */
        .prompt-composer {
            position: relative;
            isolation: isolate;
            --mode-accent: #4DA9EE;
            --mode-accent-rgb: 77,169,238;
            background: var(--sg-panel);
            transition: border-color .2s ease, box-shadow .2s ease;
        }
        .prompt-composer[data-mode="plan"] { --mode-accent: #B58BF5; --mode-accent-rgb: 181,139,245; }
        .prompt-composer[data-mode="autopilot"] { --mode-accent: #F6BE55; --mode-accent-rgb: 246,190,85; }
        .conversation-panel #chat-form {
            border-radius: var(--sg-radius);
            background: var(--sg-panel);
            border-color: var(--sg-line-strong);
            box-shadow: none;
        }
        .conversation-panel #chat-form:focus-within {
            border-color: rgba(var(--mode-accent-rgb), .8);
            box-shadow: 0 0 0 3px rgba(var(--mode-accent-rgb), .14);
        }
        #prompt-input { color: var(--sg-text); }
        #prompt-input::placeholder { color: var(--sg-text-3); transition: opacity .18s ease; }
        #prompt-input:focus::placeholder { opacity: .6; }
        #chat-form #send-btn {
            background-color: var(--mode-accent);
            color: #04202F;
            border-radius: var(--sg-radius-sm);
            transition: filter .15s ease;
        }
        #chat-form #send-btn:hover { filter: brightness(1.1); background-color: var(--mode-accent); }
        #chat-form[data-mode="plan"] #send-btn { background-color: var(--mode-accent); }
        #chat-form[data-mode="autopilot"] #send-btn { background-color: var(--mode-accent); }

        .mode-toggle {
            display: inline-flex;
            gap: 2px;
            padding: 2px;
            border: 1px solid var(--sg-line);
            border-radius: var(--sg-radius-sm);
            background: var(--sg-field);
        }
        .mode-toggle button {
            display: inline-flex;
            align-items: center;
            gap: .35rem;
            border-radius: 4px;
            padding: .38rem .6rem;
            color: var(--sg-text-3);
            font-size: 11px;
            font-weight: 550;
            transition: color .15s ease, background-color .15s ease;
        }
        .mode-toggle button:hover { color: var(--sg-text); }
        .mode-toggle button[aria-pressed="true"] {
            color: var(--mode-accent, #4DA9EE);
            background: rgba(var(--mode-accent-rgb, 77,169,238), .15);
        }
        .conversation-panel .prompt-suggestion {
            border-color: var(--sg-line-strong);
            background: transparent;
            color: var(--sg-text-2);
            border-radius: var(--sg-radius-sm);
        }
        .conversation-panel .prompt-suggestion:hover { background: var(--sg-hover); color: var(--sg-text); }
        #pasted-content-preview { animation: attachmentIn .22s ease-out both; }

        /* ---------- Messages ---------- */
        .message-row { animation: messageIn .25s ease-out both; }
        .message-bubble { overflow-wrap: anywhere; line-height: 1.7; }
        .conversation-panel .message-bubble {
            border-radius: var(--sg-radius);
            background-color: var(--sg-panel) !important;
            border-color: var(--sg-line) !important;
            color: var(--sg-text);
        }
        .conversation-panel .message-row.flex-row-reverse .message-bubble {
            border-radius: var(--sg-radius) 3px var(--sg-radius) var(--sg-radius);
            background: var(--sg-accent-soft) !important;
            border-color: color-mix(in srgb, var(--sg-accent) 28%, transparent) !important;
            color: var(--sg-text);
            animation: userBubbleIn .22s ease-out both;
        }
        .conversation-panel .message-row:not(.flex-row-reverse) .assistant-message-surface {
            display: block !important;
            max-width: 100%;
            padding: 0 !important;
            border: 0 !important;
            border-radius: 0 !important;
            background: transparent !important;
            box-shadow: none !important;
            color: var(--sg-text);
        }
        .assistant-final-response { animation: assistantResponseIn .2s ease-out both; }
        .assistant-final-response .markdown-content > * { animation: none; }
        .markdown-content > * { animation: messageContentIn .24s ease-out both; }
        .message-text-enter > * { animation: textReveal .24s ease-out both; }
        .ai-text-word { display: inline-block; animation: aiWordIn .28s cubic-bezier(.2,.75,.25,1) both; animation-delay: var(--word-delay, 0ms); }

        .markdown-content p { margin: .7rem 0; }
        .markdown-content p:first-child { margin-top: 0; }
        .markdown-content p:last-child { margin-bottom: 0; }
        .markdown-content h1, .markdown-content h2, .markdown-content h3 {
            margin: 1.2rem 0 .55rem;
            color: var(--sg-text);
            font-family: var(--sg-font-display);
            font-weight: 650;
            letter-spacing: -.015em;
            line-height: 1.3;
        }
        .markdown-content h1 { font-size: 1.3rem; }
        .markdown-content h2 { font-size: 1.15rem; }
        .markdown-content h3 { font-size: 1.02rem; }
        .markdown-content ul, .markdown-content ol { margin: .6rem 0; padding-left: 1.35rem; }
        .markdown-content ul { list-style: disc; }
        .markdown-content ol { list-style: decimal; }
        .markdown-content li { margin: .28rem 0; }
        .markdown-content li::marker { color: var(--sg-text-3); }
        .markdown-content blockquote { margin: .8rem 0; padding: .3rem .9rem; border-left: 2px solid var(--sg-accent); color: var(--sg-text-2); }
        .markdown-content hr { margin: 1rem 0; border-color: var(--sg-line); }
        .markdown-content a { color: var(--sg-accent); text-decoration: underline; text-underline-offset: 3px; }
        .markdown-content img { max-width: 100%; height: auto; border-radius: var(--sg-radius); }
        .markdown-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
        .markdown-content th, .markdown-content td { border: 1px solid var(--sg-line); padding: .45rem .65rem; text-align: left; }
        .markdown-content th { background: var(--sg-panel-2); font-weight: 600; }
        .markdown-content :not(pre) > code {
            border: 1px solid var(--sg-line);
            border-radius: 4px;
            padding: .1rem .35rem;
            background: var(--sg-panel-2);
            color: var(--sg-accent);
            font-family: "JetBrains Mono", monospace;
            font-size: .86em;
        }
        .markdown-content pre {
            max-width: 100%;
            overflow-x: auto;
            margin: .8rem 0;
            padding: .9rem 1rem;
            border: 1px solid var(--sg-line);
            border-radius: var(--sg-radius);
            background: #0B1722;
            color: #D6E2EC;
            font: 12px/1.7 "JetBrains Mono", monospace;
        }
        .markdown-content pre code { font: inherit; }
        .code-block { background: #0B1722 !important; border-color: var(--sg-line) !important; border-radius: var(--sg-radius) !important; }
        .code-block .hljs { background: transparent; }

        /* ---------- Tool activity ---------- */
        .live-tool-panel {
            width: min(100%, 760px);
            overflow: hidden;
            border: 1px solid var(--sg-line);
            border-radius: var(--sg-radius);
            background: var(--sg-panel);
        }
        .live-tool-summary { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .6rem .8rem; color: var(--sg-text); text-align: left; font-size: 12px; font-weight: 500; }
        .live-tool-spinner {
            width: 14px; height: 14px; flex: 0 0 14px;
            border: 1.5px solid var(--sg-line-strong);
            border-top-color: var(--sg-accent);
            border-radius: 50%;
            animation: toolSpin .9s linear infinite;
        }
        .live-tool-complete { color: var(--sg-ok); animation: toolComplete .2s ease-out both; }
        .live-tool-list { border-top: 1px solid var(--sg-line); }
        .live-tool-row {
            display: flex; align-items: center; gap: .65rem;
            min-height: 36px; padding: .5rem .8rem;
            border-bottom: 1px solid var(--sg-line);
            color: var(--sg-text-2); font-size: 12px;
            animation: toolRowIn .24s ease-out both;
        }
        .live-tool-row:last-child { border-bottom: 0; }
        .live-tool-row[data-active="true"] { color: var(--sg-text); }
        .live-tool-row[data-failed="true"] { color: var(--sg-bad); }
        .live-tool-row[data-failed="true"] .live-tool-complete { color: var(--sg-bad); }
        .live-tool-detail { color: var(--sg-text-3); font-family: "JetBrains Mono", monospace; font-size: 11px; }
        .live-tool-error { position: relative; color: var(--sg-bad); }
        .live-tool-error summary { cursor: pointer; list-style: none; border-radius: 4px; padding: .2rem .35rem; color: var(--sg-bad); font-size: 11px; }
        .live-tool-error summary::-webkit-details-marker { display: none; }
        .live-tool-error summary:hover, .live-tool-error summary:focus-visible { background: color-mix(in srgb, var(--sg-bad) 12%, transparent); }
        .live-tool-error-message {
            position: absolute; z-index: 5; top: calc(100% + .2rem); right: 0;
            width: min(22rem, 72vw); max-height: 10rem; overflow: auto;
            border: 1px solid color-mix(in srgb, var(--sg-bad) 35%, transparent);
            border-radius: var(--sg-radius-sm); padding: .65rem;
            color: var(--sg-text); background: var(--sg-panel); box-shadow: var(--sg-shadow);
            font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
        }

        .typing-orbit { position: relative; width: 38px; height: 38px; flex: 0 0 38px; animation: orbitMotion 3.2s cubic-bezier(.45,0,.2,1) infinite; }
        .typing-orbit::before, .typing-orbit::after {
            position: absolute; inset: 5px; border: 1px solid color-mix(in srgb, var(--sg-accent) 30%, transparent);
            border-radius: 50%; content: ""; animation: orbitPulse 2.4s ease-in-out infinite;
        }
        .typing-orbit::after { inset: 1px; border-color: color-mix(in srgb, var(--sg-accent) 16%, transparent); animation-delay: -1.2s; }
        .typing-orbit span {
            position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%;
            background: var(--sg-accent); opacity: .25;
            transform: rotate(calc(var(--dot-index) * 30deg)) translateY(-15px);
            animation: orbitDot 1.6s ease-in-out infinite; animation-delay: calc(var(--dot-index) * -133ms);
        }
        .typing-orbit-finishing { animation: orbitFadeOut .24s ease-in both; }
        .typing-response {
            max-height: 13rem; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
            color: var(--sg-text-2); font: 12.5px/1.7 Inter, sans-serif;
            mask-image: linear-gradient(to bottom, #000 70%, transparent);
        }
        .typing-response span { animation: responseCharIn .22s ease-out both; }
        .activity-line { animation: messageContentIn .22s ease-out both; }

        .audit-log {
            width: min(100%, 760px); margin-top: .7rem;
            border: 1px solid var(--sg-line); border-radius: var(--sg-radius);
            background: transparent; color: var(--sg-text-3); font-size: 12px;
        }
        .audit-log summary { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; color: var(--sg-text-2); cursor: pointer; list-style: none; }
        .audit-log summary::-webkit-details-marker { display: none; }
        .audit-log summary:hover { background: var(--sg-hover); }
        .audit-log-content { padding: 0 .8rem .75rem; }
        .audit-log-duration { color: var(--sg-text-3); font-size: 11px; }

        /* ---------- Review ticket (commit approval) ---------- */
        .repository-review-dialog {
            position: relative;
            width: min(92vw, 30rem);
            max-width: none;
            max-height: min(90dvh, 46rem);
            overflow-y: auto;
            border: 1px solid var(--sg-line-strong);
            border-radius: var(--sg-radius-lg);
            background: var(--sg-panel);
            color: var(--sg-text);
            box-shadow: var(--sg-shadow);
            animation: reviewDialogIn .22s cubic-bezier(.2,.8,.2,1) both;
        }
        .repository-review-dialog::before {
            content: "";
            position: absolute; inset: 0 auto 0 0; width: 3px;
            background: var(--sg-solar);
            z-index: 1;
        }
        .repository-review-dialog::backdrop { background: rgba(2, 8, 13, .7); backdrop-filter: blur(6px); }
        .repository-review-dialog > div { padding-left: 1.6rem; }
        .commit-review-orbit { display: none; }
        .commit-review-card {
            border: 1px solid var(--sg-line);
            border-radius: var(--sg-radius);
            background: var(--sg-panel-2);
        }
        .commit-review-pill { min-height: 2.6rem; border-radius: var(--sg-radius-sm); }
        .commit-review-cancel { background: transparent; color: var(--sg-text); border: 1px solid var(--sg-line-strong); }
        .commit-review-cancel:hover { background: var(--sg-hover); }
        .hold-approve-button {
            --hold-progress: 0%;
            background: linear-gradient(90deg, var(--sg-accent) var(--hold-progress), var(--sg-panel-2) var(--hold-progress));
            color: var(--sg-text);
            border: 1px solid var(--sg-accent);
            touch-action: none;
            user-select: none;
        }
        .hold-approve-button[data-holding="true"] { box-shadow: 0 0 0 3px var(--sg-accent-soft); }
        .chat-confirm-dialog { box-shadow: var(--sg-shadow); }
        .chat-confirm-dialog::backdrop, #repository-file-dialog::backdrop, #create-repo-dialog::backdrop,
        #ai-question-dialog::backdrop, .repository-code-dialog::backdrop { background: rgba(2, 8, 13, .7); backdrop-filter: blur(4px); }
        .repository-code-dialog { animation: reviewDialogIn .22s cubic-bezier(.2,.8,.2,1) both; }
        .repository-code-editor { background: #0B1722; color: #ABB8C4; tab-size: 4; }
        .repository-code-editor pre { margin: 0; min-width: max-content; padding: 1rem 1.25rem; font: 12px/1.75 "JetBrains Mono", monospace; }
        .repository-code-line-numbers { user-select: none; color: #4B6173; text-align: right; }
        .confetti-overlay { position: fixed; z-index: 100; inset: 0; width: 100%; height: 100%; pointer-events: none; }

        /* ---------- Toasts and small parts ---------- */
        .status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--sg-ok); }
        /* ---------- Notices: a slim bar docked to the top of the composer ---------- */
        .composer-dock { position: relative; }
        #agent-toast-region {
            position: absolute; z-index: 30; left: 0; right: 0; bottom: 100%;
            display: grid; gap: .4rem; padding: 0 .75rem .55rem;
            pointer-events: none;
        }
        @media (min-width: 640px) { #agent-toast-region { padding-left: 1.75rem; padding-right: 1.75rem; } }
        #agent-toast-region:empty { display: none; }
        .agent-toast {
            --toast-tone: var(--sg-bad);
            width: 100%; max-width: 64rem; margin: 0 auto; pointer-events: auto;
            display: flex; align-items: center; gap: .6rem; padding: .5rem .55rem .5rem .8rem;
            border: 1px solid var(--sg-line-strong); border-left: 2px solid var(--toast-tone);
            border-radius: var(--sg-radius-sm);
            background: var(--sg-panel); color: var(--sg-text);
            box-shadow: var(--sg-shadow); animation: toastIn .18s ease-out both;
        }
        .agent-toast[data-type="success"] { --toast-tone: var(--sg-ok); }
        .agent-toast[data-type="info"] { --toast-tone: var(--sg-accent); }
        .agent-toast[data-leaving="true"] { animation: toastOut .16s ease-in both; }
        .agent-toast-icon { display: inline-grid; flex: 0 0 auto; place-items: center; color: var(--toast-tone); }
        .agent-toast-message { min-width: 0; flex: 1; font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; color: var(--sg-text-2); }
        .agent-toast-action {
            flex: 0 0 auto; border: 1px solid var(--sg-line-strong); border-radius: 4px; padding: .2rem .55rem;
            font-size: 10.5px; font-weight: 550; color: var(--sg-text); transition: background .15s ease;
        }
        .agent-toast-action:hover { background: var(--sg-hover); }
        .agent-toast-dismiss { flex: 0 0 auto; border-radius: 4px; padding: .2rem; color: var(--sg-text-3); transition: color .15s ease, background .15s ease; }
        .agent-toast-dismiss:hover { color: var(--sg-text); background: var(--sg-hover); }

        .loading-ring { width: 15px; height: 15px; border: 2px solid var(--sg-line-strong); border-top-color: var(--sg-accent); border-radius: 999px; animation: spin .8s linear infinite; }

        @keyframes spin { to { transform: rotate(360deg); } }
        @keyframes orbitMotion { to { transform: rotate(360deg); } }
        @keyframes orbitPulse { 0%, 100% { opacity: .3; transform: scale(.9); } 50% { opacity: .9; transform: scale(1.08); } }
        @keyframes orbitDot { 0%, 100% { opacity: .35; scale: .82; } 50% { opacity: 1; scale: 1.08; } }
        @keyframes orbitFadeOut { to { opacity: 0; transform: scale(.65); } }
        @keyframes messageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes messageContentIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes textReveal { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes aiWordIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes userBubbleIn { from { opacity: 0; transform: translateY(3px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
        @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes toastOut { to { opacity: 0; transform: translateY(5px); } }
        @keyframes toolSpin { to { transform: rotate(360deg); } }
        @keyframes toolComplete { from { opacity: .4; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
        @keyframes toolRowIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes assistantResponseIn { from { opacity: .72; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes responseCharIn { from { opacity: .35; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes reviewDialogIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
        @keyframes modelMenuIn { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
        @keyframes attachmentIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes sidebarSectionIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes sidebarItemIn { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: translateX(0); } }

        /* ---------- Light theme: remap the dark-first utilities used by markup and script ---------- */
        html:not(.dark) body .text-white,
        html:not(.dark) body .text-gray-100,
        html:not(.dark) body .text-gray-200 { color: var(--sg-text); }
        html:not(.dark) body .text-gray-300 { color: var(--sg-text-2); }
        html:not(.dark) body .text-gray-400,
        html:not(.dark) body .text-gray-500 { color: var(--sg-text-3); }
        html:not(.dark) body .text-blue-200,
        html:not(.dark) body .text-blue-300 { color: var(--sg-accent); }
        html:not(.dark) body [class*="border-white"] { border-color: var(--sg-line); }
        html:not(.dark) body [class*="bg-white/"] { background-color: var(--sg-hover); }
        html:not(.dark) body [class*="bg-black/"] { background-color: var(--sg-field); }
        html:not(.dark) .code-block [class*="text-"],
        html:not(.dark) .code-block button { color: #9DB2C3; }
        html:not(.dark) .code-block button { border-color: rgba(157, 178, 195, .3); }
        html:not(.dark) img[src*="AgentAvatar"] { filter: invert(1) brightness(.35); }
        html:not(.dark) .markdown-content pre,
        html:not(.dark) .code-block,
        html:not(.dark) .repository-code-editor { color-scheme: dark; }

        /* ---------- Responsive ---------- */
        @media (max-width: 768px) {
            .agent-shell { min-height: auto; }
            .workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 0; min-height: 0; height: auto; }
            .history-panel { max-height: 46dvh; min-height: 240px; border-right: 0; border-bottom: 1px solid var(--sg-line); }
            .conversation-panel { min-height: max(520px, calc(100dvh - 120px)); height: max(520px, calc(100dvh - 120px)); }
            body.agent-nav-collapsed .workspace-grid { height: auto; }
            body.agent-nav-collapsed .conversation-panel { min-height: max(520px, calc(100dvh - 60px)); height: max(520px, calc(100dvh - 60px)); }
        }
        @media (max-width: 420px) {
            .history-panel { max-height: 220px; }
            #messages-container { padding-left: .75rem; padding-right: .75rem; }
            .chat-management-button { opacity: 1; }
        }
        @media (hover: none) { .agent-nav-toggle { opacity: .8; } }

        @media (prefers-reduced-motion: reduce) {
            .typing-orbit, .typing-orbit::before, .typing-orbit::after, .typing-orbit span, .typing-orbit-finishing,
            .typing-response span, .markdown-content > *, .message-text-enter > *, .ai-text-word, .activity-line,
            .conversation-panel .message-row.flex-row-reverse .message-bubble,
            .live-tool-spinner, .live-tool-complete, .live-tool-row,
            .repository-review-dialog, .repository-code-dialog {
                animation-duration: .01ms !important;
                animation-iteration-count: 1 !important;
            }
            .sidebar-section, .sidebar-chat-row, .chat-star-button, .agent-button,
            .sidebar-group-content, .sidebar-group-chevron, .mode-toggle button,
            site-nav > nav, .agent-shell, .workspace-grid, .agent-nav-toggle, .agent-nav-toggle span { transition: none; animation: none; }
        }

        /* =====================================================================
           Refinement layer: curved controls, glass bubbles, animated sidebar,
           sliding mode selector, and styles for the timeline / diff viewer.
           ===================================================================== */
        :root { --sg-pill: 999px; --sg-curve: 18px; --sg-ease: cubic-bezier(.22, 1, .36, 1); }
        .prompt-composer[data-mode="investigate"] { --mode-accent: #FF7A90; --mode-accent-rgb: 255,122,144; }
        #chat-form[data-mode="investigate"] #send-btn { background-color: var(--mode-accent); }
        html:not(.dark) .prompt-composer[data-mode="investigate"] { --mode-accent: #C2284D; --mode-accent-rgb: 194, 40, 77; }

        /* ---------- Sidebar: glass surface, rounded rows, staggered motion ---------- */
        .history-panel {
            background: color-mix(in srgb, var(--sg-bg-soft) 74%, transparent);
            backdrop-filter: blur(18px) saturate(125%);
            -webkit-backdrop-filter: blur(18px) saturate(125%);
        }
        .sidebar-section { animation: sidebarSectionIn .5s var(--sg-ease) both; }
        .sidebar-scroll-area > .sidebar-section:nth-of-type(2) { animation-delay: 60ms; }
        .sidebar-scroll-area > .sidebar-section:nth-of-type(3) { animation-delay: 120ms; }
        .sidebar-chat-row { animation: sidebarItemIn .42s var(--sg-ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
        .chat-history-item {
            border-radius: 12px;
            transition: background-color .2s ease, border-color .2s ease, box-shadow .3s ease, transform .3s var(--sg-ease);
        }
        .chat-history-item:hover { transform: translateX(3px); }
        .chat-history-item.active {
            background: linear-gradient(90deg, var(--sg-accent-soft), transparent 130%);
            border-color: color-mix(in srgb, var(--sg-accent) 24%, transparent);
            box-shadow: 0 10px 24px -18px var(--sg-accent);
        }
        .chat-history-item.active::before {
            left: 3px; top: 9px; bottom: 9px; width: 3px;
            box-shadow: 0 0 10px var(--sg-accent);
            animation: sidebarBarIn .4s var(--sg-ease) both;
        }
        @keyframes sidebarBarIn { from { opacity: 0; transform: scaleY(.2); } to { opacity: 1; transform: scaleY(1); } }
        .sidebar-project-button { border-radius: 12px; transition: background-color .2s ease, color .2s ease, transform .3s var(--sg-ease); }
        .sidebar-project-button:hover { transform: translateX(3px); }
        .sidebar-group-chevron { transition: transform .32s var(--sg-ease); }
        .sidebar-group-content { transition: grid-template-rows .34s var(--sg-ease), opacity .24s ease; }
        .sidebar-footer-control .agent-button { border-radius: 14px; }
        .history-panel details > summary { border-radius: 12px; }

        /* New chat: a soft pill */
        .sidebar-new-chat.agent-button {
            min-height: 42px;
            justify-content: center;
            border-radius: var(--sg-pill);
            border-color: color-mix(in srgb, #fff 18%, var(--sg-accent));
            box-shadow: 0 12px 26px -16px var(--sg-accent), inset 0 1px 0 rgba(255, 255, 255, .22);
            transition: background-color .2s ease, box-shadow .3s ease, transform .3s var(--sg-ease);
        }
        .sidebar-new-chat.agent-button:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -14px var(--sg-accent), inset 0 1px 0 rgba(255, 255, 255, .28); }

        /* Model selector: rounder button and menu */
        .sidebar-model-selector #model-dropdown-btn {
            border-radius: var(--sg-curve);
            padding: .6rem .8rem;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
            transition: background-color .2s ease, border-color .2s ease, box-shadow .3s ease;
        }
        .sidebar-model-selector #model-dropdown-btn:hover,
        .sidebar-model-selector #model-dropdown-btn[aria-expanded="true"] {
            border-color: color-mix(in srgb, var(--sg-accent) 55%, transparent);
            box-shadow: 0 0 0 3px var(--sg-accent-soft);
        }
        .model-menu {
            border-radius: 22px !important;
            background: color-mix(in srgb, var(--sg-panel) 92%, transparent) !important;
            backdrop-filter: blur(20px) saturate(130%);
            -webkit-backdrop-filter: blur(20px) saturate(130%);
        }
        .model-menu .agent-input, #model-search { border-radius: var(--sg-pill) !important; }
        .model-option { border-radius: 14px; }

        /* ---------- Mode selector: a pill with a sliding thumb ---------- */
        .mode-toggle { position: relative; isolation: isolate; gap: 2px; padding: 3px; border-radius: var(--sg-pill); }
        .mode-thumb {
            position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0;
            border-radius: var(--sg-pill);
            background-color: rgba(var(--mode-accent-rgb, 77,169,238), .18);
            box-shadow: inset 0 1px 0 rgba(var(--mode-accent-rgb, 77,169,238), .3), 0 0 18px rgba(var(--mode-accent-rgb, 77,169,238), .2);
            pointer-events: none;
            transition: transform .45s var(--sg-ease), width .45s var(--sg-ease), background-color .35s ease, box-shadow .35s ease;
        }
        .mode-toggle button { position: relative; z-index: 1; border-radius: var(--sg-pill); padding: .4rem .8rem; transition: color .25s ease; }
        .mode-toggle button[aria-pressed="true"] { background: transparent; }
        .mode-toggle button i, .mode-toggle button svg { transition: transform .35s var(--sg-ease); }
        .mode-toggle button[aria-pressed="true"] svg { transform: scale(1.12); }
        .conversation-panel #chat-form { border-radius: 22px; transition: border-color .25s ease, box-shadow .3s ease; }
        #chat-form #send-btn { border-radius: var(--sg-pill); transition: filter .15s ease, background-color .35s ease, transform .3s var(--sg-ease); }
        #chat-form #send-btn:not(:disabled):hover { transform: translateY(-1px); }
        .conversation-panel .prompt-suggestion { border-radius: var(--sg-pill); }
        #autopilot-stop-btn { border-radius: var(--sg-pill); }

        /* ---------- Glass message bubbles ---------- */
        html.has-motion .message-row { animation: none; }
        html.has-motion .conversation-panel .message-row.flex-row-reverse .message-bubble { animation: none; }
        .conversation-panel .message-row.flex-row-reverse .message-bubble {
            border-radius: 20px 20px 6px 20px;
            background:
                linear-gradient(180deg, rgba(255, 255, 255, .24) 0%, rgba(255, 255, 255, 0) 52%),
                linear-gradient(180deg, #1583cf 0%, #0a6fb3 100%) !important;
            border: 1px solid rgba(255, 255, 255, .22) !important;
            color: #fff !important;
            box-shadow:
                0 16px 32px -16px rgba(0, 166, 251, .75),
                0 0 0 1px rgba(5, 60, 100, .25),
                inset 0 1px 0 rgba(255, 255, 255, .34),
                inset 0 -12px 20px -14px rgba(0, 30, 70, .55);
            backdrop-filter: blur(12px) saturate(150%);
            -webkit-backdrop-filter: blur(12px) saturate(150%);
            padding-inline: 1rem;
        }
        .conversation-panel .message-row.flex-row-reverse .message-bubble,
        .conversation-panel .message-row.flex-row-reverse .message-bubble .markdown-content,
        .conversation-panel .message-row.flex-row-reverse .message-bubble p { color: #fff !important; }
        .conversation-panel .message-row.flex-row-reverse .message-bubble a { color: #fff; }
        .conversation-panel .message-row.flex-row-reverse .message-bubble :not(pre) > code {
            background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .22); color: #fff;
        }

        /* ---------- Live activity timeline ---------- */
        .agent-timeline { position: relative; margin: .5rem 0 0; padding-left: 1.5rem; max-width: 760px; }
        .agent-timeline::before {
            content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 1px;
            background: linear-gradient(180deg, color-mix(in srgb, var(--sg-accent) 60%, transparent), var(--sg-line));
        }
        .timeline-step { position: relative; padding: .28rem 0 .5rem; animation: toolRowIn .35s var(--sg-ease) both; }
        .timeline-dot {
            position: absolute; left: -1.5rem; top: .5rem; width: 13px; height: 13px; border-radius: 50%;
            background: var(--sg-bg); border: 2px solid var(--sg-line-strong);
            transition: background-color .3s ease, border-color .3s ease, box-shadow .3s ease;
        }
        .timeline-step[data-state="active"] .timeline-dot { border-color: var(--sg-accent); box-shadow: 0 0 0 4px var(--sg-accent-soft); animation: orbitPulse 1.6s ease-in-out infinite; }
        .timeline-step[data-state="done"] .timeline-dot { background: var(--sg-accent); border-color: var(--sg-accent); }
        .timeline-step[data-state="failed"] .timeline-dot { background: var(--sg-bad); border-color: var(--sg-bad); }
        .timeline-head { display: flex; align-items: baseline; gap: .6rem; font-size: 12px; color: var(--sg-text); }
        .timeline-title { font-weight: 500; }
        .timeline-time { margin-left: auto; font-size: 10px; color: var(--sg-text-3); font-variant-numeric: tabular-nums; }
        .timeline-detail { margin-top: .15rem; font: 10.5px "JetBrains Mono", ui-monospace, monospace; color: var(--sg-text-3); overflow-wrap: anywhere; }
        .timeline-error { margin-top: .3rem; font-size: 10.5px; color: var(--sg-bad); }
        .timeline-link { color: var(--sg-accent); text-decoration: underline; text-underline-offset: 3px; }

        .activity-summary { margin-top: .75rem; max-width: 760px; }
        .activity-summary > summary {
            display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; list-style: none;
            padding: .38rem .85rem; border-radius: var(--sg-pill); font-size: 11px; color: var(--sg-text-2);
            background: var(--sg-hover); border: 1px solid var(--sg-line);
            transition: background-color .25s ease, color .2s ease, border-color .25s ease;
        }
        .activity-summary > summary::-webkit-details-marker { display: none; }
        .activity-summary > summary:hover { color: var(--sg-text); border-color: var(--sg-line-strong); }
        .activity-summary[open] > summary { background: var(--sg-accent-soft); color: var(--sg-accent); border-color: color-mix(in srgb, var(--sg-accent) 30%, transparent); }
        .activity-summary .activity-body { padding: .5rem .25rem 0; animation: toolRowIn .3s var(--sg-ease) both; }
        .activity-summary[data-has-failure="true"] > summary { color: var(--sg-bad); border-color: color-mix(in srgb, var(--sg-bad) 35%, transparent); }
        .activity-summary .audit-log-duration { color: var(--sg-text-3); }
        .activity-files { margin-top: .6rem; display: grid; gap: .25rem; }
        .activity-file { display: flex; gap: .5rem; font: 10.5px "JetBrains Mono", ui-monospace, monospace; color: var(--sg-text-2); }
        .activity-file b { font-weight: 600; color: var(--sg-accent); }

        /* ---------- Visual diff viewer (always dark, like the code editor) ---------- */
        .diff-view {
            margin-top: .75rem; border-radius: 16px; overflow: hidden;
            border: 1px solid var(--sg-line); background: #0B1722; color: #D6E2EC; color-scheme: dark;
            font: 11.5px/1.6 "JetBrains Mono", ui-monospace, Menlo, monospace;
        }
        .diff-toolbar {
            display: flex; align-items: center; gap: .75rem; padding: .55rem .8rem;
            border-bottom: 1px solid rgba(140, 185, 220, .13); background: rgba(255, 255, 255, .03);
            font-family: Inter, sans-serif; font-size: 11px; color: #9DB2C3;
        }
        .diff-stat-add { color: #5BE3A4; font-weight: 600; }
        .diff-stat-del { color: #FF8DA1; font-weight: 600; }
        .diff-segmented { margin-left: auto; display: inline-flex; padding: 2px; border-radius: var(--sg-pill); background: rgba(255, 255, 255, .07); }
        .diff-segmented button { border-radius: var(--sg-pill); padding: .2rem .7rem; color: #9DB2C3; font-size: 10.5px; transition: background-color .25s ease, color .2s ease; }
        .diff-segmented button[aria-pressed="true"] { background: rgba(77, 169, 238, .28); color: #fff; }
        .diff-scroll { max-height: min(46dvh, 420px); overflow: auto; }
        .diff-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
        .diff-table td { padding: 0 .6rem; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
        .diff-num { width: 3.1rem; text-align: right; color: #5F7787; user-select: none; background: rgba(255, 255, 255, .025); }
        .diff-sign { width: 1.2rem; text-align: center; user-select: none; color: #5F7787; }
        .diff-row[data-kind="add"] td { background: rgba(46, 204, 142, .11); }
        .diff-row[data-kind="add"] .diff-sign { color: #5BE3A4; }
        .diff-row[data-kind="del"] td { background: rgba(255, 99, 132, .11); }
        .diff-row[data-kind="del"] .diff-sign { color: #FF8DA1; }
        .diff-row[data-kind="add"] .diff-num { background: rgba(46, 204, 142, .17); }
        .diff-row[data-kind="del"] .diff-num { background: rgba(255, 99, 132, .17); }
        .diff-row[data-kind="empty"] td { background: rgba(255, 255, 255, .02); }
        .diff-fold td {
            padding: .3rem .8rem; text-align: center; color: #7D94A3; background: rgba(77, 169, 238, .07);
            font-family: Inter, sans-serif; font-size: 10.5px; cursor: pointer;
        }
        .diff-fold td:hover { color: #fff; background: rgba(77, 169, 238, .16); }
        .diff-split .diff-half { width: 50%; }
        .diff-split .diff-half + .diff-half { border-left: 1px solid rgba(140, 185, 220, .13); }
        .diff-empty { padding: 1.25rem; text-align: center; color: #9DB2C3; font-family: Inter, sans-serif; }

        /* Multi-change review progress */
        .review-progress { display: flex; justify-content: center; gap: .35rem; margin: .75rem 0 0; }
        .review-progress span { width: 22px; height: 4px; border-radius: var(--sg-pill); background: var(--sg-line-strong); transition: background-color .3s ease, width .35s var(--sg-ease); }
        .review-progress span[data-state="done"] { background: var(--sg-accent); }
        .review-progress span[data-state="current"] { background: var(--sg-text); width: 34px; }

        @media (prefers-reduced-motion: reduce) {
            .mode-thumb, .chat-history-item, .sidebar-new-chat.agent-button, .timeline-step,
            .timeline-dot, .activity-summary .activity-body { transition: none; animation: none; }
        }


/* =====================================================================
   Stop in the composer, stopped responses, search, edit, notifications
   ===================================================================== */

/* Stop takes Send's slot: same size and place. It is styled like the mode selector
   (field background, hairline border, accent only on the icon), not as a red alarm. */
#chat-form #send-btn .stop-icon { display: none; fill: currentColor; }
#chat-form #send-btn[data-state="stop"] .send-icon { display: none; }
#chat-form #send-btn[data-state="stop"] .stop-icon { display: block; }
#chat-form #send-btn[data-state="stop"] {
    background-color: var(--sg-field);
    border: 1px solid var(--sg-line-strong);
    color: var(--mode-accent);
    animation: stopIn .16s ease-out both;
}
#chat-form #send-btn[data-state="stop"]:hover { background-color: rgba(var(--mode-accent-rgb), .15); filter: none; border-color: var(--mode-accent); }
#chat-form #send-btn[data-state="stop"]:focus-visible { outline: 2px solid var(--mode-accent); outline-offset: 2px; }
@keyframes stopIn { from { transform: scale(.88); opacity: .4; } to { transform: scale(1); opacity: 1; } }

/* A response the person stopped: clearly not a finished answer. */
.stopped-response .stopped-surface {
    border: 1px dashed var(--sg-line-strong); border-radius: var(--sg-radius);
    background: transparent; padding: .7rem .9rem; font-size: 12.5px; color: var(--sg-text-2);
}
.stopped-response .stopped-partial {
    margin-top: .55rem; max-height: 9rem; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
    color: var(--sg-text-3); font-size: 12px; line-height: 1.6;
    -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent);
}
.stopped-response .stopped-head { display: flex; align-items: center; gap: .45rem; font-weight: 550; color: var(--sg-text); }
.stopped-response .stopped-head i { color: var(--sg-text-3); }
.stopped-response .stopped-actions { margin-top: .6rem; display: flex; gap: .4rem; }

/* Sidebar search */
.sidebar-search { position: relative; }
.sidebar-search-icon { position: absolute; left: .65rem; top: 50%; width: .85rem; height: .85rem; transform: translateY(-50%); color: var(--sg-text-3); pointer-events: none; }
.sidebar-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.sidebar-search-clear { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); border-radius: 4px; padding: .2rem; color: var(--sg-text-3); }
.sidebar-search-clear:hover { color: var(--sg-text); background: var(--sg-hover); }
.sidebar-search-status { margin-top: .4rem; padding: 0 .2rem; font-size: 10px; color: var(--sg-text-3); }
.chat-title mark, .chat-snippet mark {
    background: var(--sg-accent-soft); color: var(--sg-text); border-radius: 2px; padding: 0 1px;
    box-shadow: inset 0 -1.5px 0 var(--sg-accent);
}
.chat-history-item.has-snippet { align-items: flex-start; }
.chat-history-item .chat-main { min-width: 0; flex: 1; }
.chat-snippet {
    margin-top: .15rem; font-size: 10px; line-height: 1.4; color: var(--sg-text-3);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.chat-match-badge {
    margin-left: .3rem; border: 1px solid var(--sg-line-strong); border-radius: 4px; padding: 0 .3rem;
    font-size: 9px; font-weight: 550; color: var(--sg-text-3); white-space: nowrap;
}
.message-row[data-search-hit="true"] .message-bubble { animation: searchHit 2.2s ease-out 1; }
@keyframes searchHit {
    0%, 55% { box-shadow: 0 0 0 2px var(--sg-accent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* Edit and resend */
.message-row:hover .message-actions, .message-actions:focus-within { opacity: 1; }
.message-actions { opacity: 0; transition: opacity .15s ease; }
@media (hover: none) { .message-actions { opacity: 1; } }
.message-edit { width: min(36rem, 100%); text-align: left; }
.message-edit textarea {
    width: 100%; min-height: 5rem; max-height: 18rem; resize: vertical; padding: .65rem .8rem;
    font-size: 13px; line-height: 1.6; color: var(--sg-text); background: var(--sg-field);
    border: 1px solid var(--sg-line-strong); border-radius: var(--sg-radius); outline: none;
}
.message-edit textarea:focus { border-color: rgba(var(--mode-accent-rgb), .8); box-shadow: 0 0 0 3px rgba(var(--mode-accent-rgb), .14); }
.message-edit-note { margin-top: .4rem; font-size: 10.5px; color: var(--sg-text-3); }
.message-edit-actions { margin-top: .5rem; display: flex; justify-content: flex-end; gap: .4rem; }

/* Notification toggle */
.notify-toggle { display: inline-flex; align-items: center; gap: .4rem; color: var(--sg-text-3); }
.notify-toggle[aria-pressed="true"] { color: var(--mode-accent); border-color: rgba(var(--mode-accent-rgb), .45); background: rgba(var(--mode-accent-rgb), .1); }
.notify-toggle[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    #chat-form #send-btn[data-state="stop"], .message-row[data-search-hit="true"] .message-bubble { animation: none; }
}


/* =====================================================================
   Redesign: calm, flat, Antigravity-inspired.
   Sidebar of plain rows with ages; one centred conversation column; a composer card
   (attach, model, send) with the repository and mode beneath it; a quiet work log.
   Everything is built from the shared theme variables, so light and dark both work.
   ===================================================================== */

.workspace-grid { grid-template-columns: 264px minmax(0, 1fr); }
.history-panel { border-right: 1px solid var(--sg-line); background: transparent; }
.conversation-panel { background: transparent; position: relative; }
.conversation-panel .agent-panel-header { border-bottom: 0; min-height: 48px; }

/* ---- Sidebar ---- */
.sidebar-new-chat.agent-button {
    justify-content: flex-start; gap: .55rem; width: 100%;
    background: var(--sg-hover); border: 1px solid transparent; color: var(--sg-text);
    border-radius: 9px; box-shadow: none; font-weight: 500; transform: none;
}
.sidebar-new-chat.agent-button:hover { background: var(--sg-accent-soft); border-color: transparent; transform: none; box-shadow: none; }
.sidebar-section-label { font-size: 10.5px; letter-spacing: .02em; }
.chat-history-item {
    border-radius: 8px; min-height: 30px; padding-top: .32rem; padding-bottom: .32rem;
    gap: .5rem; align-items: center;
}
.chat-history-item:hover { transform: none; background: var(--sg-hover); }
.chat-history-item.active { background: var(--sg-hover); box-shadow: none; }
.chat-history-item.active::before { display: none; }
.chat-history-item .chat-title { font-weight: 450; color: var(--sg-text-2); }
.chat-history-item.active .chat-title { color: var(--sg-text); font-weight: 550; }
.chat-time { flex: 0 0 auto; margin-left: auto; padding-left: .4rem; font-size: 10.5px; color: var(--sg-text-3); font-variant-numeric: tabular-nums; transition: opacity .15s ease; }
.sidebar-chat-row:hover .chat-time, .sidebar-chat-row:focus-within .chat-time { opacity: 0; }
.sidebar-footer-control { display: flex; gap: .25rem; border-top: 1px solid var(--sg-line); }
.sidebar-footer-control > a { flex: 1; width: auto !important; justify-content: center !important; }

/* ---- Header: repo / conversation ---- */
.chat-crumb { display: flex; align-items: baseline; gap: .45rem; min-width: 0; font-size: 12.5px; }
.chat-crumb-repo { color: var(--sg-text-3); white-space: nowrap; font-size: 12.5px; margin: 0 !important; }
.chat-crumb-sep { color: var(--sg-text-3); display: none; }
.chat-crumb-repo:not(.hidden) + .chat-crumb-sep { display: inline; }
.chat-crumb-title { font-size: 12.5px !important; font-weight: 500 !important; color: var(--sg-text-2); }
.notify-toggle { border-color: transparent; background: transparent; }

/* ---- Conversation column ---- */
#messages-container { padding-top: 1.25rem; padding-bottom: 1rem; }
.conversation-panel .message-row.max-w-5xl { max-width: 46rem; gap: 0; margin-bottom: 1.6rem; }
.conversation-panel .message-row > .w-8.h-8 { display: none; }
.conversation-panel .message-row.flex-row-reverse { flex-direction: row; }
.conversation-panel .message-row > div:last-child { max-width: 100%; flex: 1; min-width: 0; text-align: left; }
.message-label { display: none; }
.conversation-panel .message-row.flex-row-reverse .message-bubble {
    display: block; width: 100%; background: var(--sg-field); background-image: none;
    border: 1px solid var(--sg-line-strong); border-radius: 10px; box-shadow: none;
    padding: .7rem .95rem; color: var(--sg-text) !important; font-size: 13.5px;
}
.conversation-panel .message-row.flex-row-reverse .message-bubble,
.conversation-panel .message-row.flex-row-reverse .message-bubble .markdown-content,
.conversation-panel .message-row.flex-row-reverse .message-bubble p,
.conversation-panel .message-row.flex-row-reverse .message-bubble a { color: var(--sg-text) !important; }
.conversation-panel .message-row:not(.flex-row-reverse) .assistant-message-surface {
    background: transparent; border: 0; box-shadow: none; padding: .25rem 0; font-size: 13.5px; line-height: 1.75;
}
.message-actions { justify-content: flex-start !important; }

/* ---- Message attachments ---- */
.message-attachments { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .55rem; }
.message-attachment {
    display: inline-flex; align-items: center; gap: .4rem; max-width: 100%;
    border: 1px solid var(--sg-line-strong); border-radius: 7px; padding: .22rem .55rem;
    font-size: 11px; color: var(--sg-text-2); background: transparent;
}
button.message-attachment:hover { background: var(--sg-hover); color: var(--sg-text); }
.message-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Work log ---- */
.worklog { margin: 0 0 .7rem; font-size: 12.5px; }
.worklog-summary, .worklog-row { display: flex; align-items: center; gap: .45rem; color: var(--sg-text-3); cursor: pointer; list-style: none; }
.worklog-summary::-webkit-details-marker, .worklog-row::-webkit-details-marker { display: none; }
.worklog-summary { width: fit-content; padding: .2rem 0; }
.worklog-summary:hover, details.worklog-step > summary:hover { color: var(--sg-text-2); }
.worklog-caret { width: .45rem; height: .45rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .18s ease; margin-left: .1rem; }
details[open] > summary > .worklog-caret { transform: rotate(45deg); }
.worklog-steps { display: grid; gap: .1rem; padding: .25rem 0 .1rem .9rem; border-left: 1px solid var(--sg-line); margin-left: .25rem; }
.live-work .worklog-steps { border-left: 0; padding-left: 0; margin-left: 0; }
.worklog-row { padding: .22rem 0; }
.worklog-plain { cursor: default; }
.worklog-label { color: inherit; }
.worklog-thought { margin: .2rem 0 .5rem; padding-left: .85rem; border-left: 2px solid var(--sg-line-strong); color: var(--sg-text-3); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; }
.worklog-files { list-style: none; margin: .15rem 0 .45rem; padding: 0 0 0 .85rem; display: grid; gap: .2rem; font-size: 11.5px; color: var(--sg-text-3); }
.worklog-files li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.worklog-files code, .worklog-detail { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: var(--sg-text-2); overflow-wrap: anywhere; }
.worklog-files em { font-style: normal; color: var(--sg-bad); }
.worklog-verb { color: var(--sg-text-3); }
.worklog-edit { cursor: default; flex-wrap: wrap; }
.worklog-file { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--sg-text-2); background: var(--sg-hover); border-radius: 5px; padding: .08rem .4rem; }
.worklog-added { color: var(--sg-ok); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.worklog-removed { color: var(--sg-bad); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.worklog-link { color: var(--sg-text-3); font-size: 11px; text-decoration: underline; text-underline-offset: 2px; }
.worklog-link:hover { color: var(--sg-text); }
.worklog-row.is-failed .worklog-label, .worklog-error { color: var(--sg-bad); }
.worklog-error { margin: 0 0 .3rem; font-size: 11.5px; }
.worklog[data-has-failure="true"] > .worklog-summary { color: var(--sg-bad); }
.live-work { color: var(--sg-text-2); }
.live-work-head { display: flex; align-items: center; gap: .6rem; font-size: 12.5px; margin-bottom: .35rem; }
.live-work-status { color: var(--sg-text-2); }
.live-work-elapsed { color: var(--sg-text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.live-work .typing-response { margin-top: .6rem; font-size: 13.5px; line-height: 1.75; color: var(--sg-text); }
.worklog-shimmer {
    background: linear-gradient(90deg, var(--sg-text-3) 0%, var(--sg-text) 45%, var(--sg-text-3) 90%);
    background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: worklogShimmer 2.2s linear infinite;
}
@keyframes worklogShimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }

/* ---- Composer ---- */
.composer-dock { max-width: 50rem; width: 100%; margin: 0 auto; border: 0 !important; background: transparent !important; }
.conversation-panel #chat-form, .conversation-panel #chat-form:focus-within {
    background: transparent; border: 0; box-shadow: none; border-radius: 0; margin: 0; max-width: none;
}
.composer-card {
    border: 1px solid var(--sg-line-strong); border-radius: 16px; background: var(--sg-field);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.composer-card:focus-within { border-color: rgba(var(--mode-accent-rgb), .55); box-shadow: 0 0 0 3px rgba(var(--mode-accent-rgb), .1); }
.composer-row { display: flex; align-items: center; gap: .35rem; padding: 0 .55rem .55rem; }
.composer-icon-btn { width: 1.9rem; height: 1.9rem; display: inline-grid; place-items: center; border-radius: 8px; color: var(--sg-text-3); transition: background-color .15s ease, color .15s ease; }
.composer-icon-btn:hover { background: var(--sg-hover); color: var(--sg-text); }
.composer-hint { font-size: 10.5px; color: var(--sg-text-3); white-space: nowrap; }
@media (max-width: 720px) { .composer-hint { display: none; } }
.composer-model #model-dropdown-btn {
    width: auto; min-height: 0; padding: .32rem .6rem; gap: .3rem; border: 0; border-radius: 8px;
    background: transparent; box-shadow: none; color: var(--sg-text-2); transform: none;
}
.composer-model #model-dropdown-btn:hover, .composer-model #model-dropdown-btn[aria-expanded="true"] { background: var(--sg-hover); transform: none; }
.composer-model #selected-model-meta { display: none; }
.composer-model #selected-model-name { font-size: 11.5px; font-weight: 500; max-width: 15rem; }
.composer-model .model-menu { top: auto; bottom: calc(100% + 10px); left: 0; right: auto; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .5rem .25rem 0; }
.repo-chip {
    display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; border-radius: 8px; padding: .3rem .55rem;
    font-size: 11.5px; color: var(--sg-text-2); border: 1px solid transparent; transition: background-color .15s ease;
}
.repo-chip:hover { background: var(--sg-hover); }
.repo-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 20rem; }
.repo-chip[data-state="none"] { color: var(--sg-text-3); }
.repo-chip[data-state="loading"] span { animation: worklogShimmer 1.6s linear infinite; }
.repo-chip[data-state="ready"] > i:first-child { color: var(--sg-ok); }
.repo-chip[data-state="error"] { color: var(--sg-bad); border-color: color-mix(in srgb, var(--sg-bad) 35%, transparent); }
.mode-toggle { font-size: 11px; }
.mode-toggle button { padding: .28rem .6rem; }
#chat-form #send-btn { width: 2rem; height: 2rem; }

/* ---- Attachments in the composer ---- */
.attachment-tray { display: flex; flex-wrap: wrap; gap: .45rem; padding: .65rem .65rem 0; }
.attachment-chip { display: inline-flex; align-items: center; max-width: 16rem; border: 1px solid var(--sg-line-strong); border-radius: 9px; background: var(--sg-hover); animation: toastIn .16s ease-out both; }
.attachment-chip-main { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; padding: .3rem .25rem .3rem .55rem; color: var(--sg-text-2); text-align: left; }
.attachment-chip[data-kind="image"] .attachment-chip-main { cursor: default; padding-left: .3rem; }
.attachment-thumb { width: 1.9rem; height: 1.9rem; border-radius: 6px; object-fit: cover; flex: 0 0 auto; }
.attachment-chip-text { display: grid; min-width: 0; line-height: 1.25; }
.attachment-chip-name { font-size: 11.5px; font-weight: 500; color: var(--sg-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip-meta { font-size: 10px; color: var(--sg-text-3); }
.attachment-chip-remove { padding: .35rem .45rem; color: var(--sg-text-3); border-radius: 0 9px 9px 0; }
.attachment-chip-remove:hover { color: var(--sg-text); background: var(--sg-hover); }
.drop-overlay { position: absolute; inset: .6rem; z-index: 40; display: grid; place-items: center; border: 1.5px dashed var(--sg-accent); border-radius: 16px; background: color-mix(in srgb, var(--sg-panel) 86%, transparent); backdrop-filter: blur(6px); pointer-events: none; }
.drop-overlay > div { display: grid; justify-items: center; gap: .25rem; color: var(--sg-text); font-size: 13px; font-weight: 550; }
.drop-overlay small { color: var(--sg-text-3); font-weight: 400; font-size: 11px; }
.attachment-viewer::backdrop { background: rgba(0, 0, 0, .6); }

/* ---- Empty conversation: composer centred, like a fresh start ---- */
.conversation-panel[data-empty="true"] { justify-content: center; }
.conversation-panel[data-empty="true"] #messages-container { flex: 0 0 auto; overflow: visible; min-height: 0; padding-bottom: 0; }
.conversation-panel[data-empty="true"] #empty-state { height: auto; min-height: 0; padding: 1rem 0 1.4rem; }
#empty-state .max-w-md { max-width: 34rem; }
#empty-state .max-w-md > div:first-child { display: none; }
#empty-state h2 { font-size: 1.6rem; font-weight: 500; letter-spacing: -.02em; }
#empty-state p { max-width: 28rem; margin-left: auto; margin-right: auto; }

@media (max-width: 1023px) { .workspace-grid { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .worklog-shimmer, .repo-chip[data-state="loading"] span { animation: none; color: var(--sg-text-2); background: none; } }


/* =====================================================================
   Sidebar that hides, rounder surfaces, answer actions and details panel
   ===================================================================== */

/* No site navigation on this page: the app fills the window. */
.agent-shell { padding-top: 0 !important; --sg-radius: 16px; --sg-radius-sm: 11px; }
.workspace-grid {
    height: 100dvh; grid-template-columns: 280px minmax(0, 1fr);
    transition: grid-template-columns .34s cubic-bezier(.4, 0, .2, 1);
}
body.agent-sidebar-collapsed .workspace-grid { grid-template-columns: 0px minmax(0, 1fr); }

/* The sidebar keeps its width while the column animates, so nothing reflows or squashes. */
.history-panel { min-width: 0; overflow: hidden; transition: visibility 0s linear 0s, border-color .3s ease; }
.history-panel > * { width: 280px; transition: opacity .22s ease .05s, transform .34s cubic-bezier(.4, 0, .2, 1); }
body.agent-sidebar-collapsed .history-panel { visibility: hidden; border-right-color: transparent; transition: visibility 0s linear .34s, border-color .3s ease; }
body.agent-sidebar-collapsed .history-panel > * { opacity: 0; transform: translateX(-18px); transition-delay: 0s; pointer-events: none; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem .8rem .35rem 1rem; }
.sidebar-brand { display: inline-flex; align-items: center; gap: .55rem; font-size: 13px; font-weight: 600; color: var(--sg-text); text-decoration: none; letter-spacing: -.005em; }
.sidebar-brand i { color: var(--sg-accent); }
.sidebar-icon-btn {
    width: 2rem; height: 2rem; display: inline-grid; place-items: center; flex: 0 0 auto;
    border-radius: 11px; color: var(--sg-text-3);
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-icon-btn:hover { background: var(--sg-hover); color: var(--sg-text); }
.sidebar-icon-btn:active { transform: scale(.92); }
.sidebar-open-btn { display: none; }
body.agent-sidebar-collapsed .sidebar-open-btn { display: inline-grid; animation: fadeSlideIn .3s ease .12s both; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

/* Footer: Dashboard first, then the rest as soft rounded pills. */
.sidebar-footer-control { display: grid; gap: .45rem; padding: .7rem .75rem .8rem; border-top: 1px solid var(--sg-line); }
.sidebar-pill-row { display: flex; gap: .45rem; }
.sidebar-pill {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.35rem; padding: 0 .8rem;
    border-radius: 14px; border: 1px solid var(--sg-line); background: transparent; color: var(--sg-text-2);
    font-size: 11.5px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-pill:hover { background: var(--sg-hover); color: var(--sg-text); border-color: var(--sg-line-strong); transform: translateY(-1px); }
.sidebar-pill:active { transform: scale(.97); }
.sidebar-pill-row .sidebar-pill:not(.sidebar-pill-icon) { flex: 1; }
.sidebar-pill-primary { background: var(--sg-accent-soft); border-color: transparent; color: var(--sg-text); font-weight: 600; }
.sidebar-pill-primary:hover { background: color-mix(in srgb, var(--sg-accent) 22%, transparent); border-color: transparent; }
.sidebar-pill-icon { width: 2.35rem; padding: 0; }
.sidebar-pill-icon span { display: none; }
.sidebar-pill.notify-toggle[aria-pressed="true"] { color: var(--sg-accent); background: var(--sg-accent-soft); border-color: transparent; }

/* Rounder in general */
.sidebar-new-chat.agent-button { border-radius: 14px; min-height: 2.4rem; }
.history-panel .agent-input, #chat-search { border-radius: 14px; }
.chat-history-item { border-radius: 11px; }
.composer-card { border-radius: 22px; }
.attachment-chip { border-radius: 13px; }
.conversation-panel .message-row.flex-row-reverse .message-bubble { border-radius: 16px; }
.agent-toast { border-radius: 14px; }
.mode-toggle { border-radius: 14px; }
.repo-chip, .composer-model #model-dropdown-btn, .composer-icon-btn { border-radius: 12px; }
.model-menu { border-radius: 16px; }
.message-edit textarea { border-radius: 16px; }

/* Smooth motion on interaction */
.chat-history-item, .composer-card, .repo-chip, .answer-action, .message-menu-item { transition-property: background-color, border-color, color, box-shadow, transform, opacity; transition-duration: .18s; transition-timing-function: ease; }
.sidebar-chat-row { animation: fadeSlideIn .28s ease both; }

/* ---- Actions under an answer ---- */
.answer-actions { position: relative; display: flex; align-items: center; gap: .15rem; margin-top: .35rem; }
.answer-action { width: 1.9rem; height: 1.9rem; display: inline-grid; place-items: center; border-radius: 10px; color: var(--sg-text-3); }
.answer-action:hover:not(:disabled) { background: var(--sg-hover); color: var(--sg-text); }
.answer-action:disabled { opacity: .4; cursor: not-allowed; }
.answer-action[aria-expanded="true"] { background: var(--sg-hover); color: var(--sg-text); }
.message-menu {
    position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; min-width: 14.5rem; padding: .35rem;
    border: 1px solid var(--sg-line-strong); border-radius: 16px; background: var(--sg-panel);
    box-shadow: var(--sg-shadow); backdrop-filter: blur(14px); transform-origin: top left;
    animation: menuIn .16s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
.message-menu-item { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .65rem; border-radius: 11px; font-size: 12px; color: var(--sg-text-2); text-align: left; }
.message-menu-item:hover:not(:disabled), .message-menu-item:focus-visible { background: var(--sg-hover); color: var(--sg-text); outline: none; }
.message-menu-item:disabled { opacity: .4; cursor: not-allowed; }
.message-menu-item i { color: var(--sg-text-3); flex: 0 0 auto; }
.message-menu-sep { height: 1px; margin: .3rem .4rem; background: var(--sg-line); }

/* ---- Response details: slides in from the right ---- */
.response-details {
    position: fixed; z-index: 70; top: .6rem; right: .6rem; bottom: .6rem; width: min(22rem, calc(100vw - 1.2rem));
    display: flex; flex-direction: column; border: 1px solid var(--sg-line-strong); border-radius: 22px;
    background: var(--sg-panel); box-shadow: var(--sg-shadow); backdrop-filter: blur(16px);
    transform: translateX(calc(100% + 1rem)); opacity: 0; visibility: hidden;
    transition: transform .36s cubic-bezier(.4, 0, .2, 1), opacity .24s ease, visibility 0s linear .36s;
}
body.agent-details-open .response-details { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
.response-details-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .6rem 1.25rem; }
.response-details-head h2 { font-size: 14px; font-weight: 600; color: var(--sg-text); }
.response-details-body { padding: .25rem 1.25rem 1.25rem; overflow: auto; font-size: 12.5px; }
.response-detail-list { display: grid; gap: .85rem; margin: 0 0 1.1rem; }
.response-detail dt { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--sg-text-3); }
.response-detail dd { margin: .15rem 0 0; color: var(--sg-text); overflow-wrap: anywhere; }
.response-details-body .worklog-steps { border-left: 0; margin: 0; padding-left: 0; }

/* ---- Small screens: the sidebar becomes a drawer ---- */
.sidebar-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px); animation: scrimIn .25s ease both; }
.sidebar-scrim[hidden] { display: none; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 1023px) {
    .workspace-grid, body.agent-sidebar-collapsed .workspace-grid { grid-template-columns: minmax(0, 1fr); height: 100dvh; }
    .history-panel {
        position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(20rem, 86vw); border-right: 1px solid var(--sg-line-strong);
        border-radius: 0 22px 22px 0; background: var(--sg-panel); backdrop-filter: blur(18px);
        transition: transform .34s cubic-bezier(.4, 0, .2, 1), visibility 0s linear 0s;
    }
    .history-panel > * { width: auto; }
    body.agent-sidebar-collapsed .history-panel { transform: translateX(-102%); transition: transform .34s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .34s; }
    body.agent-sidebar-collapsed .history-panel > * { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .workspace-grid, .history-panel, .history-panel > *, .response-details, .message-menu, .sidebar-chat-row, .sidebar-scrim, .sidebar-open-btn { transition-duration: 0s !important; animation: none !important; }
}


/* Elements I give an explicit `display` must still disappear when the page marks them hidden
   (the Tailwind `hidden` class or the `hidden` attribute), whichever stylesheet loads last. */
.drop-overlay.hidden, .drop-overlay[hidden],
.attachment-tray.hidden, .attachment-tray[hidden],
.sidebar-scrim[hidden], .response-details[hidden],
.chat-crumb-repo.hidden, .sidebar-search-status.hidden, .sidebar-search-clear.hidden { display: none !important; }


/* =====================================================================
   Pop-ups (repository context, plan usage) and sidebar tool rows
   ===================================================================== */

.sidebar-tools { display: grid; gap: .3rem; padding: .55rem .7rem; border-top: 1px solid var(--sg-line); }
.sidebar-tool {
    display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem .7rem; border-radius: 14px;
    text-align: left; color: var(--sg-text-2);
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-tool:hover { background: var(--sg-hover); color: var(--sg-text); }
.sidebar-tool:active { transform: scale(.98); }
.sidebar-tool > i:first-child { color: var(--sg-accent); flex: 0 0 auto; }
.sidebar-tool-text { display: grid; min-width: 0; flex: 1; font-size: 12px; font-weight: 500; line-height: 1.3; }
.sidebar-tool-text small { font-size: 10.5px; font-weight: 400; color: var(--sg-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-tool-arrow { color: var(--sg-text-3); transition: transform .2s ease; flex: 0 0 auto; }
.sidebar-tool:hover .sidebar-tool-arrow { transform: translateX(3px); }
.sidebar-tool.hidden, .sidebar-tools .sidebar-tool[hidden] { display: none !important; }

dialog.app-dialog {
    margin: auto; padding: 0; width: min(94vw, 34rem); max-height: min(88dvh, 44rem);
    border: 1px solid var(--sg-line-strong); border-radius: 22px; background: var(--sg-panel); color: var(--sg-text);
    box-shadow: var(--sg-shadow); overflow: hidden;
}
dialog.app-dialog-narrow { width: min(94vw, 26rem); }
dialog.app-dialog[open] { display: flex; flex-direction: column; }
.app-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem .9rem .5rem 1.25rem; }
.app-dialog-head h2 { display: flex; align-items: center; gap: .55rem; font-size: 14px; font-weight: 600; }
.app-dialog-head h2 i { color: var(--sg-accent); }
.app-dialog-body { padding: .25rem 1.25rem 1.25rem; overflow-y: auto; font-size: 12.5px; }
.app-dialog-body #github-repos-list, .app-dialog-body #file-tree { max-height: 9rem; border-radius: 14px; }

dialog[open] { animation: dialogIn .28s cubic-bezier(.2, .8, .3, 1) both; }
dialog[open]::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); animation: scrimIn .25s ease both; }
dialog[data-closing] { animation: dialogOut .2s ease-in both; }
dialog[data-closing]::backdrop { animation: scrimOut .2s ease-in both; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes dialogOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes scrimOut { from { opacity: 1; } to { opacity: 0; } }

/* The model list opens with the same small motion as the other menus. */
.model-menu:not(.hidden) { animation: menuIn .18s cubic-bezier(.2, .8, .3, 1) both; transform-origin: bottom left; }

@media (prefers-reduced-motion: reduce) {
    dialog[open], dialog[open]::backdrop, dialog[data-closing], dialog[data-closing]::backdrop, .model-menu:not(.hidden) { animation: none !important; }
    .sidebar-tool, .sidebar-tool-arrow { transition: none; }
}


/* =====================================================================
   Repository picker and GitHub actions
   ===================================================================== */
.repo-search { position: relative; }
.repo-search-icon { position: absolute; left: .85rem; top: 50%; width: .9rem; height: .9rem; transform: translateY(-50%); color: var(--sg-text-3); pointer-events: none; }
.repo-search .agent-input { border-radius: 14px; }
.repo-list {
    display: grid; align-content: start; gap: .2rem; max-height: 15rem; margin-top: .6rem; padding: .35rem;
    overflow-y: auto; border: 1px solid var(--sg-line); border-radius: 16px; background: transparent;
}
.repo-card {
    display: grid; gap: .15rem; width: 100%; padding: .55rem .75rem; border-radius: 12px; text-align: left;
    border: 1px solid transparent; color: var(--sg-text-2);
    transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.repo-card:hover:not(:disabled) { background: var(--sg-hover); transform: translateX(2px); }
.repo-card[aria-selected="true"] { background: var(--sg-accent-soft); border-color: color-mix(in srgb, var(--sg-accent) 35%, transparent); }
.repo-card:disabled { opacity: .45; cursor: not-allowed; }
.repo-card-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.repo-card-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--sg-text); font-weight: 550; }
.repo-card-owner { color: var(--sg-text-3); font-weight: 400; }
.repo-badge { flex: 0 0 auto; padding: .05rem .45rem; border: 1px solid var(--sg-line-strong); border-radius: 999px; font-size: 9.5px; color: var(--sg-text-3); }
.repo-card-desc { font-size: 11px; line-height: 1.4; color: var(--sg-text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.repo-card-meta { font-size: 10.5px; color: var(--sg-text-3); }
.repo-row-action { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .6rem .75rem; border-radius: 12px; font-size: 12px; color: var(--sg-accent); text-align: left; transition: background-color .16s ease; }
.repo-row-action:hover:not(:disabled) { background: var(--sg-accent-soft); }
.repo-row-action:disabled { opacity: .45; }
.repo-list-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .45rem; padding: 0 .25rem; font-size: 10.5px; color: var(--sg-text-3); }
.repo-mini-btn { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem; border: 1px solid var(--sg-line); border-radius: 999px; font-size: 10.5px; color: var(--sg-text-2); transition: background-color .16s ease; }
.repo-mini-btn:hover:not(:disabled) { background: var(--sg-hover); color: var(--sg-text); }
.repo-mini-btn:disabled { opacity: .45; }
.repo-section { margin-top: 1.15rem; }
.repo-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-bottom: .45rem; }
.repo-section-head label { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--sg-text-3); }
.repo-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--sg-text-3); }
.repo-section .agent-input { border-radius: 14px; }
.repo-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .6rem; }
.repo-action {
    display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .8rem; border: 1px solid var(--sg-line); border-radius: 14px;
    font-size: 11.5px; font-weight: 500; color: var(--sg-text-2);
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.repo-action:hover:not(:disabled) { background: var(--sg-hover); border-color: var(--sg-line-strong); color: var(--sg-text); transform: translateY(-1px); }
.repo-action:active:not(:disabled) { transform: scale(.97); }
.repo-action:disabled { opacity: .4; cursor: not-allowed; }
.repo-hint { font-size: 10.5px; font-weight: 400; color: var(--sg-text-3); text-transform: none; letter-spacing: 0; }
.repo-note { margin-top: .8rem; line-height: 1.5; }
.repo-files { max-height: 9rem; overflow-y: auto; padding: .5rem; border: 1px solid var(--sg-line); border-radius: 14px; }

/* Forms that unfold below the buttons. */
.inline-form { display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden; margin-top: 0;
    transition: grid-template-rows .3s cubic-bezier(.4, 0, .2, 1), opacity .24s ease, margin-top .3s ease, visibility 0s linear .3s; }
.inline-form.open { grid-template-rows: 1fr; opacity: 1; visibility: visible; margin-top: .7rem; transition-delay: 0s; }
.inline-form-inner { overflow: hidden; min-height: 0; display: grid; gap: .45rem; padding: 0 .15rem; }
.inline-form.open .inline-form-inner { padding: .85rem .9rem; border: 1px solid var(--sg-line); border-radius: 16px; background: var(--sg-hover); }
.inline-form-inner label { font-size: 11px; font-weight: 550; color: var(--sg-text-2); }
.inline-form-buttons { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .25rem; }
.repo-form-status { min-height: 1rem; font-size: 11px; color: var(--sg-text-3); }
.repo-form-status[data-tone="error"] { color: var(--sg-bad); }
.repo-form-status[data-tone="ok"] { color: var(--sg-ok); }
@media (prefers-reduced-motion: reduce) { .inline-form, .repo-card, .repo-action { transition: none; } }

/* =====================================================================
   Loading: a ring of soft, glowing dots, modelled on the Siri / Apple Intelligence indicator.
   One element, no images or scripts. Seven dots of different sizes turn slowly while each one
   swells and shrinks on its own rhythm (animated through registered custom properties, so they
   stay independent); warm and cool whites with a bloom behind. Where animated properties are not
   supported the dots simply keep their sizes and turn.
   ===================================================================== */
@property --r0 { syntax: '<number>'; inherits: false; initial-value: 0.085; }
@property --r1 { syntax: '<number>'; inherits: false; initial-value: 0.07; }
@property --r2 { syntax: '<number>'; inherits: false; initial-value: 0.1; }
@property --r3 { syntax: '<number>'; inherits: false; initial-value: 0.06; }
@property --r4 { syntax: '<number>'; inherits: false; initial-value: 0.088; }
@property --r5 { syntax: '<number>'; inherits: false; initial-value: 0.065; }
@property --r6 { syntax: '<number>'; inherits: false; initial-value: 0.095; }

.sg-orbit, .loading-ring {
    --u: var(--orbit-size, 1.2rem);
    --c0: var(--sg-text, #fff); --c1: var(--c0); --c2: var(--c0); --c3: var(--c0); --c4: var(--c0); --c5: var(--c0); --c6: var(--c0);
    position: relative; display: inline-block; flex: 0 0 auto; width: var(--u); height: var(--u);
    border: 0; border-radius: 0; isolation: isolate;
    background:
        radial-gradient(circle calc(var(--u) * .26) at 50.0% 14.5%, var(--c0) 0, var(--c0) calc(var(--u) * var(--r0)), transparent calc(var(--u) * (var(--r0) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 79.2% 27.2%, var(--c1) 0, var(--c1) calc(var(--u) * var(--r1)), transparent calc(var(--u) * (var(--r1) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 84.9% 58.7%, var(--c2) 0, var(--c2) calc(var(--u) * var(--r2)), transparent calc(var(--u) * (var(--r2) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 63.5% 81.8%, var(--c3) 0, var(--c3) calc(var(--u) * var(--r3)), transparent calc(var(--u) * (var(--r3) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 34.4% 83.5%, var(--c4) 0, var(--c4) calc(var(--u) * var(--r4)), transparent calc(var(--u) * (var(--r4) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 15.4% 58.0%, var(--c5) 0, var(--c5) calc(var(--u) * var(--r5)), transparent calc(var(--u) * (var(--r5) + .075))),
        radial-gradient(circle calc(var(--u) * .26) at 21.6% 27.0%, var(--c6) 0, var(--c6) calc(var(--u) * var(--r6)), transparent calc(var(--u) * (var(--r6) + .075)));
    filter: drop-shadow(0 0 calc(var(--u) * .035) rgba(255, 255, 255, .85)) drop-shadow(0 0 calc(var(--u) * .12) rgba(165, 198, 255, .5));
    animation: orbitTurn 7s linear infinite, orbitDot0 2.3s ease-in-out 0.00s infinite, orbitDot1 1.9s ease-in-out -0.37s infinite, orbitDot2 2.7s ease-in-out -0.74s infinite, orbitDot3 2.1s ease-in-out -1.11s infinite, orbitDot4 2.5s ease-in-out -1.48s infinite, orbitDot5 1.7s ease-in-out -1.85s infinite, orbitDot6 2.9s ease-in-out -2.22s infinite;
}
.sg-orbit::before, .loading-ring::before {
    content: ""; position: absolute; inset: -45%; z-index: -1; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, rgba(190, 212, 255, .2) 0%, rgba(190, 212, 255, .08) 40%, transparent 68%);
    animation: orbitBloom 3.4s ease-in-out infinite;
}
.sg-orbit-sm { --orbit-size: 1rem; }
.sg-orbit-lg { --orbit-size: 3.8rem; }
@keyframes orbitTurn { to { rotate: 360deg; } }
@keyframes orbitBloom { 0%, 100% { opacity: .65; scale: .92; } 50% { opacity: 1; scale: 1.08; } }
@keyframes orbitDot0 { 0%, 100% { --r0: 0.045; } 50% { --r0: 0.115; } }
@keyframes orbitDot1 { 0%, 100% { --r1: 0.04; } 50% { --r1: 0.1; } }
@keyframes orbitDot2 { 0%, 100% { --r2: 0.06; } 50% { --r2: 0.125; } }
@keyframes orbitDot3 { 0%, 100% { --r3: 0.035; } 50% { --r3: 0.09; } }
@keyframes orbitDot4 { 0%, 100% { --r4: 0.05; } 50% { --r4: 0.11; } }
@keyframes orbitDot5 { 0%, 100% { --r5: 0.038; } 50% { --r5: 0.095; } }
@keyframes orbitDot6 { 0%, 100% { --r6: 0.055; } 50% { --r6: 0.12; } }

@media (prefers-reduced-motion: reduce) {
    .sg-orbit, .loading-ring { animation: none; }
    .sg-orbit::before, .loading-ring::before { animation: none; }
}

/* ---- Full-screen start-up: the app, dark and blurred, with the loader in front ---- */
.agent-boot {
    --sg-text: #f4f6fa; --sg-text-2: #c5ccd7; --sg-text-3: #96a0ae; --sg-bg: #06080c; --sg-panel: #0c0f14;
    --sg-line: rgba(255, 255, 255, .1); --sg-line-strong: rgba(255, 255, 255, .18);
    --sg-field: rgba(255, 255, 255, .06); --sg-hover: rgba(255, 255, 255, .09);
    position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1.5rem; overflow: hidden;
    background: radial-gradient(120% 90% at 50% 40%, rgba(8, 11, 17, .55), rgba(2, 3, 6, .86));
    backdrop-filter: blur(26px) saturate(1.25) brightness(.72);
    -webkit-backdrop-filter: blur(26px) saturate(1.25) brightness(.72);
    transition: opacity .55s ease, backdrop-filter .55s ease, visibility 0s linear .55s;
}
.agent-boot[hidden] { display: none; }
.agent-boot.leaving { opacity: 0; visibility: hidden; pointer-events: none; backdrop-filter: blur(0) brightness(1); -webkit-backdrop-filter: blur(0) brightness(1); }
.agent-boot::before {
    content: ""; position: absolute; left: 50%; top: 50%; width: min(90vw, 46rem); aspect-ratio: 2 / 1; translate: -50% -50%;
    border-radius: 50%; pointer-events: none; filter: blur(46px);
    background: radial-gradient(ellipse, rgba(120, 165, 255, .2), rgba(255, 200, 150, .07) 45%, transparent 70%);
    animation: bootAmbient 5s ease-in-out infinite;
}
@keyframes bootAmbient { 0%, 100% { opacity: .55; scale: .94; } 50% { opacity: 1; scale: 1.06; } }
.boot-state { position: relative; display: grid; justify-items: center; gap: 1.2rem; text-align: center; animation: bootIn .6s cubic-bezier(.2, .8, .3, 1) both; }
.boot-state[hidden] { display: none; }
@keyframes bootIn { from { opacity: 0; transform: translateY(14px) scale(.97); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

/* No container: the ring of dots floats on the blurred, darkened app, with the current step beneath. */
.boot-stage { display: grid; justify-items: center; gap: 2rem; }
.boot-orbit {
    --orbit-size: 6.4rem;
    --c0: #fff6e8; --c1: #e4eeff; --c2: #ffffff; --c3: #ffeed8; --c4: #dbe8ff; --c5: #ffffff; --c6: #ffefd6;
    filter: drop-shadow(0 0 .25rem rgba(255, 255, 255, .9)) drop-shadow(0 0 1rem rgba(165, 198, 255, .6)) drop-shadow(0 0 2.4rem rgba(120, 160, 255, .35));
}
.boot-orbit::before { inset: -70%; background: radial-gradient(circle, rgba(190, 212, 255, .26) 0%, rgba(190, 212, 255, .1) 38%, transparent 66%); }
.boot-label { font-size: 15px; font-weight: 500; letter-spacing: .01em; color: #e9edf4; text-shadow: 0 1px 14px rgba(0, 0, 0, .6); }
#boot-label { transition: opacity .25s ease, transform .25s ease; }
#boot-label.swap { opacity: 0; transform: translateY(4px); }
.boot-hint { font-size: 12px; color: var(--sg-text-3); animation: bootIn .6s ease both; }
.boot-hint[hidden] { display: none; }

/* The failure card sits on the same dark glass. */
.boot-card {
    width: min(92vw, 26rem); gap: .65rem; padding: 2.1rem 1.75rem 1.6rem; border-radius: 28px;
    background: rgba(14, 17, 23, .66); border: 1px solid rgba(255, 255, 255, .13);
    backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .1);
}
.boot-icon {
    display: grid; place-items: center; width: 4rem; height: 4rem; margin-bottom: .9rem; border-radius: 18px;
    background: rgba(255, 255, 255, .07); border: 1px solid var(--sg-line-strong); color: var(--sg-text-2);
}
.boot-card h1 { font-size: 1.2rem; font-weight: 600; letter-spacing: -.012em; color: var(--sg-text); }
.boot-card p { font-size: 13.5px; line-height: 1.6; color: var(--sg-text-3); }
.boot-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: .9rem; }
.boot-retry {
    display: inline-flex; align-items: center; gap: .55rem; padding: .72rem 1.4rem; border-radius: 16px; font-size: 14px; font-weight: 600;
    background: #f4f6fa; color: #07090d; transition: transform .16s ease, opacity .16s ease;
}
.boot-retry:hover { opacity: .92; transform: translateY(-1px); }
.boot-retry:active { transform: scale(.97); }
.boot-retry:disabled { opacity: .55; cursor: progress; }
.boot-link { display: inline-flex; align-items: center; padding: .72rem 1.15rem; border-radius: 16px; font-size: 14px; color: var(--sg-text-2); border: 1px solid var(--sg-line-strong); transition: background-color .16s ease; }
.boot-link:hover { background: var(--sg-hover); }
.boot-details { margin-top: .7rem; max-width: 100%; font-size: 11.5px; color: var(--sg-text-3); }
.boot-details summary { cursor: pointer; list-style: none; }
.boot-details pre { margin-top: .45rem; padding: .6rem .75rem; max-height: 6rem; overflow: auto; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 12px; border: 1px solid var(--sg-line); background: rgba(255, 255, 255, .05); }

/* The app itself shows, blurred, behind the loader (it has nothing private on it until signed in). */
html[data-boot] #agent-main.hidden { display: block !important; }
html[data-chat-url] .agent-boot { display: none; }
@media (prefers-reduced-motion: reduce) { .agent-boot, .boot-state, .agent-boot::before { animation: none; transition: none; } }


/* Saved pictures in a conversation */
.message-image {
    position: relative; width: 11rem; height: 8rem; overflow: hidden; border-radius: 14px;
    border: 1px solid var(--sg-line-strong); background: var(--sg-hover); cursor: zoom-in;
    transition: transform .2s ease, box-shadow .2s ease;
}
.message-image:hover { transform: translateY(-1px); box-shadow: var(--sg-shadow); }
.message-image img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s ease; }
.message-image[data-ready="true"] img { opacity: 1; }
.message-image:not([data-ready]):not([data-missing])::after {
    content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--sg-hover), transparent);
    background-size: 200% 100%; animation: statusShimmer 1.3s linear infinite;
}
.message-image[data-missing="true"]::before { content: "Image unavailable"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--sg-text-3); }
@keyframes statusShimmer { to { background-position: -200% 0; } }
dialog.image-dialog { width: min(94vw, 60rem); }
.image-dialog-body { display: grid; place-items: center; padding: .25rem 1rem 1rem; background: transparent; overflow: auto; }
.image-dialog-body img { max-width: 100%; max-height: 74dvh; border-radius: 14px; }
@media (prefers-reduced-motion: reduce) { .message-image:not([data-ready]):not([data-missing])::after { animation: none; } }


/* The signed-in person in the sidebar and beside their messages */
.sidebar-user { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border-radius: 14px; color: var(--sg-text-2); text-decoration: none; transition: background-color .18s ease; }
.sidebar-user:hover { background: var(--sg-hover); }
.sidebar-user-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.sidebar-user-text strong { font-size: 12.5px; font-weight: 600; color: var(--sg-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text small { font-size: 10.5px; color: var(--sg-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user:hover .sidebar-tool-arrow { transform: rotate(40deg); }
.conversation-panel .message-row > .message-user-avatar { display: grid; flex: none; margin: .3rem .8rem 0 0; }
