* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Warm taupe / stone theme */
:root {
    --color-bg: #1f1f1e;
    --color-surface: #2c2c2a;
    --color-surface-mid: #35332f;
    /* Primary UI text */
    --color-text: #97958c;
    /* Higher-contrast text (headings, active states) */
    --color-text-bright: #c3c2b7;
    --color-border: #3a3834;
    --color-border-subtle: #2d2c28;
    --color-muted: rgba(151, 149, 140, 0.62);

    /* Subtle warm accent (low-saturation, Claude-like) */
    --color-accent: #bdb19b;
    --color-accent-strong: #a79a82;
    --color-accent-soft: rgba(189, 177, 155, 0.10);
    --color-accent-border: rgba(189, 177, 155, 0.28);
    --color-accent-glow: rgba(189, 177, 155, 0.16);
    --color-accent-text-soft: rgba(209, 199, 180, 0.92);
}

html, body {
    height: 100%;
    width: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    overflow: hidden;
}

.hidden { display: none !important; }

/* ── [BETA] Image attach UI ─────────────────────────────────────────────── */
.beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    color: var(--color-accent-text-soft);
    background: rgba(189, 177, 155, 0.12);
    border: 1px solid var(--color-accent-border);
    border-radius: 999px;
}

.beta-image-attach {
    margin-bottom: 10px;
    padding: 10px 10px;
    background: rgba(53, 51, 47, 0.55);
    border: 1px solid rgba(189, 177, 155, 0.22);
    border-radius: 12px;
}

.beta-image-attach__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.beta-image-attach__title {
    color: var(--color-text-bright);
    font-weight: 550;
    font-size: 12.5px;
}

.beta-image-attach__remove {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: rgba(44, 44, 42, 0.6);
    color: var(--color-text-bright);
    cursor: pointer;
}
.beta-image-attach__remove:hover {
    border-color: rgba(189, 177, 155, 0.35);
    background: rgba(44, 44, 42, 0.9);
}

.beta-image-attach__body {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
    align-items: center;
}

.beta-image-attach__preview {
    width: 72px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(58, 56, 52, 0.9);
    background: rgba(31, 31, 30, 0.7);
}

.beta-image-attach__name {
    color: var(--color-text-bright);
    font-size: 12px;
    margin-bottom: 4px;
}

.beta-image-attach__status {
    color: var(--color-muted);
    font-size: 12px;
}

/* Drop highlight */
.beta-drop-active {
    outline: 2px dashed rgba(189, 177, 155, 0.45);
    outline-offset: 4px;
}

/* Attachment corner indicator (paperclip wrapping the bubble) */
.message--has-attach .message-content {
    position: relative;
    padding-top: 18px; /* room for the corner badge */
}

.attach-corner {
    position: absolute;
    top: -10px;
    left: 10px;
    width: 44px;
    height: 26px;
    border-radius: 12px;
    border: 1px solid rgba(189, 177, 155, 0.28);
    background: rgba(31, 31, 30, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--color-accent-text-soft);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.attach-corner__clip {
    opacity: 0.9;
}
.attach-corner__glyph {
    opacity: 0.95;
}

/* One-shot notice when auto-merge saved profile to disk */
.memory-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    max-width: min(420px, 92vw);
    padding: 10px 16px;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--color-text-bright);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    z-index: 900;
    display: none;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 0;
    pointer-events: none;
    text-align: center;
}
.memory-toast.memory-toast--show {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* ── Auth Overlay ── */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-box {
    width: 100%;
    max-width: 340px;
    padding: 40px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    text-align: center;
}

.auth-title {
    font-size: 30px;
    font-weight: 650;
    color: var(--color-text-bright);
    text-align: center;
    margin-bottom: 22px;
    letter-spacing: -0.02em;
}

#login-form,
#register-form,
#change-password-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#login-form input,
#register-form input,
#change-password-form input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--color-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    text-align: left;
}

#login-form input:focus,
#register-form input:focus,
#change-password-form input:focus {
    border-color: #5a5a6e;
}

#login-form input::placeholder,
#register-form input::placeholder,
#change-password-form input::placeholder {
    color: #666;
}

.auth-btn {
    margin-top: 8px;
    padding: 11px;
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    align-self: center;
    padding-left: 32px;
    padding-right: 32px;
    transition: background 0.2s, border-color 0.2s;
    font-family: inherit;
}

#login-form .auth-btn,
#register-form .auth-btn {
    min-width: 180px;
}

.auth-btn:hover {
    background: #333338;
    border-color: #4a4a5e;
}

.auth-toggle {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
}

.auth-toggle span {
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}

.auth-toggle span:hover {
    color: var(--color-text);
}

.auth-message {
    font-size: 12px;
    text-align: center;
    margin-top: 10px;
    min-height: 16px;
    color: #ef4444;
}

/* ── Modal ── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(12, 11, 9, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 24px 16px;
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 28px 28px 26px;
    width: 100%;
    max-width: 360px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 24px 64px rgba(0, 0, 0, 0.55);
}

.modal-content--compact {
    max-width: 380px;
}

.project-modal .modal-header {
    margin-bottom: 18px;
}

.modal-input {
    display: block;
    width: 100%;
    margin-bottom: 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--color-text-bright);
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-input::placeholder {
    color: var(--color-muted);
}

.modal-input:focus {
    border-color: var(--color-accent-border);
    box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.project-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.auth-btn--primary {
    margin-top: 4px;
    background: linear-gradient(180deg, rgba(189, 177, 155, 0.22), rgba(189, 177, 155, 0.08));
    border-color: var(--color-accent-border);
    color: var(--color-text-bright);
    font-weight: 600;
}

.auth-btn--primary:hover {
    background: rgba(189, 177, 155, 0.2);
    border-color: rgba(189, 177, 155, 0.45);
    color: #e8e6df;
}

/* ── Settings hub (prototype) ── */
.settings-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-top-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.settings-top-tab {
    border: 1px solid var(--color-border);
    background: rgba(0,0,0,0.10);
    color: var(--color-text);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    user-select: none;
}
.settings-top-tab:hover {
    background: rgba(189, 177, 155, 0.10);
    border-color: var(--color-accent-border);
}
.settings-top-tab--active {
    background: rgba(189, 177, 155, 0.16);
    border-color: rgba(189, 177, 155, 0.34);
    color: var(--color-text-bright);
}

.settings-panels {
    min-height: 240px;
}
.settings-panel {
    display: none;
}
.settings-panel.settings-panel--active {
    display: block;
}

.settings-section {
    margin-top: 12px;
}
.settings-section:first-child {
    margin-top: 0;
}

.settings-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-muted);
    line-height: 1.35;
}

.settings-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.settings-action {
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: 12px;
    padding: 12px 12px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.settings-action:hover {
    background: rgba(255,255,255,0.03);
    border-color: rgba(189, 177, 155, 0.32);
}
.settings-action:active {
    transform: translateY(1px);
}

.settings-action--danger {
    border-color: rgba(255, 120, 120, 0.35);
    background: rgba(255, 120, 120, 0.06);
    color: #ffd7d7;
}
.settings-action--danger:hover {
    border-color: rgba(255, 120, 120, 0.55);
    background: rgba(255, 120, 120, 0.10);
}

.session-list {
    margin-top: 10px;
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    background: rgba(0,0,0,0.12);
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.session-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.16);
    margin-bottom: 8px;
}
.session-item:last-child {
    margin-bottom: 0;
}
.session-item.is-current {
    border-color: rgba(189, 177, 155, 0.32);
    background: rgba(189, 177, 155, 0.08);
}
.session-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.session-title {
    font-size: 13px;
    color: var(--color-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-sub {
    font-size: 12px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--color-muted);
    background: rgba(0,0,0,0.18);
    flex: 0 0 auto;
}
.session-revoke-btn {
    margin-left: auto;
    flex: 0 0 auto;
}

@media (max-width: 520px) {
    .settings-actions-grid {
        grid-template-columns: 1fr;
    }
}

.modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-bright);
    margin: 0;
    text-align: center;
    letter-spacing: -0.02em;
}

/* ── App Layout ── */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ── Sidebar ── */
.sidebar {
    width: 56px;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
    overflow-x: hidden;
    transition:
        width 0.26s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.24s ease,
        align-items 0.2s ease;
}

.sidebar--expanded {
    width: 190px;
    align-items: stretch;
    padding: 12px 10px;
}

.sidebar-top,
.sidebar-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.sidebar--expanded .sidebar-top,
.sidebar--expanded .sidebar-mid,
.sidebar--expanded .sidebar-bottom {
    align-items: stretch;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    /* Push the utility stack to the bottom, without inserting extra space *between* its items */
    margin-top: auto;
    width: 100%;
}

.sidebar-bottom-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.sidebar-tools-sep {
    width: 100%;
    height: 1px;
    margin: 2px 0;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-bottom-account {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin-top: auto;
}

.sidebar--expanded .sidebar-bottom-tools,
.sidebar--expanded .sidebar-bottom-account {
    align-items: stretch;
}

.sidebar--expanded .sidebar-tools-sep {
    margin: 4px 10px;
    width: auto;
}

.sidebar-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--color-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font: inherit;
    text-decoration: none;
    font-weight: 500;
}

a.sidebar-btn {
    /* Match button styling (anchors have UA defaults) */
    color: var(--color-muted);
}

.sidebar-label {
    display: none;
    margin-left: 10px;
    font-size: 12.5px;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.sidebar--expanded .sidebar-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 0 10px;
    gap: 10px;
}

.sidebar--expanded .sidebar-label {
    display: inline;
    margin-left: 0;
    opacity: 1;
}

.sidebar-btn:hover {
    background: var(--color-surface-mid);
    color: var(--color-text);
}

