/* =====================================================================
   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; }

        /* ---------- Commit review: the same dialog style as the rest of the app ---------- */
        dialog.repository-review-dialog { width: min(94vw, 30rem); max-width: none; max-height: min(90dvh, 46rem); }
        .repository-review-dialog .review-body { display: grid; gap: .7rem; padding-top: .5rem; font-size: 13px; }
        .review-meta { display: flex; align-items: center; gap: .6rem; min-width: 0; }
        .review-path { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px "JetBrains Mono", monospace; color: var(--sg-text-3); }
        .review-chip { display: inline-flex; align-items: center; flex: 0 0 auto; padding: .2rem .6rem; border-radius: var(--sg-pill); background: var(--sg-accent-soft); color: var(--sg-accent); font-size: 11px; font-weight: 600; }
        .review-chip:empty { display: none; }
        .review-branch { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--sg-hover); color: var(--sg-text-2); font: 11px "JetBrains Mono", monospace; }
        .review-card { display: block; width: 100%; padding: .85rem 1rem; text-align: left; border: 1px solid var(--sg-line); border-radius: 16px; background: transparent; color: var(--sg-text); }
        .review-commit { display: flex; align-items: center; gap: .8rem; }
        .review-icon { display: grid; place-items: center; flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%; background: var(--sg-hover); color: var(--sg-text-2); }
        .review-label { margin: 0 0 .3rem; font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--sg-text-3); }
        .review-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; color: var(--sg-text); }
        .review-link { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-weight: 500; color: var(--sg-text-2); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
        .review-link:hover { background: var(--sg-hover); color: var(--sg-text); border-color: var(--sg-line-strong); }
        .review-note { display: flex; align-items: center; gap: .5rem; margin: .2rem 0 0; font-size: 12px; line-height: 1.5; color: var(--sg-text-3); }
        .review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .3rem; }
        .review-actions .btn { min-height: 2.75rem; justify-content: center; }
        .hold-approve-button {
            --hold-progress: 0%;
            position: relative; overflow: hidden;
            background: linear-gradient(90deg, var(--sg-accent) var(--hold-progress), var(--sg-accent-soft) 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); color: var(--sg-on-accent); }
        .repository-code-dialog { width: min(94vw, 64rem); max-height: min(90dvh, 52rem); }
        .repository-code-dialog .code-head { padding: .8rem .9rem .8rem 1.25rem; border-bottom: 1px solid var(--sg-line); }
        .repository-code-dialog .code-head h2 { font-weight: 600; }
        .repository-code-line-numbers { border-right: 1px solid var(--sg-line); }
        .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); }
        /* ---------- Toasts: floating cards, bottom-right ---------- */
        .composer-dock { position: relative; }
        #agent-toast-region {
            position: fixed; z-index: 90; right: 1.25rem; bottom: 1.25rem;
            width: min(24rem, calc(100vw - 2rem));
            display: grid; gap: .65rem; justify-items: stretch;
            pointer-events: none;
        }
        #agent-toast-region:empty { display: none; }
        /* (helpers.js lifts the cards just above the message box when they would otherwise cover it.) */
        @media (max-width: 640px) { #agent-toast-region { left: 1rem; right: 1rem; width: auto; } }
        .agent-toast {
            --toast-tone: var(--sg-bad);
            position: relative; overflow: hidden; pointer-events: auto;
            display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: .8rem;
            padding: .95rem .8rem 1.05rem .95rem;
            border: 1px solid var(--sg-line-strong); border-radius: 14px;
            background: var(--sg-panel); color: var(--sg-text);
            box-shadow: var(--sg-shadow), 0 0 0 1px color-mix(in srgb, var(--toast-tone) 8%, transparent);
            animation: toastIn .38s cubic-bezier(.2, .9, .3, 1.15) 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 .22s cubic-bezier(.4, 0, 1, 1) both; pointer-events: none; }
        .agent-toast-icon {
            display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
            color: var(--toast-tone);
            background: color-mix(in srgb, var(--toast-tone) 15%, transparent);
            animation: toastIconPop .5s .12s cubic-bezier(.3, 1.6, .5, 1) both;
        }
        .agent-toast-body { min-width: 0; padding-top: 1px; }
        .agent-toast-title { font-size: 13px; font-weight: 650; line-height: 1.3; color: var(--sg-text); }
        .agent-toast-message { margin-top: .2rem; font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; color: var(--sg-text-2); }
        .agent-toast-actions { margin-top: .7rem; display: flex; gap: .5rem; }
        .agent-toast-action {
            border: 1px solid var(--sg-line-strong); border-radius: 8px; padding: .32rem .75rem;
            font-size: 12px; font-weight: 600; color: var(--sg-text);
            transition: background-color .15s ease, border-color .15s ease;
        }
        .agent-toast-action:hover { background: var(--sg-hover); border-color: var(--toast-tone); }
        .agent-toast-dismiss {
            display: grid; place-items: center; width: 24px; height: 24px; margin: -.15rem -.1rem 0 0; border-radius: 7px;
            color: var(--sg-text-3); transition: color .15s ease, background-color .15s ease;
        }
        .agent-toast-dismiss:hover { color: var(--sg-text); background: var(--sg-hover); }
        /* Time left: a thin bar that drains; it stops while the card is hovered or focused. */
        .agent-toast-progress {
            position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
            background: var(--toast-tone); opacity: .75; transform-origin: left center;
            animation: toastProgress var(--toast-duration, 5s) linear both;
        }
        .agent-toast.is-paused .agent-toast-progress { animation-play-state: paused; }
        @media (prefers-reduced-motion: reduce) {
            .agent-toast, .agent-toast[data-leaving="true"] { animation: toastFade .15s linear both; }
            .agent-toast-icon { animation: none; }
            .agent-toast-progress { animation: none; transform: scaleX(0); }
        }

        .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: translateX(28px) scale(.94); } to { opacity: 1; transform: translateX(0) scale(1); } }
        @keyframes toastOut { to { opacity: 0; transform: translateX(32px) scale(.96); } }
        @keyframes toastIconPop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
        @keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
        @keyframes toastFade { from { opacity: 0; } to { opacity: 1; } }
        @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*="WhiteFavIconLogo"] { filter: brightness(0) opacity(.82); }
        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 { 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; }
}


