@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --bg: #0c0c0e;
    --sidebar: #121214;
    --sheet: #141417;
    --hover: rgba(255,255,255,0.05);
    --line: rgba(255,255,255,0.08);
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --dim: #71717a;
}

* { box-sizing: border-box; }
html {
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
}
body {
    margin: 0;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    max-width: 100vw;
}
.tabular-nums, .font-mono { font-variant-numeric: tabular-nums; }
.font-mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }

#app {
    background: var(--bg);
    overflow-x: hidden;
    max-width: 100vw;
}

.roster-group {
    padding: 0.85rem 0.5rem 0.35rem;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
}
.roster-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    padding: 0.75rem 0.85rem;
    min-height: 54px;
    border-radius: 1.15rem;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition-property: background-color, border-color, transform;
    transition-duration: 0.15s;
}
.roster-item:hover { background: var(--hover); }
.roster-item:active { transform: scale(0.98); }
.roster-item.active {
    background: #1c1c20;
    border-color: var(--line);
}
.avatar {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    position: relative;
    user-select: none;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
@media (max-width: 767px) {
    .avatar {
        width: 3rem;
        height: 3rem;
        font-size: 0.95rem;
        border-radius: 1rem;
    }
}
.avatar-md {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 1rem;
    font-size: 1.05rem;
}
.avatar-lg {
    width: 4rem;
    height: 4rem;
    border-radius: 1.25rem;
    font-size: 1.25rem;
}
.dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 99px;
    position: absolute;
    right: -2px;
    bottom: -2px;
    outline: 2px solid var(--sidebar);
}
.dot-online { background: #34d399; }
.dot-degraded { background: #fbbf24; }
.dot-stopped, .dot-unknown { background: #52525b; }

.stat {
    background: #16161a;
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    padding: 0.9rem 1rem;
}
.stat dt { font-size: 11px; color: var(--dim); }
.stat dd { margin: 0.2rem 0 0; font-size: 0.95rem; color: var(--text); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.skill-cat { width: 100%; text-align: left; background: transparent; border: 0; color: inherit; cursor: pointer; padding: 0.5rem 0; min-height: 40px; }
.skill-cat + .skill-items { display: none; }
.skill-cat.open + .skill-items { display: block; }

#workspace.detail #roster { display: none; }
#workspace.detail #home { display: flex; }
@media (min-width: 768px) {
    #workspace.detail #roster { display: flex; }
    #btn-back { display: none !important; }
}
@media (max-width: 767px) {
    #home { display: none; }
    #workspace.detail #home { display: flex; }
}

button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

/* ==========================================
   TAB NAVIGATION (Hub vs Chat)
   ========================================== */
.tab-btn {
    background: transparent;
    color: var(--muted);
    border: 0;
}
.tab-btn:hover {
    color: var(--text);
}
.tab-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

#app > header.hub-header {
    height: auto;
    min-height: calc(3rem + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
}
#chat-subheader {
    min-height: 3rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}
.agent-git {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    margin-left: 0.35rem;
}
.agent-git.is-idle { display: none; }
#ws-project-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================
   CHAT DRAWER & CONVERSATIONS
   ========================================== */
@media (max-width: 767px) {
    #chat-sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
        width: 85vw;
        max-width: 320px;
    }
    #chat-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0,0,0,0.85);
    }
    button, select, input, textarea, .roster-item, .chat-agent-item, .conv-item {
        min-height: 44px;
    }
    .tool-copy-btn, .engine-opt, .section-icon, .chat-section-toggle, .chat-feedback-btn {
        min-height: 32px;
        min-width: 0;
        padding: 0.25rem 0.4rem;
    }
    .chat-feedback-btn {
        width: 2rem;
        height: 2rem;
        min-width: 2rem;
        min-height: 2rem;
        padding: 0;
    }
    #chat-send-btn, #chat-mic-btn, #chat-attach-btn {
        min-width: 44px;
        min-height: 44px;
    }
    #btn-toggle-chat-sidebar, #btn-clear-active-chat, #btn-ws-refresh, #btn-close-chat-sidebar, #btn-manage-projects, #btn-sync, #btn-user {
        min-width: 44px;
        min-height: 44px;
    }
    #chat-agent-picker {
        max-height: 9.5rem;
    }
    #project-modal {
        padding: 0;
    }
    #project-modal-panel {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    #project-modal-list {
        max-height: min(22vh, 10rem);
    }
    #chat-form textarea {
        min-height: 24px;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }
    #chat-workspace-banner .max-w-4xl {
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }
    #ws-project-name {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

