/* =========================================================================
   Biashara AI — design tokens
   Palette: cool pale sage-grey paper, deep ink-blue, muted harvest gold.
   Type: Fraunces (display) / Inter (body) / IBM Plex Mono (labels, data).
   ========================================================================= */

:root {
    --bg: #EDF1EF;
    --bg-raised: #E4EAE6;
    --surface: #FFFFFF;
    --surface-2: #F5F7F5;
    --ink: #161D22;
    --ink-muted: #59636B;
    --ink-faint: #8A939A;
    --border: #D9DFDA;
    --border-strong: #C3CBC5;

    --gold: #B8862A;
    --gold-strong: #96701F;
    --indigo: #1F3A5F;
    --indigo-strong: #16293F;
    --success: #3A7D5C;
    --danger: #B34640;

    --user-bubble: #1F3A5F;
    --user-bubble-ink: #F3F6F9;
    --assistant-bubble: #FFFFFF;

    --shadow-sm: 0 1px 2px rgba(20, 30, 24, 0.06);
    --shadow-md: 0 8px 24px rgba(20, 30, 24, 0.10);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #10161B;
    --bg-raised: #171F25;
    --surface: #182027;
    --surface-2: #131A20;
    --ink: #E9EDEF;
    --ink-muted: #9BA6AC;
    --ink-faint: #6C7680;
    --border: #29333A;
    --border-strong: #384049;

    --gold: #D9B24C;
    --gold-strong: #E8C56A;
    --indigo: #6C93BE;
    --indigo-strong: #8AAFD6;
    --success: #5FAE86;
    --danger: #E08A85;

    --user-bubble: #2A4A70;
    --user-bubble-ink: #F3F6F9;
    --assistant-bubble: #182027;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);

    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.eyebrow, .ledger-tick {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold-strong);
}

/* ---------------------------------------------------------------- theme toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 20;
}
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* =========================================================================
   Landing page
   ========================================================================= */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1120px;
    margin: 0 auto;
    padding: 22px 24px;
}
.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
    color: var(--ink);
}
.brand-glyph {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--indigo);
    color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 1rem;
}
.nav-links { display: flex; align-items: center; gap: 18px; }
.nav-links a { text-decoration: none; color: var(--ink-muted); font-size: 0.92rem; font-weight: 500; }
.nav-links a:hover { color: var(--ink); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--indigo); color: #F3F6F9; }
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.btn-block { width: 100%; }
.btn-google {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--ink);
}
.btn-google:hover { border-color: var(--ink-faint); }

.hero {
    position: relative;
    max-width: 1120px;
    margin: 0 auto;
    padding: 64px 24px 40px;
    background-image:
        linear-gradient(var(--bg) 0 0),
        repeating-linear-gradient(0deg, var(--border) 0 1px, transparent 1px 32px),
        repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 32px);
    background-blend-mode: normal;
    -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 96%);
            mask-image: linear-gradient(to bottom, black 55%, transparent 96%);
    opacity: 1;
}
.hero-inner { position: relative; z-index: 2; max-width: 720px; }
.hero h1 {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1.08;
    margin: 18px 0 20px;
}
.hero p.lede {
    font-size: 1.1rem;
    color: var(--ink-muted);
    max-width: 60ch;
    margin: 0 0 30px;
}
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 44px; }

.hero-prompts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 560px;
}
.hero-prompt {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 0.9rem;
    color: var(--ink-muted);
    box-shadow: var(--shadow-sm);
}
.hero-prompt b { color: var(--ink); font-weight: 600; }

.section {
    max-width: 1120px;
    margin: 0 auto;
    padding: 56px 24px;
    border-top: 1px solid var(--border);
}
.section-head { max-width: 640px; margin-bottom: 34px; }
.section-head h2 { font-size: 1.7rem; margin: 10px 0 8px; }
.section-head p { color: var(--ink-muted); margin: 0; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}
.card .num { font-family: var(--font-mono); color: var(--gold-strong); font-size: 0.8rem; }
.card h3 { font-size: 1.05rem; margin: 10px 0 8px; }
.card p { color: var(--ink-muted); margin: 0; font-size: 0.92rem; }