a.sidebar-btn:hover {
    color: var(--color-text);
}

.sidebar-btn.user-avatar {
    /* Same row geometry as other sidebar buttons */
    cursor: default;
    /* Inherit the same muted row color as other sidebar buttons */
    color: inherit;
}

.sidebar--expanded .sidebar-btn.user-avatar {
    min-width: 0;
}

.sidebar-btn > svg {
    width: 20px;
    height: 20px;
    display: block;
    flex: 0 0 20px;
}

.user-avatar-initial {
    /* Slightly larger than icon slot (~1.2×) */
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* User-requested PFP palette */
    color: #1f1f1e;
    background: #6a6862;
    border: 1px solid #35332f;
    font-weight: 400;
    font-size: 13px;
    line-height: 1;
    flex: 0 0 24px;
    box-sizing: border-box;
}

.user-avatar-name {
    display: none;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Match other sidebar button labels */
    font-family: inherit;
    font-size: 12.5px;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    /* Same token as `.sidebar-label` */
    color: var(--color-text);
    text-align: left;
    min-width: 0;
}

.sidebar--expanded .user-avatar-name {
    display: inline;
}

/* ── Main ── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.workspace {
    flex: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
}

.workspace-chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.artifact-resizer {
    width: 8px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    flex: 0 0 auto;
}
.artifact-resizer::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 3px;
    right: 3px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Right project sidebar (exact mirror of left .sidebar) ───────────────── */
.artifact-pane {
    width: 56px;
    height: 100%;
    background: #1f1f1e;
    border-left: 1px solid #2d2c28;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
    overflow: hidden;
    transition:
        width 0.26s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.24s ease,
        align-items 0.2s ease;
}

.artifact-pane[hidden] { display: none; }

.artifact-pane--expanded {
    width: 260px;
    align-items: stretch;
    padding: 12px 10px;
}

/* Top section holds the expand button */
.artifact-pane-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.artifact-pane--expanded .artifact-pane-top {
    align-items: stretch;
}

/* Expand button — mirrors .sidebar-btn */
.artifact-pane-expand-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font: inherit;
    font-weight: 500;
    flex-shrink: 0;
}
.artifact-pane-expand-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e5e7eb;
}
.artifact-pane--expanded .artifact-pane-expand-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 0 10px;
    gap: 10px;
}

/* Label hidden when collapsed, shown when expanded — mirrors .sidebar-label */
.artifact-pane-label {
    display: none;
    font-size: 12.5px;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.artifact-pane--expanded .artifact-pane-label {
    display: inline;
    opacity: 1;
}

/* Content area — hidden when collapsed */
.artifact-pane-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}
.artifact-pane-content[hidden] { display: none; }

/* Staggered fade-in for content children */
.artifact-pane-content > * {
    animation: apItemIn 0.2s ease-out both;
}
.artifact-pane-content > *:nth-child(1) { animation-delay: 20ms; }
.artifact-pane-content > *:nth-child(2) { animation-delay: 60ms; }
.artifact-pane-content > *:nth-child(3) { animation-delay: 100ms; }

@keyframes apItemIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.artifact-pane-section-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #6b7280;
    text-transform: uppercase;
    padding: 10px 4px 6px;
}

.artifact-pane-title-sub { font-size: 11px; color: #6b7280; }

.artifact-pane-body {
    display: block;
    min-height: 0;
    flex: 1;
}

.artifact-pane-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.artifact-pane-files {
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.artifact-pane-filelist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.artifact-pane-file {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #3a3936;
    background: #2d2c28;
    cursor: pointer;
    color: #d1d5db;
    font-size: 12px;
    min-width: 0;
    transition: background 0.15s, border-color 0.15s;
}
.artifact-pane-file:hover {
    background: #3a3936;
    border-color: #4a4945;
}
.artifact-pane-file.is-active {
    border-color: #6b7280;
    background: #3a3936;
}
.artifact-pane-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.artifact-pane-file-badge {
    font-size: 10px;
    color: #9ca3af;
    border: 1px solid #4a4945;
    padding: 2px 6px;
    border-radius: 999px;
    background: #2d2c28;
}
.artifact-pane-actions {
    padding: 0 8px 10px;
    flex-shrink: 0;
}

.artifact-pane-view {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.artifact-pane-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.artifact-tab {
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: #9ca3af;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
}
.artifact-tab--active {
    color: var(--color-text-bright);
    border-color: var(--color-border);
    background: rgba(72, 58, 39, 0.28);
}
.artifact-code {
    margin: 0;
    padding: 12px 14px;
    overflow: auto;
    flex: 1;
    min-height: 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--color-text);
    background: transparent;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    display: block;
    white-space: pre;
}

.artifact-preview {
    border: none;
    flex: 1;
    min-height: 0;
    width: 100%;
    background: #1f1f1e;
    display: none;
}

.artifact-pop {
    position: fixed;
    left: 76px;
    right: 316px;
    top: 72px;
    bottom: 24px;
    width: auto;
    height: auto;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    background: rgba(28, 27, 26, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

/* Backdrop behind the popup — blurs chat + sidebars */
.artifact-pop-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 19;
}
.artifact-pop-backdrop[hidden] { display: none; }

/* Ensure HTML `hidden` wins over `.artifact-pop { display: flex; }` */
.artifact-pop[hidden] {
    display: none !important;
}

.artifact-pane[hidden] {
    display: none !important;
}

.artifact-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-subtle);
    background: rgba(72, 58, 39, 0.12);
    gap: 10px;
}
.artifact-pop-title {
    color: var(--color-text-bright);
    font-weight: 650;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.artifact-pop-actions { display: flex; align-items: center; gap: 8px; }

/* ── Top bar ── */
.topbar {
    position: absolute;
    top: 0;
    right: 0;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

.topbar-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}
.topbar-btn:hover {
    color: #e5e7eb;
    background: rgba(255,255,255,0.06);
}
.topbar-label {
    white-space: nowrap;
    font-size: 10px;
}

.context-info--footer {
    padding: 0;
    border: none;
    gap: 0;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
}

.context-info--footer .context-bar {
    gap: 0;
    margin: 0;
    padding: 0;
}

.context-info--footer .context-circle-container {
    width: 30px;
    height: 30px;
}

.context-info--footer .context-circle-text {
    font-size: 10px;
}

/* No extra info next to the circle in footer */

.status-pills {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-pill {
    font-size: 11px;
    color: #555;
}

.queue-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Hide buggy queue dots in the top bar */
#queue-indicator {
    display: none !important;
}

.queue-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent-strong);
    animation: pulse 0.8s ease-in-out infinite;
}

.queue-status {
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(107, 114, 128, 0.1);
    transition: color 0.2s ease;
}

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

/* ── Context info ── */
.context-info {
    display: flex;
    flex-direction: column;
    padding: 12px 24px 14px;
    border-bottom: 1px solid var(--color-border-subtle);
    flex-shrink: 0;
    gap: 8px;
}

.context-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 11px;
    min-width: 0;
}

/* Circular progress indicator */
.context-circle-container {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.context-circle-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.context-circle-bg {
    fill: none;
    stroke: var(--color-surface-mid);
    stroke-width: 3.5;
}

.context-circle-fill {
    fill: none;
    stroke: #c4c0b8;
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-dasharray: 176;
    stroke-dashoffset: 176;
    transition: stroke-dashoffset 0.35s ease;
}

.context-circle-fill.progress-fill--high {
    stroke: #d2cec6;
    filter: drop-shadow(0 0 6px rgba(196, 192, 184, 0.3));
}

.context-circle-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-text-bright);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    width: 100%;
    text-align: center;
}

.context-meta {
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--color-muted);
    min-width: 0;
    display: block;
}

.context-meta[hidden] {
    display: none;
}

.context-meta .context-meta-sep {
    color: #3e3e44;
    margin: 0 0.15em;
}

.context-meta .context-meta-search {
    color: #5d5d66;
}

.chunks-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    margin-top: 8px;
}

.chunk-item {
    background: var(--color-surface-mid);
    border-left: 2px solid #3a3a4e;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    color: #888;
}

.chunk-module {
    color: var(--color-accent);
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.chunk-similarity {
    color: #555;
    font-size: 10px;
    margin-top: 2px;
}

/* ── Chat history ── */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: var(--color-surface-mid); border-radius: 2px; }

/* ── Home screen ── */
.home-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.greeting {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 40px;
    font-weight: 400;
    color: var(--color-text);
    letter-spacing: -0.5px;
}

/* ── Messages ── */
.message {
    display: flex;
    padding: 0 max(24px, calc(50% - 360px));
    margin-bottom: 4px;
    animation: fadeUp 0.2s ease-out;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.message.status { justify-content: center; }

.message--cull-spacer {
    justify-content: center;
    margin-bottom: 4px;
}

.message--cull-spacer .message-content {
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.08);
}

