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

:root, [data-theme="dark"] {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-alt: #111;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --muted: #888;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warn: #f59e0b;
    --running: var(--success);
    --paused: var(--warn);
    --error: var(--danger);
    --provisioning: var(--muted);
    --overlay-light: rgba(255,255,255,0.06);
    --overlay-subtle: rgba(255,255,255,0.03);
    --overlay-dark: rgba(0,0,0,0.3);
    --shadow-color: rgba(0,0,0,0.4);
    --code-lang: rgba(255,255,255,0.35);
    --code-btn-bg: rgba(255,255,255,0.1);
    --code-btn-border: rgba(255,255,255,0.15);
    --code-btn-text: rgba(255,255,255,0.6);
    --code-btn-hover-bg: rgba(255,255,255,0.2);
    --code-btn-hover-text: rgba(255,255,255,0.9);
    --error-text: #fca5a5;
    --warn-text: #fcd34d;
    --limit-text: #d1d5db;
    --scrollbar-hover: #444;
}

[data-theme="light"] {
    --bg: #faf9f7;
    --surface: #ffffff;
    --surface-alt: #f5f4f1;
    --border: #e5e7eb;
    --text: #1a1a1a;
    --muted: #6b7280;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    --running: var(--success);
    --paused: var(--warn);
    --error: var(--danger);
    --provisioning: var(--muted);
    --overlay-light: rgba(0,0,0,0.04);
    --overlay-subtle: rgba(0,0,0,0.02);
    --overlay-dark: rgba(0,0,0,0.06);
    --shadow-color: rgba(0,0,0,0.08);
    --code-lang: rgba(0,0,0,0.3);
    --code-btn-bg: rgba(0,0,0,0.06);
    --code-btn-border: rgba(0,0,0,0.1);
    --code-btn-text: rgba(0,0,0,0.5);
    --code-btn-hover-bg: rgba(0,0,0,0.1);
    --code-btn-hover-text: rgba(0,0,0,0.8);
    --error-text: #dc2626;
    --warn-text: #d97706;
    --limit-text: #4b5563;
    --scrollbar-hover: #c4c4c4;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ── Page background gradients ── */
body.landing {
    background: var(--bg);
    position: relative;
}
body.landing::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        /* left edge — indigo wash */
        linear-gradient(135deg, rgba(99,102,241,0.22) 0%, transparent 25%),
        /* right edge — purple wash */
        linear-gradient(225deg, rgba(139,92,246,0.16) 0%, transparent 25%),
        /* left mid streak */
        linear-gradient(170deg, transparent 20%, rgba(99,102,241,0.10) 40%, transparent 55%),
        /* right bottom streak */
        linear-gradient(190deg, transparent 55%, rgba(139,92,246,0.08) 75%, transparent 90%);
    -webkit-mask-image: linear-gradient(90deg,
        black 0%, transparent 25%,
        transparent 75%, black 100%);
    mask-image: linear-gradient(90deg,
        black 0%, transparent 25%,
        transparent 75%, black 100%);
}
[data-theme="light"] body.landing::after,
body.landing[data-theme="light"]::after {
    background:
        linear-gradient(135deg, rgba(79,70,229,0.10) 0%, transparent 25%),
        linear-gradient(225deg, rgba(251,105,81,0.08) 0%, transparent 25%),
        linear-gradient(170deg, transparent 20%, rgba(79,70,229,0.05) 40%, transparent 55%),
        linear-gradient(190deg, transparent 55%, rgba(246,216,77,0.06) 75%, transparent 90%);
}
body.landing > *:not(.sticky-cta-bar) { position: relative; z-index: 1; }

/* App shell: subtle gradient on sidebar */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1a1a1a 0%, #1a1a22 100%);
}
[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, #f5f5f4 0%, #f0f0f6 100%);
}

[v-cloak] { display: none !important; }

#app-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.loader-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { color: var(--accent-hover); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 6px; border: none;
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-icon-sq {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; color: var(--muted);
}
.btn-icon-sq:hover:not(:disabled) { color: var(--text); background: var(--overlay-light); }
.btn-icon-sq svg { display: block; flex-shrink: 0; }
.btn-danger { background: var(--danger); color: white; }
.btn-large { padding: 12px 24px; font-size: 15px; }

/* ── App shell ── */
#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body.landing #app {
    display: block;
    height: auto;
    overflow: visible;
}

/* ── Sidebar ── */
.sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    flex-shrink: 0;
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 0 16px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}
.logo-icon { border-radius: 4px; flex-shrink: 0; }

.btn-collapse {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.sidebar:hover .btn-collapse, .sidebar.collapsed .btn-collapse { opacity: 1; }
.btn-collapse:hover { color: var(--text); background: var(--overlay-light); }

/* ── Collapsed sidebar ── */
.sidebar.collapsed {
    width: 48px;
    min-width: 48px;
}
.sidebar.collapsed .sidebar-top { padding: 8px 0 0; justify-content: center; }
.sidebar.collapsed .logo { justify-content: center; }
.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .btn-collapse { position: absolute; right: 2px; top: 8px; opacity: 1; }
.sidebar.collapsed .sidebar-bots-header { justify-content: center; padding: 8px 4px !important; }
.sidebar.collapsed .sidebar-bots-header span,
.sidebar.collapsed .sidebar-bots-header .btn-icon,
.sidebar.collapsed .sidebar-bots-header .sidebar-bots-label { display: none; }
.sidebar.collapsed .sidebar-bot-list { padding: 0 4px; }
.sidebar.collapsed .sidebar-bot-item { justify-content: center; padding: 6px 4px; gap: 0; }
.sidebar.collapsed .sidebar-bot-name { display: none; }
.sidebar.collapsed .unread-dot { margin-left: 0; position: absolute; top: 2px; right: 2px; }
.sidebar.collapsed .sidebar-bot-item { position: relative; }
.sidebar.collapsed .sidebar-nav { padding: 0 4px; }
.sidebar.collapsed .sidebar-nav a { text-align: center; padding: 8px 4px; font-size: 0; }
.sidebar.collapsed .sidebar-nav a::before {
    font-size: 16px;
    display: block;
}
/* Nav icons when collapsed */
.sidebar.collapsed .sidebar-nav a:nth-child(1)::before { content: "🧩"; }
.sidebar.collapsed .sidebar-nav a:nth-child(2)::before { content: "🔗"; }
.sidebar.collapsed .sidebar-nav a:nth-child(3)::before { content: "⚙"; }
.sidebar.collapsed .sidebar-nav a:nth-child(4)::before { content: "📖"; }
.sidebar.collapsed .sidebar-nav a:nth-child(5)::before { content: "💳"; }
.sidebar.collapsed .sidebar-account { display: none; }
.sidebar.collapsed .sidebar-dashboard-link { display: none; }
.sidebar.collapsed .sidebar-bots { border-bottom: none; margin-bottom: 0; }
.sidebar.collapsed .sidebar-bot-empty { display: none; }

/* ── Sidebar click flash ── */
@keyframes sidebar-flash {
    0% { background: transparent; }
    30% { background: var(--overlay-light); }
    100% { background: transparent; }
}
.sidebar-flash {
    animation: sidebar-flash 0.35s ease-out;
}

/* ── Sidebar bot list ── */
.sidebar-bots {
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-bots-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-bots-label {
    cursor: pointer;
    transition: color 0.15s;
}
.sidebar-bots-label:hover, .sidebar-bots-label.active { color: var(--text); }
.btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

.sidebar-bot-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-bot-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}
.sidebar-bot-item:hover,
.sidebar-bot-item.active {
    background: var(--border);
    color: var(--text);
}
.sidebar-bot-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.status-dot.xs { width: 6px; height: 6px; }
.sidebar-bot-empty {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--muted);
}
.unread-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-nav {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.sidebar-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--border);
    color: var(--text);
}

.sidebar-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-email {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Main content ── */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    min-width: 0;
    background:
        radial-gradient(ellipse at 70% 0%, rgba(99,102,241,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 60%, rgba(139,92,246,0.03) 0%, transparent 40%),
        var(--bg);
}

.main:has(.bot-detail) {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
}
.bot-actions { display: flex; gap: 8px; }

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--muted);
}
.status-dot.running { background: var(--running); }
.status-dot.paused { background: var(--paused); }
.status-dot.error { background: var(--error); }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state p { margin-bottom: 16px; }
.empty { color: var(--muted); padding: 20px 0; }

/* ── Bot detail layout ── */
.bot-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.bot-detail .page-header {
    flex-shrink: 0;
}

.detail-columns {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.detail-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.detail-right {
    width: 340px;
    min-width: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    flex-shrink: 0;
}

.panel-header {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    font-weight: 600;
}

.budget-status {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text);
}

.detail-settings {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
    flex-shrink: 0;
}

.settings-form-inline .settings-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
.settings-form-inline .settings-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.settings-form-inline > .form-group {
    margin-bottom: 12px;
}

/* ── Stat cards ── */
.stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat-card {
    background: var(--overlay-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 600; text-transform: capitalize; }
.stat-value.running { color: var(--running); }
.stat-value.paused { color: var(--paused); }
.stat-value.error { color: var(--error); }

/* ── Costs ── */
.cost-summary {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    color: var(--muted);
}
.cost-summary strong { color: var(--text); }

.budget-form {
    margin-bottom: 0;
}
.budget-form label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 12px; }
.input-row { display: flex; gap: 8px; }
.input-row input { width: 140px; }
.limits-grid { display: flex; gap: 16px; flex-wrap: wrap; max-width: 500px; }
.limits-grid .form-group { margin-bottom: 0; }

.cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.cost-table th, .cost-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.cost-table th { color: var(--muted); font-weight: 500; }

/* ── Messages ── */
.panel .message-list { max-height: 200px; overflow-y: auto; }
.message-list { display: flex; flex-direction: column; gap: 6px; }
.message-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 8px;
    border-radius: 6px;
}
.message-row.in { background: rgba(99,102,241,0.08); }
.msg-dir { color: var(--muted); font-size: 12px; min-width: 16px; margin-top: 1px; }
.msg-content { flex: 1; font-size: 13px; overflow-x: auto; }
.msg-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ── Markdown inside messages (activity panel + chat bubbles) ── */
.msg-content p, .chat-bubble-content p { margin: 0 0 8px; }
.msg-content p:last-child, .chat-bubble-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3,
.chat-bubble-content h1, .chat-bubble-content h2, .chat-bubble-content h3 { margin: 12px 0 6px; font-size: 14px; font-weight: 600; }
.msg-content h1, .chat-bubble-content h1 { font-size: 16px; }
.msg-content ul, .msg-content ol, .chat-bubble-content ul, .chat-bubble-content ol { margin: 4px 0 8px 20px; padding: 0; }
.msg-content li, .chat-bubble-content li { margin-bottom: 2px; }
.msg-content table, .chat-bubble-content table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; }
.msg-content th, .msg-content td, .chat-bubble-content th, .chat-bubble-content td { border: none; border-bottom: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.msg-content th, .chat-bubble-content th { font-weight: 700; border-bottom: 2px solid var(--text); padding-bottom: 8px; }
.msg-content tr:last-child td, .chat-bubble-content tr:last-child td { border-bottom: none; }
.msg-content pre, .chat-bubble-content pre { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 8px; overflow-x: auto; margin: 8px 0; }
.msg-content code, .chat-bubble-content code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.msg-content pre code, .chat-bubble-content pre code { background: none; padding: 0; }
.msg-content blockquote, .chat-bubble-content blockquote { border-left: 3px solid var(--border); margin: 8px 0; padding: 4px 12px; color: var(--muted); }
.msg-content hr, .chat-bubble-content hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.chat-bubble-content { overflow-x: auto; }

/* ── Forms ── */
.settings-form { max-width: 480px; }
.settings-form-inline { max-width: none; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.form-group small { color: var(--muted); font-size: 11px; display: block; margin-top: 4px; }
input, select, textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
}
textarea { resize: vertical; }

.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.success-msg { color: var(--success); font-size: 13px; margin-left: 12px; }

/* ── Badges ── */
.badge { padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-warn { background: rgba(245,158,11,0.15); color: var(--warn); }

/* ── Integrations ── */
.centered-page { max-width: 640px; margin: 0 auto; }
.integration-list { display: flex; flex-direction: column; gap: 12px; }
.integration-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}
.integration-card > div:first-child { flex: 1; }
.integration-card strong { display: block; margin-bottom: 4px; }
.integration-card > div:first-child div { color: var(--muted); font-size: 12px; }
.badge-connected { background: rgba(34,197,94,0.12); color: var(--success); font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; margin-left: 8px; }
.integration-card-google { flex-direction: column; align-items: stretch; }
.integration-card-header {
    display: flex; align-items: center; gap: 12px;
}
.integration-card-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; }
.integration-card-header > div { flex: 1; }
.integration-card-header > div:last-child { flex: none; }
.integration-products {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.integration-product {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-radius: 6px; background: var(--bg);
}
.integration-product strong { display: inline; margin-bottom: 0; font-size: 13px; }
.integration-product .muted { display: block; font-size: 11px; }
.integration-icon { width: 32px; height: 32px; flex-shrink: 0; }
.integration-section { margin-bottom: 24px; }
.integration-section-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
    color: var(--muted); margin-bottom: 8px; padding-left: 2px;
}
.integration-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn-auto-enable {
    background: transparent; cursor: pointer; transition: all 0.15s; border: none;
}
.btn-auto-enable.on { color: var(--success); }
.btn-auto-enable.on:hover { background: rgba(34,197,94,0.08); }
.btn-auto-enable.off { color: var(--muted); }
.btn-auto-enable.off:hover { background: var(--bg); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 480px;
    max-width: 95vw;
}
.modal h3 { margin-bottom: 20px; font-size: 16px; }
.modal-header { display: flex; align-items: center; gap: 12px; }
.modal-header h3 { margin-bottom: 0; }
.modal-body { margin: 16px 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Chat ── */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
    min-height: 0;
    position: relative;
    max-width: 680px;
    width: 100%;
    align-self: center;
}
.chat-empty {
    color: var(--muted);
    text-align: center;
    padding: 60px 20px;
}

/* ── Chat Welcome (onboarding) ── */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 40px;
    flex: 1;
}
.chat-welcome-hero {
    text-align: center;
    margin-bottom: 24px;
}
.chat-welcome-hero h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.chat-welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 400px;
    margin-bottom: 32px;
}
.chip {
    padding: 9px 16px;
    border-radius: 20px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover {
    background: var(--accent);
    color: white;
}
.chip-telegram {
    border-color: #2AABEE;
    color: #2AABEE;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.chip-telegram:hover {
    background: #2AABEE;
    color: white;
}
.chip-whatsapp {
    border-color: #25D366;
    color: #25D366;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.chip-whatsapp:hover {
    background: #25D366;
    color: white;
}
.chat-intro-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 8px 48px;
    max-width: 600px;
}
.chat-welcome-setup {
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
}
.setup-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 14px 6px;
}
.setup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-top: 1px solid var(--border);
}
.setup-row:hover {
    background: var(--overlay-subtle);
}
.setup-icon {
    color: var(--accent);
    font-size: 10px;
    flex-shrink: 0;
}
.setup-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.setup-desc {
    font-size: 12px;
    flex: 1;
    text-align: right;
}
.setup-arrow {
    font-size: 12px;
    flex-shrink: 0;
}
.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}
.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 3px;
}
.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 3px;
}
.chat-bubble.intro {
    font-size: 16px;
    line-height: 1.6;
    max-width: 100%;
    align-self: center;
    text-align: center;
    background: transparent;
    border: none;
    padding: 0 20px 8px;
    color: var(--muted);
}
.chat-intro-state .chat-intro-chips {
    justify-content: center;
    padding-left: 0;
    max-width: 100%;
}

.chat-intro-title {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    padding: 0 20px 4px;
}

/* ── Intro state: centered layout like ChatGPT/Claude ── */
.chat-intro-state {
    justify-content: center;
}
.chat-intro-state .chat-messages {
    flex: 0 0 auto;
    overflow: visible;
    justify-content: flex-end;
}
.chat-intro-state .chat-input-area {
    border-top: none;
    padding-top: 12px;
}

/* ── Chat separator (cron/webhook) ── */
.chat-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0 4px;
    color: var(--muted);
    font-size: 11px;
    align-self: stretch;
}
.chat-separator::before,
.chat-separator::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}
.chat-separator-time {
    opacity: 0.7;
}
.chat-bubble-content pre {
    background: var(--overlay-dark);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 12px;
}
.chat-bubble-content code {
    background: var(--overlay-dark);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}
.chat-bubble-content pre code {
    background: none;
    padding: 0;
}

/* ── Code block copy button ── */
.code-block-wrap {
    position: relative;
}
.code-block-wrap .code-lang {
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    color: var(--code-lang);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--code-btn-bg);
    border: 1px solid var(--code-btn-border);
    color: var(--code-btn-text);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.code-block-wrap:hover .code-copy-btn {
    opacity: 1;
}
.code-copy-btn:hover {
    background: var(--code-btn-hover-bg);
    color: var(--code-btn-hover-text);
}

/* ── Stop button ── */
.btn-stop {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-right: 12px;
    transition: background 0.15s;
}
.btn-stop::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-color: var(--text);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='2' y='2' width='12' height='12' rx='2' fill='black'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='2' y='2' width='12' height='12' rx='2' fill='black'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}
.btn-stop:hover {
    background: var(--border);
}

/* ── Scroll to bottom ── */
.scroll-to-bottom {
    position: sticky;
    bottom: 8px;
    align-self: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px var(--shadow-color);
    z-index: 10;
    transition: background 0.15s, border-color 0.15s;
    margin-top: -52px;
    opacity: 0.86;
}
.scroll-to-bottom::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-color: var(--text);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2 L8 13 M3 8 L8 13 L13 8' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2 L8 13 M3 8 L8 13 L13 8' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}
.scroll-to-bottom:hover {
    background: var(--border);
    border-color: var(--text);
}