.footer {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--ink-faint);
    font-size: 0.85rem;
}

@media (max-width: 860px) {
    .grid-3 { grid-template-columns: 1fr; }
}

/* =========================================================================
   Auth pages (login / register)
   ========================================================================= */
.auth-body { background: var(--bg); }
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-side {
    background: var(--indigo-strong);
    color: #E7ECF1;
    padding: 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
[data-theme="dark"] .auth-side { background: #0D1721; }
.auth-side .brand-mark { color: #F3F6F9; }
.auth-side .brand-glyph { background: var(--gold); color: #1B1200; }
.auth-side-copy .ledger-tick { color: var(--gold); }
.auth-side-copy h2 { font-size: 1.9rem; margin: 14px 0 14px; color: #F3F6F9; }
.auth-side-copy p { color: #C6D1DC; max-width: 42ch; }
.auth-side-foot { color: #93A2B2; font-size: 0.82rem; }

.auth-main { position: relative; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-eyebrow { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-strong); margin: 0 0 6px; }
.auth-card h1 { font-size: 1.9rem; margin: 0 0 8px; }
.auth-sub { color: var(--ink-muted); margin: 0 0 24px; font-size: 0.94rem; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink-faint); font-size: 0.82rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 0.85rem; font-weight: 500; color: var(--ink-muted); margin-bottom: 6px; }
.field input {
    width: 100%;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.95rem;
}
.field input:focus { border-color: var(--indigo); }

.form-alert {
    background: rgba(179, 70, 64, 0.08);
    border: 1px solid rgba(179, 70, 64, 0.3);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.88rem;
    margin-bottom: 18px;
}
.form-alert p { margin: 0; }
.form-alert p + p { margin-top: 4px; }

.auth-foot { text-align: center; margin-top: 22px; font-size: 0.9rem; color: var(--ink-muted); }
.auth-foot a { color: var(--indigo); font-weight: 600; text-decoration: none; }

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-side { display: none; }
}

/* =========================================================================
   Chat application
   ========================================================================= */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-raised);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.2s ease;
}
.sidebar-top { padding: 18px; border-bottom: 1px solid var(--border); }
.sidebar .brand-mark { font-size: 0.98rem; margin-bottom: 14px; }
.new-chat-btn {
    width: 100%;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
}
.new-chat-btn:hover { border-color: var(--indigo); }

.conversation-list { flex: 1; overflow-y: auto; padding: 10px; }
.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink-muted);
    font-size: 0.88rem;
    margin-bottom: 2px;
}
.conversation-item:hover { background: var(--surface); color: var(--ink); }
.conversation-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.conversation-item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conversation-item .del {
    opacity: 0; border: none; background: none; color: var(--ink-faint); cursor: pointer; padding: 2px;
    flex-shrink: 0;
}
.conversation-item:hover .del { opacity: 1; }
.conversation-item .del:hover { color: var(--danger); }

.sidebar-bottom {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--indigo); color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem;
    overflow: hidden; flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { flex: 1; min-width: 0; }
.user-meta .name { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .email { font-size: 0.76rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
    background: transparent; color: var(--ink-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--ink); }

.main-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
}
.main-header .conv-title { font-weight: 600; font-size: 0.95rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 28px 0 12px; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; }

.empty-state { max-width: 640px; margin: 6vh auto 0; padding: 0 24px; text-align: center; }
.empty-state .brand-glyph { margin: 0 auto 18px; width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; }
.empty-state h2 { font-size: 1.6rem; margin: 0 0 10px; }
.empty-state p { color: var(--ink-muted); margin: 0 0 26px; }
.prompt-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.prompt-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px 15px;
    font-size: 0.86rem;
    color: var(--ink-muted);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.prompt-chip:hover { border-color: var(--indigo); color: var(--ink); }
@media (max-width: 640px) { .prompt-chips { grid-template-columns: 1fr; } }

.msg-row { display: flex; margin-bottom: 20px; gap: 12px; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 600;
}
.msg-row.assistant .msg-avatar { background: var(--indigo); color: #F3F6F9; }
.msg-row.user .msg-avatar { background: var(--gold); color: #241A02; }

.msg-col { display: flex; flex-direction: column; max-width: 78%; min-width: 0; gap: 4px; }
.msg-row.user .msg-col { align-items: flex-end; }
.msg-row.assistant .msg-col { align-items: flex-start; }

.msg-bubble {
    max-width: 100%;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    font-size: 0.94rem;
    line-height: 1.6;
}
.msg-row.assistant .msg-bubble { background: var(--assistant-bubble); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg-row.user .msg-bubble { background: var(--user-bubble); color: var(--user-bubble-ink); border-top-right-radius: 4px; }
.msg-bubble.is-typing { cursor: pointer; }
.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 0 0 10px; padding-left: 20px; }
.msg-bubble strong { font-weight: 700; }

.typing-caret {
    display: inline-block;
    color: var(--indigo);
    animation: caretBlink 0.9s steps(1) infinite;
}
.msg-row.user .typing-caret { color: var(--user-bubble-ink); }
@keyframes caretBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.msg-actions { display: flex; gap: 6px; padding: 0 2px; }
.msg-action-btn {
    display: inline-flex; align-items: center; gap: 5px;
    border: none; background: transparent; color: var(--ink-faint);
    font-size: 0.72rem; font-family: inherit;
    padding: 3px 7px; border-radius: 6px; cursor: pointer;
}
.msg-action-btn:hover { background: var(--bg-raised); color: var(--ink-muted); }
.msg-action-btn.copied { color: var(--success); }
.msg-action-btn.rated-up { color: var(--success); background: rgba(58, 125, 92, 0.12); }
.msg-action-btn.rated-down { color: var(--danger); background: rgba(179, 70, 64, 0.1); }
.msg-action-btn:disabled { opacity: 0.7; cursor: default; }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint);
    animation: dotPulse 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.error-banner {
    max-width: 760px; margin: 0 auto 16px; padding: 0 24px;
}
.error-banner .inner {
    background: rgba(179, 70, 64, 0.08);
    border: 1px solid rgba(179, 70, 64, 0.3);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 0.86rem;
}

.composer { border-top: 1px solid var(--border); padding: 16px 24px 20px; }
.composer-inner {
    max-width: 760px; margin: 0 auto;
    display: flex; align-items: flex-end; gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 10px;
    box-shadow: var(--shadow-sm);
}
.composer-inner:focus-within { border-color: var(--indigo); }
.composer-icon-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none; flex-shrink: 0;
    background: transparent; color: var(--ink-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.composer-icon-btn:hover { background: var(--bg-raised); color: var(--ink); }
.composer-icon-btn.recording {
    color: #fff; background: var(--danger);
    animation: recPulse 1.4s infinite ease-in-out;
}
@keyframes recPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(179,70,64,0.45); } 50% { box-shadow: 0 0 0 7px rgba(179,70,64,0); } }
#messageInput {
    flex: 1;
    border: none; outline: none; resize: none;
    background: transparent; color: var(--ink);
    font-family: inherit; font-size: 0.95rem; line-height: 1.5;
    max-height: 160px; padding: 8px 0;
}
.send-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none;
    background: var(--indigo); color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.composer-hint { text-align: center; font-size: 0.74rem; color: var(--ink-faint); margin: 10px 0 0; }