.cull-spacer-restore {
    width: 100%;
    margin: 0;
    padding: 8px 10px;
    font: inherit;
    font-size: 12px;
    color: var(--color-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.cull-spacer-restore:hover {
    color: var(--color-text-bright);
    background: rgba(255, 255, 255, 0.05);
}

.message-content {
    max-width: 680px;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.65;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: var(--color-surface);
    color: var(--color-text-bright);
    border-radius: 18px 18px 4px 18px;
}

.message.assistant .message-content {
    background: transparent;
    color: var(--color-text);
    padding-left: 0;
}

.message.status .message-content {
    background: transparent;
    color: #555;
    font-size: 12px;
    font-style: italic;
}

/* Markdown */
.message-content strong { font-weight: 600; color: var(--color-text-bright); }
.message-content em { font-style: italic; }

.message-content h1 { font-size: 22px; font-weight: 600; color: var(--color-text-bright); margin: 16px 0 8px; }
.message-content h2 { font-size: 18px; font-weight: 600; color: var(--color-text-bright); margin: 14px 0 6px; }
.message-content h3 { font-size: 15px; font-weight: 600; color: var(--color-text-bright); margin: 12px 0 4px; }
.message-content h4 { font-size: 17px; font-weight: 600; color: var(--color-text-bright); margin: 14px 0 6px; letter-spacing: -0.02em; }

.message-content code {
    background: var(--color-surface-mid);
    color: var(--color-accent-text-soft);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
}

/* Fenced code: wrapper + scrollable pre + copy (top-right) */
.code-block-wrap {
    position: relative;
    margin: 12px 0;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    overflow: hidden;
    max-width: 100%;
}

.code-block-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    color: #9ca3af;
    background: rgba(26, 26, 28, 0.94);
    border: 1px solid #3a3a42;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.code-block-copy:hover {
    color: #e5e7eb;
    border-color: #52525b;
    background: #252529;
}

.code-block-pre {
    margin: 0;
    border: none;
    border-radius: 0;
    padding: 38px 14px 14px 16px;
    overflow: auto;
    /* Scrollable without showing scrollbars (wheel / trackpad / touch still work). */
    scrollbar-width: none;
    -ms-overflow-style: none;
    max-height: 400px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    background: transparent;
    --keyword: var(--color-accent);
    --type: #4ec9b0;
    --string: #ce9178;
    --comment: #6a9955;
    --number: #b5cea8;
}

.code-block-pre::-webkit-scrollbar:vertical {
    width: 0;
}

.code-block-pre code {
    background: transparent;
    color: #e8e8e8;
    padding: 0;
    font-size: inherit;
    line-height: inherit;
    font-family: inherit;
    display: block;
}

.wlm-md .code-block-wrap {
    margin: 8px 0;
}

.artifact-stream-preview .code-block-pre {
    padding-top: 8px;
    max-height: 320px;
}

.artifact-stream-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255,255,255,0.03);
    font-size: 11px;
}

.artifact-stream-lang {
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.85;
}

.artifact-stream-name {
    color: #9ca3af;
    font-family: 'SF Mono', Monaco, monospace;
}

.message-content p { margin: 6px 0; color: var(--color-text); }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }

.message-content a {
    color: var(--color-accent-text-soft);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.message-content a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

/* Live plan streaming display */
.plan-live {
    padding: 12px 14px;
    border-left: 3px solid var(--color-accent);
    background: var(--color-accent-glow);
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text);
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: planPulse 1.2s ease-in-out infinite;
}

@keyframes planPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Large number formatting for scientific notation and extreme exponents */
.number-scientific {
    display: inline-block;
    word-spacing: 0.1em;
    font-feature-settings: 'tnum';
}

.number-large-exponent {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8em;
    vertical-align: super;
}

sup {
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 480px) {
    .number-large-exponent {
        max-width: 100px;
        font-size: 0.7em;
    }
}

.message-content ul {
    list-style: none;
    padding-left: 0;
    margin: 8px 0;
    color: var(--color-text);
}

.message-content li {
    margin: 4px 0;
    padding-left: 20px;
    position: relative;
}

.message-content li:before {
    content: '•';
    position: absolute;
    left: 0;
    color: #666;
}

/* Thinking indicator */
.thinking-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px max(24px, calc(50% - 360px));
    margin: 2px 0;
    font-size: 13px;
    font-style: italic;
    color: #6b7280;
    animation: fadeUp 0.2s ease-out;
}

.thinking-indicator--knowledge { color: var(--color-accent); }
.thinking-indicator--modules   { color: #6ee7b7; }
.thinking-indicator--think     { color: #9ca3af; }
.thinking-indicator--default   { color: #6b7280; }
.thinking-indicator--wait      { color: var(--color-accent); }
.thinking-indicator--learning  { color: var(--color-accent); }

.thinking-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50%       { opacity: 1;    transform: scale(1.15); }
}

.thinking-indicator--wait .thinking-pulse-dot {
    animation-duration: 0.9s;
}

.thinking-text {
    flex: 1;
    min-width: 0;
}

.thinking-timer {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    opacity: 0.7;
    margin-left: 8px;
    white-space: nowrap;
    font-style: italic;
}

/* ── Input area ── */
.input-area {
    padding: 0 max(24px, calc(50% - 380px)) 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.selected-modules {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 0;
}

.module-tag {
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent-border);
    color: var(--color-accent-text-soft);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.module-tag--enter {
    animation: moduleTagPop 0.5s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

@keyframes moduleTagPop {
    from {
        transform: scale(0.65) rotate(-4deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.06) rotate(1deg);
    }
    to {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.input-box {
    position: relative;
    z-index: 4;
    overflow: visible;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 10px 12px 8px;
    transition: border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-box:focus-within {
    border-color: #5a5850;
}

#prompt-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    flex: 0 1 auto;
    /* One text line until content / JS auto-resize needs more */
    min-height: calc(1em * 1.6);
    min-height: 1lh;
    align-self: stretch;
    box-sizing: border-box;
}

#prompt-input::placeholder {
    color: var(--color-muted);
}

.input-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* Desktop / tablet: composer height follows content (single-line stays compact). */
@media (min-width: 641px) {
    #prompt-input {
        flex: 0 1 auto;
    }
}

.input-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.model-profile-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.model-profile-btn {
    height: 26px;
    /* Dynamic width: shrink to content, cap to avoid eating the input area. */
    width: fit-content;
    max-width: min(260px, 36vw);
    padding: 0 6px 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-muted);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.model-profile-label {
    /* Don't expand to fill the button; keep chevron tight to text.
       Still allow shrinking so long names ellipsize. */
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.model-profile-chevron {
    flex: 0 0 auto;
    margin-left: 0;
    opacity: 0.75;
    transition: transform 0.2s ease;
}

.model-profile-btn:hover {
    background: var(--color-surface-mid);
    border-color: #4a4842;
    color: var(--color-text);
}

.model-profile-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(176, 172, 164, 0.35);
}

.model-profile-btn.model-profile-btn--open {
    border-color: #4a4842;
    background: rgba(72, 58, 39, 0.18);
    color: var(--color-text-bright);
}

.model-profile-btn.model-profile-btn--open .model-profile-chevron {
    transform: rotate(180deg);
}

/* Match `.agent-prefs-panel` stacking + surface tokens (avoid bespoke glass rules). */
.model-profile-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    top: auto;
    z-index: 55;
    min-width: 232px;
    max-width: min(320px, calc(100vw - 48px));
    padding: 9px 10px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.model-profile-menu .agent-prefs-panel-head {
    margin: 0;
}

/* `display: flex` above wins over the UA [hidden] rule in some engines — force closed state */
.model-profile-menu[hidden] {
    display: none !important;
}

.model-profile-item {
    width: auto;
    text-align: left;
    padding: 6px 10px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-bright);
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-profile-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: #3a3a3e;
}

.model-profile-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(176, 172, 164, 0.35);
}

.model-profile-item.is-active {
    background: rgba(72, 58, 39, 0.18);
    border-color: #4a4842;
    color: var(--color-text-bright);
}

/* Desktop: wider, single-line list, cleaner spacing */
@media (min-width: 900px) {
    .model-profile-menu {
        /* Size to longest entry; cap to viewport */
        width: fit-content;
        min-width: 0;
        max-width: min(720px, calc(100vw - 80px));
        padding: 10px 12px 12px;
        gap: 5px;
    }
    .model-profile-item {
        padding: 6px 10px;
        font-size: 11px;
    }
    .model-profile-menu .agent-prefs-panel-head {
        font-size: 9px;
        padding-bottom: 2px;
    }
}

.input-right .context-info--footer {
    /* Override `.context-info` base styles (padding/borders) */
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-start;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-bottom: 0 !important;
    gap: 0 !important;
    flex-direction: row !important;
    width: auto !important;
}

.input-right .context-info--footer .context-bar {
    display: inline-flex;
    align-items: center;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.send-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #b0aca4;
    border: none;
    border-radius: 8px;
    color: #1f1f1e;
    cursor: pointer;
    transition: opacity 0.15s;
}

.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Chips ── */
.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--color-border);
    /* Match the rest of the UI (auth buttons, modal actions): subtle rounding, not pill */
    border-radius: 10px;
    color: var(--color-muted);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.chip:hover {
    background: var(--color-surface-mid);
    border-color: #4a4842;
    color: var(--color-text);
}

/* ── Agent prefs (dropdown inside input bar) ── */
.agent-prefs-inline {
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.agent-prefs-toggles {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
}

.agent-prefs-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    min-height: 30px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.agent-prefs-toggle-compact {
    color: var(--color-text);
    opacity: 0.92;
}

.agent-prefs-toggle:hover {
    color: var(--color-text);
    border-color: #3a3a3e;
    background: rgba(255, 255, 255, 0.03);
}

.agent-prefs-toggle--open {
    border-color: #4a4842;
    background: rgba(72, 58, 39, 0.18);
    color: var(--color-text-bright);
}

.agent-prefs-toggle--open .agent-prefs-chevron {
    transform: rotate(180deg);
}

.agent-prefs-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
    opacity: 0.75;
}

.agent-prefs-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    top: auto;
    z-index: 50;
    min-width: 232px;
    max-width: min(320px, calc(100vw - 48px));
    padding: 10px 12px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tokens-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tokens-row input[type="range"] {
    flex: 1;
}

.tokens-val {
    min-width: 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-bright);
    font-size: 12px;
    font-weight: 600;
}

