/* ============================================
   BPC Buddy — AI Help Chat Widget
   Floating bottom-right chat panel
   Full-featured: streaming, suggestions, voice,
   ratings, export, share, search, personas, tips
   Theme-aware (follows dark/light mode)
   ============================================ */

:root {
    --chat-width: 400px;
    --chat-height: 560px;
    --chat-radius: 12px;
    /* Theme tokens — overridden by dark.css / light.css */
    --chat-bg: #1a1a2e;
    --chat-text: #e2e8f0;
    --chat-text-secondary: #94a3b8;
    --chat-border: rgba(255,255,255,.10);
    --chat-bubble-assistant: rgba(255,255,255,.08);
    --chat-hover: rgba(255,255,255,.06);
    --chat-surface: rgba(255,255,255,.05);
    --chat-accent: #0d6efd;
    --chat-shadow: rgba(0,0,0,.35);
    --chat-grip: rgba(255,255,255,.18);
    --chat-grip-hover: rgba(255,255,255,.4);
}

/* ── Floating action button ──────────────────── */
#ai-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
#ai-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.ai-chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bs-warning, #ffc107);
    display: none;
    border: 2px solid var(--bs-primary, #0d6efd);
}

/* ── Chat panel ──────────────────────────────── */
#ai-chat-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 9001;
    width: var(--chat-width);
    height: var(--chat-height);
    min-width: 320px;
    min-height: 360px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    border-radius: var(--chat-radius);
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--chat-shadow);
    background: var(--chat-bg);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    /* Base font size — JS updates this on resize */
    font-size: var(--chat-font-size, 0.84rem);
}
#ai-chat-panel.open { display: flex; }

/* ── Resize handles ──────────────────────────── */
.ai-chat-resize-handle {
    position: absolute;
    z-index: 2;
}
.ai-chat-resize-handle.top    { top: 0; left: 12px; right: 12px; height: 6px; cursor: n-resize; }
.ai-chat-resize-handle.left   { top: 12px; left: 0; bottom: 12px; width: 6px; cursor: w-resize; }
.ai-chat-resize-handle.topleft { top: 0; left: 0; width: 14px; height: 14px; cursor: nw-resize; }

/* Subtle visual grip on top-left corner */
.ai-chat-resize-handle.topleft::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--chat-grip);
    border-left: 2px solid var(--chat-grip);
    border-radius: 2px 0 0 0;
    pointer-events: none;
    transition: border-color .15s;
}
.ai-chat-resize-handle.topleft:hover::after {
    border-color: var(--chat-grip-hover);
}
#ai-chat-panel.resizing { user-select: none; }

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    font-weight: 600;
    font-size: 1em;
    flex-shrink: 0;
    gap: 4px;
}
.ai-chat-header .chat-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-chat-header .header-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.ai-chat-header button {
    background: none;
    border: none;
    color: #fff;
    font-size: .95rem;
    cursor: pointer;
    opacity: .8;
    padding: 2px 5px;
    border-radius: 4px;
    transition: opacity .15s;
}
.ai-chat-header button:hover { opacity: 1; background: rgba(255,255,255,.18); }