.composer-hint.recording-hint { color: var(--danger); font-weight: 600; }

.attachment-preview {
    max-width: 760px; margin: 0 auto 10px;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font-size: 0.85rem;
}
.attachment-preview img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.attachment-preview .doc-icon {
    width: 42px; height: 42px; border-radius: 8px; flex-shrink: 0;
    background: var(--indigo); color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
}
.attachment-preview .meta { flex: 1; min-width: 0; }
.attachment-preview .meta .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-preview .meta .sub { color: var(--ink-faint); font-size: 0.78rem; }
.attachment-preview .remove-att {
    border: none; background: transparent; color: var(--ink-faint); cursor: pointer;
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.attachment-preview .remove-att:hover { background: var(--bg-raised); color: var(--danger); }

/* attachments rendered inside a sent message bubble */
.msg-attachment { margin-bottom: 8px; }
.msg-attachment img {
    max-width: 100%; max-height: 260px; border-radius: 10px; display: block;
}
.msg-attachment .doc-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 10px;
    background: rgba(255,255,255,0.12);
    font-size: 0.85rem;
}
.msg-row.assistant .msg-attachment .doc-chip { background: var(--surface-2); border: 1px solid var(--border); }
.msg-attachment .doc-chip .doc-icon-sm { flex-shrink: 0; display: flex; }

