/* Agent activity panel. Tokens follow the terminal theme (data-theme), not the OS scheme. */

#chat-overlay {
    --act-card: #0b141a;
    --act-card2: #0f1a21;
    --act-inset: #081015;
    --act-code: #04080b;
    --act-codeTx: #7fd8de;
    --act-bd: #1a2a35;
    --act-bd2: #15232c;
    --act-btnbd: #22343f;
    --act-tx: #dbe6ec;
    --act-strong: #f2f7fa;
    --act-mid: #a9bcc7;
    --act-mut: #93a9b6;
    --act-faint: #7f97a5;
    --act-acc: #3fd6e0;
    --act-accTx: #6fe3ea;
    --act-wBg: #33240b;
    --act-wTx: #f6c46a;
    --act-wNode: #f6c46a;
    --act-err: #ffb4b4;
    --act-apBg: #1c140a;
    --act-apBd: #5a3a12;
    --act-apTx: #f2e6d2;
    --act-apBtn: #f6c46a;
    --act-rail: #1c2b35;
    --act-node: #5d7684;
    --act-logo: #0b1a20;
    --act-sh1: #9fb3bf;
    --act-sh2: #e9f3f6;
}

html[data-theme="light"] #chat-overlay {
    --act-card: #ffffff;
    --act-card2: #f6f8f9;
    --act-inset: #f3f6f8;
    --act-code: #f4f7f8;
    --act-codeTx: #0b6670;
    --act-bd: #e3e7ea;
    --act-bd2: #edf0f2;
    --act-btnbd: #d6dde1;
    --act-tx: #1f2a30;
    --act-strong: #0f171c;
    --act-mid: #4a5a64;
    --act-mut: #5f707a;
    --act-faint: #6b7b85;
    --act-acc: #0e8a94;
    --act-accTx: #0b6f78;
    --act-wBg: #fff4dd;
    --act-wTx: #8a5a00;
    --act-wNode: #d99a1c;
    --act-err: #9f2d2d;
    --act-apBg: #fff8ea;
    --act-apBd: #f0d49a;
    --act-apTx: #4a3a1c;
    --act-apBtn: #e3a52b;
    --act-rail: #e3e7ea;
    --act-node: #9aa8b0;
    --act-logo: #3d6b80;
    --act-sh1: #7c8c95;
    --act-sh2: #0f171c;
}

#chat-overlay .chat-run-header {
    gap: 10px;
    flex-shrink: 0;
}

#chat-overlay .chat-run-avatar {
    width: 36px;
    height: 36px;
    background: var(--act-logo);
    border: none;
    box-shadow: none;
}

#chat-overlay .chat-run-avatar img {
    width: 18px;
    height: 18px;
    opacity: 1;
}

#chat-overlay .chat-run-label-name {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0;
    color: var(--act-strong);
}

#chat-overlay .chat-run-label-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--act-mut);
    border-color: var(--act-btnbd);
    background: transparent;
    padding: 1px 6px;
}

#chat-overlay .chat-run-desks {
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
    margin-left: 4px;
    height: 22px;
    overflow: visible;
}

#chat-overlay .chat-run-desks .chat-work-bots {
    height: 16px;
    gap: 4px;
}

#chat-overlay .chat-run-desks .chat-work-bot svg {
    width: 16px;
    height: 16px;
}

#chat-overlay .chat-run-header.is-running .chat-work-bot {
    animation: chat-work-bob 1.1s ease-in-out infinite;
}

#chat-overlay .chat-run-header.is-running .chat-work-eye {
    animation: chat-work-blink 4s infinite;
}

#chat-overlay .chat-run-body.chat-activity {
    position: relative;
    flex: 0 0 auto;
    align-self: stretch;
    min-height: 52px;
    width: 100%;
    background: var(--act-card);
    border: 1px solid var(--act-bd);
    border-radius: 14px;
    padding: 0;
    gap: 0;
    box-shadow: none;
    color: var(--act-tx);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    max-height: none;
    overflow: hidden;
}