.results-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.results-row input[type="range"] {
    flex: 1;
}

.results-val {
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-bright);
    font-size: 12px;
    font-weight: 600;
}

.search-depth-row {
    flex-wrap: wrap;
}

.search-depth-row input[type="range"] {
    flex: 1;
}

/* ── Range sliders (tokens/admin) ── */
input[type="range"]{
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    background: transparent;
    cursor: pointer;
}

/* Track: filled = #b0aca4, unfilled = #6f6d67 (via --range-pct set in JS) */
input[type="range"]::-webkit-slider-runnable-track{
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, #b0aca4 0%, #b0aca4 var(--range-pct, 50%), #6f6d67 var(--range-pct, 50%), #6f6d67 100%);
}
input[type="range"]::-webkit-slider-thumb{
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-top: -4px;
    background: #2c2c2a;
    border: 2px solid #b0aca4;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.18);
}

/* Firefox */
input[type="range"]::-moz-range-track{
    height: 6px;
    border-radius: 999px;
    background: #6f6d67;
}
input[type="range"]::-moz-range-progress{
    height: 6px;
    border-radius: 999px;
    background: #b0aca4;
}
input[type="range"]::-moz-range-thumb{
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2c2c2a;
    border: 2px solid #b0aca4;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.18);
}

.search-depth-ticks {
    flex-basis: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    margin-top: -4px;
    font-size: 10px;
    color: #4b5563;
}

.search-depth-ticks span { flex: 1; text-align: center; }
.search-depth-ticks span:first-child { text-align: left; }
.search-depth-ticks span:last-child { text-align: right; }

.search-depth-rec {
    flex-basis: 100%;
    margin-top: 4px;
    padding-left: calc(17.6% - 4px);
    font-size: 10px;
    color: #4b5563;
}

.search-depth-rec::before {
    content: '|';
    margin-right: 4px;
    color: #4b5563;
}

/* `display: flex` above wins over the UA [hidden] rule in some engines — force closed state */
.agent-prefs-panel[hidden] {
    display: none !important;
}

.agent-prefs-panel-head {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    padding-bottom: 2px;
    border-bottom: 1px solid var(--color-border);
}

/* Popover body copy: avoid cool slate grays that read “blue” on dark UI */
.agent-prefs-panel .effort-hint,
.agent-prefs-panel .agent-pref-hint {
    color: var(--color-muted);
}

.agent-pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.agent-pref-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.agent-pref-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
}

.agent-pref-hint {
    font-size: 10px;
    line-height: 1.25;
    color: #6b7280;
    max-width: 160px;
}

/* Toggle switch (checkbox + slider) */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--color-surface-mid);
    border-radius: 22px;
    transition: background 0.2s;
}

.switch-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #9a978c;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-slider {
    background: #3a3834;
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
    background: #f3f2ed;
}

.switch input:focus-visible + .switch-slider {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ── Web Search UI ── */
.web-search-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px max(24px, calc(50% - 360px));
    color: #888;
    font-size: 13px;
    font-style: italic;
    animation: fadeUp 0.25s ease-out;
    position: relative;
}

.web-search-indicator--active .web-search-svg {
    animation: webSearchIconPulse 1.2s ease-in-out infinite;
}

.web-search-glow {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-accent-glow) 0%, transparent 70%);
    animation: webSearchGlow 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes webSearchGlow {
    0%, 100% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.9; }
}

@keyframes webSearchIconPulse {
    0%, 100% { transform: scale(1); opacity: 0.75; }
    50% { transform: scale(1.08); opacity: 1; }
}

.web-search-label {
    font-style: italic;
    color: var(--color-accent-text-soft);
}

.web-search-timer {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--color-muted);
    margin-left: 8px;
    white-space: nowrap;
}

.web-search-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.web-search-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: webSearchDotBounce 0.9s ease-in-out infinite;
}

.web-search-dots span:nth-child(2) { animation-delay: 0.12s; }
.web-search-dots span:nth-child(3) { animation-delay: 0.24s; }

@keyframes webSearchDotBounce {
    0%, 100% { transform: translateY(0); opacity: 0.35; }
    50% { transform: translateY(-5px); opacity: 1; }
}

.web-search-svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--color-accent);
    position: relative;
    z-index: 1;
}

.search-results-card {
    margin: 8px max(24px, calc(50% - 360px));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeUp 0.2s ease-out;
}

.search-results-title {
    font-size: 13px;
    color: var(--color-text);
    font-weight: 500;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease, transform 0.35s ease;
}

.search-result-item--loading {
    border-color: var(--color-accent-border);
    animation: searchRowPulse 1.1s ease-in-out infinite;
}

@keyframes searchRowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(209, 177, 132, 0.10); }
    50% { box-shadow: 0 0 0 4px rgba(209, 177, 132, 0.06); }
}

.search-result-item--success {
    border-color: rgba(74, 222, 128, 0.85) !important;
    background: rgba(22, 101, 52, 0.22) !important;
    animation: trustRowPlopOk 0.55s cubic-bezier(0.34, 1.55, 0.64, 1);
    box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.2), 0 0 24px rgba(74, 222, 128, 0.12);
}

.search-result-item--fail {
    border-color: rgba(248, 113, 113, 0.75) !important;
    background: rgba(127, 29, 29, 0.18) !important;
    animation: trustRowPlopBad 0.45s cubic-bezier(0.36, 1.2, 0.66, 1);
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.15);
}

@keyframes trustRowPlopOk {
    0% { transform: scale(0.98); }
    55% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes trustRowPlopBad {
    0% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

.star-burst-origin {
    position: absolute;
    right: 18px;
    top: 50%;
    width: 1px;
    height: 1px;
    pointer-events: none;
    z-index: 3;
}

.star-burst-star {
    position: absolute;
    left: 0;
    top: 0;
    font-size: 11px;
    line-height: 1;
    color: #bbf7d0;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.9);
    animation: starBurstFly 0.78s ease-out forwards;
}

@keyframes starBurstFly {
    from {
        transform: translate(0, -50%) rotate(var(--burst-angle, 0deg)) translateX(0);
        opacity: 1;
    }
    to {
        transform: translate(0, -50%) rotate(var(--burst-angle, 0deg)) translateX(var(--burst-dist, 32px));
        opacity: 0;
    }
}

.btn-mini-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(209, 177, 132, 0.22);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -2px;
    animation: btnSpin 0.65s linear infinite;
}

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

.trust-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.trust-result-badge--ok {
    background: rgba(22, 101, 52, 0.35);
    border-color: rgba(74, 222, 128, 0.5);
}

.trust-result-badge--bad {
    background: rgba(127, 29, 29, 0.35);
    border-color: rgba(248, 113, 113, 0.45);
}

.search-result-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-title:hover { color: var(--color-accent-text-soft); }

.search-result-url {
    font-size: 10px;
    color: #555;
    font-family: 'SF Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-snippet {
    font-size: 12px;
    color: #777;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trust-btn {
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    color: var(--color-text);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
}

.trust-btn:hover { background: #3a3a4e; border-color: #5a5a7e; }
.trust-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.search-results-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.trust-all-btn {
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    color: var(--color-text);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
    flex: 1;
}

.trust-all-btn:hover { background: #3a3a4e; border-color: #5a5a7e; }
.trust-all-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.skip-search-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: #555;
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    border-radius: 8px;
    transition: color 0.15s, border-color 0.15s;
    flex: 1;
}

.skip-search-btn:hover { color: #888; border-color: #3a3a3e; }

.web-learning-banner {
    margin: 6px max(24px, calc(50% - 360px));
    padding: 10px 14px 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--color-accent-text-soft);
    background: linear-gradient(135deg, rgba(209, 177, 132, 0.12), rgba(30, 27, 45, 0.95));
    border: 1px solid var(--color-accent-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.25s ease-out, webLearnBannerGlow 2s ease-in-out infinite;
}

@keyframes webLearnBannerGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(209, 177, 132, 0.06); }
    50% { box-shadow: 0 0 20px 1px rgba(209, 177, 132, 0.10); }
}

.web-learning-edge {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--color-accent), var(--color-accent-strong));
    animation: webLearnEdgeShine 1.5s ease-in-out infinite;
}

@keyframes webLearnEdgeShine {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.web-learning-icon {
    font-style: normal;
    animation: webLearnIconWiggle 0.9s ease-in-out infinite;
}

@keyframes webLearnIconWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-6deg); }
    75% { transform: rotate(6deg); }
}

.web-learning-text {
    flex: 1;
    min-width: 0;
    font-style: italic;
    color: var(--color-text-bright);
}

.web-learning-bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
    flex-basis: 100%;
}

.web-learning-bar-fill {
    display: block;
    height: 100%;
    width: 35%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--color-accent-strong), var(--color-accent), var(--color-accent-strong));
    background-size: 200% 100%;
    animation: webLearnBarSlide 1.1s ease-in-out infinite;
}

@keyframes webLearnBarSlide {
    0% { transform: translateX(-30%); background-position: 0% 0; }
    100% { transform: translateX(220%); background-position: 100% 0; }
}

.web-learning-banner--live {
    flex-wrap: nowrap;
    align-items: stretch;
}

.learn-live-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 8px;
}

.learn-live-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    width: 100%;
}