.chat-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.chat-tool {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(99,102,241,0.12);
    color: var(--muted);
    position: relative;
    overflow: hidden;
}
/* Running shimmer */
.chat-tool:not(.done)::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--overlay-subtle), transparent);
    animation: tool-shimmer 2.2s ease-in-out infinite;
}
@keyframes tool-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}
/* Done state */
.chat-tool.done { color: var(--success); animation: tool-done-flash 0.4s ease-out; }
.chat-tool.done .tool-icon { display: inline-block; animation: tool-check-pop 0.3s ease-out; }
@keyframes tool-done-flash {
    0% { background: rgba(52,211,153,0.25); }
    100% { background: rgba(99,102,241,0.12); }
}
@keyframes tool-check-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.chat-tool-wrap { display: contents; }
.chat-tool-subtasks {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-left: 16px;
    border-left: 2px solid rgba(99,102,241,0.2);
    margin: 2px 0;
}
.chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.btn-action {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-action:hover {
    background: var(--accent);
    color: #fff;
}
.btn-action-done {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    cursor: default;
}
.btn-action-done:hover {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}
/* File cards (share_files tool) */
.chat-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.file-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    max-width: 260px;
}
.file-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}
.file-card-icon { font-size: 20px; flex-shrink: 0; }
.file-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.file-card-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-card-size {
    font-size: 11px;
    color: var(--muted);
}
.file-card-dl {
    font-size: 0;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid var(--accent);
    background: transparent;
    line-height: 1;
}
.file-card-dl::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='%236366f1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.file-card-dl:hover {
    background: var(--accent);
}
.file-card-dl:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
}
/* Email cards (chat) */
.email-card-wrap { padding: 2px 0; }
.email-card {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    max-width: 360px;
}
.email-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--muted);
}
.email-card-icon { font-size: 14px; opacity: 0.9; }
.email-card-dir { font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.email-card.outbound .email-card-dir { color: var(--success); }
.email-card.outbound.source-gmail .email-card-dir { color: #f59e0b; }
.email-card.outbound.source-imap .email-card-dir { color: #8b5cf6; }
.email-card.inbound .email-card-dir { color: #3b82f6; }
.email-card-failed { color: var(--danger); font-weight: 500; }
.email-card-source { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding: 1px 5px; border-radius: 3px; }
.email-card-source.gmail { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.email-card-source.imap { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.email-card-route { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 4px; overflow: hidden; }
.email-card-arrow { color: var(--muted); flex-shrink: 0; font-size: 11px; }
.email-card-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.email-card-date { margin-left: auto; flex-shrink: 0; }
.email-card-field { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.email-card-label { font-weight: 600; color: var(--text); margin-right: 4px; }
.email-card-subject { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.email-card-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Activity cards (cron, webhook, telegram) */
.activity-card {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    max-width: 360px;
    margin: 4px 0;
}
.activity-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--muted);
}
.activity-card-icon { font-size: 13px; }
.activity-card-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 10px; }
.activity-card-time { margin-left: auto; font-size: 11px; color: var(--muted); }
.activity-card-body { font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.activity-card.cron .activity-card-label { color: #f59e0b; }
.activity-card.hook .activity-card-label { color: #ec4899; }
.activity-card.telegram .activity-card-label { color: #3b82f6; }
.activity-card.whatsapp .activity-card-label { color: #25d366; }

/* Channel badge on assistant bubbles */
.channel-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-bottom: 6px;
}
.channel-badge.telegram { background: rgba(59,130,246,0.15); color: #3b82f6; }
.channel-badge.email { background: rgba(34,197,94,0.15); color: #22c55e; }
.channel-badge.cron { background: rgba(245,158,11,0.15); color: #f59e0b; }
.channel-badge.hook { background: rgba(236,72,153,0.15); color: #ec4899; }
.channel-badge.whatsapp { background: rgba(37,211,102,0.15); color: #25d366; }

/* Muted automated assistant bubbles */
.chat-bubble.automated { opacity: 0.7; }

/* Email tab */
.email-list { display: flex; flex-direction: column; gap: 2px; }
.email-list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
}
.email-list-row:hover { background: var(--surface); }
.email-list-icon { font-size: 16px; flex-shrink: 0; }
.email-list-addr { font-size: 13px; color: var(--text); font-weight: 500; min-width: 120px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.email-list-subject { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-list-failed { font-size: 11px; color: var(--danger); font-weight: 500; flex-shrink: 0; }
.email-list-date { font-size: 11px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.email-list-detail {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}
.email-list-row:has(.email-list-detail) { flex-wrap: wrap; background: var(--surface); }
.email-detail-field { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.email-detail-field strong { color: var(--text); margin-right: 4px; }
.email-detail-body { font-size: 12px; color: var(--text); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); white-space: pre-wrap; }

/* Sidebar email panel */
.sidebar-email-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar-email-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding: 2px 0;
}
.sidebar-email-row .email-list-icon { font-size: 12px; }
.sidebar-email-subject { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Page link cards (inline in markdown) */
.page-link-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none !important;
    color: var(--text) !important;
    margin: 4px 0;
    max-width: 300px;
}
.page-link-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(99,102,241,0.15);
}
.page-link-icon { font-size: 18px; flex-shrink: 0; }
.page-link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.page-link-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-link-type {
    font-size: 11px;
    color: var(--muted);
}
.page-link-open {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    flex-shrink: 0;
    padding: 2px 8px;
    border: 1px solid var(--accent);
    border-radius: 4px;
}
.page-link-card:hover .page-link-open {
    background: var(--accent);
    color: white;
}

.tool-icon { font-size: 10px; }
.chat-tool:not(.done) .tool-icon { display: inline-block; animation: tool-spin 1s linear infinite; }
@keyframes tool-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.tool-name { font-family: monospace; }
/* ── Ghost character ── */
.ghost-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
}
.ghost-icon svg { width: 100%; height: 100%; }

.ghost-thinking {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.ghost-thinking .ghost-icon {
    width: 22px;
    height: 22px;
    animation: ghost-float 2s ease-in-out infinite;
}
.ghost-thinking .ghost-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.ghost-thinking .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--muted);
    animation: typing-bounce 1.4s infinite ease-in-out;
}
.ghost-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.ghost-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}
@keyframes ghost-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Welcome ghost */
.ghost-welcome {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    animation: ghost-float 3s ease-in-out infinite;
    opacity: 0.7;
}
.ghost-welcome svg { width: 100%; height: 100%; }
.chat-error-banner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    color: var(--error-text);
}
.chat-error-banner.budget, .chat-error-banner.credits {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.25);
    color: var(--warn-text);
}
.chat-error-banner .credit-cta {
    margin-left: auto;
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(245,158,11,0.4);
    background: rgba(245,158,11,0.15);
    color: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.chat-error-banner .credit-cta:hover {
    background: rgba(245,158,11,0.25);
}
.chat-error-banner.overloaded {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.25);
    color: var(--warn-text);
}
.chat-error-banner.limit {
    background: rgba(156,163,175,0.1);
    border-color: rgba(156,163,175,0.25);
    color: var(--limit-text);
}
.chat-error-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.chat-error-text strong { font-weight: 600; }
.chat-low-balance-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.25);
    color: var(--warn-text);
}
.chat-low-balance-banner .credit-cta {
    margin-left: auto;
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(245,158,11,0.4);
    background: rgba(245,158,11,0.15);
    color: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.chat-low-balance-banner .credit-cta:hover {
    background: rgba(245,158,11,0.25);
}
.chat-credits-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 13px;
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.25);
    color: var(--warn-text);
}
.chat-credits-banner .credit-cta {
    margin-left: auto;
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(245,158,11,0.4);
    background: rgba(245,158,11,0.15);
    color: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.chat-credits-banner .credit-cta:hover {
    background: rgba(245,158,11,0.25);
}
.chat-input-area {
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    max-width: 680px;
    width: 100%;
    align-self: center;
}

/* ── File attachment pills ── */
.chat-file-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 8px;
}
.chat-file-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text);
}
.chat-file-pill-icon { display: flex; align-items: center; flex-shrink: 0; }
.chat-file-pill-icon svg { display: block; }
.chat-file-pill-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-file-pill-size {
    color: var(--muted);
    font-size: 12px;
}
.chat-file-pill-remove {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
.chat-file-pill-remove:hover { color: var(--text); }

/* ── Chat input row (horizontal layout) ── */
.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}
.chat-input-row textarea {
    flex: 1;
    resize: none;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: 16px;
    line-height: 1.5;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.chat-input-row textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15), 0 1px 6px rgba(0,0,0,0.06);
}

/* ── Attach button (paperclip) ── */
.btn-attach {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color 0.15s, border-color 0.15s;
    align-self: flex-end;
    margin-bottom: 8px;
}
.btn-attach:hover { color: var(--text); border-color: var(--text); }
.btn-attach:disabled { opacity: 0.3; cursor: default; }

/* ── Drag-and-drop overlay ── */
.chat-messages.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
}

/* ── File pills in user messages ── */
.msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.msg-attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    font-size: 13px;
    color: rgba(255,255,255,0.9);
}
.msg-attachment-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.msg-attachment-icon svg { display: block; }
.chat-bubble.user .msg-attachment-icon svg { stroke: white; }
.msg-attachment-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.msg-attachment-size {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
}

/* ── Send button (arrow-up icon) ── */
.btn-send {
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-right: 12px;
    transition: opacity 0.15s;
}
.btn-send::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 3 L10 16 M4 9 L10 3 L16 9' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Loading ── */
.loading { color: var(--muted); padding: 20px 0; }

/* ── Landing ── */
body.landing {
    height: auto;
    overflow: visible;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
body.landing nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 40px;
    border-bottom: 1px solid rgba(99,102,241,0.15);
    background: rgba(15,15,15,0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
}
body.landing nav .logo { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
body.landing nav .nav-center {
    display: flex;
    align-items: center;
    gap: 32px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 72px 20px 48px;
}
.hero h1 { font-size: 64px; font-weight: 800; margin-bottom: 18px; letter-spacing: -1.5px; }
.hero p { font-size: 24px; color: rgba(255,255,255,0.7); max-width: 600px; margin-bottom: 32px; line-height: 1.5; }
.hero .hero-sub-mobile { display: none; }
[data-theme="light"] .hero p { color: #444; }
.subtext { color: var(--muted); font-size: 13px; margin-top: 12px; }

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 40px;
    border-top: 1px solid var(--border);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}
.feature h3 { font-size: 15px; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: 13px; }

body.legal-page {
    height: auto;
    overflow: visible;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── Landing: full-width sections ── */
.landing-section {
    width: 100%;
    padding: 80px 0;
}
.landing-section.alt {
    background: var(--surface);
}
.landing-section.compact {
    padding: 36px 0;
}
.landing-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 40px;
}
.landing-inner.wide {
    max-width: 1200px;
}

.landing-footer {
    width: 100%;
    padding: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 13px;
}
[data-theme="dark"] .landing-footer {
    background: #0a0a0f;
}
.landing-footer .landing-inner {
    padding-top: 64px;
    padding-bottom: 56px;
}
.landing-footer-columns {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 48px;
}
.landing-footer-brand {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.landing-footer-brand .footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.landing-footer-brand .footer-logo img { opacity: 0.8; }
.landing-footer-brand .footer-tagline {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}
.landing-footer-brand .footer-contact {
    color: var(--muted);
    font-size: 14px;
}
.landing-footer-brand .footer-contact a { color: var(--muted); text-decoration: none; }
.landing-footer-brand .footer-contact a:hover { color: var(--text); }
.landing-footer-col h4 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
    margin-bottom: 16px;
}
.landing-footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.landing-footer-col ul li a {
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    transition: color 0.15s;
}
.landing-footer-col ul li a:hover { color: var(--text); }
.landing-footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    opacity: 0.6;
}
.landing-footer-bottom a { color: var(--muted); text-decoration: none; }
.landing-footer-bottom a:hover { color: var(--text); }
@media (max-width: 768px) {
    .landing-section { padding: 48px 0; }
    .landing-inner { padding: 0 20px; }
    .landing-footer .landing-inner { padding: 40px 20px 140px; }
    .landing-footer-columns {
        grid-template-columns: 1fr 1fr;
        gap: 28px;
    }
    .landing-footer-brand { grid-column: 1 / -1; }
}

/* ── Landing: animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
body.landing .hero h1 { animation: fadeInUp 0.6s ease-out; }
body.landing .hero p { animation: fadeInUp 0.6s ease-out 0.1s both; }
body.landing .hero .btn { animation: fadeInUp 0.6s ease-out 0.2s both; }
body.landing .proof-strip { animation: fadeInUp 0.6s ease-out 0.3s both; }
body.landing .feature { animation: fadeInUp 0.5s ease-out both; }
body.landing .feature:nth-child(1) { animation-delay: 0.2s; }
body.landing .feature:nth-child(2) { animation-delay: 0.3s; }
body.landing .feature:nth-child(3) { animation-delay: 0.4s; }
body.landing .feature:nth-child(4) { animation-delay: 0.35s; }
body.landing .feature:nth-child(5) { animation-delay: 0.45s; }
body.landing .feature:nth-child(6) { animation-delay: 0.55s; }
body.landing .dashboard-mockup { animation: fadeInUp 0.7s ease-out 0.3s both; }

/* ── Landing: hero glow ── */
body.landing .hero { position: relative; }
body.landing .hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: 400px;
    background: radial-gradient(ellipse at center, rgba(99,102,241,0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
body.landing .hero > * { position: relative; z-index: 1; }
[data-theme="light"] .hero::before {
    display: none;
}

/* ── Landing: nav logo ── */
body.landing .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
body.landing .logo img {
    display: block;
}
body.landing .logo svg { flex-shrink: 0; }
body.landing nav .nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
body.landing nav .nav-link {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
    opacity: 0.7;
}
body.landing nav .nav-link:hover { opacity: 1; }
body.landing nav .nav-right .nav-link {
    font-size: 15px;
}

/* ── Theme toggle ── */
.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ── Landing: CTA glow ── */
body.landing .btn-primary.btn-large {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    box-shadow: 0 4px 20px rgba(99,102,241,0.3);
    transition: box-shadow 0.2s, transform 0.2s, opacity 0.15s;
    animation: fadeInUp 0.6s ease-out 0.2s both, ctaPulse 3s ease-in-out 2s infinite;
    font-size: 17px;
    padding: 16px 32px;
}
body.landing .btn-primary.btn-large:hover {
    box-shadow: 0 6px 30px rgba(99,102,241,0.5);
    transform: scale(1.03);
    opacity: 1;
    animation: none;
}
@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(99,102,241,0.3); }
    50% { box-shadow: 0 4px 30px rgba(99,102,241,0.55); }
}

/* ── Landing: proof strip ── */
.proof-strip {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 0 20px 48px;
    flex-wrap: wrap;
}
.proof-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 24px;
    border: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
}
.proof-badge svg { flex-shrink: 0; }

/* ── Landing: section labels ── */
.section-label {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    text-align: center;
    padding: 0 0 32px;
}

/* ── Landing: feature cards with icons ── */
body.landing .feature {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.2s, transform 0.2s;
}
body.landing .feature:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(99,102,241,0.1);
    margin-bottom: 12px;
}
.feature-icon svg { color: var(--accent); }
.feature-icon.green { background: rgba(34,197,94,0.1); }
.feature-icon.green svg { color: #22c55e; }
.feature-icon.amber { background: rgba(245,158,11,0.1); }
.feature-icon.amber svg { color: #f59e0b; }

body.landing .feature h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
body.landing .feature p { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ── Landing: features grid wider ── */
body.landing .features {
    max-width: 1000px;
    gap: 16px;
}

/* ── Landing: dashboard mockup (teams) ── */
.dashboard-mockup {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 28px;
}
.dashboard-mockup .mockup-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
}
.dashboard-mockup .mockup-frame {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.08);
}
[data-theme="dark"] .mockup-frame {
    box-shadow: 0 8px 40px var(--shadow-color);
}
.dashboard-mockup .mockup-inner {
    padding: 20px 24px 16px;
}
.dashboard-mockup .mockup-caption {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 12px 0 0;
    opacity: 0.7;
}

.sidebar-footer-links {
    display: flex;
    gap: 10px;
    font-size: 12px;
}
.sidebar-footer-links a { color: var(--muted); text-decoration: none; }
.sidebar-footer-links a:hover { color: var(--text-primary); }

/* ── Bot integrations ── */
.bot-integrations { display: flex; flex-direction: column; gap: 8px; }
.toggle-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: 13px;
}
.toggle-row:hover { border-color: var(--accent); }
.toggle-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.toggle-row span:first-of-type { font-weight: 500; min-width: 120px; }
.toggle-desc { color: var(--muted); font-size: 12px; }
.integration-notice { color: var(--muted); font-size: 13px; padding: 12px 0; }
.integration-notice a { color: var(--accent); }
.saving-msg { color: var(--muted); font-size: 12px; padding-top: 4px; }

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.detail-bot-name {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-bot-name-text {
    outline: none;
    border-radius: 4px;
    padding: 0 4px;
    margin: -1px -4px;
    border: 1px solid transparent;
    cursor: text;
}
.detail-bot-name-text:hover { border-color: var(--border); }
.detail-bot-name-text:focus { border-color: var(--accent); background: var(--surface); }

.status-dot.sm { width: 7px; height: 7px; }


/* ── Sub-page toolbar (e.g. Files actions) ── */
.sub-page-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.back-btn { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.back-btn svg { display: block; flex-shrink: 0; }
.detail-tab-label { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 4px; }

.detail-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.detail-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.detail-chat-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.detail-chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    position: relative;
}

.chat-offline {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 8px;
}

/* ── Detail sidebar ── */
.detail-sidebar {
    width: 300px;
    min-width: 260px;
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    position: relative;
}

/* Collapse button inside detail sidebar */
.detail-collapse-btn {
    position: absolute;
    top: 8px;
    left: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.detail-sidebar:hover .detail-collapse-btn { opacity: 1; }
.detail-collapse-btn:hover { color: var(--text); background: var(--overlay-light); }

/* Expand tab when detail sidebar is hidden */
.detail-expand-tab {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    border-radius: 8px 0 0 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: color 0.15s, background 0.15s;
}
.detail-expand-tab:hover { color: var(--text); background: var(--overlay-light); }

.sidebar-panel {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-panel[onclick],
.sidebar-panel.soul-panel,
.sidebar-panel.memory-panel,
.sidebar-panel.automations-panel,
.sidebar-panel.skills-panel,
.sidebar-panel.nav-panel {
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    padding: 10px 14px;
    border-left: 2px solid transparent;
}
.sidebar-panel.nav-panel:hover {
    background: var(--overlay-subtle);
}
.sidebar-panel.nav-panel .sidebar-panel-header {
    margin-bottom: 0;
}
.sidebar-panel.nav-panel .sidebar-panel-header:not(:last-child) {
    margin-bottom: 6px;
}
.memory-preview.compact, .skills-list.compact {
    margin-top: 0;
}
.memory-preview.compact .memory-preview-line {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.skills-list.compact .skill-row {
    padding: 0;
    margin: 0;
}
.skills-list.compact .skill-name {
    font-size: 11px;
    color: var(--text);
}

.sidebar-panel-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin-bottom: 8px;
}

.panel-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.55;
}

.panel-chevron {
    margin-left: auto;
    font-size: 16px;
    line-height: 1;
    opacity: 0.3;
    font-weight: 400;
    transition: opacity 0.15s;
}
.nav-panel:hover .panel-chevron { opacity: 0.6; }

.nav-panel.active {
    border-left: 2px solid var(--accent);
    background: var(--overlay-subtle);
}
.nav-panel.active .sidebar-panel-header { color: var(--text); }
.nav-panel.active .panel-icon { opacity: 0.85; }

.panel-link {
    margin-left: auto;
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.panel-count {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    background: var(--overlay-light);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0;
    text-transform: none;
}

.panel-empty {
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

.soul-preview { display: flex; flex-direction: column; gap: 3px; }
.soul-preview-line {
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.soul-preview-line:first-child { font-weight: 500; }
.soul-preview-line:not(:first-child) { color: var(--muted); }

.memory-preview { display: flex; flex-direction: column; gap: 2px; }
.memory-preview-line {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-panel .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 12px;
}
.stats-panel .stat-label { color: var(--muted); }
.stats-panel .stat-val { font-weight: 500; text-transform: capitalize; display: flex; align-items: center; gap: 6px; }
.stats-panel .stat-val.running { color: var(--running); }
.stats-panel .stat-val.paused { color: var(--paused); }
.stats-panel .stat-val.error { color: var(--error); }
.stats-panel .stat-email { text-transform: none; }
.stat-link { color: var(--accent); cursor: pointer; font-size: 12px; text-transform: none; }
.stat-link:hover { text-decoration: underline; }
.stats-panel .stat-val.spend-ok { color: var(--success); }
.stats-panel .stat-val.spend-warn { color: var(--warn); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.running { background: var(--running); }
.status-dot.paused { background: var(--paused); }
.status-dot.error { background: var(--error); }

.stat-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
    opacity: 0.6;
}
.stats-panel .stat-val.spend-over { color: var(--danger); }

/* ── Limits panel ── */
.limits-panel .sidebar-panel-header:not(:last-child) { margin-bottom: 8px; }
.limit-row { margin-bottom: 8px; }
.limit-row:last-child { margin-bottom: 0; }
.limit-label-row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; }
.limit-name { color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.limit-vals { color: var(--text); font-weight: 500; }
.limit-bar-track { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.limit-bar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; min-width: 1px; }
.limit-bar-fill.bar-ok { background: var(--success); }
.limit-bar-fill.bar-warn { background: var(--warn); }
.limit-bar-fill.bar-over { background: var(--danger); }
.limits-empty { font-size: 12px; color: var(--muted); }

/* ── Automations panel ── */
.automations-list { display: flex; flex-direction: column; gap: 3px; }
.automation-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.automation-icon { font-size: 11px; width: 14px; text-align: center; flex-shrink: 0; }
.automation-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.automation-detail { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* ── Skills panel ── */
.skills-list { display: flex; flex-direction: column; gap: 3px; }
.page-row { display: flex; align-items: center; gap: 6px; font-size: 12px; text-decoration: none; color: var(--text); padding: 1px 0; }
.page-row:hover { color: var(--accent); }
.page-icon { font-size: 11px; flex-shrink: 0; }
.page-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pages-list { display: flex; flex-direction: column; gap: 2px; }

.skill-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.skill-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-detail { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

.skill-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s; }
.skill-card:hover { border-color: var(--accent); }
.skill-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.skill-card-desc { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.skill-card-path { font-size: 11px; color: var(--muted); font-family: monospace; }
.skill-card-header { cursor: pointer; }
.skill-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.skill-card-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.skill-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.skill-linked-badge { font-size: 11px; background: rgba(99,102,241,0.1); color: var(--accent); padding: 2px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.skill-linked-badge:hover { background: rgba(99,102,241,0.2); }
.skill-type-badge { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: var(--border); color: var(--muted); font-family: monospace; font-weight: 500; }
.skill-type-js { background: rgba(234,179,8,0.15); color: #eab308; }
.skill-type-both { background: rgba(99,102,241,0.15); color: var(--accent); }

/* ── Skill editor modal ── */
.skill-editor-modal { width: 800px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.skill-editor-tabs { display: flex; gap: 4px; margin-right: 8px; }
.skill-editor-body { flex: 1; min-height: 0; overflow: hidden; margin: 0 16px 16px; border: 1px solid var(--border); border-radius: 6px; }
.skill-editor-body .CodeMirror {
    height: 100%;
    min-height: 400px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg);
}
.skill-editor-body .CodeMirror-gutters { background: var(--surface); border-right: 1px solid var(--border); }
.skill-editor-body .CodeMirror-cursor { border-left-color: var(--text); }

.sidebar-meta-row {
    font-size: 12px;
    color: var(--muted);
    padding: 2px 0;
}
.integration-badge {
    display: inline-block;
    margin-right: 12px;
    color: var(--success);
    font-size: 11px;
}

/* ── Sub-pages (soul, memory, activity, settings) ── */
.sub-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}


.sub-page-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.sub-page-desc {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.sub-page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

/* ── Files ── */
.files-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.breadcrumb-item { color: var(--muted); cursor: pointer; }
.breadcrumb-item:hover { color: var(--text); }
.breadcrumb-item.current { color: var(--text); font-weight: 500; }
.breadcrumb-sep { color: var(--muted); margin: 0 2px; }

.files-body { max-width: 100%; padding: 0; }

.file-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.file-row:hover { background: var(--overlay-subtle); }
.file-icon { width: 20px; text-align: center; flex-shrink: 0; }
.file-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { width: 70px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.file-modified { width: 90px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.1s; }
.file-row:hover .file-actions { opacity: 1; }

.btn-inline {
    background: none; border: none; color: var(--muted); cursor: pointer;
    padding: 2px 6px; border-radius: 3px; font-size: 13px;
}
.btn-inline:hover { color: var(--text); background: var(--overlay-light); }
.btn-inline.danger:hover { color: var(--danger); }

/* ── Download SVG icon (reusable) ── */
.dl-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
}
.dl-icon::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background-color: var(--muted);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M7 1.5 L7 9.5 M3 6.5 L7 10.5 L11 6.5 M2 12.5 L12 12.5' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}
.dl-icon:hover::before {
    background-color: var(--text);
}
.tool-file-link.dl-icon { margin-left: 6px; }

.btn-sm { font-size: 12px; padding: 4px 10px; }

/* Inline file links in chat tool results */
.tool-file-sep { color: var(--muted); margin: 0 4px; }
.tool-file-name { font-family: monospace; font-size: 11px; color: var(--text); }
.tool-file-link { font-size: 11px; color: var(--accent); cursor: pointer; margin-left: 6px; }
.tool-file-link:hover { color: var(--accent-hover); text-decoration: underline; }

.file-viewer-size { font-size: 12px; color: var(--muted); }

.file-viewer-modal { width: 900px; max-width: 90vw; max-height: 80vh; display: flex; flex-direction: column; }
.file-viewer-content {
    flex: 1; overflow: auto; padding: 16px;
    font-family: monospace; font-size: 12px; line-height: 1.6;
    background: var(--bg); border-radius: 6px; margin: 0 16px 16px;
    white-space: pre-wrap; word-wrap: break-word;
}
.file-viewer-rendered {
    font-family: var(--font); font-size: 14px; white-space: normal;
}
.file-viewer-rendered h1, .file-viewer-rendered h2, .file-viewer-rendered h3,
.file-viewer-rendered h4, .file-viewer-rendered h5, .file-viewer-rendered h6 {
    margin: 1em 0 0.5em; color: var(--text);
}
.file-viewer-rendered h1 { font-size: 1.5em; }
.file-viewer-rendered h2 { font-size: 1.3em; }
.file-viewer-rendered h3 { font-size: 1.1em; }
.file-viewer-rendered p { margin: 0.5em 0; }
.file-viewer-rendered ul, .file-viewer-rendered ol { margin: 0.5em 0; padding-left: 1.5em; }
.file-viewer-rendered li { margin: 0.25em 0; }
.file-viewer-rendered code { background: var(--surface); padding: 2px 5px; border-radius: 3px; font-size: 0.9em; }
.file-viewer-rendered pre { white-space: pre-wrap; }
.file-viewer-rendered pre code { background: none; padding: 0; }
.file-viewer-rendered a { color: var(--accent); }
.file-viewer-rendered blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--muted); margin: 0.5em 0; }
.file-viewer-rendered table { border-collapse: collapse; margin: 0.5em 0; }
.file-viewer-rendered th, .file-viewer-rendered td { border: 1px solid var(--border); padding: 6px 10px; }
.file-viewer-rendered hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }

/* ── Soul page ── */
.soul-body { max-width: 720px; }

.soul-section {
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.soul-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.soul-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 6px;
}

.soul-section-desc {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.soul-name-input {
    font-size: 16px !important;
    font-weight: 500;
    padding: 10px 12px !important;
}

.soul-textarea {
    width: 100%;
    font-size: 13px !important;
    line-height: 1.6 !important;
    padding: 12px 14px !important;
    border-radius: 8px !important;
    resize: vertical;
    min-height: 70px;
}

.soul-textarea-raw {
    font-family: monospace !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    min-height: 300px;
}

.raw-toggle {
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
}
.raw-toggle:hover { color: var(--accent); }

.label-opt {
    color: var(--muted);
    font-weight: 400;
}

/* ── Activity ── */
.activity-group { margin-bottom: 24px; }

.activity-date {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.activity-daily-cost {
    font-weight: 600;
    font-size: 11px;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

/* Exchange rows */
.activity-exchange {
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.1s;
}
.activity-exchange:hover { background: rgba(99,102,241,0.06); }

.activity-exchange-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 8px;
    font-size: 12px;
}

.activity-time { color: var(--muted); min-width: 40px; font-size: 11px; flex-shrink: 0; }
.activity-channel {
    font-size: 10px;
    background: var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--muted);
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
}
.activity-channel-cron { background: rgba(245,158,11,0.12); color: #b45309; }
.activity-channel-hook { background: rgba(99,102,241,0.12); color: #6366f1; }
.activity-dir { color: var(--muted); min-width: 14px; flex-shrink: 0; display: flex; align-items: center; }
.activity-dir svg { display: block; }
.activity-content { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.activity-user-text { color: var(--text); }
.activity-arrow { color: var(--muted); margin: 0 4px; font-size: 11px; }
.activity-bot-text { color: var(--muted); }
.activity-cost { color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }

/* Tool badges */
.activity-tools { display: flex; gap: 3px; flex-shrink: 0; }
.activity-tool-badge {
    font-size: 9px;
    font-family: var(--font-mono, monospace);
    background: rgba(99,102,241,0.1);
    color: #6366f1;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

/* Expanded detail */
.activity-exchange-detail {
    padding: 8px 12px 10px 56px;
    font-size: 12px;
    border-left: 2px solid var(--border);
    margin-left: 20px;
    margin-bottom: 4px;
}
.activity-detail-msg { margin-bottom: 6px; }
.activity-detail-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 8px;
}
.activity-detail-in .activity-detail-text { color: var(--muted); }
.activity-detail-out .activity-detail-text { color: var(--text); white-space: pre-wrap; }
.activity-detail-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Automation rows (cron/hook) */
.activity-automation {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 12px;
}
.activity-automation:hover { background: rgba(0,0,0,0.02); }
.activity-status { font-size: 12px; flex-shrink: 0; }
.activity-status.status-ok { color: #22c55e; }
.activity-status.status-err { color: #ef4444; }
.activity-auto-detail { color: var(--muted); font-size: 11px; }
.activity-error { color: #ef4444; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Settings sections ── */
.settings-body { max-width: 860px; }

.settings-section {
    padding-top: 40px;
    padding-bottom: 40px;
    border-top: 1px solid var(--border);
}

.settings-section:first-child {
    padding-top: 0;
    border-top: none;
}

.settings-section:last-child {
    padding-bottom: 0;
}

.settings-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 24px;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.channel-row:last-child { border-bottom: none; }
.channel-info { display: flex; flex-direction: column; gap: 2px; }
.channel-name { font-size: 13px; font-weight: 500; }
.channel-desc { font-size: 12px; }

.telegram-connect-form { display: flex; gap: 8px; align-items: center; }

.badge-ok { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-muted { background: var(--border); color: var(--muted); }

.muted { color: var(--muted); }

/* ── Schedule jobs ── */
.schedule-job-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.btn-sm:hover:not(:disabled) { border-color: var(--accent); }
.btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-sm.btn-ghost { background: transparent; border-color: transparent; }
.badge-off { background: var(--border); color: var(--muted); padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }

/* ── Trigger webhook URL ── */
.trigger-url {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.trigger-url code {
    font-family: 'SF Mono', SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* ── Container log panel ── */
.log-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
}
.log-panel-header:hover { border-color: var(--muted); }
.log-panel-toggle { color: var(--muted); font-size: 14px; }

.bot-log-panel {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
    max-height: 420px;
    overflow-y: auto;
}

.bot-log-panel .log-content {
    font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.55;
    padding: 12px 14px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
}

.bot-log-panel .log-empty {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

.log-timestamp { color: var(--muted); opacity: 0.6; }
.log-line-error { color: #ef4444; }
.log-line-agent { color: #22c55e; }
.log-line-scheduler { color: #60a5fa; }
.log-line-hook { color: #f59e0b; }

.danger-zone .settings-section-title { color: var(--danger); }

.danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px;
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 8px;
    background: rgba(239,68,68,0.04);
}
.danger-row + .danger-row { margin-top: 12px; }

.danger-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; }

/* ── Toasts ── */
.impersonate-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #f59e0b;
    color: #000;
    text-align: center;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
}
.impersonate-banner a {
    color: #000;
    margin-left: 12px;
    text-decoration: underline;
    font-weight: 700;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    background: var(--surface);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateX(40px);
    animation: toast-in 0.25s ease forwards;
    max-width: 320px;
}
.toast.toast-out {
    animation: toast-out 0.2s ease forwards;
}
.toast.success { background: var(--success); border-color: var(--success); }
.toast.error { background: var(--danger); border-color: var(--danger); }
.toast.info { background: var(--accent); border-color: var(--accent); }
@keyframes toast-in {
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Billing ── */
.sidebar-account {
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.sidebar-account-info {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.1s;
}
.sidebar-account-info:hover { background: var(--overlay-subtle); }

.sidebar-account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tier-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--border);
    color: var(--muted);
}
.tier-badge.pro { background: rgba(99,102,241,0.2); color: var(--accent); }

/* ── Appearance toggle (settings) ── */
.theme-options {
    display: flex;
    gap: 8px;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    font-family: inherit;
}
.theme-option:hover { border-color: var(--accent); color: var(--text); }
.theme-option.active { border-color: var(--accent); background: rgba(99,102,241,0.1); color: var(--accent); }
.theme-option svg { display: block; flex-shrink: 0; }

.sidebar-balance {
    font-size: 13px;
    font-weight: 600;
}

/* Welcome card */
.welcome-card {
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.welcome-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}
.welcome-plan {
    font-size: 14px;
    margin-bottom: 8px;
}
.welcome-explain {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.5;
}
.welcome-actions {
    display: flex;
    gap: 10px;
}

.billing-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.billing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}

.billing-card-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 12px;
}

.credit-balance {
    font-size: 32px;
    font-weight: 700;
}
.credit-balance.balance-ok { color: var(--success); }
.credit-balance.balance-low { color: var(--warn); }
.credit-balance.balance-zero { color: var(--danger); }

.credit-packs {
    display: flex;
    gap: 12px;
}

.credit-pack-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.credit-pack-card:hover { border-color: var(--accent); }

.credit-pack-amount {
    font-size: 20px;
    font-weight: 600;
}

.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }

.usage-range-btns { display: flex; gap: 4px; }
.usage-summary { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ── Mobile back button (hidden on desktop) ── */
.mobile-back { display: inline-flex; }
.mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
}
.mobile-back-btn:hover { color: var(--text); background: var(--hover); }
.mobile-panels-btn { display: none !important; }

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE — max-width: 768px
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Mobile back button ── */
    .mobile-back {
        display: inline-flex;
        font-size: 18px;
        padding: 4px 8px;
    }
    .mobile-back-btn { display: inline-flex; }
    .mobile-panels-btn { display: inline-flex !important; }
    .sidebar-dashboard-link { display: none; }

    /* ── Left sidebar: full-width on mobile, hidden when main content is active ── */
    .sidebar, .sidebar.collapsed {
        width: 100%;
        min-width: 0;
    }
    #app.mobile-show-main .sidebar { display: none; }
    .sidebar.collapsed .logo-text { display: inline; }
    .sidebar.collapsed .sidebar-bot-name { display: inline; }
    .sidebar.collapsed .sidebar-nav a { font-size: 13px; text-align: left; padding: 10px 12px; }
    .sidebar.collapsed .sidebar-nav a::before { display: none !important; }
    .sidebar.collapsed .sidebar-bots-header span,
    .sidebar.collapsed .sidebar-bots-header .btn-icon,
    .sidebar.collapsed .sidebar-bots-header .sidebar-bots-label { display: inline; }
    .sidebar.collapsed .sidebar-account { display: flex; }
    .sidebar.collapsed .sidebar-dashboard-link { display: flex; }
    .sidebar.collapsed .sidebar-bot-item { justify-content: flex-start; padding: 10px 12px; gap: 8px; }
    .sidebar.collapsed .sidebar-bot-empty { display: block; }
    .sidebar.collapsed .sidebar-bots { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
    .btn-collapse { display: none; }

    /* Larger touch targets for bot list items */
    .sidebar-bot-item {
        padding: 10px 12px;
        font-size: 14px;
    }

    .sidebar-nav a {
        padding: 12px 12px;
        font-size: 14px;
    }

    /* ── Main content: reduce padding ── */
    .main {
        padding: 16px;
    }

    /* ── Detail header: compact ── */
    .detail-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .detail-expand-tab { display: none !important; }
    .detail-collapse-btn { display: none !important; }

    /* ── Right sidebar: hidden by default on mobile, shown as overlay when toggled ── */
    .detail-sidebar {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 200;
        background: var(--surface);
        border-left: 1px solid var(--border);
        box-shadow: -4px 0 24px rgba(0,0,0,0.3);
        overflow-y: auto;
        padding-top: 8px;
    }
    .detail-sidebar.mobile-open {
        display: block;
    }
    .mobile-detail-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 199;
    }
    .mobile-detail-backdrop.mobile-open {
        display: block;
    }

    /* ── Chat area: tighter padding ── */
    .detail-chat {
        padding: 8px 12px;
    }

    /* Chat bubbles: wider on mobile */
    .chat-bubble {
        max-width: 90%;
    }

    /* Prevent iOS zoom on textarea focus */
    .chat-input-row textarea {
        font-size: 16px;
    }

    /* ── Sub-pages: reduce padding ── */
    .sub-page-body {
        padding: 16px;
    }

    .sub-page-toolbar {
        padding: 10px 12px;
    }

    /* ── Settings: touch-friendly inputs ── */
    .settings-form input,
    .settings-form select,
    .settings-form textarea,
    .settings-form .btn {
        min-height: 44px;
    }

    .toggle-row {
        padding: 12px;
        min-height: 44px;
    }

    /* ── Files: reduce padding ── */
    .file-row {
        padding: 10px 12px;
    }

    .files-breadcrumbs {
        padding: 8px 12px;
    }

    /* Hide less-important file columns on mobile */
    .file-size,
    .file-modified {
        display: none;
    }

    /* File actions always visible on mobile (no hover) */
    .file-actions {
        opacity: 1;
    }

    /* ── Settings rows: stack vertically ── */
    .settings-form-inline .settings-row {
        flex-direction: column;
        gap: 0;
    }

    /* ── Danger zone: stack ── */
    .danger-row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    /* ── Integrations: compact ── */
    .integration-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .integration-card-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .integration-card-header > div {
        min-width: 0;
    }
    .integration-card-header > div div,
    .integration-card-header > div .muted {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
    .integration-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .integration-products { grid-template-columns: repeat(2, 1fr); }

    /* ── Chat welcome: tighter ── */
    .chat-welcome {
        padding: 30px 12px 20px;
    }

    .chat-welcome-chips {
        max-width: 100%;
    }
    .chat-intro-chips {
        padding-left: 12px;
    }

    /* ── Billing: stack credit packs ── */
    .credit-packs {
        flex-direction: column;
    }

    /* ── Landing page: responsive ── */
    .hero { padding: 48px 16px 32px; }
    .hero h1 { font-size: 40px; margin-bottom: 12px; }
    .hero p { font-size: 19px; margin-bottom: 24px; }
    .hero .hero-sub-desktop { display: none; }
    .hero .hero-sub-mobile { display: block; }
    .hero .btn-large { width: 100%; box-sizing: border-box; justify-content: center; }
    .section-label { font-size: 26px; padding-bottom: 16px; }
    .features { grid-template-columns: 1fr; padding: 24px 16px; }
    body.landing nav { padding: 16px 20px; }
    body.landing nav .nav-center { display: none; }
    body.landing nav .nav-right .nav-link:not(.nav-login) { display: none; }
    .proof-strip { gap: 8px; padding-bottom: 24px; }
    .proof-badge { font-size: 13px; padding: 8px 14px; }
    .dashboard-mockup { padding: 0 16px; }
    .dashboard-mockup .mockup-inner { padding: 16px; }
    .dashboard-mockup .dashboard-kpis { grid-template-columns: repeat(3, 1fr); }
    .dashboard-mockup .dashboard-table { font-size: 11px; }
    .dashboard-mockup .dashboard-table thead th,
    .dashboard-mockup .dashboard-table tbody td { padding: 8px 10px; }

    /* ── Modal: full-width on mobile ── */
    .modal {
        width: 100%;
        max-width: 100vw;
        border-radius: 12px 12px 0 0;
        margin: auto 0 0 0;
    }

    .skill-editor-modal {
        width: 100%;
        max-height: 95vh;
    }

    .file-viewer-modal {
        width: 100%;
        max-height: 90vh;
    }

    /* ── Toasts: center on mobile ── */
    .toast-container {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .toast {
        max-width: 100%;
    }

    /* ── Trigger URL: allow wrapping ── */
    .trigger-url code {
        max-width: 100%;
        white-space: normal;
        word-break: break-all;
    }

    /* ── Schedule job rows: wrap ── */
    .schedule-job-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ── Telegram connect form: stack ── */
    .telegram-connect-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* ── Channel rows: stack on mobile ── */
    .channel-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dashboard-kpis { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom { grid-template-columns: 1fr; }
    .dashboard-table-wrap { overflow-x: auto; }

    /* ── Fleet dashboard: scrollable tabs, wrap header ── */
    .dashboard-header { flex-wrap: wrap; gap: 8px; }
    .fleet-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Fleet Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

.fleet-dashboard {
    height: 100%;
    overflow-y: auto;
    padding: 0;
}

.fleet-dashboard .empty-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.dashboard-content {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 28px 48px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.dashboard-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.dashboard-period {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}
.dashboard-period .btn-xs {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 4px;
    color: var(--muted);
}
.dashboard-period .btn-xs.active {
    background: var(--accent);
    color: white;
}

/* ── Fleet tabs ── */
.fleet-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.fleet-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.fleet-tab:hover { color: var(--text); }
.fleet-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.fleet-tab-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
}
.fleet-tab-toolbar .btn-sm.active {
    background: var(--accent);
    color: white;
}
.fleet-tab-content {
    min-height: 200px;
}
.automation-type-tag, .page-type-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.automation-type-tag.schedule { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.automation-type-tag.trigger { background: rgba(236, 72, 153, 0.15); color: #ec4899; }
.page-type-tag.public { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.page-type-tag.private { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.fleet-bot-link {
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
}
.fleet-bot-link:hover { text-decoration: underline; }
td:has(.fleet-bot-link) { white-space: nowrap; }
.fleet-status-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}
.fleet-status-badge.active { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.fleet-status-badge.paused { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.skill-type-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.skill-type-tag.md { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.skill-type-tag.js { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.skill-type-tag.both { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.fleet-bot-search {
    position: relative;
    margin-left: auto;
}
.fleet-bot-search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text);
    width: 160px;
    outline: none;
}
.fleet-bot-search-input:focus { border-color: var(--accent); }
.fleet-bot-search-input::placeholder { color: var(--muted); }
.fleet-bot-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 2px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 12px var(--shadow-color);
}
.fleet-bot-dropdown-item {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fleet-bot-dropdown-item:hover { background: var(--overlay-light); }
.fleet-bot-check { color: var(--accent); font-size: 11px; }
.fleet-filter-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.dashboard-row:hover .fleet-filter-btn,
.email-list-row:hover .fleet-filter-btn { opacity: 0.7; }
.fleet-filter-btn:hover { opacity: 1 !important; color: var(--accent); }
.fleet-bot-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.fleet-bot-filter-label { font-size: 11px; color: var(--muted); }
.fleet-bot-filter-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    white-space: nowrap;
}
.fleet-bot-filter-tag:hover { opacity: 0.8; }

/* Fleet automations list */
.fleet-auto-list { display: flex; flex-direction: column; gap: 2px; }
.fleet-auto-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
}
.fleet-auto-row:hover { background: var(--overlay-light); }
.fleet-auto-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.fleet-auto-schedule {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}
.fleet-auto-prompt-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.fleet-auto-detail {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.fleet-auto-detail-row {
    font-size: 12px;
    margin-bottom: 4px;
}
.fleet-auto-detail-row code {
    font-size: 11px;
    background: var(--overlay-light);
    padding: 1px 5px;
    border-radius: 3px;
}
.fleet-auto-detail-prompt {
    font-size: 13px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.5;
    padding: 8px 12px;
    background: var(--overlay-subtle);
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
}

/* Fleet skill modal */
.fleet-skill-modal { width: 800px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.fleet-skill-modal .modal-header { flex-shrink: 0; }
.fleet-skill-modal .modal-footer { flex-shrink: 0; }
.fleet-skill-body { margin: 12px 0; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.fleet-skill-textarea {
    width: 100%;
    flex: 1;
    min-height: 200px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
}
.fleet-skill-textarea:focus { border-color: var(--accent); }
.fleet-skill-rendered {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
}
.fleet-skill-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    margin-right: 8px;
}
.fleet-skill-view-toggle .btn-xs {
    padding: 3px 10px;
    font-size: 11px;
    border-radius: 4px;
    color: var(--muted);
}
.fleet-skill-view-toggle .btn-xs.active {
    background: var(--accent);
    color: white;
}

/* Fleet email cards */
.fleet-email-list { display: flex; flex-direction: column; gap: 4px; }
.fleet-email-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
}
.fleet-email-card:hover { background: var(--overlay-light); }
.fleet-email-card.expanded { background: var(--surface); border-color: var(--accent); }
.fleet-email-line1 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.fleet-email-direction {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.fleet-email-direction.inbound { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.fleet-email-direction.outbound { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.fleet-email-addresses {
    color: var(--muted);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fleet-email-addresses strong { color: var(--text); font-weight: 500; }
.fleet-email-date { color: var(--muted); font-size: 11px; flex-shrink: 0; white-space: nowrap; }
.fleet-email-line2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.fleet-email-subject {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}
.fleet-email-failed { font-size: 10px; color: var(--danger); font-weight: 500; flex-shrink: 0; }
.fleet-email-line3 {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fleet-email-body {
    font-size: 13px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.6;
    padding: 10px 12px;
    background: var(--overlay-subtle);
    border-radius: 6px;
    margin-top: 6px;
    max-height: 400px;
    overflow-y: auto;
}

/* KPI Cards */
.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.kpi-sub {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.kpi-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}
.kpi-tag.running { background: rgba(34,197,94,0.15); color: #22c55e; }
.kpi-tag.paused { background: rgba(245,158,11,0.15); color: #f59e0b; }
.kpi-tag.error { background: rgba(239,68,68,0.15); color: #ef4444; }
.kpi-tag.deleted { background: rgba(136,136,136,0.15); color: #888; }

.kpi-cost { color: var(--accent); }
.kpi-balance-ok { color: var(--success); }
.kpi-balance-low { color: var(--warn); }
.kpi-sub.muted-sub { color: var(--muted); }

.tier-badge.sm {
    font-size: 9px;
    padding: 1px 5px;
}

/* Bot table */
.dashboard-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.dashboard-table thead th {
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.dashboard-table thead th.num { text-align: right; }
.dashboard-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.dashboard-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dashboard-table tbody tr:last-child td { border-bottom: none; }
.dashboard-row { cursor: pointer; transition: background 0.1s; }
.dashboard-row:hover { background: rgba(99,102,241,0.05); }

.bot-name-cell { font-weight: 500; }

.status-label { font-size: 12px; }
.status-label.running { color: var(--success); }
.status-label.paused { color: var(--warn); }
.status-label.error { color: var(--danger); }
.status-label.provisioning { color: var(--muted); }

.budget-bar-wrap {
    display: inline-block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 6px;
}
.budget-bar {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}
.budget-bar.warn { background: var(--warn); }

.channels-cell { display: flex; gap: 4px; }
.channel-tag {
    font-size: 10px;
    font-weight: 600;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: rgba(99,102,241,0.1);
    color: var(--accent);
}

/* Bottom row: chart + channels */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
}
.dashboard-chart, .dashboard-channels {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.dashboard-chart-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 10px;
}

/* Sparkline */
.sparkline-wrap { position: relative; }
.sparkline-svg {
    width: 100%;
    height: 40px;
    display: block;
}
.sparkline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
}

/* Channel bars */
.channel-bars { display: flex; flex-direction: column; gap: 8px; }
.channel-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.channel-bar-label {
    width: 60px;
    text-transform: capitalize;
    color: var(--muted);
}
.channel-bar-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.channel-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.channel-bar-pct {
    width: 32px;
    text-align: right;
    color: var(--muted);
    font-size: 11px;
}

/* Recent Activity */
.dashboard-activity {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.fleet-activity-list {
    display: flex;
    flex-direction: column;
}
.fleet-activity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
}
.fleet-activity-row:last-child { border-bottom: none; }
.fleet-activity-row:hover { background: rgba(99,102,241,0.05); border-radius: 6px; }
.fleet-activity-bot {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    min-width: 70px;
    flex-shrink: 0;
}
.fleet-activity-text {
    flex: 1;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fleet-activity-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.fleet-activity-channel {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}
.fleet-activity-channel.web { background: rgba(99,102,241,0.12); color: #818cf8; }
.fleet-activity-channel.telegram { background: rgba(34,197,94,0.12); color: #22c55e; }
.fleet-activity-channel.cron { background: rgba(245,158,11,0.12); color: #f59e0b; }
.fleet-activity-channel.hook { background: rgba(236,72,153,0.12); color: #ec4899; }
.fleet-activity-channel.whatsapp { background: rgba(37,211,102,0.12); color: #25d366; }
.fleet-activity-time {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 50px;
    text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Template Picker
   ═══════════════════════════════════════════════════════════════════════════ */

.template-picker-header {
    text-align: center;
    margin-bottom: 28px;
}
.template-picker-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}
.template-picker-header p {
    font-size: 14px;
    line-height: 1.5;
}

.template-category {
    max-width: 860px;
    margin: 0 auto 28px;
}
.template-category-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
    padding-left: 2px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.template-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.template-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(99,102,241,0.1);
    transform: translateY(-1px);
}
.template-card.disabled {
    opacity: 0.5;
    pointer-events: none;
}
.template-card-blank {
    border: 2px dashed var(--accent);
    background: rgba(99,102,241,0.05);
}
.template-card-blank:hover {
    background: rgba(99,102,241,0.1);
}
.template-card-blank .template-icon {
    font-size: 24px;
    color: var(--accent);
}

.template-icon {
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
}

.template-info {
    min-width: 0;
}
.template-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 5px;
}
.template-tagline {
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.template-footer {
    text-align: center;
    margin-top: 24px;
}

/* Template overlay (for existing users with bots) */
.template-overlay {
    max-width: 900px;
    margin: 0 auto;
    padding: 48px 28px;
    overflow-y: auto;
    max-height: 100%;
}

/* Empty state template picker */
.fleet-dashboard .empty-welcome .template-picker-header,
.fleet-dashboard .empty-welcome .template-category,
.fleet-dashboard .empty-welcome .template-footer {
    max-width: 860px;
}
.fleet-dashboard .empty-welcome {
    flex-direction: column;
    padding: 48px 28px;
}

.builder-create {
    text-align: center;
    max-width: 420px;
    margin: 0 auto;
    padding: 48px 24px;
}
.builder-create h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
}
.builder-create p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Inline template picker in chat area */
.chat-template-picker {
    padding: 24px;
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
}
.chat-template-picker .template-grid {
    grid-template-columns: repeat(2, 1fr);
}
.chat-template-picker .template-card {
    padding: 16px;
}
.chat-template-picker .template-icon {
    font-size: 30px;
}
.chat-template-picker .template-category {
    margin-bottom: 20px;
}

@media (max-width: 860px) {
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 540px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
    .template-category {
        margin-bottom: 20px;
    }
}

/* ═══ SKILL MARKETPLACE ═══ */
.skills-market-page { max-width: 920px; }
.skills-market-page .template-card {
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    padding: 16px;
}
.skill-bookmark {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    color: var(--muted);
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
    z-index: 1;
}
.skill-bookmark:hover { color: var(--accent); }
.skill-bookmark.bookmarked { color: #eab308; }

/* ═══ GUIDE PAGE ═══ */
.guide-page { max-width: 860px; }

.guide-hero {
    text-align: center;
    padding: 40px 24px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 20px;
}
.guide-hero-icon { margin-bottom: 16px; }
.guide-hero h3 { font-size: 24px; margin-bottom: 8px; }
.guide-hero .muted { font-size: 15px; }

.guide-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
}
.guide-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}
.guide-text {
    line-height: 1.7;
    font-size: 14px;
    color: var(--muted);
    margin-top: 16px;
}
.guide-text code {
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* SVG diagram */
.guide-diagram {
    overflow-x: auto;
    padding: 8px 0;
}
.guide-svg {
    width: 100%;
    min-width: 600px;
    height: auto;
}

.guide-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
}
.guide-tile strong { font-size: 14px; }
.guide-tile .muted { font-size: 12px; }
.guide-tile-blue   { background: rgba(96,165,250,0.06); }
.guide-tile-cyan   { background: rgba(34,211,238,0.06); }
.guide-tile-amber  { background: rgba(251,191,36,0.06); }
.guide-tile-green  { background: rgba(34,197,94,0.06); }

/* Integration grid (3 col, wraps to 2) */
.guide-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.guide-integ {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 10px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}
.guide-integ strong { font-size: 13px; }
.guide-integ .muted { font-size: 11px; }
.guide-integ-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

/* Pricing side-by-side */
.guide-pricing {
    display: flex;
    gap: 16px;
}
.guide-price-card {
    flex: 1;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    position: relative;
}
.guide-price-card h4 { font-size: 18px; margin-bottom: 4px; }
.guide-price-tag { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.guide-price-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.guide-price-card li {
    display: flex;
    align-items: center;
    gap: 8px;
}
.guide-price-card li svg { flex-shrink: 0; }
.guide-price-credits { background: rgba(34,197,94,0.04); }
.guide-price-byok   { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.25); }
.guide-price-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--success);
    color: #fff;
}
.guide-price-badge-pro { background: var(--accent); }

/* Dashboard preview */
.guide-dashboard-preview {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.guide-dash-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}
.guide-dash-item svg { flex-shrink: 0; }
.guide-dash-item div { display: flex; flex-direction: column; gap: 2px; }
.guide-dash-item strong { font-size: 14px; }
.guide-dash-item .muted { font-size: 12px; }

/* Get started steps */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.guide-step {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-alt);
}
.guide-step-primary { border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.06); }
.guide-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.guide-step-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.guide-step-body strong { font-size: 14px; }
.guide-step-body .muted { font-size: 13px; }
.guide-step .btn { flex-shrink: 0; }

@media (max-width: 700px) {
    .guide-grid-3 { grid-template-columns: 1fr 1fr; }
    .guide-pricing { flex-direction: column; }
    .guide-step {
        flex-direction: column;
        align-items: flex-start;
    }
    .guide-step .btn { align-self: flex-end; }
}