.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; margin-left: -280px; }
    .sidebar.open { margin-left: 0; box-shadow: var(--shadow-md); }
    .menu-btn { display: flex; }
    .sidebar-backdrop.open {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 30;
    }
    .prompt-chips { grid-template-columns: 1fr; }
}

/* =========================================================================
   Admin dashboard (knowledge review)
   ========================================================================= */
.admin-shell { min-height: 100vh; }
.admin-top {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 900px; margin: 0 auto; padding: 20px 24px;
}
.admin-body { max-width: 900px; margin: 0 auto; padding: 0 24px 60px; }

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 40px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: var(--indigo); }
[data-theme="dark"] .stat-num { color: var(--gold); }
.stat-label { font-size: 0.76rem; color: var(--ink-muted); margin-top: 4px; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.admin-section { margin-bottom: 44px; }
.admin-section h2 { font-size: 1.25rem; margin: 0 0 6px; }
.admin-sub { color: var(--ink-muted); font-size: 0.88rem; margin: 0 0 18px; }
.empty-note { color: var(--ink-faint); font-size: 0.88rem; }

.insight-card, .feedback-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.insight-meta { display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.76rem; color: var(--ink-faint); margin-bottom: 10px; font-family: var(--font-mono); }
.insight-card .field { margin-bottom: 10px; }
.insight-actions { display: flex; gap: 10px; margin-top: 6px; }
.fb-comment { font-style: italic; color: var(--ink); margin: 0 0 8px; }
.fb-excerpt { color: var(--ink-muted); font-size: 0.88rem; margin: 0; }

/* =========================================================================
   Admin control panel additions (tabs, tables, prompt editor, viewer)
   ========================================================================= */
.admin-badge {
    font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--gold-strong);
    border: 1px solid var(--gold-strong); border-radius: 5px; padding: 1px 5px; margin-left: 6px;
}
.admin-badge-line {
    display: inline-block; font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--gold-strong); background: rgba(184,134,42,0.1);
    border-radius: 6px; padding: 3px 8px; margin-bottom: 12px;
}

.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.admin-tab {
    border: none; background: transparent; color: var(--ink-muted);
    font-family: inherit; font-weight: 600; font-size: 0.86rem;
    padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }
[data-theme="dark"] .admin-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.panel-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.filter-pills { display: flex; gap: 6px; }
.pill {
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-muted);
    border-radius: 999px; padding: 6px 13px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.pill.active { background: var(--indigo); border-color: var(--indigo); color: #F3F6F9; }
#knowledgeSearch {
    flex: 1; min-width: 180px; padding: 9px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-size: 0.86rem;
}

.status-badge {
    font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.03em;
    padding: 2px 7px; border-radius: 5px;
}
.status-pending { background: rgba(184,134,42,0.15); color: var(--gold-strong); }
.status-approved { background: rgba(58,125,92,0.14); color: var(--success); }
.status-rejected { background: rgba(179,70,64,0.1); color: var(--danger); }

#promptText { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.admin-table th {
    text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--ink-faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table td .btn { padding: 6px 12px; font-size: 0.8rem; }