.learn-live-ico { font-size: 15px; line-height: 1; }
.learn-live-meta { color: #9ca3af; font-variant-numeric: tabular-nums; }
.learn-live-note { color: #f5e8ff; font-weight: 500; }

.learn-live-http {
    font-size: 10px;
    font-weight: 600;
    color: #a1a1aa;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    margin-left: auto;
}

.learn-live-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-accent-text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.learn-live-step {
    font-size: 11px;
    color: #b8bfd4;
    line-height: 1.35;
    word-break: break-word;
}

.learn-live-hint {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.35;
    font-style: italic;
}

.learn-live-bytes {
    font-size: 10px;
    color: #7c8498;
    font-variant-numeric: tabular-nums;
}

.learn-live-bar--batch {
    margin-top: 2px;
}

.learn-live-bar--bytes {
    margin-top: 4px;
}

.learn-live-bar--indeterminate span {
    animation: learnBytePulse 1.2s ease-in-out infinite;
}

@keyframes learnBytePulse {
    0%, 100% { opacity: 0.35; transform: scaleX(0.85); transform-origin: left center; }
    50% { opacity: 1; transform: scaleX(1); transform-origin: left center; }
}

.learn-live-url {
    font-size: 11px;
    color: #8b92a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.learn-live-bar {
    height: 4px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.learn-live-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent-strong), var(--color-accent));
    border-radius: 3px;
    transition: width 0.28s ease-out;
}

.web-learn-result--merged {
    padding: 12px 14px;
}

.web-learn-merge-head {
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 8px;
}

.web-learn-merge-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.web-learn-merge-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 8px;
    border: 1px solid rgba(248, 113, 113, 0.18);
    animation: fadeUp 0.22s ease-out;
}

.web-learn-merge-row.is-unsafe {
    border-color: rgba(251, 191, 36, 0.22);
}

.wlm-ico {
    flex-shrink: 0;
    line-height: 1.35;
}

.wlm-md {
    font-size: 12px;
    color: var(--color-text);
    min-width: 0;
}

.wlm-md p { margin: 4px 0; }

.web-learn-result {
    margin: 4px max(24px, calc(50% - 360px));
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    animation: fadeUp 0.2s ease-out;
    position: relative;
    overflow: hidden;
}

.web-learn-result.safe {
    background: rgba(74, 222, 128, 0.08);
    border: 1px solid rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.web-learn-result.unsafe {
    background: rgba(75, 85, 99, 0.08);
    border: 1px solid rgba(75, 85, 99, 0.25);
    color: #9ca3af;
}

.web-learn-skip-note {
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
}

.web-learn-result--celebrate::after {
    content: '✦ ✧ ✦';
    position: absolute;
    right: 10px;
    top: 8px;
    font-size: 10px;
    letter-spacing: 4px;
    color: rgba(74, 222, 128, 0.5);
    animation: celebrateSparkle 1.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes celebrateSparkle {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.08); }
}

/* ── SSH Session Cards ── */
.ssh-confirm-card {
    margin: 8px max(24px, calc(50% - 360px));
    background: var(--color-surface);
    border: 1px solid #3a3a2e;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeUp 0.2s ease-out;
}

.ssh-confirm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text);
}

.ssh-confirm-icon { font-style: normal; }

.ssh-confirm-host {
    color: #888;
    font-size: 11px;
    font-family: 'SF Mono', monospace;
}

.ssh-confirm-command {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
}

.ssh-confirm-command code {
    color: var(--color-accent-text-soft);
    font-family: 'SF Mono', Monaco, monospace;
    background: transparent;
    padding: 0;
}

.ssh-confirm-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ssh-result-card {
    margin: 8px max(24px, calc(50% - 360px));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeUp 0.2s ease-out;
}

.ssh-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--color-text);
    gap: 12px;
}

.ssh-result-cmd {
    font-size: 11px;
    color: #888;
    font-family: 'SF Mono', monospace;
    background: transparent;
}

.ssh-result-output {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    color: #d4d4d4;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* ── SSH Modal ── */
.ssh-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.ssh-session-hint {
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 4px;
    color: var(--color-muted);
}

.ssh-session-hint--demo {
    color: #c8b896;
}

.ssh-session-hint--error {
    color: #f87171;
}

.ssh-add-section.is-disabled {
    opacity: 0.48;
    pointer-events: none;
}

.ssh-endpoint-item {
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ssh-endpoint-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.ssh-endpoint-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

.ssh-endpoint-meta {
    font-size: 11px;
    color: #555;
    font-family: 'SF Mono', monospace;
}

.ssh-endpoint-remove {
    background: transparent;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.15s;
}

.ssh-endpoint-remove:hover {
    background: var(--color-surface-mid);
    color: #f87171;
}

.ssh-add-section {
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ssh-section-title {
    font-size: 13px;
    font-weight: 500;
    color: #888;
}

#ssh-add-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#ssh-add-form input {
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--color-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
}

#ssh-add-form input:focus { border-color: #5a5a6e; }
#ssh-add-form input::placeholder { color: #555; }

.ssh-form-row {
    display: flex;
    gap: 8px;
}

.ssh-form-row input:first-child { flex: 1; }

.ssh-key-result {
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ssh-key-label {
    font-size: 12px;
    color: #888;
}

.ssh-key-label code {
    background: var(--color-surface-mid);
    color: var(--color-accent-text-soft);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
}

.ssh-pubkey {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px;
    color: var(--color-accent-text-soft);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    resize: none;
    width: 100%;
    height: 70px;
    outline: none;
    line-break: anywhere;
}

/* ── Profile & memory modal ── */
.memory-modal-content {
    max-width: 480px;
}

.memory-panel-hint {
    font-size: 12px;
    color: #7c7c8a;
    line-height: 1.55;
    margin-bottom: 12px;
}

.memory-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #c4c4d4;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.memory-toggle-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
}

.memory-profile-text {
    width: 100%;
    min-height: 180px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #121214;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: #e5e7eb;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.memory-profile-text:focus {
    border-color: var(--color-accent);
}

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

/* Consistent modal action buttons (Save / Clear / Turn off / etc.) */
.memory-actions > button,
.memory-actions > a,
.admin-actions > button,
.admin-actions > a,
.ssh-confirm-actions > button,
.ssh-confirm-actions > a,
.artifact-pane-actions > a {
    min-height: 34px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.02em;
    line-height: 1;
}

/* Make secondary chips match the same height/padding */
.memory-actions .chip,
.admin-actions .chip {
    padding: 8px 14px;
    min-height: 34px;
    border-radius: 10px;
}

/* Keep primary buttons visually primary but consistent size */
.memory-actions .auth-btn,
.admin-actions .auth-btn,
.ssh-confirm-actions .trust-btn {
    padding: 8px 16px;
    border-radius: 10px;
    min-height: 34px;
    margin-top: 0;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.02em;
}

/* ── Personality modal ── */
.personality-modal-content {
    max-width: 480px;
}

.personality-panel-hint {
    font-size: 12px;
    color: #7c7c8a;
    line-height: 1.55;
    margin-bottom: 12px;
}

.personality-dismiss-hint {
    display: block;
    margin-top: 8px;
    color: var(--color-muted);
    font-size: 11px;
}

.personality-toggle-container {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.personality-mode-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #7c7c8a;
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.personality-mode-btn:hover {
    color: var(--color-text-bright);
    background: var(--color-surface);
    border-color: var(--color-border);
}

.personality-mode-btn--active {
    color: var(--color-text-bright);
    background: var(--color-accent-strong);
    border-color: var(--color-accent-strong);
    box-shadow: 0 2px 10px rgba(209, 177, 132, 0.22);
}

.personality-mode-display {
    font-size: 12px;
    color: #7c7c8a;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--color-surface-mid);
    border-radius: 8px;
}

.personality-modal-body {
    padding: 20px;
}

/* ── Admin modal ── */
.admin-modal-content {
    max-width: 640px;
    /* Keep the modal "full size", scroll the overlay instead */
    max-height: none;
    overflow: visible;
    padding: 0; /* padding moves into .admin-modal-body */
}

.admin-modal-content .modal-header { flex: 0 0 auto; }

.admin-modal-body {
    overflow: visible;
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.admin-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.02);
}

#admin-modal .admin-modal-body > *,
#learn-modal .admin-modal-body > * {
    margin: 0;
}

#admin-modal .ssh-section-title {
    margin: 0;
    letter-spacing: 0.01em;
}

#admin-modal #admin-message.auth-message {
    margin-top: 0;
}

#admin-modal .admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0;
}

#admin-modal .admin-actions > .auth-btn,
#admin-modal .admin-actions > .chip {
    flex: 1 1 220px;
    min-width: 0;
    justify-content: center;
}

/* Admin modal: allow scrolling the overlay to see the tail */
#admin-modal.modal {
    align-items: flex-start;
    overflow-y: auto;
    padding: 48px 0;
}

#admin-modal .admin-modal-content {
    margin: 0 auto;
}

#admin-modal #admin-new-key.ssh-key-result {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

#admin-modal #admin-new-key .ssh-pubkey {
    border-radius: 10px;
}

#admin-modal .memory-toggle-row {
    margin-bottom: 0;
    flex: 1 1 220px;
    min-width: 0;
    color: var(--color-text);
}

#learn-modal .learn-modal-size-display {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.knowledge-modal-content {
    max-width: 480px;
}

.knowledge-hint {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.knowledge-item {
    padding: 10px 12px;
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text);
}

.knowledge-item strong {
    color: #e8e8f0;
    display: block;
    margin-bottom: 4px;
}

.knowledge-item small {
    color: #888;
    line-height: 1.4;
}

.admin-panel-hint {
    font-size: 12px;
    color: #666;
    line-height: 1.55;
    margin-bottom: 0;
}

.admin-panel-hint code {
    background: var(--color-surface-mid);
    color: #a8a8b8;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}

#admin-modal input[type="text"],
#admin-modal input[type="password"] {
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--color-text);
    outline: none;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.2s;
}

#admin-modal input:focus {
    border-color: #5a5a6e;
}

#admin-modal input::placeholder {
    color: #555;
}