html[data-theme="light"] #chat-overlay .chat-run-body.chat-activity {
    background: var(--act-card);
    border-color: var(--act-bd);
    color: var(--act-tx);
    box-shadow: none;
}

#chat-overlay .chat-run-body.chat-activity.collapsed {
    max-height: none !important;
    padding: 0 !important;
    border: 1px solid var(--act-bd) !important;
    opacity: 1;
    margin-bottom: 12px !important;
    overflow: hidden;
}

.chat-activity-head {
    width: 100%;
    min-height: 52px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.chat-activity-head:focus-visible,
.chat-act-think:focus-visible,
.chat-act-group:focus-visible,
.chat-act-raw:focus-visible,
.chat-activity-jump:focus-visible,
.chat-act-approve button:focus-visible {
    outline: 2px solid var(--act-acc);
    outline-offset: 2px;
}

.chat-activity-head-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-activity-mark {
    display: inline-flex;
    flex: none;
    color: var(--act-acc);
}

.chat-activity-mark .chat-activity-err { color: var(--act-err); }

.chat-activity-step {
    min-width: 0;
    font-weight: 500;
    color: var(--act-strong);
}

.chat-activity-shimmer {
    background: linear-gradient(90deg, var(--act-sh1) 0%, var(--act-sh2) 50%, var(--act-sh1) 100%);
    background-size: 400px 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: chat-act-shim 1.6s linear infinite;
}

.chat-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--act-acc);
    animation: chat-act-pulse 1.2s ease-in-out infinite;
}

@keyframes chat-act-pulse { 50% { opacity: .35; } }
@keyframes chat-act-shim {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.chat-activity-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.chat-activity-head-side {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    margin-left: auto;
}

.chat-activity-pill {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
}

.chat-activity-pill.is-warn { background: var(--act-wBg); color: var(--act-wTx); }
.chat-activity-pill.is-err { background: var(--act-wBg); color: var(--act-err); }

.chat-activity-head .chat-activity-chev {
    flex: none;
    color: var(--act-mut);
    transition: transform .15s;
}

.chat-activity.is-open .chat-activity-head .chat-activity-chev { transform: rotate(180deg); }

.chat-activity-scroll { border-top: 1px solid var(--act-bd2); }

.chat-activity.is-open.is-live .chat-activity-scroll {
    max-height: 60vh;
    overflow: auto;
}

.chat-activity:not(.is-open) .chat-activity-scroll,
.chat-activity:not(.is-open) .chat-activity-jump { display: none; }

.chat-activity-tl {
    list-style: none;
    margin: 0;
    padding: 4px 16px 16px;
}

.chat-act-item {
    display: flex;
    gap: 12px;
    content-visibility: auto;
    contain-intrinsic-size: auto 48px;
}

.chat-act-rail {
    flex: none;
    width: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 14px;
}

.chat-act-line {
    width: 1px;
    flex: 1 1 auto;
    background: var(--act-rail);
    margin-top: 4px;
    min-height: 8px;
}

.chat-act-item:last-child .chat-act-line { display: none; }

.chat-act-node.is-thought {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid var(--act-node);
    flex: none;
    box-sizing: border-box;
}

.chat-act-node.is-tool {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--act-acc);
    flex: none;
}

.chat-act-node.is-tool.is-warn { background: var(--act-wNode); }

.chat-act-body {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 0;
}

