/* Lucille Dashboard v2 — Mobile-first responsive overrides
   Imports the existing style.css via base_v2.html (separate link tag).
   This file adds responsive rules, mobile nav, chat UI styles, and
   new component styles for the v2 dashboard. */

/* ── CSS Variables (extend existing) ──────────────────────── */
:root {
    --bottom-nav-h: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --chat-input-h: 56px;
}

/* ── Body: v2 layout ──────────────────────────────────────── */
body.v2 {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ── Desktop: sidebar + content (unchanged from v1) ──────── */
@media (min-width: 769px) {
    .mobile-only { display: none !important; }

    body.v2 .v2-content {
        margin-left: var(--sidebar-w);
        padding: 24px 32px;
        padding-bottom: 24px;
        flex: 1;
    }

    /* Sidebar nav links with icons */
    body.v2 .sidebar .nav-links a {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    body.v2 .sidebar .nav-links a svg {
        flex-shrink: 0;
    }

    .nav-divider {
        border-top: 1px solid var(--border);
        margin: 8px 16px;
    }

    /* Sidebar footer with user info */
    body.v2 .sidebar-footer {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 20px;
    }
    .user-avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
    }
    .user-name {
        font-size: 13px;
        color: var(--text-muted);
        flex: 1;
    }
    .logout-link {
        font-size: 12px;
        color: var(--text-dim);
        text-decoration: none;
    }
    .logout-link:hover {
        color: var(--red);
    }
}

/* ── Mobile: bottom nav + no sidebar ─────────────────────── */
@media (max-width: 768px) {
    .desktop-only { display: none !important; }

    /* Hide the original sidebar on mobile */
    body.v2 .sidebar { display: none !important; }

    /* Mobile sticky header */
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        background: rgba(12, 10, 26, 0.85);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
    }
    .mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .mobile-header-icon {
        width: 28px;
        height: 28px;
        border-radius: 6px;
    }
    .mobile-header-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--text);
        letter-spacing: -0.02em;
    }
    .mobile-header-page {
        font-size: 13px;
        font-weight: 500;
        color: var(--text-muted);
    }

    body.v2 .v2-content {
        margin-left: 0;
        padding: 16px;
        padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
        flex: 1;
        width: 100%;
    }

    /* Bottom navigation bar */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--bottom-nav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 100;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 11px;
        padding: 6px 12px;
        min-width: 60px;
        min-height: 44px;
        border: none;
        background: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-item.active {
        color: var(--accent);
    }
    .bottom-nav-item svg {
        stroke: currentColor;
    }

    /* More menu (slide-up sheet) */
    .more-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 200;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }
    .more-menu-overlay.open {
        opacity: 1;
        pointer-events: all;
    }

    .more-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        z-index: 201;
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
        max-height: 80vh;
        overflow-y: auto;
        padding-bottom: var(--safe-bottom);
    }
    .more-menu.open {
        transform: translateY(0);
    }

    .more-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px 12px;
        font-weight: 600;
        font-size: 16px;
        border-bottom: 1px solid var(--border);
    }
    .more-menu-close {
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 24px;
        cursor: pointer;
        padding: 4px 8px;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .more-menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px;
        text-decoration: none;
        color: var(--text);
        font-size: 15px;
        min-height: 44px;
    }
    .more-menu-item:active {
        background: var(--bg-hover);
    }
    .more-menu-item svg {
        flex-shrink: 0;
    }

    .more-menu-divider {
        border-top: 1px solid var(--border);
        margin: 4px 0;
    }

    .more-menu-user {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 20px;
        font-size: 14px;
        color: var(--text-muted);
    }
    .more-menu-user .user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
    }

    .more-menu-logout {
        color: var(--red) !important;
    }

    /* Card responsive */
    .card { padding: 16px; }
    .card-row { flex-direction: column; }

    /* Metric cards responsive */
    .metric-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Tables horizontal scroll */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Sales table mobile */
    .sales-table { table-layout: auto; font-size: 12px; }
    .sales-table thead th { padding: 8px 4px; font-size: 10px; }
    .sales-table thead th.sales-metric-col { width: auto; padding-left: 10px; }
    .sales-table tbody td { padding: 8px 4px; }
    .sales-metric { padding-left: 10px !important; font-size: 12px; white-space: normal !important; }
    .sales-value { font-size: 14px; }
    .pct-val { font-size: 12px; }
    .conversion-label { padding-left: 10px !important; font-size: 11px; }

    /* Page headings */
    .page-header h2 {
        font-size: 20px;
    }
}

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: white;
    color: #333;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 0.15s;
    min-height: 44px;
}
.login-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.login-btn svg {
    flex-shrink: 0;
}