/* ── Proactive tip banner ────────────────────── */
.ai-chat-tip {
    display: none;
    padding: 7px 12px;
    font-size: .78rem;
    background: rgba(255,193,7,.12);
    color: var(--bs-warning, #ffc107);
    border-bottom: 1px solid rgba(255,193,7,.15);
    flex-shrink: 0;
    position: relative;
}
.ai-chat-tip .tip-dismiss {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: .9rem;
    opacity: .6;
}
.ai-chat-tip .tip-dismiss:hover { opacity: 1; }

/* ── Messages area ───────────────────────────── */
.ai-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual bubble */
.ai-chat-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 1em;
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-chat-msg.user {
    align-self: flex-end;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    border-bottom-right-radius: 2px;
}
.ai-chat-msg.assistant {
    align-self: flex-start;
    background: var(--chat-bubble-assistant);
    color: var(--chat-text);
    border-bottom-left-radius: 2px;
}

/* Markdown inside assistant bubble */
.ai-chat-msg.assistant strong { font-weight: 600; }
.ai-chat-msg.assistant code {
    font-size: .78rem;
    background: var(--chat-hover);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Navigate-from-chat links */
.chat-nav-link {
    color: var(--bs-info, #0dcaf0);
    text-decoration: underline dotted;
    cursor: pointer;
    font-weight: 500;
}
.chat-nav-link:hover { text-decoration: underline solid; }

/* ── Message action bar (ratings, copy, tokens) ─ */
.msg-action-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    padding-top: 4px;
    border-top: 1px solid var(--chat-border);
}
.msg-action-bar button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .72rem;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: .45;
    color: var(--chat-text);
    transition: opacity .15s, background .15s;
}
.msg-action-bar button:hover { opacity: .85; background: var(--chat-hover); }
.msg-action-bar button.active { opacity: 1; }
.msg-rate-up.active { color: var(--bs-success, #198754); }
.msg-rate-down.active { color: var(--bs-danger, #dc3545); }
.msg-tokens {
    font-size: .65rem;
    opacity: .35;
    margin-left: auto;
    user-select: none;
}

/* ── Typing indicator ────────────────────────── */
.ai-chat-typing {
    align-self: flex-start;
    padding: 8px 14px;
    font-size: .95em;
    opacity: .6;
    font-style: italic;
}
.typing-dots span {
    animation: typingBounce .6s infinite;
    display: inline-block;
    font-weight: bold;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ── Suggestion chips ────────────────────────── */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 12px 4px;
    flex-shrink: 0;
}
.ai-chat-chip {
    background: rgba(13,110,253,.12);
    color: var(--bs-primary, #0d6efd);
    border: 1px solid rgba(13,110,253,.2);
    border-radius: 14px;
    padding: 3px 10px;
    font-size: .88em;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.ai-chat-chip:hover {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}

/* ── Input area ──────────────────────────────── */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 10px;
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}
.ai-chat-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1em;
    background: var(--chat-bg);
    color: var(--chat-text);
    outline: none;
    max-height: 80px;
    min-height: 36px;
}
.ai-chat-input-area textarea:focus {
    border-color: var(--bs-primary, #0d6efd);
}

/* Send button */
.ai-chat-input-area button.ai-chat-send {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: .85rem;
}
.ai-chat-input-area button.ai-chat-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Voice button */
.ai-chat-voice {
    background: none;
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: .85rem;
    opacity: .6;
    transition: opacity .15s, border-color .15s;
}
.ai-chat-voice:hover { opacity: 1; border-color: var(--bs-primary, #0d6efd); }
.ai-chat-voice.recording {
    color: var(--bs-danger, #dc3545);
    border-color: var(--bs-danger, #dc3545);
    opacity: 1;
    animation: voicePulse 1s infinite;
}
@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,.3); }
    50% { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
}

/* ── Conversation list ───────────────────────── */
.ai-chat-conv-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 14px;
}
.ai-chat-conv-item {
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
}
.ai-chat-conv-item:hover { background: var(--chat-hover); }
.ai-chat-conv-item .conv-preview { flex: 1; min-width: 0; }
.ai-chat-conv-item .conv-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-chat-conv-item .conv-meta {
    font-size: .82em;
    opacity: .5;
    margin-top: 1px;
}
.conv-persona-tag {
    background: rgba(13,110,253,.15);
    color: var(--bs-primary, #0d6efd);
    font-size: .62rem;
    padding: 1px 5px;
    border-radius: 8px;
    vertical-align: middle;
    margin-left: 4px;
    text-transform: uppercase;
    font-weight: 600;
}
.ai-chat-conv-item .conv-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.ai-chat-conv-item .conv-action {
    opacity: 0;
    font-size: .72rem;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--chat-text);
    transition: opacity .15s, background .15s;
}
.ai-chat-conv-item:hover .conv-action { opacity: .5; }
.ai-chat-conv-item .conv-action:hover { opacity: 1; background: var(--chat-hover); }
.ai-chat-conv-item .conv-delete:hover { color: var(--bs-danger, #dc3545); background: rgba(220,53,69,.12); }

/* ── Search view ─────────────────────────────── */
.ai-chat-search-view {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
}
.search-input-wrap { margin-bottom: 10px; flex-shrink: 0; }
.search-input-wrap input {
    font-size: 1em;
    background: var(--chat-bg);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
}
.search-results { flex: 1 1 auto; overflow-y: auto; }
.search-result-item {
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: .95em;
}
.search-result-item:hover { background: var(--chat-hover); }
.search-result-title { font-weight: 500; font-size: .95em; margin-bottom: 2px; }
.search-result-snippet { opacity: .7; font-size: .88em; }
.search-result-snippet mark {
    background: rgba(255,193,7,.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.search-result-meta { font-size: .65rem; opacity: .4; margin-top: 2px; }

/* ── Persona picker ──────────────────────────── */
.ai-chat-persona-picker {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 10px 14px;
}
.persona-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 1em;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
.persona-item:hover { background: var(--chat-hover); }
.persona-item.active {
    background: rgba(13,110,253,.12);
    border-color: rgba(13,110,253,.3);
}
.persona-item i { font-size: 1.1rem; opacity: .7; }
.persona-item small { line-height: 1.3; }

/* ── Token stats view ────────────────────────── */
.ai-chat-stats-view {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat-box {
    background: var(--chat-surface);
    border-radius: 8px;
    padding: 12px 10px;
    text-align: center;
}
.stat-box.highlight {
    grid-column: 1 / -1;
    background: rgba(13,110,253,.1);
}
.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--bs-primary, #0d6efd);
}
.stat-box.highlight .stat-value { font-size: 1.4rem; }
.stat-label {
    font-size: .7rem;
    opacity: .5;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 480px) {
    #ai-chat-panel {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        bottom: 80px !important;
        height: calc(100vh - 110px) !important;
    }
    .ai-chat-resize-handle { display: none; }
}

/* ══════════════════════════════════════════════════════
   NEW FEATURE STYLES (Features 16-28)
   ══════════════════════════════════════════════════════ */

/* ── Attach Button & Preview ──────────────────── */
.ai-chat-attach {
    background: none;
    border: none;
    color: var(--chat-text, #adb5bd);
    font-size: 1.1em;
    padding: 4px 6px;
    cursor: pointer;
    opacity: .7;
    transition: opacity .15s;
    flex-shrink: 0;
}
.ai-chat-attach:hover { opacity: 1; }

.ai-chat-attach-preview {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: .78em;
    background: var(--chat-input-bg, #2a2a3d);
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.08));
    color: var(--chat-text, #c9d1d9);
}
.attach-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.attach-remove {
    background: none;
    border: none;
    color: var(--chat-text, #adb5bd);
    cursor: pointer;
    padding: 0 2px;
    font-size: 1.1em;
    opacity: .6;
}
.attach-remove:hover { opacity: 1; color: #f55; }

/* ── Model Picker ─────────────────────────────── */
.ai-chat-model-picker {
    overflow-y: auto;
    flex: 1;
    padding: 12px 14px;
}
.model-picker-intro {
    font-size: .82em;
    color: var(--chat-text, #c9d1d9);
    opacity: .7;
    margin-bottom: 10px;
}
.model-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 6px;
    background: var(--chat-input-bg, #2a2a3d);
    border: 1px solid transparent;
    transition: border-color .15s, background .15s;
}
.model-item:hover { border-color: var(--chat-accent, #646cff); }
.model-item.active { border-color: var(--chat-accent, #646cff); background: rgba(100,108,255,.12); }
.model-name { font-size: .88em; font-weight: 600; color: var(--chat-text, #e4e4e7); }
.model-desc { font-size: .75em; color: var(--chat-text, #adb5bd); opacity: .7; margin-top: 2px; }
.model-id { font-size: .68em; font-family: monospace; color: var(--chat-text, #8b949e); opacity: .5; margin-top: 2px; }

/* ── Chat Model Tag (in header) ───────────────── */
.chat-model-tag {
    font-size: .63em;
    background: rgba(100,108,255,.15);
    color: var(--chat-accent, #646cff);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 500;
    vertical-align: middle;
}

/* ── Slash Command Hints ──────────────────────── */
.ai-chat-slash-hint {
    position: absolute;
    bottom: 60px;
    left: 10px;
    right: 10px;
    z-index: 10;
    background: var(--chat-bg, #1a1a2e);
    border: 1px solid var(--chat-border, rgba(255,255,255,.1));
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    overflow: hidden;
}
.slash-hint-item {
    padding: 8px 12px;
    font-size: .8em;
    color: var(--chat-text, #c9d1d9);
    cursor: pointer;
    transition: background .1s;
}
.slash-hint-item:hover { background: var(--chat-input-bg, rgba(255,255,255,.06)); }
.slash-hint-item i { color: var(--chat-accent, #646cff); }

/* ── Templates View ───────────────────────────── */
.ai-chat-templates-view {
    overflow-y: auto;
    flex: 1;
    padding: 12px 14px;
}
.templates-intro {
    font-size: .82em;
    color: var(--chat-text, #c9d1d9);
    opacity: .7;
    margin-bottom: 10px;
}
.template-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 6px;
    background: var(--chat-input-bg, #2a2a3d);
    border: 1px solid transparent;
    transition: border-color .15s, transform .1s;
}
.template-item:hover { border-color: var(--chat-accent, #646cff); transform: translateY(-1px); }
.template-icon { font-size: 1.3em; color: var(--chat-accent, #646cff); padding-top: 2px; flex-shrink: 0; }
.template-name { font-size: .85em; font-weight: 600; color: var(--chat-text, #e4e4e7); }
.template-desc { font-size: .73em; color: var(--chat-text, #adb5bd); opacity: .7; margin-top: 2px; }

/* ── Anomaly View ─────────────────────────────── */
.ai-chat-anomaly-view {
    overflow-y: auto;
    flex: 1;
    padding: 12px 14px;
}
.anomaly-scan-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.anomaly-alerts-list { }
.anomaly-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--chat-input-bg, #2a2a3d);
    margin-bottom: 6px;
}
.anomaly-icon { font-size: 1.2em; flex-shrink: 0; padding-top: 2px; }
.anomaly-content { flex: 1; min-width: 0; }
.anomaly-metric { font-size: .82em; font-weight: 600; color: var(--chat-text, #e4e4e7); }
.anomaly-desc { font-size: .72em; color: var(--chat-text, #adb5bd); opacity: .8; margin-top: 1px; }
.anomaly-ask, .anomaly-dismiss {
    background: none;
    border: none;
    color: var(--chat-text, #adb5bd);
    cursor: pointer;
    font-size: .85em;
    padding: 4px;
    opacity: .5;
    transition: opacity .1s;
    flex-shrink: 0;
}
.anomaly-ask:hover { opacity: 1; color: var(--chat-accent, #646cff); }
.anomaly-dismiss:hover { opacity: 1; color: #f55; }

/* ── Digest View ──────────────────────────────── */
.ai-chat-digest-view {
    overflow-y: auto;
    flex: 1;
    padding: 14px 16px;
}
.digest-section { }
.digest-title {
    font-size: .9em;
    font-weight: 600;
    color: var(--chat-text, #e4e4e7);
    margin-bottom: 6px;
}
.digest-desc {
    font-size: .78em;
    color: var(--chat-text, #adb5bd);
    opacity: .7;
    margin-bottom: 10px;
}
.digest-content {
    font-size: .82em;
    color: var(--chat-text, #c9d1d9);
    background: var(--chat-input-bg, #2a2a3d);
    border-radius: 8px;
    padding: 12px;
    line-height: 1.5;
}

/* ── Folder View ──────────────────────────────── */
.ai-chat-folder-view {
    overflow-y: auto;
    flex: 1;
    padding: 12px 14px;
}
.folder-section-title {
    font-size: .7em;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--chat-text, #8b949e);
    opacity: .6;
    margin: 10px 0 4px;
}
.folder-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .82em;
    color: var(--chat-text, #c9d1d9);
    transition: background .1s;
}
.folder-item:hover { background: var(--chat-input-bg, rgba(255,255,255,.05)); }
.folder-item.active { background: rgba(100,108,255,.12); color: var(--chat-accent, #646cff); font-weight: 600; }
.folder-count {
    margin-left: auto;
    font-size: .75em;
    opacity: .5;
}
.folder-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}
.folder-tag-chip {
    display: inline-block;
    font-size: .72em;
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(100,108,255,.1);
    color: var(--chat-accent, #646cff);
    cursor: pointer;
    transition: background .1s;
}
.folder-tag-chip:hover { background: rgba(100,108,255,.2); }
.folder-tag-chip.active { background: var(--chat-accent, #646cff); color: #fff; }

/* ── Conversation list folder/tag/model badges ── */
.conv-folder-tag {
    display: inline-block;
    font-size: .62em;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(100,108,255,.1);
    color: var(--chat-accent, #646cff);
    margin-right: 4px;
}
.conv-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}
.conv-tag-chip {
    font-size: .58em;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(158,168,255,.08);
    color: var(--chat-text, #8b949e);
}
.conv-model-tag {
    display: inline-block;
    font-size: .58em;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(46,160,67,.1);
    color: #3fb950;
    margin-left: 4px;
}

/* (conv-actions styles already defined under .ai-chat-conv-item above) */

/* ── Inline AI Assist Tooltip ─────────────────── */
.ai-inline-tooltip {
    position: fixed;
    z-index: 100000;
    background: var(--bs-body-bg, #1a1a2e);
    border: 1px solid var(--bs-border-color, rgba(255,255,255,.12));
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    padding: 12px 14px;
    width: 300px;
    max-height: 280px;
    overflow-y: auto;
    font-size: .82em;
    color: var(--bs-body-color, #c9d1d9);
}
.ai-inline-loading { text-align: center; padding: 12px; }
.ai-inline-error { color: #f55; text-align: center; padding: 8px; }
.ai-inline-result { line-height: 1.5; }
.ai-inline-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--bs-border-color, rgba(255,255,255,.08));
}
.ai-inline-chat {
    background: var(--chat-accent, #646cff);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: .8em;
    cursor: pointer;
}
.ai-inline-chat:hover { filter: brightness(1.15); }
.ai-inline-close {
    background: none;
    border: none;
    color: var(--bs-body-color, #adb5bd);
    font-size: 1em;
    cursor: pointer;
    opacity: .6;
}
.ai-inline-close:hover { opacity: 1; }

/* ── Inline AI Assist button on data pages ────── */
.ai-assist-btn {
    background: none;
    border: none;
    color: var(--chat-accent, #646cff);
    font-size: .72em;
    cursor: pointer;
    padding: 1px 4px;
    opacity: .4;
    transition: opacity .15s;
    vertical-align: middle;
}
.ai-assist-btn:hover { opacity: 1; }

/* ── Digest Badge ─────────────────────────────── */
.digest-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: .52em;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    border-radius: 7px;
    text-align: center;
    padding: 0 3px;
    pointer-events: none;
}

/* ── Digest Tabs ──────────────────────────────── */
.digest-tabs {
    display: flex;
    border-bottom: 1px solid var(--chat-border, rgba(255,255,255,.1));
    padding: 0 12px;
    flex-shrink: 0;
}
.digest-tab {
    background: none;
    border: none;
    color: var(--chat-text, #adb5bd);
    font-size: .8em;
    padding: 8px 14px;
    cursor: pointer;
    opacity: .6;
    border-bottom: 2px solid transparent;
    transition: opacity .15s, border-color .15s;
}
.digest-tab:hover { opacity: .85; }
.digest-tab.active {
    opacity: 1;
    border-bottom-color: var(--chat-accent, #646cff);
    color: var(--chat-accent, #646cff);
    font-weight: 600;
}
.digest-tab-badge {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    font-size: .72em;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    text-align: center;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.digest-tab-content {
    overflow-y: auto;
    flex: 1;
    padding: 12px 14px;
}

/* ── Digest Notification Cards ────────────────── */
.digest-notif-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}
.digest-notif-card {
    background: var(--chat-input-bg, #2a2a3d);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: border-color .15s;
}
.digest-notif-card.unread {
    border-left-color: var(--chat-accent, #646cff);
    background: rgba(100,108,255,.06);
}
.digest-notif-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.digest-notif-bu {
    font-size: .78em;
    font-weight: 600;
    color: var(--chat-text, #e4e4e7);
}
.digest-notif-date {
    font-size: .68em;
    color: var(--chat-text, #8b949e);
    opacity: .6;
    margin-left: auto;
}
.digest-notif-freq {
    font-size: .6em;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(100,108,255,.1);
    color: var(--chat-accent, #646cff);
    text-transform: capitalize;
}
.digest-notif-body {
    font-size: .78em;
    color: var(--chat-text, #c9d1d9);
    line-height: 1.5;
}
.digest-notif-body ul { padding-left: 16px; margin: 4px 0; }
.digest-notif-body strong { color: var(--chat-text, #e4e4e7); }