.chat-agent-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    min-height: 48px;
    border-radius: 1rem;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.chat-agent-item:hover {
    background: var(--hover);
}
.chat-agent-item:active {
    transform: scale(0.98);
}
.chat-agent-item.active {
    background: #1c1c20;
    border-color: var(--line);
}

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    width: 100%;
    text-align: left;
    padding: 0.65rem 0.75rem;
    min-height: 52px;
    border-radius: 1rem;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}
.conv-item:hover {
    background: var(--hover);
}
.conv-item:active {
    transform: scale(0.98);
}
.conv-item.active {
    background: #1c1c20;
    border-color: var(--line);
}
.conv-item .delete-conv-btn {
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
}
.conv-item:hover .delete-conv-btn,
.conv-item:focus-within .delete-conv-btn {
    opacity: 1;
}

.agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.03);
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}
.agent-chip:hover {
    background: rgba(255,255,255,0.07);
    color: var(--text);
}
.agent-chip.active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.3);
    color: #ffffff;
    font-weight: 500;
}

/* ==========================================
   CHAT MESSAGES (conversación fina)
   ========================================== */
.chat-msg-row {
    display: flex;
    max-width: 48rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    overflow-x: hidden;
}
.chat-msg-row.user {
    justify-content: flex-end;
    overflow: visible;
}
.chat-msg-row.assistant {
    justify-content: flex-start;
}
.chat-assistant-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}
.chat-feedback {
    display: flex;
    align-items: center;
    gap: 0.1rem;
}
.chat-feedback-btn {
    position: relative;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    min-height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.38);
    cursor: pointer;
    transition-property: color, background-color, transform;
    transition-duration: 0.15s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.chat-feedback-btn::before {
    content: '';
    position: absolute;
    inset: -6px;
}
.chat-feedback-btn svg {
    width: 14px;
    height: 14px;
}
.chat-feedback-btn:hover,
.chat-feedback-btn:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}
.chat-feedback-btn:active {
    transform: scale(0.96);
}
.chat-feedback-btn.is-on {
    color: #34d399;
}
.chat-feedback-btn.is-down {
    color: #fb7185;
}

/* Columna del usuario: chips de adjuntos arriba, burbuja compacta debajo */
.chat-user-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    max-width: 80%;
    min-width: 0;
}

.chat-bubble-user {
    background: rgba(255, 255, 255, 0.055);
    color: #f4f4f5;
    border-radius: 1.1rem;
    padding: 0.55rem 0.95rem;
    font-size: 0.935rem;
    line-height: 1.55;
    max-width: 100%;
    word-break: break-word;
    white-space: pre-wrap;
    text-wrap: pretty;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

/* Copiar + hora, alineados al borde derecho de la burbuja */
.chat-user-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: -0.15rem;
    min-height: 1.75rem;
}
.chat-user-copy {
    position: relative;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    min-height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.42);
    cursor: pointer;
    transition-property: color, background-color, transform;
    transition-duration: 0.15s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.chat-user-copy::before {
    content: '';
    position: absolute;
    inset: -6px;
}
.chat-user-copy:hover,
.chat-user-copy:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}
.chat-user-copy:active {
    transform: scale(0.96);
}
.chat-user-copy-glyph {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition-property: opacity, transform, filter;
    transition-duration: 0.2s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.chat-user-copy-glyph svg {
    width: 15px;
    height: 15px;
}
.chat-user-copy .is-check {
    opacity: 0;
    transform: scale(0.25);
    filter: blur(4px);
    color: #34d399;
}
.chat-user-copy.is-copied .is-copy {
    opacity: 0;
    transform: scale(0.25);
    filter: blur(4px);
}
.chat-user-copy.is-copied .is-check {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}
.chat-user-time {
    font-size: 12px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.38);
    font-variant-numeric: tabular-nums;
    user-select: none;
    padding-right: 0.2rem;
}