.login-error {
    color: var(--red);
    font-size: 14px;
    margin-top: 16px;
}

/* ── Chat UI Styles ───────────────────────────────────────── */

/* Two-panel layout: sidebar + main chat */
.chat-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

body.v2 .v2-content.chat-page { padding: 0; }
body.v2.page-chat .mobile-header { display: none; }

/* ── Chat Sidebar ── */
.chat-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
}
.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}
.sidebar-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.new-project-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.new-project-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-muted); }
.new-chat-btn {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--accent-hover); }

.chat-sidebar-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.chat-sidebar-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.chat-sidebar-item {
    position: relative;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
.chat-sidebar-item:hover { background: var(--bg-hover); }
.chat-sidebar-item.active {
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}
.session-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
}
.session-ctx-dot {
    color: var(--accent);
    font-size: 10px;
    margin-left: 4px;
}
.session-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 3px;
}
.session-preview {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.session-time {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
    margin-left: 8px;
}
.session-delete {
    position: absolute;
    top: 8px; right: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 2px 6px;
    border-radius: 4px;
}
.chat-sidebar-item:hover .session-delete { opacity: 0.6; }
.session-delete:hover { opacity: 1 !important; color: var(--red); }

/* ── Project Groups ── */
.sidebar-section-label {
    padding: 10px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}
.project-group {
    border-bottom: 1px solid var(--border);
}
.project-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.project-header:hover { background: var(--bg-hover); }
.project-chevron {
    font-size: 11px;
    color: var(--text-dim);
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.project-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.project-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-ctx-dot {
    color: var(--accent);
    font-size: 9px;
    margin-left: 4px;
}
.project-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: auto;
    flex-shrink: 0;
}
.project-header:hover .project-actions { opacity: 1; }
.project-action-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
}
.project-action-btn:hover { background: var(--bg-card); color: var(--text); }
.project-chats {
    padding-left: 14px;
}
.project-chats .chat-sidebar-item {
    border-bottom-color: rgba(255,255,255,0.04);
    padding: 7px 14px 7px 10px;
}
.project-chats .chat-sidebar-item.active {
    border-left: 3px solid var(--accent);
    padding-left: 7px;
}
.project-chats .session-title { font-size: 12px; }
.project-chats .session-meta { margin-top: 2px; }
.project-empty {
    padding: 6px 14px 10px;
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
}
.btn-danger-text {
    background: none;
    border: none;
    color: var(--red, #dc3545);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 0;
}
.btn-danger-text:hover { text-decoration: underline; }

/* ── Chat Main ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: none;
}
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}
.chat-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.chat-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.1s;
}
.chat-action-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ── Sidebar Backdrop (mobile) ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}
.sidebar-backdrop.visible {
    display: block;
}

/* Mobile: sidebar as slide-in overlay */
@media (max-width: 768px) {
    .chat-layout {
        height: calc(100dvh - var(--bottom-nav-h) - var(--safe-bottom));
    }
    .chat-sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 280px;
        box-shadow: none;
    }
    .chat-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .chat-sidebar-toggle { display: flex; }
}