.admin-auth-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.admin-auth-row input[type="text"],
.admin-auth-row input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    color: var(--color-text-bright);
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.2s, background-color 0.2s;
}

.admin-auth-row input[type="text"]::placeholder,
.admin-auth-row input[type="password"]::placeholder {
    color: var(--color-text);
}

.admin-auth-row input[type="text"]:focus,
.admin-auth-row input[type="password"]:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-surface);
}

/* Learn Modal Input Row */
.admin-learn-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 0;
}

.admin-learn-input-row input[type="text"] {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg);
    color: var(--color-text-bright);
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.2s, background-color 0.2s;
}

.admin-learn-input-row input[type="text"]::placeholder {
    color: var(--color-text);
}

.admin-learn-input-row input[type="text"]:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-surface);
}

.admin-learn-input-row input[type="range"] {
    flex: 0 0 140px;
    height: 24px;
    cursor: pointer;
}

.admin-learn-input-row span {
    flex: 0 0 40px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 0;
}

.admin-keys-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 0;
}

.admin-users-list {
    overflow-x: auto;
    margin-bottom: 0;
}

.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-users-table th {
    background: var(--color-surface-mid);
    padding: 8px 10px;
    text-align: left;
    font-weight: 500;
    color: #e8e8f0;
    border-bottom: 1px solid var(--color-border);
}

.admin-users-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #3a3a3e;
    color: #a8a8b8;
}

.admin-users-table tr:hover {
    background: var(--color-surface-mid);
}

.admin-timings {
    margin-top: 0;
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
}

.admin-timing-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-subtle);
    font-size: 12px;
    color: var(--color-text);
}
.admin-timing-row:last-child { border-bottom: none; }
.admin-timing-main { min-width: 0; }
.admin-timing-title { font-weight: 650; color: var(--color-text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-timing-sub { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.admin-timing-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.admin-timing-badge {
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--color-border-subtle);
    background: rgba(72, 58, 39, 0.12);
    color: var(--color-text);
    font-size: 11px;
    white-space: nowrap;
}

.admin-key-item {
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #888;
    line-height: 1.5;
}

.admin-key-item .admin-key-id {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--color-text);
    font-size: 12px;
}

.admin-key-item .admin-key-meta {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #555;
}

.admin-toggles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
}

@media (max-width: 560px) {
    .admin-toggles-grid {
        grid-template-columns: 1fr;
    }
}

.admin-toggle-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
}

.admin-toggle-item .chip {
    margin: 0;
}

.admin-open-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
    margin-top: 10px;
}

.admin-global-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
}

.admin-global-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 12px;
}

.admin-global-item--toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-global-label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.admin-global-value {
    font-size: 12px;
    color: var(--color-text);
}

.admin-global-item input[type="range"] {
    width: 100%;
}

.admin-open-hint {
    font-size: 11px;
    color: #6b6b70;
}

/* ── Learning UI ── */
/* ── Context Menu ── */
.context-menu-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.context-menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--color-surface-mid);
    border: 1px solid #3a3a3e;
    border-radius: 10px;
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.context-menu-btn:hover {
    background: #333338;
    border-color: #4a4a5e;
    color: #e5e7eb;
}

.context-menu-btn svg {
    color: #9ca3af;
    transition: color 0.2s ease;
}

.context-menu-btn:hover svg {
    color: var(--color-text);
}

/* ── Effort buttons ── */
.effort-options {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.effort-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    border: 1px solid #3a3a3e;
    background: var(--color-surface-mid);
    color: var(--color-text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.effort-btn:hover {
    border-color: #4a4a5e;
    background: #333338;
    color: #e5e7eb;
}

.effort-btn-active {
    border-color: var(--color-accent-strong);
    background: var(--color-accent-strong);
    color: #090909;
    box-shadow: 0 0 14px rgba(209, 177, 132, 0.22);
}

.effort-hint {
    font-size: 10px;
    color: #6b7280;
    line-height: 1.4;
    margin-top: 4px;
}

/* ── Chat History ── */
#history-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#history-list button {
    border: 1px solid transparent;
    background: var(--color-surface-mid);
    padding: 6px 10px;
    border-radius: 4px;
    color: var(--color-text);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

#history-list button:hover {
    background: #3a3a3e;
    border-color: #4a4a5e;
}

#history-list button:active {
    transform: scale(0.98);
}

/* ── Reasoning panel ── */
.reasoning-panel {
    margin: 8px auto;
    border-radius: 0;
    background: transparent;
    border: none;
    overflow: visible;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.reasoning-toggle {
    width: auto;
    text-align: center;
    padding: 0;
    background: transparent;
    border: none;
    color: #97958c;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0;
    transition: opacity 0.2s ease;
    margin-bottom: 6px;
}
.reasoning-toggle:hover {
    opacity: 0.8;
}
.reasoning-toggle::before { content: '↓'; font-size: 11px; transition: transform 0.2s; display: inline-block; }
.reasoning-toggle--open::before { transform: rotate(180deg); }
.reasoning-body {
    padding: 0 20px 8px 20px;
    font-size: 13px;
    line-height: 1.5;
    color: #97958c;
    white-space: pre-wrap;
    word-break: break-word;
    border: none;
    margin: 0;
    font-family: inherit;
    text-align: center;
    max-width: 600px;
}

/* ── Artifact bubble ── */
.artifact-bubble {
    margin: 8px 0 12px;
    border-radius: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    overflow: hidden;
    max-width: 400px;
}
.artifact-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface-mid);
    border-bottom: 1px solid var(--color-border);
}
.artifact-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-bright);
}
.artifact-file-count {
    font-size: 11px;
    color: var(--color-muted);
}
.artifact-file-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}
.artifact-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
}
.artifact-file-item:hover {
    background: rgba(72, 58, 39, 0.16);
}
.artifact-file-icon { font-size: 14px; }
.artifact-file-name { flex: 1; font-family: monospace; }
.artifact-file-size { font-size: 11px; color: var(--color-muted); }
.artifact-button-container {
    display: flex;
    gap: 8px;
    padding: 8px 14px 10px;
    flex-wrap: wrap;
}

.artifact-preview-btn {
    flex: 1;
    min-width: 100px;
    padding: 7px 14px;
    background: rgba(72, 58, 39, 0.35);
    color: var(--color-text-bright);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.artifact-preview-btn:hover {
    background: rgba(72, 58, 39, 0.55);
    border-color: rgba(209, 177, 132, 0.45);
    transform: translateY(-1px);
}

.artifact-download-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 10px;
    background: rgba(72, 58, 39, 0.72);
    color: var(--color-text-bright);
    border: 1px solid #4a4945;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.artifact-download-btn:hover {
    background: rgba(72, 58, 39, 0.9);
    border-color: rgba(209, 177, 132, 0.65);
    transform: translateY(-1px);
}

.artifact-download-btn:active { transform: translateY(0); }

/* ── Browse panel (learning progress) ── */
.browse-panel {
    margin: 8px auto 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    animation: fadeUp 0.3s ease-out;
    max-width: 420px;
    width: 90%;
}
.browse-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-bright);
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.02em;
}
.browse-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}
.browse-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(209, 177, 132, 0.25), rgba(209, 177, 132, 0.85), rgba(209, 177, 132, 0.35));
    transition: width 0.3s ease-out;
}

.browse-bar-fill--indeterminate {
    width: 35% !important;
    background: linear-gradient(90deg, rgba(209, 177, 132, 0.15), rgba(209, 177, 132, 0.85), rgba(209, 177, 132, 0.15));
    animation: browseIndeterminate 1.05s ease-in-out infinite;
    will-change: transform;
}

@keyframes browseIndeterminate {
    0% { transform: translateX(-20%); opacity: 0.7; }
    50% { opacity: 1; }
    100% { transform: translateX(205%); opacity: 0.7; }
}
.browse-bar--collapsing {
    width: 0 !important;
    transition: width 0.4s ease-in-out;
}
.browse-panel--collapsing {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    border: none;
    overflow: hidden;
    transition: all 0.3s ease-in;
}

/* ── Activity chips (during response generation) ── */
.activity-chips {
    display: flex;
    gap: 8px;
    margin: 10px 0 16px;
    animation: fadeUp 0.3s ease-out;
}
.chip-item {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    background: #2a2a3a;
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
}
.chip-item--active {
    color: #fff;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-strong));
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(209, 177, 132, 0.22);
    animation: chipGlow 1.2s ease-in-out;
}
.activity-chips--out {
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.3s ease;
}

@keyframes chipGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(209, 177, 132, 0.16); }
    50% { box-shadow: 0 0 18px rgba(209, 177, 132, 0.28); }
}

/* ── Reasoning panel collapsible post-response ── */
.reasoning-panel--done .reasoning-toggle {
    cursor: pointer;
}
.reasoning-panel--done .reasoning-body {
    max-height: 500px;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
}
.reasoning-panel--done .reasoning-body[hidden] {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* ── Timing Indicators ── */
.message-timings {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 10px;
    background-color: rgba(100, 116, 139, 0.08);
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    flex-wrap: wrap;
}

.timing-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    white-space: nowrap;
}

.timing-green {
    background-color: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.timing-yellow {
    background-color: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
}

.timing-red {
    background-color: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .greeting { font-size: 28px; }
    .message { padding: 0 16px; }
    .input-area { padding: 0 16px 16px; }
    .chips { display: none; }
}

/* ── Command Preview ── */
.command-preview {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    width: 260px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.command-preview-list {
    display: flex;
    flex-direction: column;
}

.command-preview-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-subtle);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 9px;
}

.command-preview-item:last-child {
    border-bottom: none;
}

.command-preview-item:hover,
.command-preview-item.is-active {
    background: var(--color-surface-mid);
}