/* Respuesta del agente: texto plano sobre el lienzo, sin caja */
.chat-bubble-assistant {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: #e9e9ec;
    border-radius: 0;
    padding: 0;
    font-size: 0.965rem;
    line-height: 1.7;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    word-break: break-word;
    text-wrap: pretty;
}

/* ==========================================
   MARKDOWN BODY IN ASSISTANT RESPONSES
   ========================================== */
.markdown-body p { margin-top: 0; margin-bottom: 0.85rem; text-wrap: pretty; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    color: #ffffff;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin-top: 1.6em;
    margin-bottom: 0.55rem;
    text-wrap: balance;
}
.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.12rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body ul, .markdown-body ol {
    margin: 0.4rem 0 0.85rem 1.2rem;
    padding: 0;
}
.markdown-body ul { list-style-type: disc; }
.markdown-body ol { list-style-type: decimal; }
.markdown-body li { margin-bottom: 0.3rem; text-wrap: pretty; }
.markdown-body li::marker { color: rgba(255, 255, 255, 0.35); }
.markdown-body a {
    color: #a78bfa;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.markdown-body code:not(pre code) {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.855em;
    background: rgba(255, 255, 255, 0.07);
    padding: 0.12em 0.38em;
    border-radius: 0.4rem;
    color: #e4e4e7;
}
.markdown-body .code-block-wrapper {
    margin: 0.9rem 0;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #0d0d10;
    overflow: hidden;
}
.markdown-body .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--dim);
}
.markdown-body pre {
    margin: 0;
    padding: 0.85rem 1rem;
    background: transparent;
    border: 0;
    overflow-x: auto;
}
.markdown-body pre code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #e4e4e7;
    background: transparent;
    padding: 0;
    border: 0;
}
.copy-code-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.copy-code-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}
.markdown-body blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.2);
    margin: 0.75rem 0;
    padding-left: 0.75rem;
    color: var(--muted);
    font-style: italic;
}
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.9rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}
.markdown-body th, .markdown-body td {
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 0.55rem 0.8rem;
    text-align: left;
    vertical-align: top;
}
.markdown-body tr:first-child th { border-top: 1px solid rgba(255, 255, 255, 0.07); }
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th {
    background: transparent;
    font-weight: 600;
    color: #ffffff;
}
.markdown-body td:first-child {
    color: #d4d4d8;
    font-weight: 500;
}

/* ==========================================
   TELEMETRÍA FINA: tool rows, thinking y trabajo
   ========================================== */