/* 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; }

/* ---------- Model picker: the same dialog language as the rest of the app ---------- */
.model-menu { border: 1px solid var(--sg-line-strong); border-radius: 20px; background: var(--sg-panel); box-shadow: var(--sg-shadow); }
.model-menu-head { padding: .95rem 1rem .8rem; border-bottom: 1px solid var(--sg-line); }
.model-menu-title { display: inline-flex; align-items: center; gap: .5rem; font-size: 13px; font-weight: 600; color: var(--sg-text); }
.model-search-input { width: 100%; padding: .55rem .9rem .55rem 2.3rem; border-radius: var(--sg-pill); border: 1px solid var(--sg-line); background: var(--sg-field); color: var(--sg-text); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.model-search-input:focus { border-color: var(--sg-accent); box-shadow: 0 0 0 3px var(--sg-accent-soft); }
.model-group-label { padding: .8rem .65rem .35rem; font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--sg-text-3); }
.model-row { position: relative; display: flex; align-items: stretch; border-radius: 14px; border: 1px solid transparent; transition: background-color .15s, border-color .15s; }
.model-row:hover { background: var(--sg-hover); }
.model-row.selected { background: var(--sg-accent-soft); border-color: color-mix(in srgb, var(--sg-accent) 40%, transparent); }
.model-row .model-option { display: flex; flex: 1; min-width: 0; align-items: flex-start; gap: .7rem; padding: .65rem .3rem .65rem .65rem; background: none; border: 0; text-align: left; color: var(--sg-text); cursor: pointer; border-radius: 14px; }
.model-row .model-option:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: -2px; }
.model-badge { display: grid; place-items: center; flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 10px; background: var(--sg-accent-soft); color: var(--sg-accent); font-size: 12px; font-weight: 700; }
.model-name { display: flex; align-items: center; gap: .45rem; font-size: 13px; font-weight: 600; line-height: 1.3; }
.model-desc { display: block; margin-top: .15rem; font-size: 12px; line-height: 1.45; color: var(--sg-text-3); }
.model-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.model-chip { padding: .1rem .5rem; border-radius: var(--sg-pill); background: var(--sg-hover); color: var(--sg-text-2); font-size: 11px; font-weight: 500; }
.model-chip-premium { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #a78bfa; }
.model-default-mark { padding: .05rem .45rem; border-radius: var(--sg-pill); background: var(--sg-accent-soft); color: var(--sg-accent); font-size: 10px; font-weight: 600; }
.model-check { align-self: center; margin-right: .2rem; color: var(--sg-accent); opacity: 0; flex: 0 0 auto; }
.model-row.selected .model-check { opacity: 1; }
.model-star { display: grid; place-items: center; width: 2.1rem; flex: 0 0 auto; background: none; border: 0; color: var(--sg-text-3); cursor: pointer; border-radius: 12px; opacity: 0; transition: opacity .15s, color .15s; }
.model-row:hover .model-star, .model-star:focus-visible, .model-star.on { opacity: 1; }
.model-star.on { color: #f5b301; }
.model-star.on svg { fill: currentColor; }
.model-menu-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 1rem; border-top: 1px solid var(--sg-line); font-size: 12px; color: var(--sg-text-3); }
.model-default-btn { flex: 0 0 auto; padding: .3rem .8rem; border-radius: var(--sg-pill); border: 1px solid var(--sg-line-strong); background: transparent; color: var(--sg-text-2); font-size: 12px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s; }
.model-default-btn:hover { background: var(--sg-hover); color: var(--sg-text); }
@media (hover: none) { .model-star { opacity: 1; } }


/* =====================================================================
   Redesign layer (Expo-inspired): flatter surfaces, the SolarGlyph blue kept
   on primary actions, a command palette, and a bigger first-run headline.
   ===================================================================== */

/* New chat is the page's primary action, so it carries the signature blue. */
html body .sidebar-new-chat.agent-button,
html body .sidebar-new-chat.agent-button i {
    color: var(--sg-on-accent);
}
html body .sidebar-new-chat.agent-button {
    background: var(--sg-accent);
    border-color: var(--sg-accent);
    font-weight: 600;
}
html body .sidebar-new-chat.agent-button:hover {
    background: var(--sg-accent-hover);
    border-color: var(--sg-accent-hover);
}

/* In the light theme the default mode label uses the deeper blue so it stays readable on white. */
html:not(.dark) .prompt-composer { --mode-accent: #0A5F9F; --mode-accent-rgb: 10, 95, 159; }

/* Dialogs: flatter, tighter corners. */
dialog.app-dialog { border-radius: var(--sg-radius-lg); }
dialog.app-dialog::backdrop { background: rgba(8, 11, 13, .55); }

/* First-run headline: large and confident, like the reference sites. */
#empty-state h2 {
    font-size: clamp(1.9rem, 3.6vw, 2.7rem);
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.08;
}

/* ---------- Command palette ---------- */
.cmdk-trigger {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    height: 30px;
    padding: 0 .55rem 0 .7rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: var(--sg-radius-sm);
    background: transparent;
    color: var(--sg-text-3);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.cmdk-trigger:hover { background: var(--sg-hover); color: var(--sg-text); }
.cmdk-trigger kbd, .cmdk kbd {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 .35rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: 4px;
    background: var(--sg-panel-2);
    color: var(--sg-text-3);
    font: 500 10.5px "JetBrains Mono", ui-monospace, monospace;
}
@media (max-width: 640px) { .cmdk-trigger span, .cmdk-trigger kbd { display: none; } .cmdk-trigger { padding: 0 .6rem; } }

dialog.cmdk {
    width: min(94vw, 38rem);
    max-height: min(70dvh, 30rem);
    margin-top: 14vh;
    border-radius: var(--sg-radius-lg);
}
.cmdk-search {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--sg-line);
    color: var(--sg-text-3);
}
.cmdk-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--sg-text);
    font-size: 15px;
}
.cmdk-search input::placeholder { color: var(--sg-text-3); }
.cmdk-list { flex: 1; min-height: 0; overflow-y: auto; padding: .4rem; }
.cmdk-group {
    padding: .6rem .6rem .25rem;
    color: var(--sg-text-3);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.cmdk-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: .5rem .6rem;
    border: 0;
    border-radius: var(--sg-radius-sm);
    background: transparent;
    color: var(--sg-text);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.cmdk-item small { color: var(--sg-text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item.is-active { background: var(--sg-accent-soft); }
.cmdk-item.is-active span { color: var(--sg-accent); font-weight: 600; }
.cmdk-empty { padding: 1.6rem; text-align: center; color: var(--sg-text-3); font-size: 13px; }
.cmdk-foot {
    display: flex;
    gap: 1rem;
    padding: .55rem 1rem;
    border-top: 1px solid var(--sg-line);
    color: var(--sg-text-3);
    font-size: 11.5px;
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: .3rem; }

/* Run chip inside the finished work-log summary */
.worklog-summary .sg-run { margin-right: .1rem; }


/* =====================================================================
   Round pass, edge fade, search island, floating menu, glass toasts
   (last in the file on purpose: these settle the final look)
   ===================================================================== */
.agent-shell { --sg-radius: 18px; --sg-radius-sm: 12px; }

/* ---- Rounder everywhere ---- */
.sidebar-new-chat.agent-button { border-radius: var(--sg-pill); min-height: 2.5rem; }
.chat-history-item { border-radius: 14px; }
.sidebar-tool { border-radius: 16px; }
.sidebar-icon-btn { border-radius: 12px; }
.sidebar-pill { border-radius: var(--sg-pill); }
.cmdk-trigger { border-radius: var(--sg-pill); }
.attachment-chip, .message-attachment { border-radius: 14px; }
.markdown-content pre { border-radius: 16px; }
.app-dialog { border-radius: 24px; }
.composer-card { border-radius: 26px; }
.conversation-panel .message-row.flex-row-reverse .message-bubble { border-radius: 20px; }
.conversation-panel .message-row:not(.flex-row-reverse) .assistant-message-surface { border-radius: 20px; }
.message-edit textarea { border-radius: 20px; }
.response-details { border-radius: 26px; }
.model-menu { border-radius: 22px; }

/* ---- Sidebar: soft blurred fade where the list runs off the top and bottom ---- */
@property --fade-top { syntax: '<length>'; inherits: true; initial-value: 0px; }
@property --fade-bottom { syntax: '<length>'; inherits: true; initial-value: 0px; }
.history-panel { position: relative; }
.sidebar-scroll-wrap {
    position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column;
    --fade-top: 0px; --fade-bottom: 0px;
    transition: --fade-top .3s ease, --fade-bottom .3s ease;
}
.sidebar-scroll-wrap[data-fade-top="true"] { --fade-top: 26px; }
.sidebar-scroll-wrap[data-fade-bottom="true"] { --fade-bottom: 70px; }
.sidebar-scroll-area {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
}
/* a progressive blur layer over each edge, so what scrolls under it softens as well as fades */
.sidebar-scroll-wrap::before, .sidebar-scroll-wrap::after {
    content: ""; position: absolute; left: 0; right: 0; z-index: 3; pointer-events: none; opacity: 0;
    transition: opacity .3s ease;
}
.sidebar-scroll-wrap::before {
    top: 0; height: 34px;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent); mask-image: linear-gradient(to bottom, #000 20%, transparent);
}
.sidebar-scroll-wrap::after {
    bottom: 0; height: 84px;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    -webkit-mask-image: linear-gradient(to top, #000 25%, transparent); mask-image: linear-gradient(to top, #000 25%, transparent);
}
.sidebar-scroll-wrap[data-fade-top="true"]::before, .sidebar-scroll-wrap[data-fade-bottom="true"]::after { opacity: 1; }
.sidebar-footer-control {
    position: relative; z-index: 5; background: transparent;
    box-shadow: 0 -22px 34px -18px rgba(0, 0, 0, .5);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
html:not(.dark) .sidebar-footer-control { box-shadow: 0 -22px 34px -20px rgba(17, 24, 28, .24); }

/* ---- Signed-in card with the cogwheel ---- */
.sidebar-user {
    padding: .55rem .75rem .55rem .6rem; border-radius: 20px;
    border: 1px solid var(--sg-line); background: var(--sg-panel-2);
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.sidebar-user:hover { background: var(--sg-hover); border-color: var(--sg-line-strong); }
.sidebar-user:active { transform: scale(.985); }
.sidebar-user .sidebar-tool-arrow { transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), color .18s ease; color: var(--sg-text-3); }
.sidebar-user:hover .sidebar-tool-arrow { transform: rotate(90deg); color: var(--sg-text); }
.sidebar-user-avatar { border-radius: 999px; overflow: hidden; }

/* ---- Search: a button that grows into a text box (dynamic-island style) ---- */
.sidebar-search {
    --island-spring: cubic-bezier(.34, 1.56, .64, 1);
    position: relative; height: 2.5rem; margin-top: .5rem;
    border: 1px solid var(--sg-line); border-radius: var(--sg-pill);
    background: transparent; overflow: hidden;
    transition: height .5s var(--island-spring), border-color .25s ease, background-color .25s ease, box-shadow .4s ease;
}
.sidebar-search:hover { background: var(--sg-hover); border-color: var(--sg-line-strong); }
.sidebar-search[data-open="true"] {
    height: 2.85rem; background: var(--sg-field); border-color: var(--sg-accent);
    box-shadow: 0 0 0 4px var(--sg-accent-soft), 0 14px 28px -14px rgba(0, 0, 0, .55);
    animation: islandPop .55s var(--island-spring) both;
}
@keyframes islandPop {
    0% { transform: scale(1, 1); }
    30% { transform: scale(.955, 1.07); }
    65% { transform: scale(1.018, .985); }
    100% { transform: scale(1, 1); }
}
.sidebar-search-trigger {
    position: absolute; inset: 0; display: flex; align-items: center; gap: .6rem; padding: 0 .9rem;
    border-radius: inherit; color: var(--sg-text-2); font-size: 12px; font-weight: 500; text-align: left;
    transition: opacity .22s ease, transform .4s var(--island-spring), filter .3s ease, color .18s ease, visibility 0s linear 0s;
}
.sidebar-search-trigger:hover { color: var(--sg-text); }
.sidebar-search-trigger:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: -2px; }
.sidebar-search[data-open="true"] .sidebar-search-trigger {
    opacity: 0; transform: scale(.86); filter: blur(5px); pointer-events: none; visibility: hidden;
    transition: opacity .16s ease, transform .3s ease, filter .2s ease, visibility 0s linear .2s;
}
.sidebar-search-field {
    position: absolute; inset: 0; display: flex; align-items: center;
    clip-path: inset(0 42% 0 42% round 999px); opacity: 0; visibility: hidden; filter: blur(6px);
    transition: clip-path .5s var(--island-spring), opacity .2s ease, filter .3s ease, visibility 0s linear .3s;
}
.sidebar-search[data-open="true"] .sidebar-search-field {
    clip-path: inset(0 0 0 0 round 999px); opacity: 1; visibility: visible; filter: blur(0);
    transition: clip-path .5s var(--island-spring) .04s, opacity .22s ease .08s, filter .3s ease .06s, visibility 0s;
}
.sidebar-search-field .sidebar-search-icon { left: 1rem; width: 1rem; height: 1rem; color: var(--sg-accent); }
#chat-search {
    width: 100%; height: 100%; padding: 0 2.6rem 0 2.6rem; border: 0; border-radius: 0; background: transparent;
    color: var(--sg-text); font-size: 12.5px; outline: none; box-shadow: none;
}
#chat-search::placeholder { color: var(--sg-text-3); }
.sidebar-search-clear {
    right: .5rem; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; padding: 0; border-radius: 999px;
    transition: background-color .18s ease, color .18s ease, transform .3s var(--island-spring);
}
.sidebar-search-clear:hover { transform: translateY(-50%) rotate(90deg); }
.sidebar-search-clear.hidden { display: grid !important; }   /* it is also the close button now */
@media (prefers-reduced-motion: reduce) {
    .sidebar-search, .sidebar-search-trigger, .sidebar-search-field { transition-duration: .01s !important; transition-delay: 0s !important; animation: none !important; }
}

/* ---- Actions under messages: yours and the answers share one design ---- */
.answer-action { border-radius: var(--sg-pill); }
.answer-actions { gap: .2rem; margin-top: .4rem; }
.user-actions { position: relative; display: flex; align-items: center; justify-content: flex-start; gap: .2rem; margin-top: .4rem; opacity: 1 !important; }
.msg-action {
    width: 1.9rem; height: 1.9rem; display: inline-grid; place-items: center; border-radius: var(--sg-pill); color: var(--sg-text-3);
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.msg-action:hover:not(:disabled) { background: var(--sg-hover); color: var(--sg-text); }
.msg-action:active:not(:disabled) { transform: scale(.92); }
.msg-action:disabled { opacity: .4; cursor: not-allowed; }
.msg-action[aria-expanded="true"] { background: var(--sg-hover); color: var(--sg-text); }

/* ---- The ⋯ menu floats above everything, pinned to the window ---- */
.message-menu {
    position: fixed; z-index: 400; top: 0; left: 0; min-width: 15rem; padding: .4rem;
    border-radius: 20px; transform-origin: top left;
    background: color-mix(in srgb, var(--sg-panel) 88%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
    box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .6), 0 0 0 1px var(--sg-line);
}
.message-menu[data-placement="top"] { transform-origin: bottom left; animation-name: menuInUp; }
@keyframes menuInUp { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }
.message-menu-item { border-radius: 14px; }

/* ---- Toasts: frosted cards in the bottom-right, announcement style ---- */
#agent-toast-region { z-index: 500; width: min(22.5rem, calc(100vw - 2rem)); gap: .75rem; }
.agent-toast {
    --toast-tone: var(--sg-bad);
    display: block; padding: 0; border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--sg-text) 14%, transparent);
    background: color-mix(in srgb, var(--sg-panel) 70%, transparent);
    -webkit-backdrop-filter: blur(26px) saturate(1.6); backdrop-filter: blur(26px) saturate(1.6);
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .7), 0 2px 0 0 color-mix(in srgb, var(--sg-text) 8%, transparent) inset;
}
.agent-toast-hero {
    position: relative; height: 5.4rem; display: grid; place-items: center; overflow: hidden;
    background:
        radial-gradient(120% 140% at 15% 0%, color-mix(in srgb, var(--toast-tone) 38%, transparent), transparent 60%),
        radial-gradient(110% 130% at 100% 100%, color-mix(in srgb, var(--sg-accent) 30%, transparent), transparent 62%),
        color-mix(in srgb, var(--sg-bg) 60%, transparent);
}
.agent-toast-hero::before, .agent-toast-hero::after {
    content: ""; position: absolute; border-radius: 999px; filter: blur(14px); opacity: .75; pointer-events: none;
}
.agent-toast-hero::before { width: 5.5rem; height: 5.5rem; right: 12%; top: -2.4rem; background: var(--toast-tone); animation: toastDrift 6s ease-in-out infinite alternate; }
.agent-toast-hero::after { width: 4rem; height: 4rem; left: 10%; bottom: -1.9rem; background: var(--sg-accent); animation: toastDrift 7s ease-in-out infinite alternate-reverse; }
@keyframes toastDrift { from { transform: translate(0, 0) scale(1); } to { transform: translate(10px, 6px) scale(1.15); } }
.agent-toast .agent-toast-icon {
    position: relative; z-index: 1; width: 44px; height: 44px; border-radius: 16px; color: #fff;
    background: color-mix(in srgb, var(--toast-tone) 55%, rgba(255, 255, 255, .06));
    border: 1px solid rgba(255, 255, 255, .28);
    box-shadow: 0 10px 24px -8px var(--toast-tone), 0 1px 0 rgba(255, 255, 255, .3) inset;
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.agent-toast-body { padding: .95rem 1.1rem 1.05rem; }
.agent-toast-title { font-size: 14px; font-weight: 700; letter-spacing: -.005em; }
.agent-toast-message { margin-top: .3rem; font-size: 13px; line-height: 1.5; }
.agent-toast-actions { margin-top: .95rem; display: flex; align-items: center; gap: .5rem; }
.agent-toast-action, .agent-toast .agent-toast-dismiss {
    width: auto; height: auto; margin: 0; display: inline-flex; align-items: center; justify-content: center;
    padding: .45rem .95rem; border-radius: 12px; font-size: 12.5px; font-weight: 600; line-height: 1.2;
}
.agent-toast-action {
    background: color-mix(in srgb, var(--sg-text) 7%, transparent);
    border: 1px solid color-mix(in srgb, var(--sg-text) 18%, transparent);
}
.agent-toast-action:hover { background: color-mix(in srgb, var(--sg-text) 12%, transparent); border-color: color-mix(in srgb, var(--sg-text) 30%, transparent); }
.agent-toast .agent-toast-dismiss { border: 1px solid transparent; background: transparent; color: var(--sg-text-2); }
.agent-toast .agent-toast-dismiss:hover { color: var(--sg-text); background: var(--sg-hover); }
.agent-toast-progress { height: 2px; opacity: .6; }
@media (prefers-reduced-motion: reduce) {
    .agent-toast-hero::before, .agent-toast-hero::after { animation: none; }
}


/* =====================================================================
   Bubble motion, chat ⋯ buttons, live-formatted answers
   ===================================================================== */
.agent-shell, body { --bubble-spring: cubic-bezier(.34, 1.56, .64, 1); }

/* ---- Menus pop open like a bubble, items rise in one after another ---- */
.message-menu { animation: bubblePop .45s cubic-bezier(.34, 1.56, .64, 1) both; transform-origin: top left; }
.message-menu[data-align="end"] { transform-origin: top right; }
.message-menu[data-placement="top"] { transform-origin: bottom left; animation-name: bubblePop; }
.message-menu[data-placement="top"][data-align="end"] { transform-origin: bottom right; }
@keyframes bubblePop {
    0% { opacity: 0; transform: scale(.55); }
    55% { opacity: 1; }
    100% { opacity: 1; transform: scale(1); }
}
.message-menu-item { animation: bubbleItem .42s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: calc(var(--pop, 0) * 40ms + 70ms); }
@keyframes bubbleItem { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }
.message-menu-item:active:not(:disabled) { transform: scale(.97); }
.message-menu-item.danger, .message-menu-item.danger i { color: var(--sg-bad); }
.message-menu-item.danger:hover:not(:disabled), .message-menu-item.danger:focus-visible { background: color-mix(in srgb, var(--sg-bad) 14%, transparent); color: var(--sg-bad); }

/* ---- Sidebar chats: rounded rows, bubbly entrance, one ⋯ button ---- */
.sidebar-chat-row { animation: bubbleRow .55s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: calc(var(--i, 0) * 34ms); gap: .15rem; }
@keyframes bubbleRow { from { opacity: 0; transform: translateX(-10px) scale(.94); } to { opacity: 1; transform: none; } }
.chat-history-item {
    border-radius: 14px;
    transition: background-color .18s ease, color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.chat-history-item:hover { transform: translateX(2px); }
.chat-history-item:active { transform: scale(.97); }
.chat-pin-mark { width: .8rem; height: .8rem; flex: 0 0 auto; color: #fbbf24; fill: currentColor; }
.chat-more-button {
    width: 1.85rem; height: 1.85rem; display: grid; place-items: center; border-radius: 999px; color: var(--sg-text-3);
    opacity: 0; transform: scale(.7);
    transition: opacity .16s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), background-color .16s ease, color .16s ease;
}
.sidebar-chat-row:hover .chat-more-button, .sidebar-chat-row:focus-within .chat-more-button,
.chat-more-button[aria-expanded="true"] { opacity: 1; transform: scale(1); }
.chat-more-button:hover, .chat-more-button[aria-expanded="true"] { background: var(--sg-hover); color: var(--sg-text); }
.chat-more-button:active { transform: scale(.88); }
@media (hover: none) { .chat-more-button { opacity: 1; transform: none; } }
.sidebar-new-chat.agent-button { transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), background-color .18s ease, border-color .18s ease; }
.sidebar-new-chat.agent-button:active { transform: scale(.95); }
.sidebar-section { animation: bubbleRow .6s cubic-bezier(.34, 1.56, .64, 1) both; }

/* ---- The answer, formatted while it is written ---- */
.message-row.no-enter, .no-enter .markdown-content > *, .no-enter .ai-text-word, .no-enter .message-text-enter > * { animation: none !important; }
.stream-row .message-bubble { min-width: 0; }
.markdown-content.is-streaming > * { animation: none !important; }
.markdown-content.is-streaming > :last-child:not(ul):not(ol):not(table):not(.code-block):not(hr)::after,
.markdown-content.is-streaming > :is(ul, ol):last-child > li:last-child::after {
    content: ""; display: inline-block; width: .55em; height: .55em; margin-left: .3em; border-radius: 999px; vertical-align: baseline;
    background: var(--sg-accent); box-shadow: 0 0 10px var(--sg-accent); animation: streamCaret 1s ease-in-out infinite;
}
@keyframes streamCaret { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
    .message-menu, .message-menu-item, .sidebar-chat-row, .sidebar-section, .markdown-content.is-streaming > *::after { animation: none !important; }
    .chat-more-button, .chat-history-item { transition-duration: .01s !important; }
}


/* =====================================================================
   Refresh button, gear
   ===================================================================== */
.sg-gear { flex: 0 0 auto; }

/* ---- Refresh chats: a round button that spins while it works, then flashes a check ---- */
.chat-refresh-btn {
    position: relative; display: grid; place-items: center; width: 1.95rem; height: 1.95rem; padding: 0;
    border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--sg-text-3);
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.chat-refresh-btn > svg, .chat-refresh-btn > i, .chat-refresh-ring { grid-area: 1 / 1; }
.chat-refresh-btn:hover { background: var(--sg-hover); border-color: var(--sg-line); color: var(--sg-text); }
.chat-refresh-btn:active { transform: scale(.86); }
.chat-refresh-btn:focus-visible { outline: 2px solid var(--sg-accent); outline-offset: 2px; }
.chat-refresh-icon { transition: transform .55s cubic-bezier(.34, 1.56, .64, 1), opacity .2s ease, color .2s ease; }
.chat-refresh-btn:hover .chat-refresh-icon { transform: rotate(180deg); }
.chat-refresh-check { opacity: 0; transform: scale(.3) rotate(-30deg); color: var(--sg-ok, #34d399); transition: opacity .2s ease, transform .5s cubic-bezier(.34, 1.56, .64, 1); }
.chat-refresh-ring { width: 100%; height: 100%; border-radius: 999px; pointer-events: none; opacity: 0; box-shadow: 0 0 0 0 var(--sg-accent); }
.chat-refresh-btn.is-spinning { color: var(--sg-accent); background: var(--sg-accent-soft); border-color: transparent; }
.chat-refresh-btn.is-spinning .chat-refresh-icon { animation: refreshSpin .8s cubic-bezier(.55, .1, .3, 1) infinite; }
.chat-refresh-btn.is-spinning .chat-refresh-ring { animation: refreshPulse 1.1s ease-out infinite; }
.chat-refresh-btn.is-done { color: var(--sg-ok, #34d399); background: color-mix(in srgb, var(--sg-ok, #34d399) 14%, transparent); }
.chat-refresh-btn.is-done .chat-refresh-icon { opacity: 0; transform: scale(.3) rotate(90deg); }
.chat-refresh-btn.is-done .chat-refresh-check { opacity: 1; transform: none; }
.chat-refresh-btn.is-done .chat-refresh-ring { color: var(--sg-ok, #34d399); animation: refreshBurst .7s ease-out both; }
@keyframes refreshSpin { to { transform: rotate(360deg); } }
@keyframes refreshPulse { 0% { opacity: .55; box-shadow: 0 0 0 0 var(--sg-accent); } 100% { opacity: 0; box-shadow: 0 0 0 9px var(--sg-accent); } }
@keyframes refreshBurst { 0% { opacity: .7; box-shadow: 0 0 0 0 currentColor; } 100% { opacity: 0; box-shadow: 0 0 0 12px currentColor; } }

@media (prefers-reduced-motion: reduce) {
    .chat-refresh-btn .chat-refresh-icon, .chat-refresh-ring { animation: none !important; }
    .chat-refresh-btn { transition-duration: .01s !important; }
}


/* ---- The open chat in the sidebar: lifted, glowing, with an accent bar ---- */
.chat-history-item.active {
    padding-left: 1.05rem; border-color: color-mix(in srgb, var(--sg-accent) 38%, var(--sg-line));
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--sg-accent) 22%, transparent), color-mix(in srgb, var(--sg-accent) 4%, transparent) 75%),
        var(--sg-panel-2);
    box-shadow: 0 12px 26px -16px var(--sg-accent), 0 1px 0 rgba(255, 255, 255, .06) inset;
    animation: activeChatPop .55s cubic-bezier(.34, 1.56, .64, 1) both;
}
.chat-history-item.active::before {
    display: block !important; content: ""; position: absolute; left: .38rem; top: 50%; width: 3px; height: 56%;
    border-radius: 999px; background: var(--sg-accent); box-shadow: 0 0 12px var(--sg-accent);
    transform: translateY(-50%); animation: activeBarGrow .6s cubic-bezier(.34, 1.56, .64, 1) .08s both;
}
.chat-history-item.active .chat-title { color: var(--sg-text); font-weight: 600; }
.chat-history-item.active:hover { background:
    linear-gradient(90deg, color-mix(in srgb, var(--sg-accent) 28%, transparent), color-mix(in srgb, var(--sg-accent) 7%, transparent) 75%),
    var(--sg-panel-2); }
.sidebar-chat-row:has(.chat-history-item.active) .chat-more-button { opacity: 1; transform: scale(1); }
.sidebar-chat-row:has(.chat-history-item.active) .chat-time { opacity: 0; }
@keyframes activeChatPop { 0% { transform: scale(.96); } 60% { transform: scale(1.015); } 100% { transform: none; } }
@keyframes activeBarGrow { from { transform: translateY(-50%) scaleY(.2); opacity: 0; } to { transform: translateY(-50%) scaleY(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-history-item.active, .chat-history-item.active::before { animation: none !important; } }

/* ---- A failed response: red-tinted, with Retry that carries on ---- */
.stopped-surface[data-kind="failed"] {
    border-color: color-mix(in srgb, var(--sg-bad) 45%, var(--sg-line));
    background: linear-gradient(135deg, color-mix(in srgb, var(--sg-bad) 12%, transparent), transparent 70%), var(--sg-panel);
    animation: bubbleRow .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
.stopped-surface[data-kind="failed"] .stopped-head { color: var(--sg-bad); }
.stopped-reason {
    margin-top: .55rem; padding: .5rem .7rem; border-radius: 12px; font: 500 11px/1.5 "JetBrains Mono", ui-monospace, monospace;
    color: var(--sg-text-2); background: color-mix(in srgb, var(--sg-bad) 9%, transparent); overflow-wrap: anywhere;
}
.stopped-actions .agent-button { border-radius: 999px; }

/* ---- Projects: each repository is a dropdown with its own chats ---- */
.sidebar-project + .sidebar-project { margin-top: .15rem; }
.sidebar-project-button { border-radius: 14px; color: var(--sg-text-2); transition: background-color .18s ease, color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.sidebar-project-button:hover { background: var(--sg-hover); color: var(--sg-text); }
.sidebar-project-button:active { transform: scale(.97); }
.sidebar-project-chevron { color: var(--sg-text-3); transition: transform .4s cubic-bezier(.34, 1.56, .64, 1); }
.sidebar-project-button[aria-expanded="true"] .sidebar-project-chevron { transform: rotate(90deg); color: var(--sg-text); }
.sidebar-project-icon { color: var(--sg-text-3); transition: color .2s ease, transform .4s cubic-bezier(.34, 1.56, .64, 1); }
.sidebar-project-button[aria-expanded="true"] .sidebar-project-icon { color: var(--sg-accent); transform: scale(1.1); }
.sidebar-project-count {
    min-width: 1.35rem; padding: .05rem .4rem; border-radius: 999px; text-align: center; font-size: 10px; font-weight: 600;
    color: var(--sg-text-3); background: var(--sg-hover);
}
.sidebar-project-chats { margin: .1rem 0 .3rem .95rem; padding: .1rem 0 .1rem .35rem; border-left: 1px solid var(--sg-line); }
.sidebar-project-chats .sidebar-chat-row { animation-duration: .45s; }

/* =====================================================================
   Repository context
   ===================================================================== */
.repo-dialog-sub { margin: .2rem 0 0 1.55rem; font-size: 11.5px; color: var(--sg-text-3); }

/* ---- What is open right now ---- */
.repo-hero {
    --hue: 210; position: relative; display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; overflow: hidden;
    border-radius: 22px; border: 1px solid var(--sg-line);
    background: linear-gradient(135deg, color-mix(in srgb, var(--sg-accent) 10%, transparent), transparent 70%), var(--sg-panel-2);
    transition: border-color .3s ease, box-shadow .4s ease, background-color .3s ease;
}
.repo-hero::after {
    content: ""; position: absolute; right: -2.5rem; top: -2.5rem; width: 8rem; height: 8rem; border-radius: 999px; pointer-events: none;
    background: var(--sg-accent); filter: blur(46px); opacity: .1; transition: opacity .4s ease, background-color .3s ease;
}
.repo-hero[data-state="ready"] { border-color: color-mix(in srgb, var(--sg-ok) 38%, var(--sg-line)); box-shadow: 0 14px 30px -20px var(--sg-ok); }
.repo-hero[data-state="ready"]::after { background: var(--sg-ok); opacity: .16; }
.repo-hero[data-state="error"] { border-color: color-mix(in srgb, var(--sg-bad) 45%, var(--sg-line)); }
.repo-hero[data-state="error"]::after { background: var(--sg-bad); opacity: .16; }
.repo-hero-avatar {
    position: relative; display: grid; place-items: center; flex: 0 0 auto; width: 2.7rem; height: 2.7rem; border-radius: 16px;
    color: var(--sg-accent); background: var(--sg-accent-soft); border: 1px solid color-mix(in srgb, var(--sg-accent) 25%, transparent);
    transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), background .3s ease;
}
.repo-hero-avatar > * { grid-area: 1 / 1; }
.repo-hero-initial { display: none; font-size: 17px; font-weight: 700; color: #fff; }
.repo-hero[data-state="ready"] .repo-hero-avatar {
    background: linear-gradient(145deg, hsl(var(--hue) 70% 58%), hsl(calc(var(--hue) + 40) 70% 42%)); border-color: transparent;
    box-shadow: 0 10px 22px -10px hsl(var(--hue) 70% 50%); animation: heroPop .6s cubic-bezier(.34, 1.56, .64, 1) both;
}
.repo-hero[data-state="ready"] .repo-hero-icon { display: none; }
.repo-hero[data-state="ready"] .repo-hero-initial { display: block; }
.repo-hero[data-state="loading"] .repo-hero-avatar { animation: heroBreathe 1.3s ease-in-out infinite; }
.repo-hero[data-state="error"] .repo-hero-avatar { color: var(--sg-bad); background: color-mix(in srgb, var(--sg-bad) 14%, transparent); border-color: transparent; }
@keyframes heroPop { from { transform: scale(.6) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes heroBreathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.92); opacity: .7; } }
.repo-hero-text { display: grid; min-width: 0; flex: 1; gap: .1rem; position: relative; z-index: 1; }
.repo-hero-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px/1.3 "JetBrains Mono", ui-monospace, monospace; color: var(--sg-text); }
.repo-hero-sub { font-size: 11.5px; color: var(--sg-text-3); }
.repo-hero[data-state="error"] .repo-hero-sub { color: var(--sg-bad); }
.repo-hero-branch:not(.hidden) {
    position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .35rem; flex: 0 0 auto; max-width: 9rem; padding: .3rem .7rem;
    border-radius: 999px; font: 500 11px/1.2 "JetBrains Mono", ui-monospace, monospace; color: var(--sg-text);
    background: color-mix(in srgb, var(--sg-text) 8%, transparent); border: 1px solid var(--sg-line-strong); animation: heroPop .5s cubic-bezier(.34, 1.56, .64, 1) .1s both;
}
.repo-hero-branch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Picker ---- */
.repo-hero + .repo-search { margin-top: .9rem; }
.repo-search .agent-input { border-radius: 999px; padding-left: 2.4rem; }
.repo-search-icon { left: 1rem; }
.repo-list { border-radius: 20px; padding: .4rem; gap: .25rem; max-height: 16rem; }
.repo-card {
    position: relative; gap: .3rem; padding: .65rem .85rem; border-radius: 16px;
    transition: background-color .18s ease, border-color .18s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
}
.repo-card:hover:not(:disabled) { transform: translateX(3px) scale(1.005); }
.repo-card:active:not(:disabled) { transform: scale(.985); }
.repo-card[aria-selected="true"] { box-shadow: 0 10px 24px -16px var(--sg-accent); }
.repo-card-check { flex: 0 0 auto; color: var(--sg-accent); animation: heroPop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.repo-card-top { gap: .5rem; }
.repo-card-top .repo-badge { margin-left: auto; }
.repo-badge[data-private="true"] { color: #f5b942; border-color: color-mix(in srgb, #f5b942 40%, transparent); background: color-mix(in srgb, #f5b942 9%, transparent); }
.repo-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .8rem; }
.repo-meta-open { color: var(--sg-accent); font-weight: 600; }
.repo-meta-language::before { content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .35rem; border-radius: 999px; background: var(--lang, var(--sg-text-3)); vertical-align: baseline; }
.repo-skeleton { height: 3.3rem; border-radius: 16px; background: linear-gradient(100deg, var(--sg-hover) 30%, color-mix(in srgb, var(--sg-text) 9%, transparent) 50%, var(--sg-hover) 70%); background-size: 220% 100%; animation: repoShimmer 1.4s linear infinite; }
.repo-skeleton:nth-child(2) { animation-delay: .12s; } .repo-skeleton:nth-child(3) { animation-delay: .24s; } .repo-skeleton:nth-child(4) { animation-delay: .36s; }
@keyframes repoShimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.repo-list-foot { margin-top: .6rem; }
.repo-mini-btn { padding: .35rem .85rem; transition: background-color .16s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.repo-mini-btn:active:not(:disabled) { transform: scale(.93); }

/* ---- Branch and actions ---- */
.repo-section { margin-top: 1.2rem; padding: .95rem 1rem 1rem; border: 1px solid var(--sg-line); border-radius: 22px; background: var(--sg-panel-2); }
.repo-section .agent-input { border-radius: 999px; padding-left: 1rem; }
.repo-action { border-radius: 999px; padding: .5rem .95rem; transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.repo-action:hover:not(:disabled) { transform: translateY(-2px); }
#refresh-repo-btn:not(:disabled):hover i { animation: refreshSpin .8s cubic-bezier(.55, .1, .3, 1); }
.inline-form.open .inline-form-inner { border-radius: 20px; }

/* ---- Composer chip and sidebar button ---- */
.repo-chip { border-radius: 999px; padding: .32rem .8rem .32rem .65rem; border: 1px solid var(--sg-line); background: color-mix(in srgb, var(--sg-panel) 70%, transparent); transition: background-color .18s ease, border-color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.repo-chip:hover { border-color: var(--sg-line-strong); transform: translateY(-1px); }
.repo-chip:active { transform: scale(.96); }
.repo-chip[data-state="ready"] { border-color: color-mix(in srgb, var(--sg-ok) 32%, var(--sg-line)); background: color-mix(in srgb, var(--sg-ok) 7%, transparent); color: var(--sg-text); }
.repo-chip[data-state="ready"] > i:first-child { filter: drop-shadow(0 0 5px var(--sg-ok)); }
@media (prefers-reduced-motion: reduce) {
    .repo-hero-avatar, .repo-hero-branch, .repo-card-check, .repo-skeleton { animation: none !important; }
}

/* ---- Per-repository instructions line in the Repository context card ---- */
.repo-hero-instructions { margin-top: .25rem; font-size: 11px; color: var(--sg-text-3); }
.repo-hero-instructions.has-file {
    display: inline-flex; align-items: center; gap: .4rem; justify-self: start; padding: .15rem .6rem; border-radius: 999px;
    font: 500 11px/1.4 "JetBrains Mono", ui-monospace, monospace; color: var(--sg-accent);
    background: var(--sg-accent-soft); animation: heroPop .5s cubic-bezier(.34, 1.56, .64, 1) .15s both;
}
.repo-hero-instructions.has-file::before { content: ""; width: .4rem; height: .4rem; border-radius: 999px; background: currentColor; box-shadow: 0 0 8px currentColor; }

/* ---- Cost in Response details ---- */
.price-editor { margin-top: .9rem; }
.price-editor-toggle {
    display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .85rem; border-radius: 999px; font-size: 11.5px; font-weight: 500;
    color: var(--sg-text-2); border: 1px solid var(--sg-line); background: transparent;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.price-editor-toggle:hover { background: var(--sg-hover); color: var(--sg-text); border-color: var(--sg-line-strong); }
.price-editor-toggle:active { transform: scale(.96); }
.price-editor-toggle[aria-expanded="true"] { color: var(--sg-accent); border-color: color-mix(in srgb, var(--sg-accent) 40%, var(--sg-line)); }
.price-editor-form { margin-top: .6rem; padding: .85rem; border: 1px solid var(--sg-line); border-radius: 18px; background: var(--sg-panel-2); animation: bubbleRow .4s cubic-bezier(.34, 1.56, .64, 1) both; }
.price-editor-form[hidden] { display: none; }
.price-field { display: grid; gap: .3rem; margin-bottom: .6rem; font-size: 11px; color: var(--sg-text-3); }
.price-field input { width: 100%; padding: .5rem .8rem; border-radius: 999px; border: 1px solid var(--sg-line); background: var(--sg-field); color: var(--sg-text); font: 500 13px "JetBrains Mono", ui-monospace, monospace; outline: none; }
.price-field input:focus { border-color: var(--sg-accent); box-shadow: 0 0 0 3px var(--sg-accent-soft); }
.price-editor-note { margin: .2rem 0 .7rem; font-size: 11px; line-height: 1.5; color: var(--sg-text-3); }
.price-editor-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.price-editor-actions .agent-button { border-radius: 999px; padding: .4rem .95rem; font-size: 11.5px; }

/* ---- Versions of an edited message: ‹ 2 / 3 › ---- */
.version-switch { display: inline-flex; align-items: center; gap: .1rem; margin-left: .35rem; padding: .1rem .2rem; border-radius: 999px; border: 1px solid var(--sg-line); background: color-mix(in srgb, var(--sg-panel) 70%, transparent); }
.version-step { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 999px; color: var(--sg-text-3); transition: background-color .18s ease, color .18s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.version-step:hover:not(:disabled) { background: var(--sg-hover); color: var(--sg-text); }
.version-step:active:not(:disabled) { transform: scale(.85); }
.version-step:disabled { opacity: .4; cursor: not-allowed; }
.version-position { min-width: 2.4rem; text-align: center; font: 600 11px/1 "JetBrains Mono", ui-monospace, monospace; color: var(--sg-text-2); }

/* Keep the Agent workbench's layout and motion, with the shared graphite palette. */
html.dark body.agent-workspace {
    --sg-bg: #0c0c0d;
    --sg-bg-soft: #111113;
    --sg-panel: #141416;
    --sg-panel-2: #1b1b1e;
    --sg-hover: rgba(255, 255, 255, .055);
    --sg-field: #111113;
    --sg-line: rgba(255, 255, 255, .09);
    --sg-line-strong: rgba(255, 255, 255, .15);
    --sg-text: #f5f5f6;
    --sg-text-2: #c0c0c5;
    --sg-text-3: #85858d;
    --sg-accent: #4b9cff;
    --sg-accent-hover: #70b1ff;
    --sg-on-accent: #f7f9ff;
    --sg-accent-soft: rgba(75, 156, 255, .12);
    --sg-nav-bg: rgba(12, 12, 13, .86);
}
html.dark body.agent-workspace .sg-ground {
    background:
        radial-gradient(800px 450px at 50% -10%, rgba(75, 156, 255, .07), transparent 70%),
        linear-gradient(rgba(185, 185, 190, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(185, 185, 190, .035) 1px, transparent 1px),
        var(--sg-bg);
    background-size: auto, 1.7rem 1.7rem, 1.7rem 1.7rem, auto;
}
html.dark body.agent-workspace .history-panel {
    background: rgba(17, 17, 19, .9);
    border-right-color: rgba(255, 255, 255, .09);
}
html.dark body.agent-workspace .conversation-panel #chat-form {
    border-color: rgba(255, 255, 255, .1);
    background: rgba(17, 17, 19, .94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}
html.dark body.agent-workspace .conversation-panel #chat-form:focus-within {
    border-color: rgba(75, 156, 255, .35);
}
html.dark body.agent-workspace .conversation-panel .message-row.flex-row-reverse .message-bubble {
    border-color: rgba(75, 156, 255, .36) !important;
    background: #174b87 !important;
    box-shadow: 0 12px 28px -19px rgba(23, 75, 135, .5), inset 0 1px 0 rgba(255, 255, 255, .07);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
html.dark body.agent-workspace .agent-button-primary,
html.dark body.agent-workspace .sidebar-new-chat.agent-button {
    border-color: #24558f;
    background: #174b87;
    color: #f7f9ff;
}
html.dark body.agent-workspace .agent-button-primary:hover:not(:disabled),
html.dark body.agent-workspace .sidebar-new-chat.agent-button:hover {
    border-color: #2b66a8;
    background: #1b5794;
}

@media (prefers-reduced-motion: reduce) {
    html.dark body.agent-workspace .agent-button-primary,
    html.dark body.agent-workspace .sidebar-new-chat.agent-button { transition: none; }
}

/* ---- Repository dialogs: quiet graphite surfaces with a clear blue focus ---- */
dialog.repo-dialog {
    width: min(94vw, 39rem);
    max-height: min(90dvh, 52rem);
    border-radius: 26px;
    background:
        radial-gradient(34rem 18rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 8%, transparent), transparent 68%),
        var(--sg-panel);
}
.repo-dialog .app-dialog-head {
    align-items: flex-start;
    padding: 1.25rem 1.25rem .8rem 1.4rem;
}
.repo-dialog .app-dialog-head h2 { font-size: 15px; }
.repo-dialog-kicker {
    margin: 0 0 .25rem;
    color: var(--sg-accent);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .13em;
    line-height: 1.2;
    text-transform: uppercase;
}
.repo-dialog-sub {
    margin-top: .3rem;
    color: var(--sg-text-3);
    font-size: 11.5px;
    line-height: 1.5;
}
.repo-dialog .app-dialog-body { padding: .2rem 1.4rem 1.4rem; }
.repo-hero {
    border-radius: 20px;
    background: color-mix(in srgb, var(--sg-panel-2) 85%, transparent);
}
.repo-picker-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin: 1rem .15rem .15rem;
    color: var(--sg-text-2);
    font-size: 11px;
    font-weight: 600;
}
.repo-picker-label-note { color: var(--sg-text-3); font-size: 10px; font-weight: 400; }
.repo-list {
    margin-top: .45rem;
    border-color: color-mix(in srgb, var(--sg-line-strong) 75%, transparent);
    background: color-mix(in srgb, var(--sg-bg) 35%, transparent);
}
.repo-list-foot { min-height: 2rem; }
.repo-list-foot > span { display: inline-flex; align-items: center; gap: .35rem; }
.repo-mini-btn {
    min-height: 2rem;
    padding-inline: .8rem;
    border-color: color-mix(in srgb, var(--sg-accent) 28%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 7%, transparent);
    color: var(--sg-accent);
    font-weight: 550;
    transition: background-color .18s ease, border-color .18s ease, transform .24s cubic-bezier(.34, 1.56, .64, 1);
}
.repo-mini-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--sg-accent) 48%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 13%, transparent);
    transform: translateY(-1px);
}
.repo-dialog .repo-section { background: color-mix(in srgb, var(--sg-panel-2) 76%, transparent); }

dialog.new-repo-dialog {
    width: min(94vw, 34rem);
    max-height: min(90dvh, 48rem);
    border-radius: 26px;
    background:
        radial-gradient(28rem 16rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 9%, transparent), transparent 70%),
        var(--sg-panel);
}
.new-repo-form { display: flex; min-height: 0; flex-direction: column; }
.new-repo-head {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    padding: 1.35rem 1.35rem 1.1rem;
}
.new-repo-heading-icon {
    display: grid;
    flex: 0 0 auto;
    width: 2.8rem;
    height: 2.8rem;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--sg-accent) 28%, transparent);
    border-radius: 17px;
    background: color-mix(in srgb, var(--sg-accent) 11%, transparent);
    color: var(--sg-accent);
}
.new-repo-head h2 { margin: 0; color: var(--sg-text); }
.new-repo-head .sidebar-icon-btn { margin: -.25rem -.25rem 0 0; }
.new-repo-fields {
    display: grid;
    flex: 1 1 auto;
    gap: 1rem;
    min-height: 0;
    padding: .15rem 1.35rem 1.15rem;
    overflow-y: auto;
}
.new-repo-field { display: grid; gap: .45rem; min-width: 0; }
.new-repo-label {
    color: var(--sg-text-2);
    font-size: 11px;
    font-weight: 600;
}
.new-repo-hint { margin: 0; color: var(--sg-text-3); font-size: 10px; }
.new-repo-fields .agent-input {
    min-height: 2.8rem;
    border-color: var(--sg-line);
    background-color: color-mix(in srgb, var(--sg-bg) 52%, transparent);
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.new-repo-fields .agent-input:focus {
    border-color: color-mix(in srgb, var(--sg-accent) 70%, var(--sg-line));
    background-color: var(--sg-panel);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sg-accent) 13%, transparent);
    outline: none;
}
html.dark .new-repo-fields select.agent-input { color-scheme: dark; }
html:not(.dark) .new-repo-fields select.agent-input { color-scheme: light; }
.new-repo-optional-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.new-repo-readme {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem .9rem;
    border: 1px solid var(--sg-line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--sg-panel-2) 72%, transparent);
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}
.new-repo-readme:hover { border-color: var(--sg-line-strong); background: var(--sg-hover); }
.new-repo-readme-icon {
    display: grid;
    flex: 0 0 auto;
    width: 2.2rem;
    height: 2.2rem;
    place-items: center;
    border-radius: 13px;
    background: color-mix(in srgb, var(--sg-accent) 10%, transparent);
    color: var(--sg-accent);
}
.new-repo-readme strong, .new-repo-readme small { display: block; }
.new-repo-readme strong { color: var(--sg-text-2); font-size: 11px; font-weight: 600; }
.new-repo-readme small { margin-top: .15rem; color: var(--sg-text-3); font-size: 10px; }
.new-repo-readme input {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    accent-color: var(--sg-accent);
}
.new-repo-footer {
    display: grid;
    gap: .6rem;
    padding: .85rem 1.35rem 1.2rem;
    border-top: 1px solid var(--sg-line);
    background: color-mix(in srgb, var(--sg-panel) 92%, transparent);
}
.new-repo-result { display: grid; gap: .3rem; min-height: 1rem; }
#create-repo-status { margin: 0; color: var(--sg-text-3); line-height: 1.45; }
#create-repo-status.text-amber-300 { color: var(--sg-warn, #f3bb64); }
#create-repo-status.text-green-300 { color: var(--sg-ok); }
#create-repo-status.text-red-300 { color: var(--sg-bad); }
#created-repo-link { justify-self: start; }
.new-repo-actions { display: flex; justify-content: flex-end; gap: .55rem; }
.new-repo-actions .agent-button { min-height: 2.65rem; transition: background-color .18s ease, border-color .18s ease, transform .25s cubic-bezier(.34, 1.56, .64, 1), opacity .18s ease; }
.new-repo-actions .agent-button:active:not(:disabled) { transform: scale(.97); }
.new-repo-actions .agent-button:disabled { cursor: wait; opacity: .7; }

@media (max-width: 520px) {
    .repo-dialog .app-dialog-head { padding-inline: 1rem; }
    .repo-dialog .app-dialog-body { padding-inline: 1rem; }
    .new-repo-head { padding-inline: 1rem; }
    .new-repo-fields { padding-inline: 1rem; }
    .new-repo-footer { padding-inline: 1rem; }
    .new-repo-optional-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-mini-btn, .new-repo-fields .agent-input, .new-repo-readme,
    .new-repo-actions .agent-button { transition: none; }
}

/* Guided repository flow: select a project first, then show its available tools. */
dialog.repo-dialog {
    width: min(94vw, 52rem);
    height: min(46rem, 88dvh);
    max-height: 88dvh;
    border: 1px solid var(--sg-line);
    border-radius: 16px;
    background: var(--sg-panel);
    box-shadow: var(--sg-shadow);
}
.repo-dialog .app-dialog-head {
    min-height: 4.5rem;
    padding: .95rem 1.25rem;
    border-bottom: 1px solid var(--sg-line);
    background: var(--sg-panel);
}
.repo-dialog .app-dialog-head h2 { font-size: 15px; }
.repo-dialog .repo-dialog-sub { margin: .2rem 0 0 1.55rem; font-size: 11px; }
.repo-workspace {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: 1.15rem;
    padding: 1.1rem 1.35rem 1.35rem;
    overflow-y: auto;
    background: var(--sg-panel);
}
.repo-stepper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2rem minmax(0, 1fr);
    align-items: center;
    flex: 0 0 auto;
}
.repo-step {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .7rem;
    padding: .45rem .6rem;
    border: 1px solid transparent;
    border-radius: var(--sg-radius);
    color: var(--sg-text-3);
    text-align: left;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.repo-step:not(:disabled) { cursor: pointer; }
.repo-step:disabled { cursor: default; opacity: .58; }
.repo-step.is-active {
    border-color: color-mix(in srgb, var(--sg-accent) 24%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 7%, var(--sg-panel));
    color: var(--sg-text);
}
.repo-step.is-complete { color: var(--sg-text-2); }
.repo-step-number {
    display: grid;
    width: 1.8rem;
    height: 1.8rem;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--sg-line-strong);
    border-radius: 50%;
    color: var(--sg-text-2);
    font-size: 11px;
    font-weight: 650;
}
.repo-step.is-active .repo-step-number {
    border-color: var(--sg-accent);
    background: var(--sg-accent);
    color: var(--sg-on-accent);
}
.repo-step > span:last-child { display: grid; min-width: 0; gap: .1rem; }
.repo-step strong { font-size: 11px; font-weight: 650; }
.repo-step small { overflow: hidden; color: var(--sg-text-3); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.repo-step-divider { height: 1px; background: var(--sg-line-strong); }
.repo-browser {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: none;
}
.repo-browser-head { align-items: flex-end; gap: 1.25rem; }
.repo-browser-title { color: var(--sg-text); font-size: 14px; font-weight: 650; }
.repo-browser-title i {
    width: 1.6rem;
    height: 1.6rem;
    padding: .3rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel-2);
    color: var(--sg-accent);
}
.repo-browser-head > div:first-child > p {
    margin: .35rem 0 0 2.45rem;
    color: var(--sg-text-3);
    font-size: 11px;
}
.repo-browser .repo-search { flex: 0 1 19rem; }
.repo-browser .repo-search .agent-input,
.repo-config .agent-input {
    min-height: 2.65rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-field);
    color: var(--sg-text);
}
.repo-browser .repo-search .agent-input::placeholder { color: var(--sg-text-3); }
.repo-browser .repo-search .agent-input:focus,
.repo-config .agent-input:focus {
    border-color: var(--sg-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sg-accent) 13%, transparent);
    outline: none;
}
.repo-picker-label {
    margin: 1.1rem .1rem .45rem;
    color: var(--sg-text-2);
    font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
}
.repo-picker-label-note { font-size: 10px; }
.repo-browser .repo-list {
    flex: 1 1 auto;
    min-height: 9rem;
    max-height: 23rem;
    padding: .15rem .4rem .15rem .1rem;
    gap: .35rem;
}
.repo-browser .repo-card {
    padding: .8rem .85rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
}
.repo-browser .repo-card:hover:not(:disabled) {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    box-shadow: none;
    transform: none;
}
.repo-browser .repo-card[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--sg-accent) 45%, var(--sg-line));
    background: var(--sg-accent-soft);
    box-shadow: inset 3px 0 0 var(--sg-accent);
}
.repo-browser .repo-card-name { color: var(--sg-text); font-size: 12px; }
.repo-browser .repo-card-desc { color: var(--sg-text-3); font-size: 10px; }
.repo-browser .repo-card-meta { color: var(--sg-text-3); }
.repo-browser .repo-list-foot {
    margin-top: .65rem;
    padding-top: .7rem;
    border-top: 1px solid var(--sg-line);
}
.repo-browser .repo-mini-btn {
    min-height: 2.35rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-text);
}
.repo-browser .repo-mini-btn:hover:not(:disabled) {
    border-color: var(--sg-accent);
    background: var(--sg-accent-soft);
    color: var(--sg-accent);
    transform: none;
}
.repo-workspace[data-step="select"] .repo-config { display: none; }
.repo-workspace[data-step="actions"] .repo-browser { display: none; }
.repo-config {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: .85rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    animation: none;
}
.repo-config-heading { align-items: center; }
.repo-config-heading > div { display: grid; gap: .2rem; }
.repo-config-eyebrow { color: var(--sg-text-3); font-size: 9px; }
.repo-config-title { color: var(--sg-text); font-size: 15px; font-weight: 650; }
.repo-change-selection {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .65rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    color: var(--sg-text-2);
    font-size: 10px;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.repo-change-selection:hover { border-color: var(--sg-line-strong); background: var(--sg-hover); color: var(--sg-text); }
.repo-change-selection i { width: .85rem; height: .85rem; }
.repo-config .repo-hero {
    min-height: 4.5rem;
    padding: .8rem 1rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel-2);
}
.repo-config .repo-hero-label { color: var(--sg-text); font-size: 13px; }
.repo-config .repo-hero-sub { color: var(--sg-text-3); font-size: 10px; }
.repo-config .repo-hero-branch { border-color: var(--sg-line); background: var(--sg-panel); color: var(--sg-text-2); }
.repo-config .repo-section {
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
}
.repo-config .repo-section-head { align-items: center; }
.repo-config .repo-section-head label { color: var(--sg-text); font-size: 11px; }
.repo-config .repo-status { color: var(--sg-text-3); font-size: 10px; }
#repository-load-status.text-blue-300 { color: var(--sg-accent); }
#repository-load-status.text-emerald-300 { color: var(--sg-ok); }
#repository-load-status.text-red-300 { color: var(--sg-bad); }
.repo-config .repo-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .55rem;
    margin-top: .75rem;
}
.repo-config .repo-action {
    display: flex;
    min-width: 0;
    min-height: 4.35rem;
    align-items: center;
    justify-content: flex-start;
    gap: .65rem;
    padding: .7rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-text);
    text-align: left;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.repo-config .repo-action:not(:disabled):hover {
    border-color: color-mix(in srgb, var(--sg-accent) 45%, var(--sg-line));
    background: var(--sg-accent-soft);
    transform: translateY(-1px);
}
.repo-config .repo-action:disabled { cursor: not-allowed; opacity: .48; }
.repo-config .repo-action > i:first-child {
    width: 1.9rem;
    height: 1.9rem;
    flex: 0 0 auto;
    padding: .45rem;
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel-2);
    color: var(--sg-accent);
}
.repo-action-copy { display: grid; min-width: 0; gap: .18rem; }
.repo-action-copy strong { font-size: 10px; font-weight: 650; }
.repo-action-copy small { color: var(--sg-text-3); font-size: 9px; line-height: 1.3; }
.repo-config .repo-action .repo-action-arrow {
    width: .85rem;
    height: .85rem;
    flex: 0 0 auto;
    margin-left: auto;
    color: var(--sg-text-3);
}
.repo-config .repo-note { color: var(--sg-text-3); }
.repo-config .repo-files-section { display: block; }
.repo-config .repo-files { max-height: 10rem; border-color: var(--sg-line); background: var(--sg-bg); }
.repo-config .repo-files > p { color: var(--sg-text-3); }
.repo-config .inline-form {
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel-2);
}
.repo-config .inline-form-inner > label { color: var(--sg-text-2); }
.repo-config .repo-form-status { color: var(--sg-text-3); }
.repo-config .repo-form-status[data-tone="error"] { color: var(--sg-bad); }
.repo-config .repo-form-status[data-tone="ok"] { color: var(--sg-ok); }
.repo-config .repo-hint { color: var(--sg-text-3); }
.repo-config .repo-hint a { color: var(--sg-accent); }
@media (max-width: 620px) {
    dialog.repo-dialog { width: min(96vw, 42rem); height: min(48rem, 90dvh); }
    .repo-workspace { gap: .9rem; padding: .9rem 1rem 1rem; }
    .repo-step { gap: .45rem; padding-inline: .35rem; }
    .repo-step small { font-size: 8px; }
    .repo-browser-head { align-items: stretch; flex-direction: column; gap: .75rem; }
    .repo-browser .repo-search { flex: initial; }
    .repo-browser .repo-list { max-height: none; }
    .repo-config .repo-actions { grid-template-columns: 1fr; }
    .repo-config .repo-action { justify-content: flex-start; }
    .repo-config .repo-action { min-height: 3.75rem; }
}
@media (max-width: 420px) {
    .repo-step strong { font-size: 9px; }
    .repo-step small { display: none; }
    .repo-step-divider { margin-inline: .25rem; }
    .repo-config .repo-section { padding: .75rem; }
    .repo-config .repo-section-head { align-items: flex-start; flex-direction: column; gap: .25rem; }
    .repo-config .repo-status { max-width: 100%; text-align: left; }
    .repo-config-heading { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-step, .repo-change-selection, .repo-config .repo-action { transition: none; }
}

/* Repository menus use a split workspace rather than a single scrolling form. */
dialog.repo-dialog {
    width: min(96vw, 66rem);
    height: min(48rem, 88dvh);
    max-height: 88dvh;
    border-radius: 28px;
    background: var(--sg-bg);
}
.repo-dialog .app-dialog-head {
    flex: 0 0 auto;
    min-height: 5rem;
    padding: 1rem 1.25rem 1rem 1.5rem;
    border-bottom: 1px solid var(--sg-line);
    background:
        radial-gradient(35rem 10rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 9%, transparent), transparent 70%),
        var(--sg-panel);
}
.repo-dialog .app-dialog-head h2 { font-size: 15px; }
.repo-dialog .repo-dialog-sub { margin-left: 1.55rem; }
.repo-workspace {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(15rem, .78fr) minmax(0, 1.22fr);
    min-height: 0;
    padding: 0;
    overflow: hidden;
}
.repo-browser {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    padding: 1.1rem;
    border-right: 1px solid var(--sg-line);
    background:
        linear-gradient(160deg, color-mix(in srgb, var(--sg-accent) 5%, transparent), transparent 50%),
        color-mix(in srgb, var(--sg-panel-2) 72%, var(--sg-bg));
}
.repo-browser-head { display: grid; gap: .5rem; }
.repo-browser-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--sg-text);
    font-size: 12px;
    font-weight: 650;
}
.repo-browser-title i { width: 15px; height: 15px; color: var(--sg-accent); }
.repo-browser-head > p { margin: 0; color: var(--sg-text-3); font-size: 10.5px; line-height: 1.5; }
.repo-browser .repo-search { margin-top: .45rem; }
.repo-browser .repo-search .agent-input { min-height: 2.7rem; }
.repo-picker-label {
    margin: 1.15rem .15rem .35rem;
    font-size: 10px;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.repo-picker-label-note { letter-spacing: 0; text-transform: none; }
.repo-browser .repo-list {
    flex: 1 1 auto;
    min-height: 5rem;
    max-height: none;
    margin-top: 0;
    padding: .3rem;
    border: 0;
    border-radius: 14px;
    background: transparent;
}
.repo-browser .repo-card { padding: .7rem .75rem; border-radius: 13px; }
.repo-browser .repo-list-foot {
    flex: 0 0 auto;
    margin: .5rem 0 0;
    padding: .65rem .1rem 0;
    border-top: 1px solid var(--sg-line);
}
.repo-browser .repo-mini-btn { min-height: 2.15rem; }
.repo-config {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    gap: .85rem;
    padding: 1.1rem 1.25rem 1.25rem;
    overflow-y: auto;
    background: var(--sg-bg);
}
.repo-config-heading { display: flex; flex-direction: column; gap: .15rem; }
.repo-config-eyebrow {
    color: var(--sg-accent);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.repo-config-title { color: var(--sg-text); font-size: 17px; font-weight: 650; letter-spacing: -.025em; }
.repo-config .repo-hero { padding: .8rem .9rem; border-radius: 17px; }
.repo-config .repo-section { margin: 0; padding: .9rem; border-radius: 18px; }
.repo-config .repo-section-head { align-items: center; }
.repo-config .repo-section-head label { color: var(--sg-text-2); }
.repo-config .repo-status { max-width: 58%; text-align: right; }
.repo-config .repo-actions { gap: .35rem; }
.repo-config .repo-action { padding: .45rem .7rem; font-size: 10.5px; }
.repo-config .repo-note { margin-top: .65rem; }
.repo-config .repo-files-section { display: flex; min-height: 0; flex-direction: column; }
.repo-config .repo-files { max-height: none; min-height: 4.5rem; }

dialog.new-repo-dialog {
    width: min(94vw, 58rem);
    height: min(44rem, 88dvh);
    max-height: 88dvh;
    border-radius: 28px;
    background: var(--sg-bg);
}
.new-repo-form { flex: 1 1 auto; min-height: 0; }
.new-repo-layout {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: minmax(14rem, .8fr) minmax(0, 1.2fr);
    min-height: 0;
}
.new-repo-aside {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    overflow: hidden;
    padding: 1.6rem;
    border-right: 1px solid var(--sg-line);
    background:
        radial-gradient(24rem 20rem at 10% 100%, color-mix(in srgb, var(--sg-accent) 18%, transparent), transparent 72%),
        linear-gradient(155deg, color-mix(in srgb, var(--sg-accent) 9%, var(--sg-panel)) 0%, var(--sg-panel) 62%);
}
.new-repo-close { position: absolute; top: 1rem; right: 1rem; }
.new-repo-aside-mark {
    display: grid;
    width: 3rem;
    height: 3rem;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--sg-accent) 32%, transparent);
    border-radius: 18px;
    background: color-mix(in srgb, var(--sg-accent) 12%, transparent);
    color: var(--sg-accent);
    box-shadow: 0 14px 36px -24px var(--sg-accent);
}
.new-repo-aside-copy { position: relative; z-index: 1; margin: auto 0; padding-bottom: 1rem; }
.new-repo-aside-copy h2 {
    max-width: 11ch;
    margin: .5rem 0 .7rem;
    color: var(--sg-text);
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    font-weight: 650;
    letter-spacing: -.055em;
    line-height: 1.05;
}
.new-repo-aside-copy > p:last-child { max-width: 27ch; margin: 0; color: var(--sg-text-3); font-size: 12px; line-height: 1.65; }
.new-repo-aside-note {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .8rem;
    border: 1px solid var(--sg-line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--sg-panel) 70%, transparent);
}
.new-repo-aside-note-icon {
    display: grid;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 11px;
    background: color-mix(in srgb, var(--sg-ok) 11%, transparent);
    color: var(--sg-ok);
}
.new-repo-aside-note strong, .new-repo-aside-note small { display: block; }
.new-repo-aside-note strong { color: var(--sg-text-2); font-size: 10.5px; font-weight: 600; }
.new-repo-aside-note small { margin-top: .15rem; color: var(--sg-text-3); font-size: 9.5px; line-height: 1.4; }
.new-repo-aside-decoration {
    position: absolute;
    right: -2.6rem;
    bottom: 4rem;
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    height: 7rem;
    opacity: .14;
    transform: rotate(-35deg);
}
.new-repo-aside-decoration span {
    width: 1.1rem;
    height: 3rem;
    border: 1px solid var(--sg-accent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--sg-accent) 10%, transparent);
}
.new-repo-aside-decoration span:nth-child(2), .new-repo-aside-decoration span:nth-child(4) { height: 5rem; }
.new-repo-aside-decoration span:nth-child(3) { height: 7rem; }
.new-repo-main { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: var(--sg-bg); }
.new-repo-main-head { flex: 0 0 auto; padding: 1.5rem 1.6rem .8rem; }
.new-repo-main-head > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.new-repo-step { display: inline-flex; align-items: center; gap: .55rem; color: var(--sg-text); font-size: 13px; font-weight: 650; }
.new-repo-step > span {
    display: inline-grid;
    width: 1.45rem;
    height: 1.45rem;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--sg-accent) 30%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--sg-accent) 9%, transparent);
    color: var(--sg-accent);
    font: 600 9px/1 ui-monospace, monospace;
}
.new-repo-main-head p { margin: .35rem 0 0; color: var(--sg-text-3); font-size: 10.5px; }
.new-repo-fields {
    gap: 1.1rem;
    padding: .65rem 1.6rem 1.2rem;
}
.new-repo-label { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.new-repo-label > span { color: var(--sg-text-3); font-size: 9px; font-weight: 450; }
.new-repo-fields .agent-input { min-height: 2.7rem; border-radius: 13px !important; }
.new-repo-readme { border-radius: 14px; }
.new-repo-readme-icon { border-radius: 11px; }
.new-repo-advanced { border-top: 1px solid var(--sg-line); }
.new-repo-advanced summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .75rem .1rem;
    color: var(--sg-text-2);
    font-size: 10.5px;
    font-weight: 550;
    cursor: pointer;
    list-style: none;
}
.new-repo-advanced summary::-webkit-details-marker { display: none; }
.new-repo-advanced summary > span { display: inline-flex; align-items: center; gap: .45rem; }
.new-repo-advanced summary > span i { color: var(--sg-text-3); }
.new-repo-advanced-chevron { color: var(--sg-text-3); transition: transform .2s ease; }
.new-repo-advanced[open] .new-repo-advanced-chevron { transform: rotate(180deg); }
.new-repo-advanced .new-repo-optional-grid { padding: .1rem 0 .25rem; }
.new-repo-footer {
    flex: 0 0 auto;
    gap: .55rem;
    padding: .8rem 1.6rem 1.2rem;
    background: var(--sg-bg);
}