.chat-act-think {
    width: 100%;
    min-height: 36px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
    background: transparent;
    border: 0;
    text-align: left;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.chat-act-title {
    font-weight: 500;
    font-size: 13.5px;
    color: var(--act-strong);
}

.chat-act-think .chat-act-title.is-warn { color: var(--act-wTx); }
.chat-act-think .chat-act-title.is-active { color: var(--act-accTx); }

.chat-act-sum {
    color: var(--act-mut);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-act-full {
    margin: 6px 0 2px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--act-inset);
    border: 1px solid var(--act-bd2);
    color: var(--act-mid);
    font-size: 13px;
    white-space: pre-wrap;
}

.chat-act-group {
    width: 100%;
    min-height: 38px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--act-card2);
    border: 1px solid var(--act-bd);
    text-align: left;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.chat-act-group svg { flex: none; color: var(--act-accTx); }
.chat-act-group .chat-act-title { flex: 1 1 auto; min-width: 0; }
.chat-act-group .chat-activity-chev {
    flex: none;
    color: var(--act-mut);
    transition: transform .15s;
}
.chat-act-group[aria-expanded="true"] .chat-activity-chev { transform: rotate(180deg); }

.chat-act-meta {
    font-size: 12px;
    color: var(--act-mut);
    flex: none;
}

.chat-act-out {
    padding: 4px 0 0 2px;
    color: var(--act-mid);
    font-size: 13px;
}

.chat-act-calls {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-act-call {
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--act-inset);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-act-call-top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
}

.chat-act-st {
    font-size: 11px;
    font-weight: 600;
    color: var(--act-accTx);
    flex: none;
}

.chat-act-st.is-warn { color: var(--act-wTx); }
.chat-act-st.is-err { color: var(--act-err); }

.chat-act-spin {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--act-acc);
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -1px;
    animation: chat-act-spin .7s linear infinite;
}

@keyframes chat-act-spin { to { transform: rotate(360deg); } }

.chat-act-label { color: var(--act-strong); }
.chat-act-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: var(--act-faint);
}

.chat-act-result { color: var(--act-mid); font-size: 13px; }

.chat-act-raw,
.chat-act-copy {
    margin-left: auto;
    min-height: 26px;
    padding: 0 8px;
    border-radius: 5px;
    border: 1px solid var(--act-btnbd);
    background: transparent;
    color: var(--act-mut);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    cursor: pointer;
}

.chat-act-call pre {
    margin: 4px 0 0;
    padding: 10px;
    border-radius: 6px;
    background: var(--act-code);
    border: 1px solid var(--act-bd2);
    color: var(--act-codeTx);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow: auto;
}

.chat-activity-jump {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--act-btnbd);
    background: var(--act-card);
    color: var(--act-strong);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.chat-activity-approvals:empty { display: none; }

.chat-activity-approvals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-act-approve {
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--act-apBg);
    border: 1px solid var(--act-apBd);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.chat-act-approve-copy { flex: 1 1 260px; min-width: 0; }
.chat-act-approve-k {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--act-wTx);
    letter-spacing: .04em;
}
.chat-act-approve-v { color: var(--act-apTx); }
.chat-act-approve-err { color: var(--act-err); font-size: 13px; margin-top: 4px; }

.chat-act-approve button {
    min-height: 38px;
    padding: 0 16px;
    border-radius: 8px;
    border: 0;
    background: var(--act-apBtn);
    color: #1c140a;
    font-weight: 600;
    cursor: pointer;
}

.chat-act-approve button:disabled { cursor: default; opacity: .8; }

.chat-act-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

#chat-overlay .chat-md-scroll {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid var(--act-bd);
    border-radius: 10px;
    background: var(--act-card);
}

#chat-overlay .chat-md-scroll .chat-md-table {
    min-width: 480px;
    margin: 0;
}

@media (max-width: 640px) {
    .chat-activity-head { align-items: flex-start; }
    .chat-activity-head-main { flex-wrap: wrap; }
    .chat-act-call-top { align-items: center; }
    .chat-act-mono { flex: 1 1 100%; }
    #chat-overlay .chat-run-header { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-activity-dot,
    .chat-activity-shimmer,
    .chat-act-spin,
    #chat-overlay .chat-run-header.is-running .chat-work-bot,
    #chat-overlay .chat-run-header.is-running .chat-work-eye {
        animation: none;
    }
    .chat-activity-shimmer {
        color: var(--act-accTx);
        background: none;
        -webkit-text-fill-color: currentColor;
    }
    .chat-act-spin { border-right-color: var(--act-acc); }
}