.command-preview-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    flex-shrink: 0;
    font-weight: 600;
    font-size: 11px;
    border-radius: 5px;
    background: var(--color-accent-soft);
    font-family: monospace;
}

.command-preview-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.command-preview-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-bright);
    white-space: nowrap;
}

.command-preview-desc {
    font-size: 11px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Projects Panel ── */
.projects-panel {
    width: 220px;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 12px 0;
    overflow: hidden;
}
.projects-panel[hidden] { display: none !important; }

.projects-panel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--color-border-subtle);
}
.projects-panel-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text);
}

/* History panel (encrypted chats, mirrors projects) */
.history-panel {
    width: 220px;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 12px 0;
    overflow: hidden;
}
.history-panel[hidden] { display: none !important; }
.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--color-border-subtle);
}
.history-panel-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text);
    flex: 1 1 auto;
    min-width: 0;
}
.history-panel-save-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.history-panel-save-text {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.history-enabled-toggle {
    width: 32px;
    height: 18px;
    accent-color: #6b6b5b;
    cursor: pointer;
}
.history-panel-hint {
    font-size: 10px;
    line-height: 1.4;
    color: var(--color-muted);
    margin: 6px 12px 4px;
}
.history-new-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 10px 4px;
    padding: 7px 12px;
    width: calc(100% - 20px);
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}
.history-new-btn:hover { background: #3e3c38; }
.history-clear-btn {
    margin: 0 10px 8px;
    display: block;
    width: calc(100% - 20px);
    text-align: center;
}
.history-list {
    flex: 1 1 auto;
    max-height: 42vh;
    overflow-y: auto;
    padding: 4px 6px 12px;
}
.history-item {
    position: relative;
    display: block;
    padding: 7px 8px;
    margin-bottom: 4px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #2c2a26;
    cursor: pointer;
    text-align: left;
    color: var(--color-text);
    width: 100%;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.35;
    transition: border-color 0.12s, background 0.12s;
}
.history-item:hover { border-color: var(--color-border); }
.history-item--active { border-color: #6b6b5b; background: #33312c; }
.history-item-row { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 4px; }
.history-item-name { display: block; font-weight: 500; }
.history-item-meta { font-size: 10px; color: var(--color-muted); margin-top: 3px; }
.auth-registration-banner {
    font-size: 12px;
    line-height: 1.4;
    color: var(--color-warning, #c9a227);
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 0 0 10px 0;
}
.auth-inline-hint { font-size: 11.5px; color: var(--color-muted); margin: 6px 0; line-height: 1.4; }
.auth-link { color: #9bb8e8; text-decoration: underline; cursor: pointer; }

.projects-new-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 10px 6px;
    padding: 7px 12px;
    background: var(--color-surface-mid);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.projects-new-btn:hover { background: #3e3c38; }
.projects-new-btn svg { flex-shrink: 0; }

.projects-list {
    flex: 0 1 auto;
    max-height: 38vh;
    overflow-y: auto;
    padding: 4px 6px;
}

.projects-workspace {
    border-top: 1px solid var(--color-border-subtle);
    margin-top: 6px;
    padding: 10px 10px 12px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.projects-workspace-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text);
}
.projects-workspace-hint {
    font-size: 10px;
    color: var(--color-muted);
    margin: 6px 0 8px;
    line-height: 1.35;
}
.projects-workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.projects-upload-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    margin: 0;
}
.projects-file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.workspace-files-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 8px;
    font-size: 11px;
}
.workspace-files-empty {
    color: var(--color-muted);
    font-size: 11px;
    padding: 6px 4px;
}
.workspace-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 6px;
}
.workspace-file-row:hover {
    background: var(--color-surface-mid);
}
.workspace-file-meta {
    min-width: 0;
    flex: 1;
}
.workspace-file-name {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: var(--color-text-bright);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace-file-size {
    font-size: 10px;
    color: var(--color-muted);
}
.workspace-file-del {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}
.workspace-file-del:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

.project-item-meta {
    font-size: 10px;
    color: var(--color-muted);
    margin-top: 2px;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 0;
    border-radius: 8px;
    padding: 8px 8px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}
.project-item:hover { background: var(--color-surface-mid); }
.project-item.project-item--active {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.project-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.project-item-name {
    font-size: 13px;
    color: var(--color-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-bottom: 2px;
}
.project-item-date {
    font-size: 10.5px;
    color: var(--color-muted);
}
.project-item-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}
.project-item:hover .project-item-actions { display: flex; }

.project-action-btn {
    background: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-size: 11px;
    transition: color 0.12s, background 0.12s;
}
.project-action-btn:hover { color: var(--color-text-bright); background: var(--color-surface-mid); }
.project-action-btn--on {
    color: #fbbf24;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile / phone layout (max-width: 640px only — tablets in landscape unchanged)
   ═══════════════════════════════════════════════════════════════════════════ */

.sidebar-backdrop {
    display: none !important;
}

@media (max-width: 640px) {
    /* Safe areas: horizontal gutters live on `.workspace-chat` so they match input bottom inset */
    #app {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* ── Sidebar: floating menu icon; expands to drawer ── */
    .sidebar-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(0, 0, 0, 0.48);
        border: 0;
        margin: 0;
        padding: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s ease, visibility 0.28s ease;
    }

    .sidebar-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    #sidebar {
        position: fixed;
        top: max(10px, env(safe-area-inset-top));
        left: max(10px, env(safe-area-inset-left));
        z-index: 100;
        width: auto;
        height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        transition:
            top 0.3s cubic-bezier(0.22, 1, 0.36, 1),
            left 0.3s cubic-bezier(0.22, 1, 0.36, 1),
            width 0.3s cubic-bezier(0.22, 1, 0.36, 1),
            height 0.3s cubic-bezier(0.22, 1, 0.36, 1),
            padding 0.28s ease,
            background 0.25s ease,
            box-shadow 0.28s ease,
            border-radius 0.22s ease;
    }

    #sidebar:not(.sidebar--expanded) {
        width: auto;
        /* Only the menu chip captures taps; no invisible full-height hit box beside the chat */
        pointer-events: none;
        /* `.sidebar` uses overflow-x:hidden — that clips box-shadow to a rectangle and shows square “ears” */
        overflow: visible;
    }

    #sidebar:not(.sidebar--expanded) .sidebar-top {
        width: auto;
        align-self: flex-start;
        overflow: visible;
    }

    #sidebar:not(.sidebar--expanded) .sidebar-top > :not(#sidebar-expand-btn) {
        display: none !important;
    }

    #sidebar:not(.sidebar--expanded) .sidebar-mid,
    #sidebar:not(.sidebar--expanded) .sidebar-bottom {
        display: none !important;
    }

    #sidebar:not(.sidebar--expanded) #sidebar-expand-btn {
        pointer-events: auto;
        -webkit-appearance: none;
        appearance: none;
        width: 46px;
        height: 46px;
        min-width: 46px;
        box-sizing: border-box;
        background: var(--color-surface);
        background-clip: padding-box;
        border: 1px solid var(--color-border);
        border-radius: 14px;
        color: var(--color-text);
        box-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
    }

    #sidebar.sidebar--expanded {
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: min(288px, 86vw) !important;
        max-height: none;
        height: 100% !important;
        padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        background: var(--color-bg);
        border-right: 1px solid var(--color-border-subtle);
        box-shadow: 12px 0 48px rgba(0, 0, 0, 0.55);
        align-items: stretch;
        overflow-x: hidden;
        overflow-y: auto;
    }

    #sidebar.sidebar--expanded .sidebar-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 0 10px;
    }

    #sidebar.sidebar--expanded .sidebar-label {
        display: inline;
    }

    #sidebar.sidebar--expanded .user-avatar-name {
        display: inline;
    }

    #sidebar.sidebar--expanded #sidebar-expand-btn {
        box-shadow: none;
        border-radius: 10px;
        width: 100%;
        height: 40px;
        min-width: 0;
    }

    /* Same horizontal inset as input footer bottom (`max(8px, safe-area)`); menu chip is fixed, no layout gutter */
    .workspace-chat {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    #app.app--sidebar-drawer-open .workspace-chat {
        padding-left: 0;
        padding-right: 0;
    }

    .main {
        min-width: 0;
    }

    /* ── Top bar ── */
    .topbar {
        padding: 6px 0;
        padding-top: max(6px, env(safe-area-inset-top));
    }

    /* ── Chat & messages ── */
    .chat-history {
        padding: 8px 0;
    }

    .message {
        padding-left: 0;
        padding-right: 0;
    }

    .message-content {
        max-width: 100%;
        padding: 10px 12px;
        border-radius: 16px;
        font-size: 15px;
    }

    .greeting {
        font-size: clamp(22px, 7vw, 30px);
        padding-left: 0;
        padding-right: 0;
        text-align: center;
    }

    /* ── Input area & footer (wrap, no horizontal overflow) ── */
    .input-area {
        padding-left: max(4px, env(safe-area-inset-left));
        padding-right: max(4px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 6px;
    }

    .input-box {
        padding: 8px 8px 6px;
        border-radius: 12px;
        max-width: 100%;
        box-sizing: border-box;
    }

    #prompt-input {
        font-size: 16px; /* avoids iOS zoom on focus */
        flex: 0 1 auto;
        line-height: 1.45;
        min-height: calc(1em * 1.45);
        min-height: 1lh;
    }

    /* One row: prefs scroll horizontally; send/context stay pinned right */
    .input-footer {
        flex-wrap: nowrap;
        align-items: center;
        gap: 4px;
        margin-top: 4px;
        min-width: 0;
        width: 100%;
    }

    .agent-prefs-inline {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 4px;
    }

    .agent-prefs-toggles {
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x;
        scrollbar-width: thin;
        padding-bottom: 2px;
    }

    .agent-prefs-toggles::-webkit-scrollbar {
        height: 3px;
    }

    .agent-prefs-toggles::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.12);
        border-radius: 3px;
    }

    .agent-prefs-toggle {
        padding: 4px 6px;
        min-height: 28px;
        font-size: 10px;
        gap: 2px;
        flex: 0 0 auto;
    }

    .agent-prefs-toggle .agent-prefs-chevron {
        width: 10px;
        height: 10px;
    }

    .input-right {
        flex: 0 0 auto;
        min-width: 0;
        margin-left: auto;
        justify-content: flex-end;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .input-right .context-info--footer .context-circle-container {
        width: 30px;
        height: 30px;
    }

    .send-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-radius: 12px;
        flex-shrink: 0;
        touch-action: manipulation;
    }

    .send-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Dropdowns anchored to input — stay in viewport */
    .agent-prefs-panel {
        left: auto;
        right: 0;
        min-width: 0;
        width: min(300px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        box-sizing: border-box;
    }

    .model-profile-menu {
        left: auto;
        right: 0;
        min-width: 0;
        width: min(300px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        box-sizing: border-box;
    }

    /* ── Settings modal ── */
    #settings-modal .modal-content {
        width: auto;
        max-width: calc(100vw - 20px) !important;
        max-height: min(92vh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
        margin: 10px;
        padding: 18px 14px 16px;
        box-sizing: border-box;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #settings-modal .settings-modal-body {
        gap: 12px;
    }

    #settings-modal .settings-top-tabs {
        gap: 6px;
        justify-content: center;
    }

    #settings-modal .settings-top-tab {
        padding: 8px 10px;
        font-size: 11.5px;
    }

    #settings-modal .settings-actions-grid {
        grid-template-columns: 1fr;
    }

    #settings-modal .settings-action {
        min-height: 44px;
        font-size: 13px;
    }

    /* ── Other modals: comfortable on small screens ── */
    .modal-content {
        width: auto;
        max-width: calc(100vw - 20px) !important;
        box-sizing: border-box;
        margin: 10px;
        padding: 20px 16px;
        max-height: min(90vh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep admin/learn modals readable */
    .admin-modal-content {
        max-width: calc(100vw - 16px) !important;
    }

    /* ── Projects strip ── */
    .projects-panel {
        width: min(220px, 72vw);
    }
}

/* ── Artifact pane tabs ──────────────────────────────────────────────────── */
.artifact-pane-tabs {
    display: flex;
    border-bottom: 1px solid #2d2c28;
    flex-shrink: 0;
    background: #1f1f1e;
}
.artifact-pane-tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.15s, border-color 0.15s;
}
.artifact-pane-tab:hover { color: #d1d5db; }
.artifact-pane-tab.is-active {
    color: #e5e7eb;
    border-bottom-color: #818cf8;
}
.artifact-pane-tab-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.artifact-pane-tab-panel[hidden] { display: none; }

/* ── Drag-and-drop upload zone ───────────────────────────────────────────── */
.artifact-dropzone {
    border: 2px dashed #4a4945;
    border-radius: 8px;
    padding: 14px 10px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    cursor: pointer;
    margin: 8px;
    transition: border-color 0.15s, background 0.15s;
    line-height: 1.7;
    flex-shrink: 0;
    background: #2d2c28;
}
.artifact-dropzone.drag-over {
    border-color: #818cf8;
    background: rgba(129, 140, 248, 0.1);
}
.artifact-dropzone label {
    cursor: pointer;
    color: #818cf8;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.artifact-dropzone-error {
    color: var(--color-danger, #f87171);
    font-size: 11px;
    margin-top: 4px;
}

/* ── Instructions textarea ───────────────────────────────────────────────── */
.project-instructions-ta {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    background: #2d2c28;
    color: #d1d5db;
    border: 1px solid #3a3936;
    border-radius: 6px;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    display: block;
    margin: 8px;
}
.project-instructions-ta::placeholder {
    color: #6b7280;
}
.project-instructions-ta:focus {
    outline: none;
    border-color: #818cf8;
}
.instructions-meta {
    font-size: 11px;
    color: var(--color-muted);
    padding: 4px 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.instructions-save-status { color: var(--color-accent, #818cf8); }

/* ── Pinned / section headers in project list ────────────────────────────── */
.projects-list-section-header {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    text-transform: uppercase;
    padding: 8px 12px 2px;
    user-select: none;
}

/* ── Artifact pane instructions body layout ──────────────────────────────── */
#artifact-pane-instructions-panel .artifact-pane-body {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
}

/* ── Mobile artifact pane: floating button + overlay ──────────────────────── */
/* ── Mobile right sidebar ─────────────────────────────────────────────────── */
@media (max-width: 899px) {
    /* On mobile the pane slides in from the right as a full-height overlay */
    #artifact-pane {
        position: fixed !important;
        right: 0 !important;
        top: 0 !important;
        height: 100dvh !important;
        width: 300px !important;
        max-width: 88vw !important;
        /* Override the desktop width transition — use transform instead */
        transform: translateX(110%);
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
        z-index: 300 !important;
        padding: 0 !important;
        align-items: stretch !important;
        box-shadow: -8px 0 32px rgba(0,0,0,0.5);
        /* Show the expanded layout always on mobile when open */
    }
    #artifact-pane.artifact-pane--mobile-open {
        transform: translateX(0) !important;
    }
    /* Force expanded layout on mobile */
    #artifact-pane .artifact-pane-expand-btn {
        width: 100% !important;
        justify-content: flex-start !important;
        padding: 0 14px !important;
        gap: 10px !important;
    }
    #artifact-pane .artifact-pane-label {
        display: inline !important;
        opacity: 1 !important;
    }
    #artifact-pane .artifact-pane-content {
        display: flex !important;
    }

    /* Floating FAB to open it */
    .artifact-pane-mobile-toggle {
        display: flex !important;
        position: fixed;
        bottom: 80px;
        right: 16px;
        z-index: 299;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: #2d2c28;
        border: 1px solid #4a4945;
        color: #d1d5db;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
        transition: transform 0.15s ease, background 0.15s;
    }
    .artifact-pane-mobile-toggle:active {
        transform: scale(0.93);
    }

    /* Dim backdrop behind mobile right pane */
    #artifact-pane-mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 299;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s ease;
    }
    #artifact-pane-mobile-backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Desktop: hide mobile toggle + backdrop, keep sidebar inline */
