/* CoreFeed AI workspace */
:root {
    --chat-max-width: 900px;
    --chat-inspector-width: 318px;
    --chat-workspace-width: 1440px;
    --chat-surface: #101622;
    --chat-surface-raised: #151d2c;
    --chat-line: rgba(148, 163, 184, 0.16);
    --chat-blue-soft: rgba(68, 112, 255, 0.12);
    --chat-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.chat-layout {
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% -20%, rgba(41, 98, 255, 0.10), transparent 38%),
        var(--bg-app);
}

.chat-workspace {
    width: min(100%, var(--chat-workspace-width));
    min-height: 0;
    margin: 0 auto;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--chat-inspector-width);
    overflow: hidden;
}
.chat-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Workspace command bar */
.chat-commandbar {
    min-height: 58px;
    padding: 9px max(24px, calc((100vw - 1360px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--chat-line);
    background: rgba(8, 10, 16, 0.82);
    backdrop-filter: blur(16px);
}
.chat-commandbar-copy,
.chat-commandbar-actions,
.new-chat-btn,
.research-mode {
    display: flex;
    align-items: center;
}
.chat-commandbar-copy { gap: 11px; min-width: 0; }
.chat-commandbar-copy > div { min-width: 0; display: flex; flex-direction: column; }
.chat-commandbar-copy strong { color: var(--text-primary); font-size: 13.5px; line-height: 1.3; }
.chat-commandbar-copy span:not(.assistant-mark) {
    color: var(--text-muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.assistant-mark {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 11px;
    color: #8fb0ff;
    background: linear-gradient(145deg, rgba(41, 98, 255, 0.22), rgba(124, 58, 237, 0.08));
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}
.assistant-mark svg { width: 20px; height: 20px; }
.chat-commandbar-actions { gap: 9px; flex: 0 0 auto; }
.chat-agent-status { display: none; }
.research-mode {
    min-height: 34px;
    gap: 7px;
    padding: 0 11px;
    border: 1px solid var(--chat-line);
    border-radius: 999px;
    color: var(--text-secondary);
    background: rgba(15, 19, 30, 0.72);
    font-size: 11.5px;
    font-weight: 600;
}
.research-mode-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--up-color);
    box-shadow: 0 0 0 4px rgba(38, 166, 154, 0.10);
}
.new-chat-btn {
    min-height: 36px;
    gap: 7px;
    padding: 0 12px;
    border: 1px solid rgba(96, 165, 250, 0.24);
    border-radius: 10px;
    color: #cbd8ff;
    background: rgba(41, 98, 255, 0.08);
    font: 600 12px/1 var(--font-ui);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}
.new-chat-btn:hover {
    color: #fff;
    border-color: rgba(96, 165, 250, 0.48);
    background: rgba(41, 98, 255, 0.15);
    transform: translateY(-1px);
}
.new-chat-btn:focus-visible { outline: 2px solid #86a8ff; outline-offset: 2px; }
.new-chat-btn svg { width: 17px; height: 17px; }

/* Conversation */
.chat-thread {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 28px 0 36px;
    scroll-behavior: auto;
}
.chat-thread::-webkit-scrollbar { width: 10px; }
.chat-thread::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.18); border: 3px solid transparent; border-radius: 10px; background-clip: padding-box; }

.msg-row {
    width: 100%;
    max-width: var(--chat-max-width);
    margin: 0 auto 24px;
    padding: 0 24px;
    animation: messageIn 0.22s ease-out both;
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.bubble-wrap { width: 100%; min-width: 0; }
.msg-user .bubble-wrap { display: flex; justify-content: flex-end; }
.msg-user .message-main { max-width: min(72%, 660px); }
.msg-user .msg-label { text-align: right; }
.msg-user .bubble {
    padding: 11px 15px;
    border: 1px solid rgba(120, 151, 255, 0.26);
    border-radius: 15px 15px 4px 15px;
    color: #f8fbff;
    background: linear-gradient(135deg, #2f66f3, #2554d9);
    box-shadow: 0 8px 24px rgba(25, 71, 199, 0.16);
    white-space: pre-wrap;
}

.msg-assistant .bubble-wrap {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
}
.assistant-avatar {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(96, 165, 250, 0.25);
    border-radius: 11px;
    color: #8fb0ff;
    background: linear-gradient(145deg, rgba(41, 98, 255, 0.20), rgba(124, 58, 237, 0.08));
}
.assistant-avatar svg { width: 19px; height: 19px; }
.message-main { min-width: 0; }
.message-header {
    min-height: 24px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.msg-label {
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.1px;
}
.message-time { color: #4f5f76; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.msg-assistant .bubble {
    min-width: 0;
    padding: 16px 18px;
    border: 1px solid var(--chat-line);
    border-radius: 4px 15px 15px 15px;
    color: #dbe4f2;
    background: linear-gradient(145deg, rgba(18, 24, 38, 0.96), rgba(13, 18, 29, 0.96));
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.12);
    font-size: 14.5px;
    line-height: 1.72;
    overflow: hidden;
}

/* Tool activity: readable labels, details stay optional */
.tool-track {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
}
.tool-track:empty { display: none; }
.tool-chip {
    min-height: 30px;
    padding: 5px 9px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 9px;
    color: #8fa0b7;
    background: rgba(41, 98, 255, 0.06);
    font: 600 11.5px/1.2 var(--font-ui);
    cursor: default;
}
.tool-chip.is-expandable { cursor: pointer; }
.tool-chip.is-expandable:hover { color: #c9d8ee; border-color: rgba(96, 165, 250, 0.34); }
.tool-chip.done { color: #92a4ba; background: rgba(38, 166, 154, 0.05); border-color: rgba(38, 166, 154, 0.16); }
.tool-chip.error { color: #f3a4a2; border-color: rgba(239, 83, 80, 0.28); background: rgba(239, 83, 80, 0.06); }
.tool-ico {
    width: 15px;
    height: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #78a0ff;
}
.tool-ico svg { width: 15px; height: 15px; }
.tool-ico-spin {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(96, 165, 250, 0.18);
    border-top-color: #7fa1ff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
.tool-chip.done .tool-ico-spin,
.tool-chip.error .tool-ico-spin { display: none; }
.tool-ico-check { display: none; color: var(--up-color); font-size: 13px; font-weight: 800; }
.tool-chip.done .tool-ico-check,
.tool-chip.error .tool-ico-check { display: inline; }
.tool-chip.error .tool-ico-check { color: var(--down-color); }
@keyframes spin { to { transform: rotate(360deg); } }
.tool-detail {
    width: 100%;
    max-height: 170px;
    margin: -1px 0 3px;
    padding: 9px 11px;
    overflow: auto;
    border: 1px solid var(--chat-line);
    border-radius: 8px;
    color: var(--text-muted);
    background: rgba(7, 10, 16, 0.78);
    font: 11px/1.55 var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
}
.tool-detail[hidden] { display: none; }

/* Markdown */
.bubble .md-p,
.bubble p { margin: 0 0 10px; }
.bubble > :last-child { margin-bottom: 0; }
.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4,
.bubble h5,
.bubble h6 {
    margin: 19px 0 8px;
    color: #f2f6fc;
    font-weight: 700;
    line-height: 1.35;
}
.bubble h1:first-child,
.bubble h2:first-child,
.bubble h3:first-child { margin-top: 0; }
.bubble h1 { font-size: 20px; }
.bubble h2 { font-size: 17px; }
.bubble h3 { font-size: 15px; }
.bubble h4,
.bubble h5,
.bubble h6 { font-size: 14px; }
.bubble ul,
.bubble ol { margin: 6px 0 12px; padding-left: 22px; }
.bubble li { margin: 3px 0; padding-left: 2px; }
.bubble li::marker { color: #7797e8; }
.bubble li > ul,
.bubble li > ol { margin: 3px 0 3px; }
.bubble strong { color: #f4f7fb; font-weight: 700; }
.bubble em { color: #bdc9da; }
.bubble a { color: #83a6ff; text-decoration: underline; text-decoration-color: rgba(131, 166, 255, 0.34); text-underline-offset: 3px; }
.bubble a:hover { color: #b2c7ff; text-decoration-color: currentColor; }
.bubble blockquote {
    margin: 10px 0;
    padding: 9px 13px;
    border-left: 3px solid #587fe6;
    border-radius: 0 8px 8px 0;
    color: #aebdd0;
    background: rgba(41, 98, 255, 0.06);
}
.bubble blockquote > :last-child { margin-bottom: 0; }
.bubble hr { height: 1px; margin: 16px 0; border: 0; background: var(--chat-line); }
.bubble code {
    padding: 2px 5px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 5px;
    color: #c7d6ec;
    background: #090d15;
    font: 12.5px/1.45 var(--font-mono);
}
.bubble pre {
    position: relative;
    margin: 12px 0;
    padding: 14px 15px;
    overflow: auto;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    background: #080c13;
}
.bubble pre code { padding: 0; border: 0; color: #cad6e8; background: transparent; white-space: pre; }
.md-table-scroll {
    width: 100%;
    margin: 12px 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid rgba(148, 163, 184, 0.17);
    border-radius: 10px;
    background: rgba(8, 12, 19, 0.42);
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
}
.md-table-scroll::-webkit-scrollbar { height: 8px; }
.md-table-scroll::-webkit-scrollbar-thumb { border-radius: 8px; background: rgba(148, 163, 184, 0.22); }
.bubble table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: #dce5f2;
    font-size: 13px;
    line-height: 1.45;
}
.bubble th,
.bubble td { min-width: 84px; padding: 9px 11px; border-right: 1px solid rgba(148, 163, 184, 0.12); border-bottom: 1px solid rgba(148, 163, 184, 0.12); text-align: left; vertical-align: top; }
.bubble th:last-child,
.bubble td:last-child { border-right: 0; }
.bubble tr:last-child td { border-bottom: 0; }
.bubble th { position: sticky; top: 0; color: #eff4fb; background: #171f2f; font-weight: 650; white-space: nowrap; }
.bubble tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.014); }
.bubble input[type="checkbox"] { margin-right: 6px; accent-color: var(--accent); }

/* Sources and answer actions */
.source-panel { margin-top: 10px; }
.source-panel[hidden] { display: none; }
.source-toggle {
    min-height: 32px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--chat-line);
    border-radius: 9px;
    color: #9eafc4;
    background: rgba(15, 21, 33, 0.8);
    font: 600 11.5px/1 var(--font-ui);
    cursor: pointer;
}
.source-toggle:hover { color: #d5dfed; border-color: rgba(96, 165, 250, 0.32); }
.source-toggle svg { width: 14px; height: 14px; transition: transform var(--transition-fast); }
.source-panel.open .source-toggle svg { transform: rotate(180deg); }
.source-list {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
}
.source-panel.open .source-list { display: grid; }
.source-card {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 10px;
    color: inherit;
    background: rgba(15, 21, 33, 0.72);
    text-decoration: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.source-card[href]:hover { border-color: rgba(96, 165, 250, 0.34); background: rgba(24, 32, 51, 0.84); }
.source-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.source-badge { padding: 2px 6px; border-radius: 999px; color: #9bb5ff; background: rgba(41, 98, 255, 0.12); font-size: 9.5px; font-weight: 750; letter-spacing: 0.25px; }
.source-badge.web { color: #8dd6c9; background: rgba(38, 166, 154, 0.10); }
.source-date { color: #56667b; font-size: 9.5px; white-space: nowrap; }
.source-title { display: -webkit-box; overflow: hidden; color: #c9d5e5; font-size: 11.5px; font-weight: 600; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.source-domain { margin-top: 3px; overflow: hidden; color: #607087; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.response-actions { min-height: 30px; margin-top: 7px; display: flex; align-items: center; gap: 3px; }
.response-actions[hidden] { display: none; }
.response-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    color: #607087;
    background: transparent;
    cursor: pointer;
}
.response-action:hover { color: #b7c5d8; background: rgba(148, 163, 184, 0.08); }
.response-action:focus-visible { outline: 2px solid #789aff; outline-offset: 1px; }
.response-action svg { width: 15px; height: 15px; }
.response-copy-label { width: auto; padding: 0 8px; gap: 5px; font: 600 10.5px/1 var(--font-ui); }

/* Loading */
.typing { min-height: 22px; display: inline-flex; align-items: center; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: #6d84a5; animation: typingBounce 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .14s; }
.typing span:nth-child(3) { animation-delay: .28s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Welcome */
.chat-welcome {
    width: min(760px, calc(100% - 32px));
    min-height: 100%;
    margin: 0 auto;
    padding: clamp(34px, 7vh, 76px) 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.welcome-icon {
    width: 62px;
    height: 62px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(96, 165, 250, 0.25);
    border-radius: 20px;
    color: #8daeff;
    background: radial-gradient(circle at 35% 25%, rgba(81, 121, 255, 0.28), rgba(41, 98, 255, 0.08) 68%);
    box-shadow: 0 18px 50px rgba(41, 98, 255, 0.13), inset 0 1px rgba(255, 255, 255, 0.06);
}
.welcome-icon svg { width: 34px; height: 34px; }
.welcome-eyebrow { margin-bottom: 9px; color: #7289bc; font-size: 10px; font-weight: 750; letter-spacing: 1.5px; }
.chat-welcome h2 { margin-bottom: 9px; color: #f2f6fc; font-size: clamp(24px, 3vw, 31px); line-height: 1.24; letter-spacing: -0.7px; }
.chat-welcome > p { max-width: 580px; margin-bottom: 28px; color: #8190a5; font-size: 13.5px; line-height: 1.65; }
.suggestions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; text-align: left; }
.suggestion-card {
    min-height: 72px;
    padding: 12px 12px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--chat-line);
    border-radius: 13px;
    color: var(--text-secondary);
    background: linear-gradient(145deg, rgba(18, 24, 38, 0.84), rgba(12, 17, 27, 0.82));
    text-align: left;
    cursor: pointer;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
    transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.suggestion-card:hover { transform: translateY(-2px); border-color: rgba(96, 165, 250, 0.34); background: rgba(24, 32, 51, 0.88); }
.suggestion-card:focus-visible { outline: 2px solid #789aff; outline-offset: 2px; }
.suggestion-card > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.suggestion-card strong { color: #dce5f3; font-size: 12px; font-weight: 650; }
.suggestion-card small { overflow: hidden; color: #67778d; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-card-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 11px; }
.suggestion-card-icon svg { width: 19px; height: 19px; }
.suggestion-card-icon.price { color: #78a0ff; background: rgba(41, 98, 255, 0.11); }
.suggestion-card-icon.rank { color: #81c8bc; background: rgba(38, 166, 154, 0.09); }
.suggestion-card-icon.news { color: #c49df1; background: rgba(145, 82, 204, 0.09); }
.suggestion-card-icon.research { color: #e3b46d; background: rgba(211, 148, 56, 0.09); }
.suggestion-arrow { width: 17px; height: 17px; color: #47566b; transition: color var(--transition-fast), transform var(--transition-fast); }
.suggestion-card:hover .suggestion-arrow { color: #86a7ff; transform: translateX(2px); }

/* Composer */
.composer {
    position: relative;
    flex: 0 0 auto;
    padding: 10px 0 13px;
    border-top: 1px solid var(--chat-line);
    background: rgba(8, 10, 16, 0.92);
    backdrop-filter: blur(18px);
}
.composer-inner {
    position: relative;
    width: min(var(--chat-max-width), 100%);
    margin: 0 auto;
    padding: 0 24px;
}
.composer-box {
    min-width: 0;
    padding-right: 54px;
    border: 1px solid rgba(148, 163, 184, 0.19);
    border-radius: 15px;
    background: #101621;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18), inset 0 1px rgba(255, 255, 255, 0.025);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.composer-box:focus-within { border-color: rgba(96, 165, 250, 0.50); box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(41, 98, 255, 0.07); }
#chat-input {
    width: 100%;
    min-height: 46px;
    max-height: 170px;
    padding: 12px 10px 6px 14px;
    resize: none;
    overflow-y: auto;
    border: 0;
    outline: 0;
    color: #e5ebf4;
    background: transparent;
    font: 14.5px/1.5 var(--font-ui);
}
#chat-input::placeholder { color: #58677c; }
.composer-meta { min-height: 26px; padding: 0 3px 7px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #536177; font-size: 9.5px; }
.composer-source { display: inline-flex; align-items: center; gap: 5px; }
.composer-source > span { width: 5px; height: 5px; border-radius: 50%; background: var(--up-color); }
.composer-controls {
    position: absolute;
    right: 31px;
    bottom: 6px;
    z-index: 2;
}
.send-btn,
.stop-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.send-btn { background: linear-gradient(145deg, #356cff, #2454d8); box-shadow: 0 9px 24px rgba(41, 98, 255, 0.20); }
.send-btn:not(:disabled):hover { transform: translateY(-1px); background: linear-gradient(145deg, #4478ff, #2a5ce5); }
.send-btn:disabled { color: #5d6b80; background: #182033; box-shadow: none; cursor: not-allowed; }
.send-btn svg,
.stop-btn svg { width: 18px; height: 18px; }
.stop-btn { background: rgba(239, 83, 80, 0.9); box-shadow: 0 9px 24px rgba(239, 83, 80, 0.14); }
.stop-btn:hover { transform: translateY(-1px); background: #ef5350; }
.stop-btn[hidden] { display: none; }
.composer-hint { max-width: var(--chat-max-width); margin: 7px auto 0; padding: 0 24px; color: #465369; font-size: 9.5px; text-align: center; }
.jump-latest {
    position: absolute;
    z-index: 25;
    top: -47px;
    left: 50%;
    min-height: 36px;
    padding: 5px 11px 5px 6px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transform: translateX(-50%);
    border: 1px solid rgba(96, 165, 250, 0.32);
    border-radius: 999px;
    color: #c9d8ff;
    background: rgba(20, 26, 39, 0.96);
    box-shadow: var(--chat-shadow);
    font: 650 11.5px/1 var(--font-ui);
    cursor: pointer;
    backdrop-filter: blur(12px);
}
.jump-latest:hover { border-color: rgba(96, 165, 250, 0.62); color: #fff; }
.jump-latest[hidden] { display: none; }
.jump-latest-icon { width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #9ab6ff; background: rgba(41, 98, 255, 0.15); }

/* Desktop research inspector */
.chat-inspector {
    min-width: 0;
    min-height: 0;
    padding: 20px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    border-left: 1px solid var(--chat-line);
    background:
        linear-gradient(180deg, rgba(16, 22, 34, 0.86), rgba(10, 14, 22, 0.94)),
        var(--bg-app);
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.18) transparent;
}
.inspector-header,
.inspector-section-title,
.inspector-state,
.inspector-step,
.inspector-policy {
    display: flex;
    align-items: center;
}
.inspector-header { min-height: 41px; justify-content: space-between; gap: 12px; }
.inspector-eyebrow {
    display: block;
    margin-bottom: 3px;
    color: #647da9;
    font-size: 8.5px;
    font-weight: 800;
    letter-spacing: 1.35px;
}
.inspector-header h2 { color: #e8eef8; font-size: 15px; line-height: 1.25; letter-spacing: -0.2px; }
.inspector-state {
    min-height: 28px;
    gap: 6px;
    padding: 0 9px;
    flex: 0 0 auto;
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 999px;
    color: #76869c;
    background: rgba(9, 13, 21, 0.55);
    font-size: 10px;
    font-weight: 650;
}
.inspector-state i { width: 6px; height: 6px; border-radius: 50%; background: #607087; }
.inspector-state.working { color: #aebfff; border-color: rgba(96, 165, 250, 0.23); background: rgba(41, 98, 255, 0.07); }
.inspector-state.working i { background: #7698ff; box-shadow: 0 0 0 4px rgba(65, 105, 225, 0.10); animation: inspectorPulse 1.2s ease-in-out infinite; }
.inspector-state.done { color: #92c9c0; border-color: rgba(38, 166, 154, 0.19); background: rgba(38, 166, 154, 0.055); }
.inspector-state.done i { background: var(--up-color); }
.inspector-state.error { color: #e3a09e; border-color: rgba(239, 83, 80, 0.22); }
.inspector-state.error i { background: var(--down-color); }
@keyframes inspectorPulse { 50% { opacity: .45; transform: scale(.82); } }

.inspector-section { min-width: 0; }
.inspector-section-title { min-height: 24px; margin-bottom: 8px; justify-content: space-between; gap: 10px; }
.inspector-section-title h3 { color: #9eacc0; font-size: 10.5px; font-weight: 700; letter-spacing: .15px; }
.inspector-section-title > span {
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 7px;
    color: #6e7e94;
    background: rgba(8, 12, 19, 0.44);
    font-size: 9.5px;
    font-weight: 700;
}
.inspector-activity,
.inspector-sources { display: flex; flex-direction: column; gap: 7px; }
.inspector-empty {
    min-height: 96px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px dashed rgba(148, 163, 184, 0.14);
    border-radius: 12px;
    color: #5d6d82;
    background: rgba(8, 12, 19, 0.28);
    text-align: center;
}
.inspector-empty.compact { min-height: 66px; padding: 12px; }
.inspector-empty-icon { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 9px; color: #64799b; background: rgba(96, 165, 250, 0.07); }
.inspector-empty-icon svg { width: 17px; height: 17px; }
.inspector-empty p { max-width: 210px; font-size: 10.5px; line-height: 1.55; }

.inspector-step {
    position: relative;
    min-width: 0;
    min-height: 52px;
    padding: 9px;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 11px;
    background: rgba(12, 17, 27, 0.62);
}
.inspector-step-icon {
    width: 29px;
    height: 29px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 29px;
    border-radius: 9px;
    color: #7799f0;
    background: rgba(41, 98, 255, 0.09);
}
.inspector-step-icon svg { width: 16px; height: 16px; }
.inspector-step-copy { min-width: 0; padding-top: 1px; flex: 1 1 auto; }
.inspector-step-title { overflow: hidden; color: #b7c4d6; font-size: 10.5px; font-weight: 650; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.inspector-step-detail { margin-top: 3px; overflow: hidden; color: #607087; font-size: 9.5px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.inspector-step-status { width: 7px; height: 7px; margin-top: 7px; flex: 0 0 7px; border-radius: 50%; background: #7698ff; box-shadow: 0 0 0 3px rgba(65, 105, 225, 0.10); animation: inspectorPulse 1.2s ease-in-out infinite; }
.inspector-step.done .inspector-step-status { background: var(--up-color); box-shadow: none; animation: none; }
.inspector-step.error .inspector-step-status { background: var(--down-color); box-shadow: none; animation: none; }
.inspector-step.error { border-color: rgba(239, 83, 80, 0.17); }

.inspector-source-section { flex: 1 1 auto; }
.inspector-sources .source-card { padding: 10px; background: rgba(11, 16, 25, 0.64); }
.inspector-sources .source-title { font-size: 11px; }
.inspector-sources .source-domain { font-size: 9.5px; }
.inspector-policy {
    margin-top: auto;
    padding: 11px;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid rgba(38, 166, 154, 0.13);
    border-radius: 12px;
    color: #66788c;
    background: rgba(38, 166, 154, 0.035);
}
.inspector-policy-icon { width: 27px; height: 27px; display: flex; align-items: center; justify-content: center; flex: 0 0 27px; border-radius: 8px; color: #72b9ad; background: rgba(38, 166, 154, 0.08); }
.inspector-policy-icon svg { width: 16px; height: 16px; }
.inspector-policy p { font-size: 9.5px; line-height: 1.5; }
.inspector-policy strong { display: block; margin-bottom: 1px; color: #91a9a7; font-size: 10px; }

/* Connection state */
.connection-status .status-dot { background: var(--text-muted); }
.connection-status.connected .status-dot { background: var(--up-color); }
.connection-status.thinking .status-dot { background: var(--accent); }
.connection-status.error .status-dot { background: var(--down-color); }

/* Reset dialog */
.chat-dialog {
    position: fixed;
    inset: 50% auto auto 50%;
    margin: 0;
    transform: translate(-50%, -50%);
    width: min(400px, calc(100vw - 32px));
    max-height: min(80dvh, 520px);
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 16px;
    color: var(--text-primary);
    background: #111722;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}
.chat-dialog::backdrop { background: rgba(2, 5, 10, 0.70); backdrop-filter: blur(4px); }
.chat-dialog-body { padding: 20px; }
.chat-dialog h3 { margin-bottom: 7px; font-size: 16px; }
.chat-dialog p { color: var(--text-secondary); font-size: 12.5px; line-height: 1.55; }
.chat-dialog-actions { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.chat-dialog-actions button { min-height: 38px; padding: 0 14px; border: 1px solid var(--chat-line); border-radius: 10px; color: var(--text-secondary); background: var(--bg-panel); font: 600 12px/1 var(--font-ui); cursor: pointer; }
.chat-dialog-actions .confirm-reset { color: #fff; border-color: rgba(41, 98, 255, 0.5); background: var(--accent); }

@media (max-width: 900px) {
    .chat-commandbar { padding-left: 18px; padding-right: 18px; }
    .source-list { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
    .chat-workspace { display: flex; }
    .chat-main { flex: 1 1 auto; }
    .chat-inspector { display: none; }
}

@media (max-width: 768px) {
    html,
    body { height: 100dvh; overflow: hidden; }

    /* The fixed bottom nav already owns global navigation on mobile. Collapse
       the generic brand bar so the chat command bar becomes the sole top bar. */
    body.chat-page .dashboard-header {
        height: 0;
        min-height: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        overflow: visible;
    }
    body.chat-page .dashboard-header > .header-logo,
    body.chat-page .dashboard-header > .header-status { display: none; }

    .app-container {
        height: calc(100dvh - var(--mobile-nav-height) - env(safe-area-inset-bottom));
        min-height: 0;
        overflow: hidden;
    }
    .chat-layout { height: auto; min-height: 0; flex: 1 1 auto; }
    .chat-workspace { width: 100%; min-height: 0; flex: 1 1 auto; }
    .chat-main { min-height: 0; }
    .chat-commandbar { min-height: 51px; padding: 7px 12px; gap: 8px; }
    .chat-commandbar-copy { gap: 8px; }
    .chat-commandbar-copy > div > span { display: none; }
    .assistant-mark { width: 31px; height: 31px; flex-basis: 31px; border-radius: 10px; }
    .assistant-mark svg { width: 18px; height: 18px; }
    .research-mode { display: none; }
    .chat-agent-status {
        width: 31px;
        min-width: 31px;
        height: 31px;
        min-height: 31px;
        padding: 0;
        display: flex;
        justify-content: center;
        border: 1px solid var(--chat-line);
        background: rgba(15, 19, 30, 0.72);
    }
    .chat-agent-status .status-text { display: none; }
    .new-chat-btn { width: 34px; min-height: 34px; padding: 0; justify-content: center; }
    .new-chat-btn span { display: none; }

    .chat-thread { padding: 16px 0 24px; scrollbar-gutter: auto; }
    .msg-row { margin-bottom: 20px; padding: 0 12px; }
    .msg-user .message-main { max-width: 88%; }
    .msg-user .bubble { padding: 10px 13px; border-radius: 14px 14px 4px 14px; font-size: 13.5px; line-height: 1.55; }
    .msg-assistant .bubble-wrap { grid-template-columns: 29px minmax(0, 1fr); gap: 8px; }
    .assistant-avatar { width: 29px; height: 29px; border-radius: 9px; }
    .assistant-avatar svg { width: 16px; height: 16px; }
    .message-header { min-height: 21px; margin-bottom: 4px; }
    .msg-assistant .bubble { padding: 13px 12px; border-radius: 4px 13px 13px 13px; font-size: 13.5px; line-height: 1.68; }
    .tool-track { gap: 5px; margin-bottom: 6px; }
    .tool-chip { min-height: 28px; padding: 4px 8px; font-size: 10.5px; }

    .bubble h1 { font-size: 18px; }
    .bubble h2 { font-size: 16px; }
    .bubble h3 { font-size: 14px; }
    .md-table-scroll { margin: 10px 0; }
    .bubble table { width: max-content; min-width: 540px; font-size: 12px; }
    .bubble th,
    .bubble td { min-width: 80px; padding: 8px 9px; white-space: nowrap; }
    .bubble pre { padding: 12px; }
    .source-list { grid-template-columns: 1fr; }

    .chat-welcome { width: calc(100% - 24px); min-height: auto; padding: 28px 0 18px; justify-content: flex-start; }
    .welcome-icon { width: 52px; height: 52px; margin-bottom: 14px; border-radius: 17px; }
    .welcome-icon svg { width: 29px; height: 29px; }
    .welcome-eyebrow { margin-bottom: 7px; font-size: 9px; }
    .chat-welcome h2 { margin-bottom: 8px; font-size: 22px; }
    .chat-welcome > p { margin-bottom: 20px; font-size: 12px; line-height: 1.55; }
    .suggestions { grid-template-columns: 1fr; gap: 7px; }
    .suggestion-card { min-height: 60px; grid-template-columns: 33px minmax(0, 1fr) 16px; gap: 9px; padding: 9px 10px; border-radius: 12px; }
    .suggestion-card-icon { width: 33px; height: 33px; border-radius: 10px; }

    .composer { padding: 7px 0 8px; z-index: 20; }
    .composer-inner { padding: 0 10px; }
    .composer-box { padding-right: 46px; border-radius: 13px; }
    #chat-input { min-height: 43px; max-height: 132px; padding: 10px 8px 10px 11px; font-size: 16px; }
    .composer-meta { display: none; }
    .composer-controls { right: 14px; bottom: 4px; }
    .send-btn,
    .stop-btn { width: 36px; height: 36px; border-radius: 11px; }
    .composer-hint { max-height: 15px; margin-top: 5px; padding: 0 12px; overflow: hidden; font-size: 8.5px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
    .jump-latest { top: -43px; min-height: 34px; }
}

@media (max-width: 420px) {
    .chat-commandbar-copy strong { font-size: 12.5px; }
    .suggestion-card small { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .msg-row,
    .typing span,
    .tool-ico-spin { animation: none; }
    .suggestion-card,
    .new-chat-btn,
    .send-btn,
    .stop-btn { transition: none; }
}