.conv-oversight-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
@media (max-width: 800px) { .conv-oversight-layout { grid-template-columns: 1fr; } }
.conv-row {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.conv-row:hover { border-color: var(--indigo); }
.conv-row.active { border-color: var(--indigo); box-shadow: var(--shadow-sm); }
.conv-row-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 3px; }
.conv-row-meta { font-size: 0.74rem; color: var(--ink-faint); }

.conv-viewer {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; max-height: 560px; overflow-y: auto;
}
.viewer-msg { margin-bottom: 14px; }
.viewer-role { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px; }
.viewer-content { font-size: 0.86rem; white-space: pre-wrap; }
.viewer-user .viewer-role { color: var(--gold-strong); }
.viewer-assistant .viewer-role { color: var(--indigo); }

/* =========================================================================
   Drag-and-drop overlay, image lightbox, generated-file download cards
   ========================================================================= */
.main-panel { position: relative; }
.drop-overlay {
    display: none;
    position: absolute; inset: 0; z-index: 25;
    background: rgba(31, 58, 95, 0.88);
    align-items: center; justify-content: center;
}
[data-theme="dark"] .drop-overlay { background: rgba(13, 23, 33, 0.92); }
.main-panel.drag-active .drop-overlay { display: flex; }
.drop-overlay-inner {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    color: #F3F6F9; font-weight: 600; font-size: 0.95rem;
    border: 2px dashed rgba(243,246,249,0.5); border-radius: var(--radius-lg);
    padding: 40px 60px;
}