/* Piezas compartidas de las meta-líneas */
.tool-cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}
.tool-cat-svg { width: 0.85rem; height: 0.85rem; color: #a1a1aa; }
.tool-call-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: #c3c3ca;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.tool-call-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
    margin-left: auto;
}
.tool-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 11px;
    white-space: nowrap;
}
.tool-status-text { white-space: nowrap; }
.tool-status-svg { width: 0.8rem; height: 0.8rem; flex-shrink: 0; }
.tool-duration {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tool-chevron {
    width: 0.9rem;
    height: 0.9rem;
    color: #71717a;
    flex-shrink: 0;
    transition-property: transform;
    transition-duration: 0.18s;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.tool-call-card {
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    margin-bottom: 0;
    overflow: hidden;
    max-width: 100%;
    transition-property: background-color;
    transition-duration: 0.15s;
}
.tool-call-card:hover { background: rgba(255, 255, 255, 0.035); }
.tool-call-card[data-status="blocked"] .tool-cat-icon { background: rgba(245, 158, 11, 0.12); }
.tool-call-card[data-status="blocked"] .tool-cat-svg { color: #fbbf24; }
.tool-call-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    min-height: 40px;
}
.tool-call-summary:hover { color: #ffffff; }
.tool-call-summary::-webkit-details-marker { display: none; }
.tool-call-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem 0.7rem;
    margin: 0 0 0.25rem;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 0.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #a1a1aa;
    overflow-x: auto;
}

/* ==========================================================================
   Worked Timeline (Estilo Antigravity / Líneas de pensamiento y herramientas)
   ========================================================================== */
.worked-timeline {
    margin-bottom: 0.65rem;
    max-width: 100%;
}
.worked-header {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 13px;
    font-weight: 500;
    color: #a1a1aa;
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0.4rem 0.2rem 0;
    border-radius: 4px;
    transition: color 0.15s ease;
}
.worked-header:hover {
    color: #f4f4f5;
}
.worked-header::-webkit-details-marker {
    display: none;
}
.worked-chevron {
    width: 14px;
    height: 14px;
    color: #71717a;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
details[open] > .worked-header .worked-chevron {
    transform: rotate(0deg);
}
details:not([open]) > .worked-header .worked-chevron {
    transform: rotate(-90deg);
}

.worked-steps {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    padding-left: 0.85rem;
    margin-top: 0.35rem;
    margin-bottom: 0.5rem;
    position: relative;
}
.worked-steps::before {
    content: '';
    position: absolute;
    left: 0.25rem;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 1.5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 1px;
}

.worked-step {
    font-size: 12.5px;
    line-height: 1.5;
    color: #a1a1aa;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}
.worked-step-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.2rem 0.4rem;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.worked-step-summary:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #e4e4e7;
}
.worked-step-summary::-webkit-details-marker {
    display: none;
}
.worked-step-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.worked-kind {
    width: 14px;
    height: 14px;
    color: #71717a;
    flex-shrink: 0;
}
.worked-mark {
    display: block;
}
.worked-step-verb {
    color: #f4f4f5;
    font-weight: 500;
    flex-shrink: 0;
}
.worked-step-desc {
    color: #a1a1aa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.worked-step-desc code {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}
.worked-step-icon {
    flex-shrink: 0;
    font-size: 12px;
}
.worked-step-chevron {
    width: 12px;
    height: 12px;
    color: #71717a;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
details[open] > .worked-step-summary .worked-step-chevron {
    transform: rotate(90deg);
}

.worked-step-detail {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
    margin-left: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 0.5rem;
    font-size: 11.5px;
    color: #d4d4d8;
    overflow-x: auto;
    max-height: 280px;
    -webkit-overflow-scrolling: touch;
}
.worked-step-detail pre {
    margin: 0;
    background: transparent;
    border: 0;
    padding: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #d4d4d8;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.worked-status-blocked .worked-step-verb { color: #fbbf24; }
.worked-status-failed .worked-step-verb { color: #f43f5e; }

/* Razonamiento del modelo */
.thinking-accordion {
    border: 0;
    background: transparent;
    margin-bottom: 0;
    overflow: hidden;
    max-width: 100%;
    box-shadow: none;
}
.thinking-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 11px;
    color: #a78bfa;
    cursor: pointer;
    user-select: none;
    min-height: 40px;
    border-radius: 0.5rem;
}
.thinking-summary:hover { background: rgba(139, 92, 246, 0.07); }
.thinking-summary::-webkit-details-marker { display: none; }
.thinking-body {
    padding: 0.55rem 0.75rem 0.75rem;
    background: rgba(139, 92, 246, 0.05);
    border-radius: 0.5rem;
    font-size: 12.5px;
    line-height: 1.65;
    color: #a1a1aa;
    font-style: italic;
}

/* Bloque "Trabajó por Xs · N herramientas" */
.work-meta { margin-bottom: 0.15rem; }
.work-meta-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    min-height: 40px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    color: var(--dim);
    cursor: pointer;
    user-select: none;
    border-radius: 0.5rem;
    transition-property: color, background-color;
    transition-duration: 0.15s;
}
.work-meta-summary:hover { color: #e4e4e7; background: rgba(255, 255, 255, 0.035); }
.work-meta-summary::-webkit-details-marker { display: none; }
.work-meta-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.3rem 0 0 0.35rem;
}

/* Archivos modificados: chips ligeros */
.files-touched-card { margin-bottom: 0.1rem; }
.files-touched-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--dim);
}
.files-touched-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem 0.35rem;
}
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 22rem;
    padding: 0.18rem 0.5rem;
    border-radius: 0.45rem;
    background: rgba(255, 255, 255, 0.045);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #d4d4d8;
}
.file-chip-icon { width: 0.75rem; height: 0.75rem; color: #71717a; flex-shrink: 0; }
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-diff-stats {
    color: #6ee7b7;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}
.diffs-details { margin: 0.1rem 0.5rem 0.35rem; }
.diffs-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 40px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--dim);
    cursor: pointer;
    user-select: none;
}
.diffs-summary:hover { color: #e4e4e7; }
.diffs-summary::-webkit-details-marker { display: none; }
.diffs-body { margin-top: 0.3rem; }

/* Inline diff viewer */
.diff-view {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    background: #09090b;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.5rem 0;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}
.diff-line-add {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border-left: 2px solid #10b981;
    padding: 0.1rem 0.65rem;
    white-space: pre;
    display: block;
}
.diff-line-del {
    background: rgba(244, 63, 94, 0.12);
    color: #fda4af;
    border-left: 2px solid #f43f5e;
    padding: 0.1rem 0.65rem;
    white-space: pre;
    display: block;
}
.diff-line-info {
    color: #71717a;
    padding: 0.1rem 0.65rem;
    white-space: pre;
    display: block;
}

/* Prevent horizontal overflow on code / pre / diff */
pre, code, .diff-view, .tool-call-card, .thinking-accordion {
    max-width: 100%;
}
pre, .diff-view {
    overflow-x: auto;
    word-break: normal;
    -webkit-overflow-scrolling: touch;
}

/* Conversation filter toggle buttons */
.chat-tree-section + .chat-tree-section { margin-top: 0.85rem; }
.chat-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
    padding: 0 0.15rem;
}
.chat-section-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 0;
    background: transparent;
    color: #a1a1aa;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    min-height: 32px;
    padding: 0.2rem 0.35rem;
    border-radius: 8px;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.chat-section-toggle:hover { color: #fff; background: rgba(255,255,255,0.04); }
.chat-section-body { display: flex; flex-direction: column; gap: 1px; }
.folder-chevron { transition: transform 0.15s ease; }
.folder-chevron.is-open,
.proj-folder.is-open > .proj-folder-row .folder-chevron { transform: rotate(90deg); }
.proj-folder-row {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    min-height: 36px;
    border-radius: 10px;
}
.proj-folder.is-current > .proj-folder-row { background: rgba(255,255,255,0.06); }
.proj-folder-main {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
    min-height: 36px;
    border: 0;
    background: transparent;
    color: #e4e4e7;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: 8px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.proj-folder-main:hover { background: rgba(255,255,255,0.04); }
.proj-folder-main:active { transform: scale(0.98); }
.section-icon {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #71717a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.section-icon:hover { color: #fff; background: rgba(255,255,255,0.06); }
.section-icon:active { transform: scale(0.96); }
.proj-pin.is-pinned { color: #f5f5f4; }
.proj-folder-chats { margin: 0 0 0.25rem 1.15rem; display: flex; flex-direction: column; gap: 1px; }
.proj-folder-empty { margin: 0 0 0.35rem 2.2rem; font-size: 11px; color: #71717a; }
.conv-filter-btn {
    border: 0;
    cursor: pointer;
    transition-property: background-color, color, box-shadow;
    transition-duration: 0.15s;
    transition-timing-function: ease;
}

#project-modal-list {
    max-height: min(50vh, 26rem);
}
@media (max-width: 767px) {
    #project-modal #project-modal-list {
        max-height: min(22vh, 10rem);
    }
}
.manage-projects-btn {
    min-height: 36px;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.tab-btn {
    min-height: 36px;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.routine-card {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #16161a;
    border-radius: 1.15rem;
    padding: 0.95rem 1rem 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.routine-card:hover { border-color: rgba(255, 255, 255, 0.18); background: #1b1b20; }
.routine-card.is-paused { opacity: 0.62; }
.routine-card.is-builtin { cursor: pointer; }
#routine-agent {
    color-scheme: dark;
}
#routine-agent optgroup {
    color: #a1a1aa;
    background: #16161a;
    font-size: 12px;
}
#routine-agent option {
    color: #f4f4f5;
    background: #0c0c0e;
}
.routine-chip {
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.32rem 0.7rem;
    font-size: 12px;
    color: #a1a1aa;
    background: transparent;
    white-space: nowrap;
}
.routine-chip.is-on {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.routine-run {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #121214;
    border-radius: 0.9rem;
    padding: 0.7rem 0.8rem;
}
.session-link {
    border: 0;
    background: transparent;
    color: #71717a;
    font-size: 12px;
    cursor: pointer;
    min-height: 32px;
    padding: 0.25rem 0.15rem;
    transition: color 0.15s ease;
}
.session-link:hover { color: #e4e4e7; }
.session-link-out:hover { color: #fda4af; }
.engine-switch {
    display: none;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.engine-switch.is-on { display: inline-flex; }
.engine-opt {
    border: 0;
    background: transparent;
    color: #a1a1aa;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 0.35rem 0.55rem;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.engine-opt.active {
    background: #ffffff;
    color: #18181b;
}
.engine-opt:active { transform: scale(0.96); }
.conv-filter-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.composer-foot {
    flex-wrap: nowrap;
}
.composer-foot #chat-target-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#chat-mic-btn.is-recording {
    background: #e11d48;
    border-color: transparent;
    color: #fff;
    animation: micPulse 1.3s ease-out infinite;
}
#chat-mic-btn.is-busy {
    opacity: 0.55;
    cursor: progress;
}
#chat-mic-status[data-tone="recording"] { color: #fda4af; }
#chat-mic-status[data-tone="busy"] { color: #a1a1aa; }
#chat-mic-status[data-tone="ok"] { color: #86efac; }
#chat-mic-status[data-tone="error"] { color: #fb7185; }
@keyframes micPulse {
    0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45); }
    100% { box-shadow: 0 0 0 10px rgba(225, 29, 72, 0); }
}
@media (prefers-reduced-motion: reduce) {
    #chat-mic-btn.is-recording { animation: none; }
}

/* ==========================================
   IMAGE ATTACHMENTS (CHAT)
   ========================================== */
/* Chips en el compositor (antes de enviar) */
.attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.3rem 0.2rem 0.2rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    max-width: 100%;
}
.attach-chip-thumb {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 0.35rem;
    flex-shrink: 0;
    outline: 1px solid rgba(255, 255, 255, 0.1);
}
.attach-chip-name {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px;
    color: #d4d4d8;
}
.attach-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    border: 0;
    background: rgba(255, 255, 255, 0.07);
    color: #a1a1aa;
    cursor: pointer;
    flex-shrink: 0;
    transition-property: background-color, color, scale;
    transition-duration: 0.15s;
}
.attach-chip-remove:hover {
    background: rgba(244, 63, 94, 0.25);
    color: #fda4af;
}
.attach-chip-remove:active { scale: 0.96; }

/* Chips en mensajes del usuario (ya enviados) */
.chat-attach-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}
.chat-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 16rem;
    padding: 0.18rem 0.55rem 0.18rem 0.2rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    text-decoration: none;
    transition-property: background-color, scale;
    transition-duration: 0.15s;
}
.chat-attach-chip:hover { background: rgba(255, 255, 255, 0.09); }
.chat-attach-chip:active { scale: 0.96; }
.chat-attach-thumb {
    width: 22px;
    height: 22px;
    border-radius: 0.35rem;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
    outline: 1px solid rgba(255, 255, 255, 0.1);
}
.chat-attach-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10.5px;
    color: #d4d4d8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Tipografía raíz: texto más nítido en macOS */
html, body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Safe area input bar */
.chat-input-bar-container {
    padding-bottom: max(0.75rem, calc(0.5rem + env(safe-area-inset-bottom)));
}

/* Typing Dots Animation */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
}
.typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--muted);
    animation: typingPulse 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Utility */