@media (max-width: 760px) {
    dialog.repo-dialog { width: min(96vw, 40rem); height: min(52rem, 90dvh); }
    .repo-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(13rem, .85fr) minmax(17rem, 1.15fr); overflow-y: auto; }
    .repo-browser { min-height: 13rem; border-right: 0; border-bottom: 1px solid var(--sg-line); }
    .repo-browser .repo-list { max-height: 15rem; }
    .repo-config { min-height: 17rem; overflow: visible; }
    dialog.new-repo-dialog { width: min(96vw, 38rem); height: min(52rem, 90dvh); }
    .new-repo-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
    .new-repo-aside { min-height: 11rem; padding: 1.1rem 1.25rem; border-right: 0; border-bottom: 1px solid var(--sg-line); }
    .new-repo-aside-mark { width: 2.35rem; height: 2.35rem; border-radius: 14px; }
    .new-repo-aside-copy { margin: .2rem 0 0; padding: 0; }
    .new-repo-aside-copy h2 { max-width: none; margin: .25rem 0; font-size: 1.5rem; }
    .new-repo-aside-copy > p:last-child { max-width: none; font-size: 10.5px; }
    .new-repo-aside-note, .new-repo-aside-decoration { display: none; }
    .new-repo-main-head { padding: 1.1rem 1.25rem .6rem; }
    .new-repo-fields { padding-inline: 1.25rem; }
    .new-repo-footer { padding-inline: 1.25rem; }
}
@media (max-width: 440px) {
    .repo-dialog .app-dialog-head { padding-inline: 1rem; }
    .repo-config { padding: .9rem; }
    .repo-config .repo-status { max-width: 48%; }
    .repo-config .repo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .repo-config .repo-action { justify-content: center; }
    .new-repo-optional-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-mini-btn, .repo-card, .new-repo-fields .agent-input, .new-repo-readme,
    .new-repo-actions .agent-button, .new-repo-advanced-chevron { transition: none !important; }
    .new-repo-aside-decoration { display: none; }
}