.lightbox {
    display: none;
    position: fixed; inset: 0; z-index: 100;
    background: rgba(10, 14, 18, 0.92);
    align-items: center; justify-content: center;
    padding: 30px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.lightbox-close {
    position: absolute; top: 20px; right: 20px;
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.12); color: #F3F6F9; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.22); }

.msg-attachment img { cursor: zoom-in; }

.download-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface-2); border: 1px solid var(--border-strong);
    border-radius: var(--radius-md); padding: 12px 14px; margin-top: 10px;
    max-width: 320px;
}
.msg-row.user .download-card { background: rgba(255,255,255,0.14); border-color: transparent; }
.download-card .dl-icon {
    width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
    background: var(--indigo); color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
}
.download-card.dl-pdf .dl-icon { background: var(--gold); color: #241A02; }
.download-card .dl-meta { flex: 1; min-width: 0; }
.download-card .dl-name { font-weight: 600; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.download-card .dl-sub { font-size: 0.72rem; color: var(--ink-faint); }
.download-card .dl-btn {
    flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
    display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.download-card .dl-btn:hover { border-color: var(--indigo); color: var(--indigo); }

/* =========================================================================
   Code blocks (fenced ```lang blocks) + Prism syntax highlighting
   ========================================================================= */
.code-block {
    position: relative;
    margin: 4px 0 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
}
[data-theme="dark"] .code-block { background: #0F1418; border-color: var(--border); }
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 8px 7px 14px;
    border-bottom: 1px solid var(--border);
}
.code-block .code-lang {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
}
.code-block-actions { display: flex; gap: 2px; }
.code-action-btn {
    display: inline-flex; align-items: center; gap: 5px;
    border: none; background: transparent; color: var(--ink-faint);
    font-size: 0.72rem; font-family: inherit;
    padding: 4px 9px; border-radius: 6px; cursor: pointer;
}
.code-action-btn:hover { background: var(--bg-raised); color: var(--ink-muted); }
.code-action-btn.copied { color: var(--success); }
.code-block pre {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
}
.code-block code, .msg-bubble code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.55;
}
.msg-bubble > p code, .msg-bubble li code {
    background: rgba(127, 127, 127, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Prism tokens, colored to match the app palette rather than a bundled theme */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--ink-faint); font-style: italic; }
.token.keyword, .token.selector, .token.important { color: var(--indigo); }
[data-theme="dark"] .token.keyword, [data-theme="dark"] .token.selector { color: var(--indigo-strong); }
.token.string, .token.attr-value, .token.char { color: var(--success); }
.token.number, .token.boolean, .token.constant { color: var(--gold-strong); }
[data-theme="dark"] .token.number, [data-theme="dark"] .token.boolean { color: var(--gold); }
.token.function, .token.class-name { color: var(--danger); }
.token.tag, .token.property, .token.attr-name { color: var(--gold-strong); }
[data-theme="dark"] .token.tag, [data-theme="dark"] .token.property { color: var(--gold); }
.token.punctuation, .token.operator { color: var(--ink-muted); }
.token.deleted { color: var(--danger); }
.token.inserted { color: var(--success); }

/* Generated SVG images */
.generated-image { display: flex; flex-direction: column; gap: 8px; }
.generated-image img {
    max-width: 100%; max-height: 300px; border-radius: 10px;
    background: #fff; border: 1px solid var(--border); display: block;
    cursor: zoom-in;
}
.svg-dl-chip {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    font-size: 0.76rem; color: var(--ink-muted); text-decoration: none;
    padding: 5px 10px; border-radius: 7px; border: 1px solid var(--border-strong);
}
.svg-dl-chip:hover { border-color: var(--indigo); color: var(--indigo); }

/* =========================================================================
   Stop-generating button (send button swaps to a stop square while busy)
   ========================================================================= */
.send-btn .stop-icon { display: none; }
.send-btn.is-generating .send-icon { display: none; }
.send-btn.is-generating .stop-icon { display: block; }
.send-btn.is-generating { background: var(--danger); cursor: pointer; }
.send-btn:disabled:not(.is-generating) { opacity: 0.5; cursor: not-allowed; }

/* =========================================================================
   Artifact panel - Claude-style side view for generated deliverables
   ========================================================================= */
.artifact-backdrop {
    display: none;
    position: fixed; inset: 0; z-index: 60;
    background: rgba(10, 14, 18, 0.45);
}
.artifact-backdrop.open { display: block; }

.artifact-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(560px, 100vw);
    z-index: 61;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.22s ease;
}
.artifact-panel.open { transform: translateX(0); }

.artifact-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.artifact-header-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.artifact-type-icon {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: var(--indigo); color: #F3F6F9;
    display: flex; align-items: center; justify-content: center;
}
.artifact-title { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

.artifact-tabs {
    display: flex; gap: 2px; overflow-x: auto;
    padding: 8px 12px 0; flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.artifact-tabs:empty { display: none; border-bottom: none; }
.artifact-tab {
    border: none; background: transparent; color: var(--ink-muted);
    font-family: var(--font-mono); font-size: 0.78rem;
    padding: 8px 12px; cursor: pointer; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.artifact-tab:hover { color: var(--ink); }
.artifact-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }
[data-theme="dark"] .artifact-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.artifact-body { flex: 1; overflow-y: auto; }
.artifact-body pre { margin: 0; padding: 18px; overflow-x: auto; }
.artifact-body code { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; }
.artifact-body iframe { width: 100%; height: 100%; border: none; display: block; }
.artifact-body img { max-width: 100%; display: block; margin: 20px auto; background: #fff; border-radius: 8px; }

.artifact-empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; padding: 40px; text-align: center; color: var(--ink-muted); gap: 12px;
}
.artifact-empty-state .icon-wrap {
    width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; color: var(--ink-faint);
}
.artifact-empty-state a.btn { margin-top: 4px; }

@media (max-width: 720px) {
    .artifact-panel { width: 100vw; }
}

/* Make artifact cards in chat feel clickable - opens the panel above */
.download-card, .generated-image { cursor: pointer; }
.download-card .dl-btn, .generated-image .svg-dl-chip {
    /* these stay clickable independently and must not also trigger the
       card's "open artifact panel" handler - stopPropagation handles the
       logic side; this is just a visual affordance */
    position: relative; z-index: 2;
}
.download-card .dl-open-hint, .generated-image .dl-open-hint {
    font-size: 0.68rem; color: var(--ink-faint); margin-top: 2px;
}