.scrollbar-none::-webkit-scrollbar { display: none; }
.scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; }

/* ==========================================
   PANEL DE CONTROL DEL HUB
   ========================================== */
.dash-card {
    background: #16161a;
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    padding: 1rem 1.1rem;
}
.dash-card > header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.dash-card h3 {
    margin: 0;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
}
.dash-meta { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.dash-sub { display: block; margin-top: 0.15rem; font-size: 10px; color: var(--dim); }
.dash-divider { height: 1px; background: var(--line); margin: 0.6rem 0 0.2rem; }

.dash-range {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: #16161a;
    border: 1px solid var(--line);
    border-radius: 99px;
}
.dash-range button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    padding: 0.4rem 0.75rem;
    border-radius: 99px;
    cursor: pointer;
}
.dash-range button:hover { color: var(--text); }
.dash-range button.active { background: rgba(255,255,255,0.1); color: #fff; }

.dash-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 110px;
}
.dash-bar {
    flex: 1 1 0;
    min-width: 2px;
    height: 100%;
    display: flex;
    align-items: flex-end;
}
.dash-bar > span {
    display: block;
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(180deg, #6366f1, rgba(99,102,241,0.3));
}
.dash-bar:hover > span { background: linear-gradient(180deg, #818cf8, rgba(129,140,248,0.4)); }
.dash-chart-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 10px;
    color: var(--dim);
}

.dash-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dash-table th {
    text-align: left;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--line);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 500;
}
.dash-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
.dash-table tr:last-child td { border-bottom: 0; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.dash-share-pct {
    font-size: 10px;
    color: var(--dim);
    margin-right: 4px;
    font-variant-numeric: tabular-nums;
}
.dash-share {
    display: inline-block;
    width: 56px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255,255,255,0.07);
    overflow: hidden;
    vertical-align: middle;
}
.dash-share > i { display: block; height: 100%; background: #6366f1; }

/* Tarjetas con icono y barra sutil de proporción */
.dash-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: 100%;
}
.dash-stat dt { display: flex; align-items: center; }
.dash-ico { width: 12px; height: 12px; margin-right: 6px; opacity: 0.7; flex-shrink: 0; }
.dash-stat .dash-meter { margin-top: auto; }
.dash-meter {
    display: block;
    height: 3px;
    margin-top: 0.5rem;
    border-radius: 99px;
    background: rgba(255,255,255,0.07);
    overflow: hidden;
}
.dash-meter > i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: #6366f1;
    transition: width 0.3s ease;
}
.dash-meter > i.lvl-ok { background: linear-gradient(90deg, #4338ca, #6366f1); }
.dash-meter > i.lvl-warn { background: linear-gradient(90deg, #b45309, #fbbf24); }
.dash-meter > i.lvl-hot { background: linear-gradient(90deg, #be123c, #fb7185); }
.dash-meter.info > i { background: linear-gradient(90deg, #4338ca, #6366f1); }
.dash-meter.sm { width: 46px; margin-top: 0; }
.dash-meter.ghost { background: rgba(255,255,255,0.035); }

.dash-row-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}

.dash-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 12px;
}
.dash-row:last-child { border-bottom: 0; }

@media (max-width: 767px) {
    /* Controles propios del panel: el mínimo de 44px del resto de la UI no aplica */
    .dash-range button { min-height: 32px; }
    .dash-chart { height: 90px; }
}