/* Repository picker: focused, single-column flow with a softly blurred scrim. */
dialog.repo-dialog {
    width: min(94vw, 48rem);
    height: min(46rem, 88dvh);
    max-height: 88dvh;
    border: 1px solid color-mix(in srgb, var(--sg-line-strong) 78%, transparent);
    border-radius: 28px;
    background:
        radial-gradient(40rem 20rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 9%, transparent), transparent 68%),
        var(--sg-bg);
    box-shadow: 0 32px 100px -38px rgba(0, 0, 0, .8), 0 0 0 1px color-mix(in srgb, var(--sg-text) 3%, transparent);
}
dialog.repo-dialog::backdrop {
    background: rgba(5, 8, 12, .62);
    -webkit-backdrop-filter: blur(14px) saturate(.78);
    backdrop-filter: blur(14px) saturate(.78);
}
.repo-dialog .app-dialog-head {
    min-height: 5.3rem;
    padding: 1.1rem 1.25rem 1rem 1.5rem;
    border-bottom: 1px solid var(--sg-line);
    background: color-mix(in srgb, var(--sg-panel) 84%, transparent);
}
.repo-dialog .app-dialog-head > div { display: grid; gap: .05rem; }
.repo-dialog .app-dialog-head h2 {
    gap: .55rem;
    color: var(--sg-text);
    font-size: 15px;
    letter-spacing: -.015em;
}
.repo-dialog .repo-dialog-sub { margin: .2rem 0 0 1.55rem; font-size: 10.5px; }
.repo-dialog .app-dialog-head .repo-dialog-kicker { margin-left: 1.55rem; }
.repo-workspace {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: .8rem;
    padding: 1rem 1.2rem 1.2rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.repo-browser {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 1rem;
    border: 1px solid var(--sg-line);
    border-radius: 21px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--sg-accent) 5%, transparent), transparent 55%),
        color-mix(in srgb, var(--sg-panel) 82%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--sg-text) 3%, transparent);
    animation: repoSurfaceIn .42s cubic-bezier(.2, .8, .2, 1) both;
}
.repo-browser-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.repo-browser-head > div:first-child { min-width: 0; }
.repo-browser-title { gap: .5rem; font-size: 12px; }
.repo-browser-title i {
    width: 1.85rem;
    height: 1.85rem;
    padding: .4rem;
    box-sizing: content-box;
    border: 1px solid color-mix(in srgb, var(--sg-accent) 24%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--sg-accent) 8%, transparent);
    color: var(--sg-accent);
}
.repo-browser-head > div:first-child > p {
    margin: .35rem 0 0 2.85rem;
    color: var(--sg-text-3);
    font-size: 10px;
    line-height: 1.45;
}
.repo-browser .repo-search { flex: 0 1 18rem; }
.repo-browser .repo-search .agent-input {
    min-height: 2.65rem;
    border: 1px solid var(--sg-line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--sg-bg) 74%, transparent);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.repo-browser .repo-search .agent-input:focus {
    border-color: color-mix(in srgb, var(--sg-accent) 55%, var(--sg-line));
    background: var(--sg-bg);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sg-accent) 12%, transparent);
    outline: none;
}
.repo-picker-label {
    margin: .9rem .15rem .35rem;
    color: var(--sg-text-2);
    font-size: 10px;
    font-weight: 650;
    letter-spacing: .075em;
    text-transform: uppercase;
}
.repo-picker-label-note { font-size: 9px; font-weight: 450; letter-spacing: 0; text-transform: none; }
.repo-browser .repo-list {
    display: grid;
    flex: 0 1 auto;
    min-height: 5rem;
    max-height: 13.5rem;
    gap: .25rem;
    margin: 0;
    padding: .15rem .35rem .15rem .1rem;
    overflow-y: auto;
    border: 0;
    border-radius: 13px;
    background: transparent;
    scrollbar-gutter: stable;
}
.repo-browser .repo-card {
    gap: .23rem;
    padding: .65rem .8rem;
    border: 1px solid transparent;
    border-radius: 14px;
    background: color-mix(in srgb, var(--sg-bg) 45%, transparent);
    transform: none;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .2s ease, transform .2s ease;
    animation: repoRowIn .3s cubic-bezier(.2, .8, .2, 1) both;
}
.repo-browser .repo-card:nth-child(2) { animation-delay: 25ms; }
.repo-browser .repo-card:nth-child(3) { animation-delay: 50ms; }
.repo-browser .repo-card:nth-child(4) { animation-delay: 75ms; }
.repo-browser .repo-card:nth-child(5) { animation-delay: 100ms; }
.repo-browser .repo-card:hover:not(:disabled) {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    box-shadow: 0 7px 22px -18px rgba(0, 0, 0, .85);
    transform: translateY(-1px);
}
.repo-browser .repo-card:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--sg-accent) 72%, transparent);
    outline-offset: 1px;
}
.repo-browser .repo-card[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--sg-accent) 40%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 9%, var(--sg-panel));
    box-shadow: inset 3px 0 0 var(--sg-accent), 0 8px 24px -20px var(--sg-accent);
}
.repo-browser .repo-card-name { font-size: 11.5px; }
.repo-browser .repo-card-desc { font-size: 10px; }
.repo-browser .repo-card-meta { gap: .15rem .7rem; font-size: 9.5px; }
.repo-browser .repo-list-foot {
    flex: 0 0 auto;
    margin: .55rem 0 0;
    padding: .55rem .1rem 0;
    border-top: 1px solid var(--sg-line);
}
.repo-browser .repo-mini-btn {
    min-height: 2rem;
    border-radius: 12px;
}
.repo-browser .repo-row-action {
    padding: .65rem .8rem;
    border: 1px solid color-mix(in srgb, var(--sg-accent) 18%, var(--sg-line));
    border-radius: 13px;
    background: color-mix(in srgb, var(--sg-accent) 6%, transparent);
}
.repo-config {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: .7rem;
    padding: 1rem;
    border: 1px solid var(--sg-line);
    border-radius: 21px;
    background: color-mix(in srgb, var(--sg-panel) 72%, transparent);
    animation: repoSurfaceIn .48s cubic-bezier(.2, .8, .2, 1) .06s both;
}
.repo-config-heading { display: flex; flex-direction: row; align-items: baseline; justify-content: space-between; gap: .75rem; }
.repo-config-eyebrow { font-size: 8.5px; }
.repo-config-title { font-size: 12px; font-weight: 600; letter-spacing: 0; }
.repo-config .repo-hero {
    min-height: 4.25rem;
    padding: .65rem .8rem;
    border-radius: 15px;
    background-color: color-mix(in srgb, var(--sg-bg) 62%, transparent);
}
.repo-config .repo-hero-avatar { width: 2.35rem; height: 2.35rem; border-radius: 13px; }
.repo-config .repo-hero-label { font-size: 11px; }
.repo-config .repo-hero-sub { font-size: 10px; }
.repo-config .repo-section {
    margin: 0;
    padding: .75rem .8rem;
    border-radius: 16px;
    background: color-mix(in srgb, var(--sg-bg) 52%, transparent);
}
.repo-config .repo-section-head { margin-bottom: .4rem; }
.repo-config .repo-section-head label { color: var(--sg-text-2); font-size: 9.5px; }
.repo-config .repo-status { max-width: 60%; text-align: right; font-size: 9px; }
.repo-config .repo-section .agent-input { min-height: 2.55rem; border-radius: 12px; }
.repo-config .repo-actions { gap: .35rem; margin-top: .45rem; }
.repo-config .repo-action { padding: .4rem .65rem; border-radius: 11px; font-size: 10px; }
.repo-config .repo-note { margin: .55rem 0 0; font-size: 9.5px; }
.repo-config .repo-files-section { display: block; }
.repo-config .repo-files { max-height: 6rem; padding: .35rem .55rem; border-radius: 12px; }
@keyframes repoSurfaceIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes repoRowIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 620px) {
    dialog.repo-dialog { width: min(96vw, 42rem); height: min(48rem, 90dvh); }
    .repo-workspace { gap: .65rem; padding: .75rem; }
    .repo-dialog .app-dialog-head { padding-inline: 1rem; }
    .repo-browser { padding: .8rem; }
    .repo-browser-head { align-items: stretch; flex-direction: column; gap: .7rem; }
    .repo-browser .repo-search { flex: initial; }
    .repo-browser .repo-list { max-height: 12rem; }
    .repo-config { padding: .8rem; }
}
@media (max-width: 420px) {
    .repo-config .repo-section-head { align-items: flex-start; flex-direction: column; gap: .2rem; }
    .repo-config .repo-status { max-width: 100%; text-align: left; }
    .repo-config .repo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .repo-config .repo-action { justify-content: center; padding-inline: .4rem; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-browser, .repo-config, .repo-browser .repo-card { animation: none !important; }
    .repo-browser .repo-card, .repo-browser .repo-search .agent-input { transition: none !important; }
}

/* Keep the guided flow authoritative over the legacy repository layout rules above. */
dialog.repo-dialog {
    width: min(94vw, 52rem);
    height: min(46rem, 88dvh);
    max-height: 88dvh;
    border: 1px solid var(--sg-line);
    border-radius: 16px;
    background: var(--sg-panel);
    box-shadow: var(--sg-shadow);
}
.repo-dialog .app-dialog-head {
    min-height: 4.5rem;
    padding: .95rem 1.25rem;
    background: var(--sg-panel);
}
.repo-dialog .app-dialog-body.repo-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    padding: 1.1rem 1.35rem 1.35rem;
    overflow-y: auto;
    background: var(--sg-panel);
}
.repo-stepper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2rem minmax(0, 1fr);
    align-items: center;
    flex: 0 0 auto;
}
.repo-step {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: .7rem;
    padding: .45rem .6rem;
    border: 1px solid transparent;
    border-radius: var(--sg-radius);
    color: var(--sg-text-3);
    text-align: left;
}
.repo-step:not(:disabled) { cursor: pointer; }
.repo-step:disabled { cursor: default; opacity: .58; }
.repo-step.is-active {
    border-color: color-mix(in srgb, var(--sg-accent) 24%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 7%, var(--sg-panel));
    color: var(--sg-text);
}
.repo-step.is-complete { color: var(--sg-text-2); }
.repo-step-number {
    display: grid;
    width: 1.8rem;
    height: 1.8rem;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--sg-line-strong);
    border-radius: 50%;
    color: var(--sg-text-2);
    font-size: 11px;
    font-weight: 650;
}
.repo-step.is-active .repo-step-number { border-color: var(--sg-accent); background: var(--sg-accent); color: var(--sg-on-accent); }
.repo-step > span:last-child { display: grid; min-width: 0; gap: .1rem; }
.repo-step strong { font-size: 11px; font-weight: 650; }
.repo-step small { overflow: hidden; color: var(--sg-text-3); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.repo-step-divider { height: 1px; background: var(--sg-line-strong); }
.repo-browser {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    animation: none;
}
.repo-browser-head { display: flex; align-items: flex-end; gap: 1.25rem; }
.repo-browser-head > div:first-child > p { margin: .35rem 0 0 2.45rem; color: var(--sg-text-3); font-size: 11px; }
.repo-browser-title { color: var(--sg-text); font-size: 14px; font-weight: 650; }
.repo-browser-title i { color: var(--sg-accent); }
.repo-browser .repo-search { flex: 0 1 19rem; }
.repo-browser .repo-search .agent-input,
.repo-config .agent-input {
    min-height: 2.65rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-field);
    color: var(--sg-text);
}
.repo-browser .repo-search .agent-input::placeholder { color: var(--sg-text-3); }
.repo-picker-label { margin: 1.1rem .1rem .45rem; color: var(--sg-text-2); font-size: 11px; letter-spacing: 0; text-transform: none; }
.repo-browser .repo-list { flex: 1 1 auto; min-height: 9rem; max-height: 23rem; padding: .15rem .4rem .15rem .1rem; gap: .35rem; }
.repo-browser .repo-card { padding: .8rem .85rem; border: 1px solid var(--sg-line); border-radius: var(--sg-radius); background: var(--sg-panel); }
.repo-browser .repo-card-name { color: var(--sg-text); font-size: 12px; }
.repo-browser .repo-card-desc, .repo-browser .repo-card-meta { color: var(--sg-text-3); }
.repo-browser .repo-card:hover:not(:disabled) { border-color: var(--sg-line-strong); background: var(--sg-hover); box-shadow: none; transform: none; }
.repo-browser .repo-card[aria-selected="true"] { border-color: color-mix(in srgb, var(--sg-accent) 45%, var(--sg-line)); background: var(--sg-accent-soft); box-shadow: inset 3px 0 0 var(--sg-accent); }
.repo-browser .repo-list-foot { margin-top: .65rem; padding-top: .7rem; border-top: 1px solid var(--sg-line); }
.repo-browser .repo-mini-btn { min-height: 2.35rem; border: 1px solid var(--sg-line-strong); border-radius: var(--sg-radius-sm); background: var(--sg-panel); color: var(--sg-text); }
.repo-workspace[data-step="select"] .repo-config { display: none; }
.repo-workspace[data-step="actions"] .repo-browser { display: none; }
.repo-config {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: .85rem;
    padding: 0;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.repo-config-heading { align-items: center; }
.repo-config-heading > div { display: grid; gap: .2rem; }
.repo-config-eyebrow { color: var(--sg-text-3); font-size: 9px; }
.repo-config-title { color: var(--sg-text); font-size: 15px; font-weight: 650; }
.repo-change-selection { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .65rem; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-sm); color: var(--sg-text-2); font-size: 10px; }
.repo-config .repo-hero { min-height: 4.5rem; padding: .8rem 1rem; border: 1px solid var(--sg-line); border-radius: var(--sg-radius); background: var(--sg-panel-2); }
.repo-config .repo-hero-label { color: var(--sg-text); font-size: 13px; }
.repo-config .repo-hero-sub { color: var(--sg-text-3); font-size: 10px; }
.repo-config .repo-section { margin: 0; padding: 1rem; border: 1px solid var(--sg-line); border-radius: var(--sg-radius); background: var(--sg-panel); }
.repo-config .repo-section-head label { color: var(--sg-text); font-size: 11px; }
.repo-config .repo-status { max-width: 65%; color: var(--sg-text-3); font-size: 10px; }
#repository-load-status.text-blue-300 { color: var(--sg-accent); }
#repository-load-status.text-emerald-300 { color: var(--sg-ok); }
#repository-load-status.text-red-300 { color: var(--sg-bad); }
.repo-config .repo-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-top: .75rem; }
.repo-config .repo-action {
    display: flex;
    min-width: 0;
    min-height: 4.35rem;
    align-items: center;
    justify-content: flex-start;
    gap: .65rem;
    padding: .7rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-text);
    text-align: left;
}
.repo-config .repo-action:not(:disabled):hover { border-color: color-mix(in srgb, var(--sg-accent) 45%, var(--sg-line)); background: var(--sg-accent-soft); }
.repo-config .repo-action > i:first-child { width: 1.9rem; height: 1.9rem; flex: 0 0 auto; padding: .45rem; border-radius: var(--sg-radius-sm); background: var(--sg-panel-2); color: var(--sg-accent); }
.repo-action-copy { display: grid; min-width: 0; gap: .18rem; }
.repo-action-copy strong { font-size: 10px; font-weight: 650; }
.repo-action-copy small { color: var(--sg-text-3); font-size: 9px; line-height: 1.3; }
.repo-config .repo-action .repo-action-arrow { width: .85rem; height: .85rem; flex: 0 0 auto; margin-left: auto; color: var(--sg-text-3); }
#refresh-repo-btn:not(:disabled):hover > i:first-child { animation: refreshSpin .8s cubic-bezier(.55, .1, .3, 1); }
#refresh-repo-btn:not(:disabled):hover .repo-action-arrow { animation: none; }
.repo-config .repo-files { max-height: 10rem; border-color: var(--sg-line); background: var(--sg-bg); }
.repo-config .repo-files > p, .repo-config .repo-hint { color: var(--sg-text-3); }
.repo-config .inline-form { border: 1px solid var(--sg-line); border-radius: var(--sg-radius); background: var(--sg-panel-2); }
.repo-config .inline-form-inner > label { color: var(--sg-text-2); }
@media (max-width: 760px) {
    .repo-workspace { display: flex; grid-template-columns: none; grid-template-rows: none; overflow-y: auto; }
    .repo-browser { min-height: 0; border: 0; }
}
@media (max-width: 620px) {
    dialog.repo-dialog { width: min(96vw, 42rem); height: min(48rem, 90dvh); }
    .repo-workspace { gap: .9rem; padding: .9rem 1rem 1rem; }
    .repo-step { gap: .45rem; padding-inline: .35rem; }
    .repo-step small { font-size: 8px; }
    .repo-browser-head { align-items: stretch; flex-direction: column; gap: .75rem; }
    .repo-browser .repo-search { flex: initial; }
    .repo-browser .repo-list { max-height: none; }
    .repo-config .repo-actions { grid-template-columns: 1fr; }
    .repo-config .repo-action { min-height: 3.75rem; }
}
@media (max-width: 440px) {
    .repo-config { padding: 0; }
    .repo-config .repo-status { max-width: 100%; text-align: left; }
    .repo-config .repo-actions { grid-template-columns: 1fr; }
    .repo-config .repo-action { justify-content: flex-start; }
}