@media (min-width: 900px) {
    .artifact-pane-mobile-toggle { display: none !important; }
    #artifact-pane-mobile-backdrop { display: none !important; }
}

/* ── Projects button animation ──────────────────────────────────────────── */
#projects-btn {
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Chat message fade animations ──────────────────────────────────────── */
.message {
    animation: messageFadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Effort mode hover popover ─────────────────────────────────────────── */
.effort-popover {
    position: fixed;
    z-index: 9999;
    min-width: 240px;
    max-width: 320px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: rgba(44, 44, 42, 0.98);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
    color: var(--color-text-bright);
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.effort-popover-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--color-accent-text-soft);
    margin-bottom: 8px;
}

.effort-popover-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.effort-popover-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    line-height: 1.25;
}

.effort-popover-k {
    color: var(--color-muted);
    white-space: nowrap;
}

.effort-popover-v {
    color: var(--color-text-bright);
    text-align: right;
}

.effort-popover-v--mono {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.effort-popover-foot {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.25;
    color: var(--color-muted);
}

/* ── Feature toggle numeric popovers (OFF ↔ ON) ────────────────────────── */
.feature-popover {
    position: fixed;
    z-index: 9999;
    min-width: 280px;
    max-width: 360px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: rgba(44, 44, 42, 0.98);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
    color: var(--color-text-bright);
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.feature-popover-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--color-accent-text-soft);
    margin-bottom: 8px;
}

.feature-popover-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feature-popover-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.feature-popover-label {
    font-size: 12px;
    color: var(--color-muted);
    white-space: nowrap;
}

.feature-popover-vals {
    display: grid;
    grid-template-columns: auto auto auto;
    align-items: center;
    gap: 10px;
    min-width: 150px;
}

.feature-popover-off,
.feature-popover-on {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

.feature-popover-off {
    color: var(--color-muted);
}

.feature-popover-on {
    color: var(--color-accent-text-soft);
}

.feature-popover-arrow {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--color-accent);
    background: transparent;
    padding: 0;
    border: 0;
    line-height: 1;
    white-space: nowrap;
}

.feature-popover-arrowhead {
    color: var(--color-accent);
}

.feature-popover-connector {
    display: inline-block;
    color: transparent;
    letter-spacing: 0;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--color-accent);
    text-decoration-skip-ink: none;
}

/* Tool result panels */
.tool-result-panel {
    border: 1px solid #2d2c28;
    border-radius: 8px;
    margin: 6px 0;
    font-size: 12px;
    background: #0d0c0b;
}

.tool-result-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #1f1f1e;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    color: #9ca3af;
    user-select: none;
}

.tool-result-panel-head:hover {
    background: #2a2a28;
}

.tool-result-panel-head svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.tool-result-panel-head.collapsed svg {
    transform: rotate(-90deg);
}

.tool-result-panel-body {
    padding: 8px 12px;
    background: #161615;
    border-radius: 0 0 8px 8px;
    overflow: auto;
    max-height: 300px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-result-panel-body[hidden] {
    display: none;
}

/* Model profile button: remove whitespace gap between label and chevron */
#model-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

#model-profile-btn .model-profile-chevron {
    margin-left: 0;
}