@media (min-width: 769px) {
    .chat-sidebar-toggle { display: none; }
    .sidebar-backdrop { display: none !important; }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.45;
    word-wrap: break-word;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg.assistant p { margin: 0 0 8px; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }
.chat-msg.assistant code {
    background: var(--bg);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.chat-msg.assistant pre {
    background: var(--bg);
    padding: 10px 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
}
.chat-msg.assistant {
    position: relative;
}
.chat-msg .msg-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Copy button on assistant messages */
.msg-copy-btn {
    position: absolute;
    top: 6px; right: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.chat-msg.assistant:hover .msg-copy-btn { opacity: 0.7; }
.msg-copy-btn:hover { opacity: 1 !important; }

/* Copy button on code blocks */
.code-copy-btn {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-muted);
}
pre:hover .code-copy-btn { opacity: 1; }

/* Generated images in chat */
.chat-generated-img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
}

/* Attachment preview */
.attachment-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.attach-thumb {
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 6px;
}
.attach-doc-icon {
    width: 48px; height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
}
.attach-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attach-size {
    font-size: 11px;
    color: var(--text-dim);
}
.attach-remove {
    background: none;
    border: none;
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Tool use indicator */
.tool-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.tool-indicator .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Chat input area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
}
.chat-input-area textarea:focus {
    border-color: var(--accent);
}
.chat-input-area textarea::placeholder {
    color: var(--text-dim);
}

.chat-send-btn {
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: white;
    transition: background 0.15s;
    min-height: 44px;
    min-width: 44px;
}
.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-upload-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-upload-btn:hover { color: var(--text); }

/* Tool use badge */
.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

/* New chat button */
.new-chat-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.new-chat-btn:hover {
    background: var(--bg-hover);
}

/* Chat action buttons (settings gear etc) */
.chat-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}
.chat-action-btn:hover { color: var(--text); background: var(--bg-hover); }

/* Attachment preview bar */
.attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

/* ── Home / Briefing Page ─────────────────────────────────── */
.greeting {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}
.greeting-date {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.metric-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.metric-card .value {
    font-size: 24px;
    font-weight: 700;
}
.metric-card .trend {
    font-size: 12px;
    margin-top: 4px;
}
.metric-card .trend.up { color: var(--green); }
.metric-card .trend.down { color: var(--red); }

/* ── Section cards for home page ──────────────────────────── */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.section-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick action buttons */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    min-height: 36px;
    transition: background 0.15s;
}
.quick-action-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ── Alert items ──────────────────────────────────────────── */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.alert-item:last-child { border-bottom: none; }
.alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.alert-dot.urgent { background: var(--red); }
.alert-dot.warning { background: var(--yellow); }
.alert-dot.info { background: var(--accent); }

/* ── Funnel visualization ─────────────────────────────────── */
.funnel-stage {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.funnel-bar {
    height: 32px;
    background: var(--accent);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    min-width: 40px;
    transition: width 0.4s ease;
}
.funnel-label {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 80px;
}
.funnel-arrow {
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    padding: 2px 0;
}

/* ── Facebook post cards ──────────────────────────────────── */
.fb-post {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}
.fb-post .author {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}
.fb-post .text {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
    margin-bottom: 8px;
}
.fb-post .engagement {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}
.fb-post .engagement .count {
    color: var(--text);
    font-weight: 600;
}
.fb-post .classification {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 6px;
}
.fb-post .classification.urgent {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}
.fb-post .classification.notable {
    background: rgba(251, 191, 36, 0.15);
    color: var(--yellow);
}

/* ── HTMX loading states ──────────────────────────────────── */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.loading-skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
    height: 20px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Briefing / Home page ─────────────────────────────────── */
.briefing-page {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 40px;
}
.briefing-header {
    margin-bottom: 28px;
}
.briefing-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.briefing-date {
    color: var(--text-muted);
    font-size: 14px;
}
.briefing-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
.section-title svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Metric cards inside briefing */
.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.metric-value {
    font-size: 24px;
    font-weight: 700;
}
.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Section footer link */
.section-link {
    display: block;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    margin-top: 12px;
    text-align: right;
}
.section-link:hover {
    text-decoration: underline;
}

/* ── Mini funnel (home page) ──────────────────────────────── */
.funnel-mini {
    margin-top: 16px;
}
.funnel-mini .funnel-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
}
.funnel-mini .funnel-row .funnel-label {
    min-width: 90px;
    text-align: right;
}
.funnel-bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}
.funnel-bar-track .funnel-bar {
    height: 100%;
    border-radius: 4px;
    min-width: 4px;
}
.funnel-num {
    min-width: 28px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
}

/* Primary quick action button */
.quick-action-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

/* ── Window tabs (time period selector) ───────────────────── */
.window-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}
.window-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.window-tab.active {
    background: var(--accent);
    color: white;
}
.window-tab:hover:not(.active) {
    color: var(--text);
}
.window-panel {
    display: none;
}
.window-panel.active {
    display: block;
}