/* Match the graphite surfaces and blue pill actions used by sign-in and usage. */
dialog.repo-dialog {
    border-color: var(--sg-line);
    border-radius: 22px;
    background:
        radial-gradient(42rem 24rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 7%, transparent), transparent 70%),
        var(--sg-bg);
}
.repo-dialog .app-dialog-head {
    border-bottom-color: var(--sg-line);
    background: transparent;
}
.repo-dialog .app-dialog-body.repo-workspace { background: transparent; }
.repo-step { border-radius: 14px; }
.repo-step.is-active {
    border-color: color-mix(in srgb, var(--sg-accent) 32%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 9%, var(--sg-panel));
}
.repo-step.is-active .repo-step-number {
    border-color: color-mix(in srgb, var(--sg-accent) 36%, transparent);
    background: color-mix(in srgb, var(--sg-accent) 14%, var(--sg-panel));
    color: #a9ceff;
}
.repo-browser .repo-search .agent-input,
.repo-config .agent-input {
    min-height: 2.55rem;
    border-color: var(--sg-line-strong);
    border-radius: 12px;
    background: var(--sg-field);
}
.repo-browser .repo-search .agent-input:focus,
.repo-config .agent-input:focus {
    border-color: color-mix(in srgb, var(--sg-accent) 65%, transparent);
    background: color-mix(in srgb, var(--sg-accent) 3%, var(--sg-field));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sg-accent) 12%, transparent);
}
.repo-browser .repo-card {
    border-color: var(--sg-line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--sg-panel) 86%, transparent);
}
.repo-browser .repo-card[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--sg-accent) 32%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 8%, var(--sg-panel));
    box-shadow: inset 2px 0 0 var(--sg-accent);
}
.repo-browser .repo-mini-btn {
    min-height: 2.4rem;
    padding-inline: 1rem;
    border-color: #24558f;
    border-radius: 999px;
    background: #174b87;
    color: #f7f9ff;
    font-size: 11px;
    font-weight: 550;
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.repo-browser .repo-mini-btn:hover:not(:disabled) {
    border-color: #2b66a8;
    background: #1b5794;
    color: #fff;
    box-shadow: 0 5px 16px rgba(23, 75, 135, .24);
    transform: translateY(-1px);
}
.repo-change-selection {
    min-height: 2.2rem;
    padding: .4rem .8rem;
    border-color: var(--sg-line-strong);
    border-radius: 999px;
    background: var(--sg-panel);
    color: var(--sg-text-2);
}
.repo-change-selection:hover {
    border-color: color-mix(in srgb, var(--sg-accent) 40%, var(--sg-line));
    background: color-mix(in srgb, var(--sg-accent) 7%, var(--sg-panel));
    color: var(--sg-text);
}
.repo-config .repo-hero {
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(24, 24, 27, .96), rgba(15, 15, 17, .96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}
.repo-config .repo-section {
    border-color: var(--sg-line);
    border-radius: 22px;
    background: rgba(17, 17, 19, .9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}
.repo-config .repo-action {
    min-height: 4.5rem;
    border-color: var(--sg-line);
    border-radius: 16px;
    background: #111113;
}
.repo-config .repo-action:not(:disabled):hover {
    border-color: rgba(75, 156, 255, .32);
    background: rgba(75, 156, 255, .07);
}
.repo-config .repo-action > i:first-child {
    border-radius: 12px;
    background: rgba(75, 156, 255, .1);
    color: #8dbfff;
}
.repo-config .repo-action .repo-action-arrow { color: #73737a; }
.repo-config .repo-section .repo-files { border-radius: 14px; background: #0c0c0d; }
.repo-config .inline-form,
.repo-config .inline-form.open .inline-form-inner {
    border-color: var(--sg-line);
    border-radius: 18px;
    background: #151517;
}
.repo-config .agent-button { min-height: 2.4rem; border-radius: 999px; }
.repo-config .agent-button-primary {
    border-color: #24558f;
    background: #174b87;
    color: #f7f9ff;
    box-shadow: 0 3px 12px rgba(23, 75, 135, .18);
}
.repo-config .agent-button-primary:hover:not(:disabled) {
    border-color: #2b66a8;
    background: #1b5794;
    box-shadow: 0 5px 16px rgba(23, 75, 135, .24);
}
@media (max-width: 640px) {
    .repo-config .repo-section { border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-browser .repo-mini-btn { transition: none; }
}
.repo-dialog .app-dialog-head { padding-block: .85rem; }
.repo-dialog .app-dialog-head > div { gap: .1rem; }
.repo-dialog .repo-dialog-sub { margin: .15rem 0 0 1.55rem; }
.repo-dialog-footer {
    position: sticky;
    bottom: -1.35rem;
    display: flex;
    min-height: 4rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: auto -1.35rem -1.35rem;
    padding: .8rem 1.35rem;
    border-top: 1px solid var(--sg-line);
    background: color-mix(in srgb, var(--sg-bg) 94%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.repo-dialog-footer > span { color: var(--sg-text-3); font-size: 10px; }
.repo-continue-btn {
    display: inline-flex;
    min-height: 2.45rem;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 0 1rem;
    border: 1px solid #24558f;
    border-radius: 999px;
    background: #174b87;
    color: #f7f9ff;
    font-size: 11px;
    font-weight: 600;
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.repo-continue-btn:hover { transform: translateY(-1px); border-color: #2b66a8; background: #1b5794; box-shadow: 0 5px 16px rgba(23, 75, 135, .24); }
.repo-continue-btn:active { transform: scale(.985); }
.repo-continue-btn i { width: .9rem; height: .9rem; }
.repo-file-search { position: relative; margin: 0 0 .55rem; }
.repo-file-search > i { position: absolute; top: 50%; left: .75rem; width: .9rem; height: .9rem; transform: translateY(-50%); color: var(--sg-text-3); pointer-events: none; }
.repo-file-search .agent-input { width: 100%; min-height: 2.3rem; padding: .45rem .75rem .45rem 2rem; border-radius: 11px; font-size: 10px; }
.repo-tree-empty { margin: 0; padding: 1.5rem .75rem; color: var(--sg-text-3); font-size: 10px; text-align: center; }
.repo-config .repo-files {
    display: block;
    min-height: 5rem;
    max-height: min(28dvh, 18rem);
    padding: .3rem;
    border-radius: 14px;
}
.repo-tree-folder { min-width: 0; }
.repo-tree-folder-button,
.repo-tree-file {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 1.85rem;
    align-items: center;
    gap: .45rem;
    padding: .25rem .5rem;
    border-radius: 8px;
    color: var(--sg-text-2);
    text-align: left;
    transition: background-color .14s ease, color .14s ease;
}
.repo-tree-folder-button { padding-left: calc(.5rem + var(--tree-depth, 0) * .85rem); }
.repo-tree-folder-button:hover,
.repo-tree-file:hover { background: var(--sg-hover); color: var(--sg-text); }
.repo-tree-folder-button > i:first-child { width: .75rem; height: .75rem; color: var(--sg-text-3); }
.repo-tree-folder-button > i:nth-child(2) { width: .9rem; height: .9rem; color: var(--sg-accent); }
.repo-tree-folder-button > span { overflow: hidden; font-size: 10px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.repo-tree-children[hidden] { display: none; }
.repo-tree-file {
    position: relative;
    min-height: 2rem;
    padding-left: calc(1.25rem + var(--tree-depth, 0) * .85rem);
}
.repo-tree-file > i { width: .85rem; height: .85rem; flex: 0 0 auto; color: var(--sg-text-3); }
.repo-tree-file > span { overflow: hidden; color: var(--sg-text-2); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.repo-tree-file > small { overflow: hidden; margin-left: auto; color: var(--sg-text-3); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
dialog.repo-action-dialog {
    width: min(94vw, 34rem);
    max-height: min(88dvh, 42rem);
    border: 1px solid var(--sg-line-strong);
    border-radius: 22px;
    background:
        radial-gradient(34rem 18rem at 100% 0%, color-mix(in srgb, var(--sg-accent) 7%, transparent), transparent 70%),
        var(--sg-bg);
    color: var(--sg-text);
    box-shadow: var(--sg-shadow);
}
.repo-action-dialog .app-dialog-head { align-items: flex-start; padding: 1.1rem 1.1rem .75rem 1.25rem; }
.repo-action-dialog-heading { display: flex; min-width: 0; align-items: center; gap: .8rem; }
.repo-action-dialog-heading > span:last-child { min-width: 0; }
.repo-action-dialog-heading h2 { margin: 0; color: var(--sg-text); font-size: 15px; }
.repo-action-dialog-heading .repo-dialog-sub { margin: .25rem 0 0; color: var(--sg-text-3); font-size: 10px; }
.repo-action-dialog-icon { display: grid; width: 2.5rem; height: 2.5rem; flex: 0 0 auto; place-items: center; border: 1px solid color-mix(in srgb, var(--sg-accent) 25%, var(--sg-line)); border-radius: 14px; background: color-mix(in srgb, var(--sg-accent) 10%, var(--sg-panel)); color: var(--sg-accent); }
.repo-action-dialog-icon i { width: 1.15rem; height: 1.15rem; }
.repo-action-form { display: grid; gap: .65rem; padding: .5rem 1.25rem 1.25rem; overflow-y: auto; }
.repo-action-form label { color: var(--sg-text-2); font-size: 11px; font-weight: 600; }
.repo-action-form .agent-input { width: 100%; min-height: 2.65rem; border: 1px solid var(--sg-line-strong); border-radius: 12px; background: var(--sg-field); color: var(--sg-text); }
.repo-action-form textarea.agent-input { min-height: auto; }
.repo-action-form .repo-hint { margin: -.25rem 0 0; color: var(--sg-text-3); font-size: 10px; }
.repo-action-dialog-buttons { display: flex; justify-content: flex-end; gap: .55rem; padding-top: .5rem; }
.repo-action-dialog-buttons .agent-button { min-height: 2.4rem; border-radius: 999px; padding: 0 1rem; font-size: 11px; }
.dark dialog.repo-action-dialog {
    --sg-bg: #0c0c0d;
    --sg-panel: #111113;
    --sg-panel-2: #18181a;
    --sg-field: #111113;
    --sg-line: rgba(255, 255, 255, .09);
    --sg-line-strong: rgba(255, 255, 255, .15);
    --sg-text: #f5f5f6;
    --sg-text-2: #c0c0c5;
    --sg-text-3: #85858d;
    --sg-accent: #4b9cff;
    --sg-accent-hover: #70b1ff;
    --sg-on-accent: #f7f9ff;
    color-scheme: dark;
}
.dark .repo-action-form .agent-button-primary {
    border-color: #24558f;
    background: #174b87;
    color: #f7f9ff;
    box-shadow: 0 3px 12px rgba(23, 75, 135, .18);
}
.dark .repo-action-form .agent-button-primary:hover:not(:disabled) { border-color: #2b66a8; background: #1b5794; }
.repo-dialog[open] { animation: repoDialogIn .32s cubic-bezier(.2, .8, .2, 1) both; }
.repo-dialog[data-closing] { animation: repoDialogOut .24s cubic-bezier(.4, 0, 1, 1) both; }
dialog.repo-action-dialog[open] { animation: repoActionIn .26s cubic-bezier(.2, .8, .3, 1) both; }
dialog.repo-action-dialog[data-closing] { animation: repoActionOut .2s ease-in both; }
@keyframes repoDialogIn {
    from { opacity: 0; transform: translateY(18px) scale(.975); filter: blur(3px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes repoDialogOut {
    from { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
    to { opacity: 0; transform: translateY(10px) scale(.985); filter: blur(2px); }
}
@keyframes repoActionIn {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes repoActionOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(8px) scale(.985); }
}
@media (max-width: 560px) {
    .repo-dialog-footer { bottom: -.9rem; margin: auto -1rem -.9rem; padding-inline: 1rem; }
    .repo-dialog-footer > span { max-width: 45%; font-size: 9px; }
    .repo-continue-btn { padding-inline: .8rem; }
    .repo-tree-file > small { display: none; }
    dialog.repo-action-dialog { width: min(94vw, 34rem); }
    .repo-action-form { padding-inline: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-dialog[open], .repo-dialog[data-closing],
    dialog.repo-action-dialog[open], dialog.repo-action-dialog[data-closing] { animation: none !important; }
    .repo-tree-folder-button, .repo-tree-file, .repo-continue-btn { transition: none; }
}

/* Keep repository setup aligned with the shared dashboard theme and use the dialog space. */
html.dark dialog.repo-dialog {
    --sg-bg: #0c0c0d;
    --sg-bg-soft: #111113;
    --sg-panel: #111113;
    --sg-panel-2: #18181a;
    --sg-hover: rgba(255, 255, 255, .055);
    --sg-field: #111113;
    --sg-line: rgba(255, 255, 255, .09);
    --sg-line-strong: rgba(255, 255, 255, .15);
    --sg-text: #f5f5f6;
    --sg-text-2: #c0c0c5;
    --sg-text-3: #85858d;
    --sg-accent: #4b9cff;
    --sg-accent-hover: #70b1ff;
    --sg-on-accent: #f7f9ff;
    --sg-accent-soft: rgba(75, 156, 255, .12);
    color-scheme: dark;
}
dialog.repo-dialog {
    width: min(96vw, 72rem);
    height: min(54rem, 92dvh);
    max-height: 92dvh;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius-lg);
    background: var(--sg-panel);
    color: var(--sg-text);
}
.repo-dialog .app-dialog-head {
    min-height: 4.25rem;
    flex: 0 0 auto;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--sg-line);
    background: var(--sg-panel);
}
.repo-dialog .app-dialog-head h2 { font-size: 14px; font-weight: 600; }
.repo-dialog .repo-dialog-sub { margin: .15rem 0 0 1.55rem; font-size: 11px; }
.repo-dialog .app-dialog-body.repo-workspace {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: .85rem;
    padding: 1rem 1.15rem 1.15rem;
    overflow: hidden;
    background: var(--sg-panel);
}
.repo-stepper {
    width: min(100%, 46rem);
    flex: 0 0 auto;
    align-self: center;
}
.repo-step {
    min-height: 3rem;
    padding: .4rem .55rem;
    border-radius: var(--sg-radius);
}
.repo-step.is-active {
    border-color: var(--sg-line-strong);
    background: var(--sg-panel-2);
}
.repo-step.is-active .repo-step-number {
    border-color: var(--sg-accent);
    background: var(--sg-accent);
    color: var(--sg-on-accent);
}
.repo-browser {
    flex: 1 1 auto;
    min-height: 0;
}
.repo-browser-head { align-items: center; gap: 1.5rem; }
.repo-browser-title { font-size: 13px; font-weight: 600; }
.repo-browser-title i {
    width: 1.4rem;
    height: 1.4rem;
    padding: .25rem;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel-2);
    color: var(--sg-text-2);
}
.repo-browser-head > div:first-child > p {
    margin: .3rem 0 0 2.15rem;
    font-size: 11px;
}
.repo-browser .repo-search { flex: 0 1 25rem; }
.repo-browser .repo-search .agent-input,
.repo-config .agent-input { border-radius: var(--sg-radius-sm); }
.repo-browser .repo-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: .15rem .4rem .15rem .1rem;
    gap: .35rem;
}
#github-repos-list { max-height: none; }
.repo-browser .repo-card {
    border-color: var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
    box-shadow: none;
    animation: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.repo-browser .repo-card:hover:not(:disabled) {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    box-shadow: none;
    transform: none;
}
.repo-browser .repo-card[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--sg-accent) 45%, var(--sg-line));
    background: var(--sg-accent-soft);
    box-shadow: inset 2px 0 0 var(--sg-accent);
}
.repo-browser .repo-mini-btn {
    min-height: 2.25rem;
    padding-inline: .9rem;
    border-color: #24558f;
    border-radius: 999px;
    background: #174b87;
    color: #f7f9ff;
    font-weight: 550;
    box-shadow: 0 3px 12px rgba(23, 75, 135, .18);
}
.repo-browser .repo-mini-btn:hover:not(:disabled) {
    border-color: #2b66a8;
    background: #1b5794;
    color: #f7f9ff;
    box-shadow: 0 5px 16px rgba(23, 75, 135, .24);
    transform: translateY(-1px);
}
.repo-config {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: minmax(18rem, .85fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: .75rem;
    overflow: hidden;
    animation: none;
}
.repo-config-heading,
.repo-config > .repo-hero { grid-column: 1 / -1; }
.repo-config > .repo-section:not(.repo-files-section) {
    grid-column: 1;
    min-height: 0;
    margin: 0;
    padding: .9rem;
    overflow-y: auto;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
    box-shadow: none;
}
.repo-config .repo-hero {
    min-height: 3.8rem;
    padding: .65rem .8rem;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel-2);
    box-shadow: none;
}
.repo-hero::after { display: none; }
.repo-config .repo-hero-avatar,
.repo-hero[data-state="ready"] .repo-hero-avatar {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-accent);
    box-shadow: none;
    animation: none;
}
.repo-hero[data-state="ready"] .repo-hero-icon { display: block; }
.repo-hero[data-state="ready"] .repo-hero-initial { display: none; }
.repo-hero[data-state="loading"] .repo-hero-avatar { animation: none; }
.repo-hero-branch:not(.hidden) { border-radius: var(--sg-radius-sm); }
.repo-config .repo-section-head { margin-bottom: .5rem; }
.repo-config .repo-section-head label { font-size: 10px; }
.repo-config .repo-status { max-width: 60%; }
.repo-config .repo-section .agent-input { min-height: 2.4rem; border-radius: var(--sg-radius-sm); }
.repo-config .repo-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
    margin-top: .65rem;
}
.repo-config .repo-action {
    min-height: 2.4rem;
    justify-content: center;
    gap: .45rem;
    padding: .45rem .7rem;
    border-color: var(--sg-line-strong);
    border-radius: 999px;
    background: var(--sg-field);
    color: var(--sg-text-2);
    box-shadow: none;
    transform: none;
}
.repo-config .repo-action:not(:disabled):hover {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    color: var(--sg-text);
    transform: none;
}
.repo-config .repo-action > i:first-child {
    width: 1rem;
    height: 1rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: currentColor;
}
.repo-action-copy { display: block; }
.repo-action-copy strong { font-size: 10px; font-weight: 550; white-space: nowrap; }
.repo-config .repo-action .repo-action-arrow { display: none; }
.repo-config .repo-files-section {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    grid-column: 2;
    grid-row: 3;
    margin: 0;
    padding: .9rem;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
    box-shadow: none;
}
.repo-config .repo-files {
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: none;
    padding: .3rem;
    border-color: var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-bg);
}
.repo-config .repo-files-section .repo-files {
    max-height: none;
    background: var(--sg-bg);
}
.repo-tree-folder-button,
.repo-tree-file { border-radius: var(--sg-radius-sm); }
.repo-tree-folder-button { padding-block: .3rem; }
.repo-tree-file {
    min-height: 2rem;
    padding-block: .3rem;
}
.repo-tree-file > span {
    min-width: 0;
    font-family: inherit;
    font-size: 10px;
}
.repo-tree-empty { padding: 1.25rem .75rem; font-size: 11px; }
.repo-config .repo-hero,
.repo-config .repo-section,
.repo-config .repo-action,
.repo-browser .repo-card { transition-duration: .15s; }
.repo-dialog-footer {
    position: static;
    flex: 0 0 auto;
    min-height: 3.6rem;
    margin: auto -1.15rem -1.15rem;
    padding: .65rem 1.15rem;
    border-top-color: var(--sg-line);
    background: var(--sg-panel);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
.repo-continue-btn {
    min-height: 2.3rem;
    padding-inline: 1rem;
    border-color: #24558f;
    border-radius: 999px;
    background: #174b87;
    color: #f7f9ff;
    box-shadow: 0 3px 12px rgba(23, 75, 135, .18);
}
.repo-continue-btn:hover {
    border-color: #2b66a8;
    background: #1b5794;
    box-shadow: 0 5px 16px rgba(23, 75, 135, .24);
    transform: translateY(-1px);
}
.repo-change-selection {
    min-height: 2.4rem;
    padding: .4rem .8rem;
    border-color: var(--sg-line-strong);
    border-radius: 999px;
    background: var(--sg-panel);
    color: var(--sg-text-2);
}
.repo-change-selection:hover {
    border-color: rgba(255, 255, 255, .24);
    background: var(--sg-panel-2);
    color: var(--sg-text);
}
.repo-config .agent-input { border-radius: var(--sg-radius-sm); }
.repo-config .repo-hero::after { display: none; }

@media (max-width: 800px) {
    dialog.repo-dialog {
        width: min(96vw, 52rem);
        height: min(52rem, 94dvh);
        max-height: 94dvh;
    }
    .repo-dialog .app-dialog-body.repo-workspace {
        gap: .75rem;
        padding: .85rem;
        overflow-y: auto;
    }
    .repo-config {
        display: flex;
        flex: 0 0 auto;
        min-height: auto;
        flex-direction: column;
        overflow: visible;
    }
    .repo-config > .repo-section:not(.repo-files-section) { overflow: visible; }
    .repo-config .repo-files-section { min-height: 18rem; }
    .repo-config .repo-files { min-height: 12rem; max-height: 34dvh; }
    .repo-dialog-footer {
        position: sticky;
        bottom: -.85rem;
        margin: auto -.85rem -.85rem;
        padding-inline: .85rem;
    }
}
@media (max-width: 600px) {
    .repo-dialog .app-dialog-head { padding-inline: .85rem; }
    .repo-step { gap: .35rem; padding-inline: .25rem; }
    .repo-step small { font-size: 8px; }
    .repo-browser-head { align-items: stretch; flex-direction: column; gap: .7rem; }
    .repo-browser .repo-search { flex: 0 0 auto; }
    .repo-browser .repo-list { flex: 0 0 auto; min-height: 8rem; max-height: 34dvh; }
    .repo-config-heading { align-items: center; }
    .repo-config .repo-actions { grid-template-columns: 1fr; }
    .repo-config .repo-status { max-width: 100%; text-align: left; }
    .repo-dialog-footer > span { max-width: 55%; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-browser .repo-card,
    .repo-config .repo-hero,
    .repo-config .repo-action { transition: none; }
}

/* Repository picker and settings remain visible together so changing repositories
   never hides the branch, file tree, or actions the person is working with. */
html.dark dialog.repo-dialog {
    --repo-primary: #174b87;
    --repo-primary-hover: #1b5794;
    --repo-primary-border: #24558f;
    --repo-primary-hover-border: #2b66a8;
    --repo-primary-text: #f7f9ff;
}
dialog.repo-dialog {
    width: min(94vw, 82rem);
    height: min(52rem, 88dvh);
    max-height: 88dvh;
    border-radius: 22px;
    background: var(--sg-bg);
}
.repo-dialog .app-dialog-head {
    min-height: 4.25rem;
    padding: .8rem 1.15rem;
    background: var(--sg-panel);
}
.repo-dialog .app-dialog-body.repo-workspace {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: minmax(17rem, .78fr) minmax(0, 1.22fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: var(--sg-panel);
}
.repo-workspace .repo-stepper { display: none; }
.repo-workspace[data-step="select"] > .repo-config {
    display: grid;
}
.repo-workspace[data-step="actions"] > .repo-browser { display: flex; }
.repo-workspace > .repo-browser {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    padding: 1.1rem;
    border-right: 1px solid var(--sg-line);
    background: var(--sg-panel-2);
}
.repo-browser-head {
    display: grid;
    align-items: start;
    gap: .75rem;
}
.repo-browser-head > div:first-child > p {
    margin: .35rem 0 0 1.9rem;
    font-size: 11.5px;
}
.repo-browser-title { gap: .5rem; font-size: 13px; font-weight: 600; }
.repo-browser-title i {
    width: 1.35rem;
    height: 1.35rem;
    padding: .2rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-text-2);
}
.repo-browser .repo-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .4rem;
    margin-top: .2rem;
}
.repo-browser .repo-search .agent-input {
    min-width: 0;
    min-height: 2.45rem;
    grid-column: 1;
    border-radius: 999px;
    padding-left: 2.3rem;
}
.repo-search-icon { left: .85rem; }
.repo-open-btn,
.repo-browser .repo-mini-btn,
.repo-continue-btn {
    display: inline-flex;
    min-height: 2.4rem;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .95rem;
    border: 1px solid var(--repo-primary-border, var(--sg-accent));
    border-radius: 999px;
    background: var(--repo-primary, var(--sg-accent));
    color: var(--repo-primary-text, var(--sg-on-accent));
    font-size: 11px;
    font-weight: 550;
    box-shadow: 0 3px 12px color-mix(in srgb, var(--sg-accent) 18%, transparent);
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.repo-open-btn:hover:not(:disabled),
.repo-browser .repo-mini-btn:hover:not(:disabled),
.repo-continue-btn:hover:not(:disabled) {
    border-color: var(--repo-primary-hover-border, var(--sg-accent-hover));
    background: var(--repo-primary-hover, var(--sg-accent-hover));
    color: var(--repo-primary-text, var(--sg-on-accent));
    box-shadow: 0 5px 16px color-mix(in srgb, var(--sg-accent) 23%, transparent);
    transform: translateY(-1px);
}
.repo-open-btn:disabled,
.repo-browser .repo-mini-btn:disabled,
.repo-continue-btn:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.repo-open-btn:focus-visible,
.repo-browser .repo-mini-btn:focus-visible,
.repo-continue-btn:focus-visible,
.repo-change-selection:focus-visible,
.repo-action:focus-visible,
.repo-tree-folder-button:focus-visible,
.repo-tree-file:focus-visible {
    outline: 2px solid var(--sg-accent);
    outline-offset: 2px;
}
.repo-picker-label {
    margin: 1rem .1rem .45rem;
    color: var(--sg-text-2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.repo-picker-label-note { font-size: 9px; font-weight: 450; letter-spacing: 0; text-transform: none; }
.repo-browser .repo-list {
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: none;
    margin: 0;
    padding: .15rem .3rem .15rem 0;
    overflow: auto;
    overscroll-behavior: contain;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.repo-browser .repo-card {
    gap: .25rem;
    padding: .7rem .75rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
    animation: none;
    box-shadow: none;
}
.repo-browser .repo-card:hover:not(:disabled) {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    transform: none;
}
.repo-browser .repo-card[aria-selected="true"] {
    border-color: color-mix(in srgb, var(--sg-accent) 50%, var(--sg-line));
    background: var(--sg-accent-soft);
    box-shadow: inset 3px 0 0 var(--sg-accent);
}
.repo-browser .repo-list-foot {
    flex: 0 0 auto;
    margin: .6rem 0 0;
    padding: .65rem 0 0;
    border-top: 1px solid var(--sg-line);
}
.repo-browser .repo-mini-btn {
    min-height: 2.25rem;
    padding-inline: .8rem;
    font-size: 10px;
}
.repo-workspace > .repo-config {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    grid-template-columns: minmax(14rem, .82fr) minmax(0, 1.18fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: .7rem;
    padding: 1rem 1.1rem;
    overflow: hidden;
}
.repo-config-heading,
.repo-config > .repo-hero { grid-column: 1 / -1; }
.repo-config-heading { display: flex; align-items: center; }
.repo-config-eyebrow {
    color: var(--sg-text-3);
    font-size: 10px;
    font-weight: 550;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.repo-config-title { font-size: 15px; font-weight: 600; letter-spacing: 0; }
.repo-config .repo-hero {
    min-height: 3.75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel-2);
    box-shadow: none;
}
.repo-hero::after { display: none; }
.repo-config .repo-hero-avatar,
.repo-hero[data-state="ready"] .repo-hero-avatar {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-panel);
    color: var(--sg-accent);
    box-shadow: none;
    animation: none;
}
.repo-hero[data-state="ready"] .repo-hero-icon { display: block; }
.repo-hero[data-state="ready"] .repo-hero-initial { display: none; }
.repo-config .repo-hero-label { font-size: 12px; }
.repo-config .repo-hero-sub { font-size: 10px; }
.repo-config .repo-hero-instructions:not(.hidden) {
    display: block;
    overflow: hidden;
    color: var(--sg-text-3);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.repo-config > .repo-section:not(.repo-files-section) {
    grid-column: 1;
    grid-row: 3;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: .8rem;
    overflow-y: auto;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
}
.repo-config .repo-section-head { gap: .45rem; margin-bottom: .5rem; }
.repo-config .repo-section-head label { font-size: 11px; }
.repo-config .repo-status { max-width: 58%; font-size: 10px; }
.repo-config .repo-section .agent-input {
    min-height: 2.4rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-field);
}
.repo-config .repo-actions {
    grid-template-columns: 1fr;
    gap: .4rem;
    margin-top: .55rem;
}
.repo-config .repo-action {
    min-height: 2.35rem;
    justify-content: flex-start;
    gap: .55rem;
    padding: .4rem .65rem;
    border: 1px solid var(--sg-line-strong);
    border-radius: 999px;
    background: var(--sg-panel);
    color: var(--sg-text-2);
    text-align: left;
    transform: none;
}
.repo-config .repo-action:not(:disabled):hover {
    border-color: var(--sg-line-strong);
    background: var(--sg-hover);
    color: var(--sg-text);
    transform: none;
}
.repo-config .repo-action > i:first-child {
    width: 1rem;
    height: 1rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: currentColor;
}
.repo-action-copy { display: block; }
.repo-action-copy strong { font-size: 11px; font-weight: 550; white-space: normal; }
.repo-config .repo-action .repo-action-arrow { display: none; }
.repo-config .repo-note { margin: .6rem 0 0; font-size: 10px; }
.repo-config .repo-files-section {
    display: flex;
    grid-column: 2;
    grid-row: 3;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    margin: 0;
    padding: .8rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius);
    background: var(--sg-panel);
}
.repo-config .repo-files {
    display: block;
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: none;
    padding: .3rem;
    border: 1px solid var(--sg-line);
    border-radius: var(--sg-radius-sm);
    background: var(--sg-bg);
}
#file-tree {
    flex: 1 1 auto;
    min-height: 8rem;
    max-height: none;
}
.repo-tree-folder-button,
.repo-tree-file { min-height: 2rem; border-radius: var(--sg-radius-sm); }
.repo-tree-folder-button { padding-block: .3rem; }
.repo-tree-file { padding-block: .3rem; }
.repo-tree-folder-button > span { font-size: 11px; }
.repo-tree-file > span { min-width: 0; font-family: inherit; font-size: 11px; }
.repo-tree-empty { padding: 1.25rem .75rem; font-size: 12px; }
.repo-dialog-footer {
    position: static;
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 3.5rem;
    margin: 0;
    padding: .55rem 1.1rem;
    border-top: 1px solid var(--sg-line);
    background: var(--sg-panel);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
.repo-dialog-footer > span { max-width: min(70%, 38rem); font-size: 10px; }
.repo-continue-btn {
    flex: 0 0 auto;
    min-height: 2.35rem;
    padding-inline: 1.1rem;
}
.repo-change-selection { border-radius: 999px; }
@media (max-width: 1100px) and (min-width: 761px) {
    .repo-dialog .app-dialog-body.repo-workspace {
        grid-template-columns: minmax(15rem, .72fr) minmax(0, 1.28fr);
    }
    .repo-workspace > .repo-config {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto minmax(12rem, 1fr);
        overflow-y: auto;
    }
    .repo-config-heading,
    .repo-config > .repo-hero,
    .repo-config > .repo-section:not(.repo-files-section),
    .repo-config .repo-files-section { grid-column: 1; }
    .repo-config > .repo-section:not(.repo-files-section) { grid-row: 3; overflow: visible; }
    .repo-config .repo-files-section { grid-row: 4; min-height: 12rem; }
}
@media (max-width: 760px) {
    dialog.repo-dialog {
        width: min(96vw, 44rem);
        height: min(56rem, 94dvh);
        max-height: 94dvh;
    }
    .repo-dialog .app-dialog-body.repo-workspace {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .repo-workspace > .repo-browser {
        flex: 0 0 auto;
        min-height: 18rem;
        max-height: 48dvh;
        border-right: 0;
        border-bottom: 1px solid var(--sg-line);
    }
    .repo-browser .repo-list { min-height: 6rem; }
    .repo-workspace > .repo-config {
        display: grid;
        flex: 0 0 auto;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto minmax(14rem, 40dvh);
        gap: .65rem;
        padding: .9rem;
        overflow: visible;
    }
    .repo-config-heading,
    .repo-config > .repo-hero,
    .repo-config > .repo-section:not(.repo-files-section),
    .repo-config .repo-files-section { grid-column: 1; }
    .repo-config > .repo-section:not(.repo-files-section) { grid-row: 3; overflow: visible; }
    .repo-config .repo-files-section { grid-row: 4; min-height: 14rem; }
    .repo-config .repo-files { min-height: 10rem; }
    .repo-dialog-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        flex: 0 0 auto;
        min-height: 3.5rem;
    }
}
@media (max-width: 480px) {
    .repo-dialog .app-dialog-head { min-height: 3.8rem; padding: .7rem .8rem; }
    .repo-dialog .app-dialog-head h2 { font-size: 13px; }
    .repo-dialog .repo-dialog-sub { margin-left: 1.5rem; font-size: 10px; }
    .repo-workspace > .repo-browser { min-height: 16rem; padding: .8rem; }
    .repo-picker-label { margin-top: .75rem; }
    .repo-browser .repo-card { padding: .6rem; }
    .repo-config .repo-section-head { align-items: center; }
    .repo-dialog-footer { gap: .55rem; padding-inline: .75rem; }
    .repo-dialog-footer > span { max-width: 58%; font-size: 9px; }
    .repo-continue-btn { min-height: 2.25rem; padding-inline: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
    .repo-open-btn,
    .repo-browser .repo-mini-btn,
    .repo-continue-btn { transition: none; }
}

/* ---- GitHub access strip, recents, pinned files ---- */
.github-access { display: flex; align-items: center; gap: .7rem; margin: .6rem 0 .5rem; padding: .6rem .75rem; border: 1px solid var(--sg-line); border-radius: var(--sg-radius-md, .75rem); background: var(--sg-hover); }
.github-access-icon { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; flex: 0 0 auto; border-radius: 999px; background: var(--sg-panel, transparent); border: 1px solid var(--sg-line); }
.github-access-text { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: .1rem; }
.github-access-text strong { font-size: 11px; font-weight: 600; color: var(--sg-text); }
.github-access-text small { font-size: 10px; line-height: 1.35; color: var(--sg-text-3); }
.github-access-actions { display: flex; flex: 0 0 auto; gap: .35rem; }
.github-access[data-state="connected"] .github-access-icon { border-color: #34d399; }
.github-access[data-state="disconnected"] { border-color: var(--sg-accent); }
.github-access[data-state="unavailable"] .github-access-icon { border-color: #f59e0b; }
.repo-recents { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .5rem; }
.repo-recent { max-width: 9rem; overflow: hidden; padding: .2rem .6rem; border: 1px solid var(--sg-line); border-radius: 999px; background: transparent; color: var(--sg-text-2); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.repo-recent:hover:not(:disabled) { background: var(--sg-hover); color: var(--sg-text); }
.repo-hero-access { display: block; margin-top: .2rem; font-size: 10px; color: var(--sg-text-3); }
.repo-hero-access[data-access="write"] { color: #34d399; }
.repo-hero-access[data-access="read"] { color: #f59e0b; }
.pinned-list { display: flex; flex-direction: column; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.pinned-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem .5rem; border: 1px solid var(--sg-line); border-radius: .5rem; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 10px; color: var(--sg-text-2); }
.pinned-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinned-remove { border: 0; background: transparent; color: var(--sg-text-3); font-size: 14px; line-height: 1; cursor: pointer; }
.pinned-remove:hover { color: var(--sg-text); }
.pinned-empty { font-size: 10px; color: var(--sg-text-3); }
.repo-tree-row { position: relative; }
.repo-tree-row > .repo-tree-file { width: 100%; padding-right: 1.75rem; }
.repo-tree-pin { position: absolute; top: 50%; right: .4rem; transform: translateY(-50%); border: 0; background: transparent; color: var(--sg-text-3); font-size: 11px; cursor: pointer; opacity: 0; }
.repo-tree-row:hover .repo-tree-pin, .repo-tree-row[data-pinned="true"] .repo-tree-pin, .repo-tree-pin:focus-visible { opacity: 1; }
.repo-tree-row[data-pinned="true"] .repo-tree-pin { color: #f59e0b; }

/* ---- Logos: the white artwork is darkened on light backgrounds ---- */
html:not(.dark) .sg-logo-full, html:not(.dark) .sg-logo-mark { filter: brightness(0) opacity(.82); }
.sidebar-logo { height: 24px; width: auto; max-width: 100%; }