/* 4-column metric grid variant */
.metric-grid.four-col {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

/* Highlighted metric card */
.metric-card.highlight {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

/* ── Funnel visual (pipeline page) ────────────────────────── */
.funnel-visual {
    padding: 4px 0;
}

/* ── Conversion rate bars ─────────────────────────────────── */
.conversion-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.conv-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.conv-row.highlight {
    font-weight: 600;
}
.conv-label {
    min-width: 110px;
    font-size: 13px;
    color: var(--text-muted);
}
.conv-bar-track {
    flex: 1;
    height: 16px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}
.conv-bar {
    height: 100%;
    background: var(--green);
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.4s ease;
}
.conv-bar.accent {
    background: var(--accent);
}
.conv-pct {
    min-width: 40px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
}

/* Chart container */
.chart-container {
    height: 280px;
    position: relative;
}

/* ── Health grid (HTMX loaded) ────────────────────────────── */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.health-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 6px 0;
}
.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.health-label {
    color: var(--text);
}

/* Loading shimmer placeholder */
.loading-shimmer {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
    height: 60px;
}

.htmx-loading-placeholder {
    min-height: 60px;
}

/* ── Content planner ──────────────────────────────────────── */
.form-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.form-input {
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.form-input:focus {
    border-color: var(--accent);
}
.form-input-sm {
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
}
.content-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
}
.content-item-header {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.content-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.content-status.status-idea { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.content-status.status-drafted { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.content-status.status-scheduled { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.content-status.status-published { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.content-platform { font-size: 12px; color: var(--text-muted); }
.content-date { font-size: 12px; color: var(--text-muted); }
.content-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.content-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.content-actions { display: flex; gap: 8px; align-items: center; }
.btn-icon-sm {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; border-radius: 4px;
}
.btn-icon-sm:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ── Media library ────────────────────────────────────────── */
.upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 24px; text-align: center; color: var(--text-muted);
}
.upload-area p { margin-bottom: 12px; font-size: 14px; }
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.media-item { position: relative; background: var(--bg); border-radius: 8px; overflow: hidden; }
.media-thumb { width: 100%; height: 120px; object-fit: cover; display: block; }
.media-placeholder {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); color: var(--text-muted);
}
.media-info { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.media-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-size { font-size: 11px; color: var(--text-muted); }
.media-delete {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.5); color: white; border-radius: 50%;
    opacity: 0; transition: opacity 0.15s;
}
.media-item:hover .media-delete { opacity: 1; }

/* ── Facebook extras ──────────────────────────────────────── */
.fb-post-header {
    display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px;
}
.post-date { font-size: 12px; color: var(--text-muted); }
.engagement-score { color: var(--accent); font-size: 11px; font-weight: 600; }
.urgent-section { border-color: rgba(239, 68, 68, 0.3); }
.metric-card.highlight-urgent { border-color: var(--red); background: rgba(239, 68, 68, 0.05); }

/* ── Team page ────────────────────────────────────────────── */
.activity-row {
    display: flex; gap: 12px; padding: 6px 0;
    border-bottom: 1px solid var(--border); font-size: 13px; align-items: center;
}
.activity-row:last-child { border-bottom: none; }
.activity-name { flex: 1; font-weight: 500; }
.activity-agent { color: var(--accent); font-size: 12px; }
.activity-channel { color: var(--text-muted); font-size: 12px; }

/* ── Mobile responsive for new components ─────────────────── */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .form-row .form-input { width: 100%; }
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .fb-post-header { flex-direction: column; gap: 2px; }
}

/* ══ Content Studio v2 ══════════════════════════════════════ */

/* Quick input (sticky on mobile) */
.content-quick-input {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 6px 6px 6px 18px;
    margin-bottom: 16px;
}
.content-quick-input input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    outline: none;
    min-width: 0;
}
.content-quick-input input::placeholder { color: var(--text-dim); }
.content-quick-input select {
    background: var(--bg-card);
    border: none;
    color: var(--text-muted);
    border-radius: 12px;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.content-quick-input .quick-add-btn {
    background: var(--accent);
    border: none;
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 20px;
    min-height: 38px;
    min-width: 38px;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.content-quick-input .quick-add-btn:hover { background: var(--accent-hover); }

/* Tabs with badge counts */
.content-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.content-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
}
.content-tab.active {
    background: var(--accent);
    color: white;
}
.content-tab:hover:not(.active) { color: var(--text); }
.tab-badge {
    font-size: 11px;
    background: rgba(255,255,255,0.2);
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}
.content-tab:not(.active) .tab-badge {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* Content card v2 */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.content-card:hover { border-color: var(--accent); }
.content-card.drafting {
    border-color: rgba(99, 102, 241, 0.4);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.card-header .card-time {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-dim);
}

/* Status pills */
.status-pill {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.status-pill.idea { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.status-pill.drafting { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.status-pill.drafted { background: rgba(251, 191, 36, 0.15); color: #f59e0b; }
.status-pill.scheduled { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.status-pill.published { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.platform-tag {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Grade badges */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}
.grade-badge.grade-A { background: rgba(52, 211, 153, 0.2); color: var(--green); }
.grade-badge.grade-B { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.grade-badge.grade-C { background: rgba(251, 191, 36, 0.2); color: #f59e0b; }
.grade-badge.grade-D { background: rgba(239, 68, 68, 0.2); color: var(--red); }

/* Card title + body */
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    outline: none;
}
.card-title:focus {
    border-bottom: 1px dashed var(--accent);
}

.card-body-editor {
    margin: 10px 0;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.body-text {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    outline: none;
    min-height: 40px;
}
.body-text:empty::before {
    content: attr(data-placeholder);
    color: var(--text-dim);
    font-style: italic;
}
.body-text:focus {
    background: var(--bg);
    border-radius: 6px;
    padding: 8px;
    margin: -8px;
}

.char-counter {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}
.char-counter.warn { color: #f59e0b; }
.char-counter.over { color: var(--red); }

/* Draft progress shimmer */
.draft-progress {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    padding: 20px;
    background: var(--bg);
    margin: 10px 0;
    text-align: center;
}
.draft-progress .progress-text {
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}
.progress-shimmer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(99, 102, 241, 0.08) 50%,
        transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Card media strip */
.card-media-strip {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.card-media-strip .media-thumb-sm {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.add-media-btn {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 20px;
}
.add-media-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Card actions */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.card-actions-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Action buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg);
    color: var(--text);
    min-height: 36px;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn svg { flex-shrink: 0; }

.action-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.action-btn.primary:hover { background: var(--accent-hover); }

.action-btn.green {
    background: rgba(52, 211, 153, 0.1);
    border-color: var(--green);
    color: var(--green);
}
.action-btn.green:hover { background: rgba(52, 211, 153, 0.2); }

.action-btn.danger {
    color: var(--text-muted);
    border-color: transparent;
    background: none;
    padding: 7px 8px;
}
.action-btn.danger:hover { color: var(--red); }

.action-btn.subtle {
    border-color: transparent;
    background: none;
    color: var(--text-muted);
}
.action-btn.subtle:hover { color: var(--text); background: var(--bg-hover); }

/* ── Inline Feedback Thread ────────────────────────────────── */
.feedback-thread {
    border-top: 1px solid var(--border);
    padding: 10px 0 0;
    margin-top: 8px;
}
.feedback-messages {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    padding-right: 4px;
}
.feedback-msg {
    padding: 6px 10px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 13px;
    line-height: 1.4;
}
.feedback-msg.user {
    align-self: flex-end;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
}
.feedback-msg.assistant {
    align-self: flex-start;
    background: var(--bg);
    border: 1px solid var(--border);
}
.feedback-msg .msg-author {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.feedback-msg .msg-text {
    display: block;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
.feedback-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    transition: opacity 0.2s;
}
.feedback-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    min-height: 36px;
}
.feedback-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.feedback-input::placeholder { color: var(--text-dim); }
.feedback-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.feedback-send-btn:hover { background: var(--accent-hover); }
.feedback-send-btn:disabled {
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Thinking dots animation */
.thinking-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
}
.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: dotPulse 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Suggestions banner */
.suggestions-banner {
    background: var(--bg-card);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.suggestions-banner .banner-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
.refresh-suggestions-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: auto;
    transition: all 0.15s;
}
.refresh-suggestions-btn:hover { color: var(--accent); background: var(--bg-hover); }
.suggestion-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.suggestion-chip {
    flex-shrink: 0;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.15);
    transition: border-color 0.15s, background 0.15s;
}
.suggestion-chip:active { background: rgba(99, 102, 241, 0.08); border-color: var(--accent); }
.chip-source {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}
.chip-src-win { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.chip-src-hot { background: rgba(99, 102, 241, 0.12); color: var(--accent); }
.chip-src-qa { background: rgba(234, 179, 8, 0.12); color: #ca8a04; }
.chip-src-recycle { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.chip-label {
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chip-accept {
    background: rgba(99, 102, 241, 0.1);
    border: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    min-height: 32px;
    min-width: 48px;
    white-space: nowrap;
}
.chip-accept:hover, .chip-accept:active { background: rgba(99, 102, 241, 0.2); }
.chip-dismiss {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
    padding: 6px 8px;
    min-height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Schedule modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    align-items: center;
    justify-content: center;
    display: none;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: calc(100% - 32px);
    max-height: 90vh;
    overflow-y: auto;
    z-index: 301;
}
#callSummaryModal {
    z-index: 350;
}
.modal-overlay.open {
    display: flex;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    max-width: 420px;
    width: calc(100% - 32px);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
}
.modal-content .optimal-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.optimal-chip {
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.optimal-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.optimal-chip .chip-note {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: all;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}
.toast.leaving {
    animation: toastOut 0.3s ease forwards;
}
.toast-action {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    font-size: 13px;
}
@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* Engagement display on published cards */
.engagement-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.engagement-display .eng-score {
    font-weight: 600;
    color: var(--text);
}

/* Versions drawer */
.versions-list {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.version-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.version-item:last-child { border-bottom: none; }
.version-num { font-weight: 600; color: var(--accent); min-width: 24px; }
.version-date { color: var(--text-dim); flex: 1; }
.version-revert {
    background: none; border: none; color: var(--accent);
    font-size: 12px; cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.version-revert:hover { background: rgba(99, 102, 241, 0.1); }

/* ── Media Modal & Thumbnails ────────────────────────────── */
.modal-wide {
    max-width: 540px;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h3 { margin: 0; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Tab bar */
.media-modal-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
}
.media-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.media-tab.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.media-tab:hover:not(.active) { color: var(--text); }

.media-tab-content { min-height: 120px; }
.tab-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

/* Upload drop zone */
.upload-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    color: var(--text-muted);
    transition: border-color 0.15s, background 0.15s;
}
.upload-drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.06);
}
.upload-drop-zone p {
    margin: 0 0 12px 0;
    font-size: 14px;
}
.upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Generate tab */
.gen-options {
    margin: 10px 0;
}
.gen-options select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}
.gen-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Library grid */
.media-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}
.media-library-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}
.media-library-item:hover {
    border-color: var(--accent);
}
.media-library-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card media strip */
.card-media-strip {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    align-items: center;
}
.media-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}
.media-thumb-sm {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}
.media-thumb-remove, .media-thumb-edit {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s;
}
.media-thumb-wrap:hover .media-thumb-remove,
.media-thumb-wrap:hover .media-thumb-edit { opacity: 1; }
.media-thumb-remove {
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-weight: bold;
}
.media-thumb-edit {
    bottom: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
}
.add-media-btn {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}
.add-media-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 350;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    object-fit: contain;
}

/* Edit preview in modal */
.edit-preview-thumb {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 12px;
    background: var(--bg);
}

/* ── Coaches Card ────────────────────────────────────────── */
.metric-card[data-coach] { cursor: pointer; transition: border-color 0.15s; }
.metric-card.active-filter { border-color: var(--accent); }

.coach-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.coach-role {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.coaching-calls-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.call-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.call-row:last-of-type { border-bottom: none; }
.call-date {
    color: var(--text-muted);
    min-width: 50px;
    flex-shrink: 0;
}
.call-coach {
    font-weight: 600;
    color: var(--text);
    min-width: 70px;
    flex-shrink: 0;
}
.call-topic {
    flex: 1;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.call-duration {
    color: var(--text-muted);
    flex-shrink: 0;
}
.call-expand-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}
.call-expand-btn:hover { background: rgba(99, 102, 241, 0.1); }
.call-summary-preview {
    font-size: 12px;
    color: var(--text-dim);
    padding: 0 0 8px 62px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.call-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.call-summary-full {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60vh;
    overflow-y: auto;
}
.no-calls-msg {
    font-size: 13px;
    color: var(--text-dim);
    padding: 12px 0;
}
.coach-calls-section {
    margin-bottom: 4px;
}

/* ── Client search bar ──────────────────────────────────── */
.client-search-bar {
    position: relative;
    margin-bottom: 16px;
}
.client-search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    z-index: 1;
}
.client-search-bar input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}
.client-search-bar input::placeholder { color: var(--text-dim); }
.client-search-bar input:focus { border-color: var(--accent); }

.search-results-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.search-results-dropdown.open { display: block; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(99, 102, 241, 0.08); }
.search-result-item.search-result-hint {
    color: var(--text-dim);
    cursor: default;
    font-style: italic;
}
.search-result-name {
    font-weight: 600;
    color: var(--text);
}
.search-result-email {
    color: var(--text-dim);
    font-size: 12px;
}

/* ── Client profile modal ───────────────────────────────── */
.client-profile-section {
    margin-bottom: 20px;
}
.client-profile-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.client-info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}
.client-info-row .info-label {
    color: var(--text-dim);
    min-width: 100px;
}

/* Vault notes inside client profile */
.vault-note-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.vault-category-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
}
.vault-note-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.vault-note-snippet {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Content Studio responsive ────────────────────────────── */
@media (max-width: 768px) {
    .content-quick-input {
        position: sticky;
        bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
        z-index: 50;
        margin: 0 4px;
        padding: 5px 5px 5px 16px;
        border-color: rgba(139, 92, 246, 0.2);
        background: var(--bg-card);
    }
    /* ── Content Studio mobile polish ── */
    .briefing-header { margin-bottom: 16px; }
    .briefing-header h1 { font-size: 22px; }
    .briefing-date { font-size: 13px; }
    .suggestions-banner { padding: 12px; margin-bottom: 12px; }
    .suggestions-banner .banner-header { font-size: 12px; margin-bottom: 8px; }
    .suggestion-chips {
        flex-direction: column;
        overflow-x: visible;
        padding-right: 0;
        padding-bottom: 0;
        gap: 6px;
    }
    .suggestion-chip {
        flex-shrink: 1;
        padding: 8px 10px;
        border-radius: 10px;
        font-size: 13px;
    }
    .chip-label {
        white-space: normal;
        max-width: none;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.4;
    }
    .content-tabs { overflow-x: auto; margin-bottom: 12px; }
    .content-tab { padding: 6px 10px; font-size: 12px; min-height: 32px; }
    .tab-badge { font-size: 10px; padding: 1px 5px; }
    .empty-state { padding: 28px 16px; font-size: 14px; }
    .card-actions { flex-direction: column; align-items: stretch; }
    .card-actions-right {
        margin-left: 0;
        justify-content: flex-end;
    }
    .action-btn { justify-content: center; }
    .modal-content { padding: 20px 16px; }
    .toast-container { bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 10px); }
    .feedback-messages { max-height: 140px; }
    .feedback-msg { max-width: 92%; }
    .call-row { flex-wrap: wrap; gap: 4px 10px; }
    .call-topic { min-width: 100%; order: 5; }
    .call-summary-preview { padding-left: 0; }
    .client-info-row { flex-direction: column; gap: 2px; }
    .client-info-row .info-label { min-width: auto; }
    .modal-wide { max-width: 100%; }
    .media-thumb-remove, .media-thumb-edit { opacity: 1; }
    .media-library-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}

/* ── Token Usage & Cost Table (Home) ──────────────────────── */
.cost-table-v2-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.cost-table-v2 {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.cost-table-v2 th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.cost-table-v2 td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.cost-table-v2 tbody tr:last-child td { border-bottom: none; }
.cost-table-v2 tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    padding-top: 10px;
}
.cost-v2-model {
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}
.cost-v2-cell {
    white-space: nowrap;
}
.cost-v2-amount {
    display: block;
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cost-v2-total {
    color: var(--purple);
}
.cost-v2-detail {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Mobile: stack cost cells */
@media (max-width: 520px) {
    .cost-table-v2 { font-size: 0.78rem; }
    .cost-table-v2 th,
    .cost-table-v2 td { padding: 6px 6px; }
    .cost-v2-detail { font-size: 0.65rem; }
}

/* ── PWA: hide browser chrome when installed ──────────────── */
@media (display-mode: standalone) {
    .chat-container {
        padding-top: env(safe-area-inset-top, 0px);
    }
}
