/*
 * Majlis AI — design system
 * World Economic Forum palette (Forum Blue #004A93, accent #5291FF, navy ink #101C2E)
 * Light, airy and sober: white content, soft grey rails, hairline borders, subtle depth.
 */

:root {
    --blue: #004A93;
    --blue-hover: #003C78;
    --blue-accent: #5291FF;
    --blue-50: #F2F7FE;
    --blue-100: #E2ECFB;
    --blue-200: #C7DAF6;

    --ink: #101C2E;
    --ink-2: #2F3C52;
    --mute: #5B6B84;
    --faint: #8B97AB;

    --line: #E8ECF2;
    --line-strong: #D8DEE8;
    --canvas: #F7F9FC;
    --surface: #FFFFFF;
    --hover: #F0F3F8;

    --danger: #B93A2E;
    --danger-50: #FDF2F1;
    --success: #1E8A4C;
    --success-50: #E9F6EE;

    --speaker-0: #004A93;
    --speaker-1: #0E8A7B;
    --speaker-2: #B26A1F;
    --speaker-3: #7A4FA3;
    --speaker-4: #C0453A;
    --speaker-5: #2F6FE0;
    --speaker-6: #5B6B84;
    --speaker-7: #4D7C2A;
    --highlight: rgba(82, 145, 255, 0.12);

    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-xs: 0 1px 2px rgba(16, 28, 46, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 28, 46, 0.07), 0 1px 2px rgba(16, 28, 46, 0.04);
    --shadow-md: 0 10px 28px rgba(16, 28, 46, 0.07), 0 2px 6px rgba(16, 28, 46, 0.04);
    --shadow-lg: 0 24px 56px rgba(16, 28, 46, 0.14), 0 4px 12px rgba(16, 28, 46, 0.05);
    --ring: 0 0 0 3px rgba(82, 145, 255, 0.28);

    --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Source Serif 4', Georgia, serif;

    --sidebar-w: 268px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 64px;
    --reading-w: 768px;
}

/* ─────────────────────────── Base ─────────────────────────── */

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

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.app-body { overflow: hidden; }

h1, h2, h3, h4, p { margin: 0; }

button, input, textarea { font: inherit; color: inherit; }

button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

svg { flex-shrink: 0; }

.hidden, [hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--ring); }

* {
    scrollbar-width: thin;
    scrollbar-color: #CDD5E0 transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #CDD5E0;
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: #B7C1CF; }

kbd {
    font-family: var(--font);
    font-size: 10.5px;
    font-weight: 500;
    padding: 1px 5px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--mute);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes thinking {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
    30% { transform: translateY(-3px); opacity: 1; }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────── Buttons ─────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--blue);
    color: #FFFFFF;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--blue-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--ink-2);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--hover); color: var(--ink); }

.btn.is-danger {
    background: var(--danger);
    color: #FFFFFF;
    border-color: var(--danger);
    box-shadow: var(--shadow-xs);
}
.btn.is-danger:hover { background: #9E3126; border-color: #9E3126; }

.btn-block { width: 100%; }

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--mute);
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn-sm { width: 28px; height: 28px; border-radius: var(--radius-xs); }
.icon-btn-sm svg { width: 15px; height: 15px; }
.icon-btn.is-danger:hover { background: var(--danger-50); color: var(--danger); }

.upload-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.upload-btn.is-busy { pointer-events: none; }
.upload-btn.is-busy .upload-spinner { display: inline-block; }
.upload-btn.is-busy .upload-idle-icon { display: none; }

/* ─────────────────────────── App shell ─────────────────────────── */

.app {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ─────────────────────────── Sidebar ─────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    border-right: 1px solid var(--line);
    transition: width 0.22s ease;
    overflow: hidden;
}

.sidebar-head {
    height: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 0;
    position: relative;
}

.brand {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 56px;          /* keeps room for the collapse button on the right */
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
}
/* World Economic Forum logo (official lockup, blue emblem + wordmark) */
.wef-logo {
    display: block;
    width: auto;
    height: 56px;
    flex-shrink: 0;
}
.sidebar-head #sidebarToggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}
.wef-logo-lg {
    height: 92px;
}
/* Small WEF logo used as the "open sidebar" button when the rail is collapsed */
.wef-logo-sm {
    height: 32px;
}
.sidebar-logo-btn {
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}
.sidebar-logo-btn:hover { background: var(--hover); }
/* Event identity — the demo is built on the Annual Meeting 2026 (Davos) data */
.sidebar-event {
    margin: 0 20px 16px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.45;
    text-align: center;
    color: var(--faint);
}
.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.brand-mark span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
}
.brand-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.sidebar-section { padding: 0 16px 16px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 16px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nav-item svg {
    width: 18px;
    height: 18px;
    color: var(--faint);
    transition: color 0.15s ease;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item:hover svg { color: var(--mute); }
.nav-item.is-active {
    background: var(--surface);
    border-color: var(--blue-accent);
    color: var(--blue);
    box-shadow: var(--shadow-xs);
}
.nav-item.is-active svg { color: var(--blue); }
.nav-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-count { color: var(--blue); }

.sidebar-divider {
    height: 1px;
    background: var(--line);
    margin: 18px 20px 6px;
    flex-shrink: 0;
}
.sidebar-section-label {
    padding: 10px 28px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}

.conv-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 16px 12px;
}
.conv-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
    padding: 8px 6px 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.conv-item:hover { background: var(--hover); }
.conv-item.conv-active {
    background: var(--surface);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-xs);
}
.conv-main { flex: 1; min-width: 0; }
.conv-title {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
}
.conv-item.conv-active .conv-title { color: var(--ink); }
.conv-title.is-editing {
    background: var(--surface);
    box-shadow: var(--ring);
    padding: 1px 6px;
    text-overflow: clip;
    cursor: text;
}
.conv-time {
    margin-top: 1px;
    font-size: 11.5px;
    color: var(--faint);
}
.conv-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.conv-item:hover .conv-actions,
.conv-item.conv-active .conv-actions { opacity: 1; }
.conv-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--faint);
}

.sidebar-foot {
    margin-top: auto;
    flex-shrink: 0;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--line);
}
.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 6px;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role { font-size: 11.5px; color: var(--faint); }

/* Collapsed rail */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed-only { display: none !important; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-expanded-only { display: none !important; }
.sidebar.collapsed .sidebar-collapsed-only { display: inline-flex !important; }
.sidebar.collapsed .sidebar-head { height: var(--topbar-h); position: static; justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-head #sidebarToggle { position: static; transform: none; }
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-foot { padding-left: 14px; padding-right: 14px; }
.sidebar.collapsed .new-chat-btn { padding: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar.collapsed .user-row { justify-content: center; padding: 4px 0; }

/* ─────────────────────────── Main area ─────────────────────────── */

.main-content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    transition: margin-right 0.3s ease;
}
.main-content-area.pdf-open { margin-right: 50%; }

.topbar {
    height: var(--topbar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.topbar-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--faint);
    letter-spacing: 0.01em;
}
/* A bare bar: the title lives inside the message column for the chat view */
.topbar-actions { flex-shrink: 0; }

/* Conversation intro inside the message thread */
.chat-intro {
    text-align: center;
    padding: 18px 0 10px;
    margin-bottom: 8px;
}
.chat-intro-kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 10px;
}
.chat-intro-title {
    max-width: 60ch;
    margin: 0 auto;
    font-family: var(--font-display);
    font-size: clamp(24px, 3.2vw, 32px);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.015em;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.chat-intro-date {
    margin-top: 10px;
    font-size: 13.5px;
    color: var(--mute);
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.view-actions { display: flex; align-items: center; gap: 8px; }

.view {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}
.view.is-active { display: flex; }

/* ─────────────────────────── Chat ─────────────────────────── */

.messages-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.messages-list {
    max-width: var(--reading-w);
    margin: 0 auto;
    padding: 36px 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.msg { animation: fadeUp 0.25s ease both; }

.msg-user {
    display: flex;
    justify-content: flex-end;
}
.msg-bubble {
    max-width: 78%;
    padding: 11px 16px;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    border-radius: 18px 18px 6px 18px;
    color: var(--ink);
}
.msg-bubble .msg-text {
    font-size: 14.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-assistant {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.msg-avatar span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
}
.msg-body { flex: 1; min-width: 0; padding-top: 4px; }
.msg-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}
.msg-content .msg-text {
    font-size: 15px;
    line-height: 1.72;
    color: var(--ink-2);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.msg-content strong { color: var(--ink); font-weight: 600; }

.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.msg-assistant:hover .msg-actions { opacity: 1; }
.msg-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 500;
    color: var(--mute);
    transition: background 0.15s ease, color 0.15s ease;
}
.msg-action svg { width: 14px; height: 14px; }
.msg-action:hover { background: var(--hover); color: var(--ink); }
.msg-action.is-done { color: var(--success); }

.msg-sources { margin-top: 18px; }
.msg-sources-label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.msg-sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    height: 30px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--ink-2);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.source-chip svg { width: 13px; height: 13px; color: var(--blue); }
.source-chip:hover {
    border-color: var(--blue-accent);
    background: var(--blue-50);
    color: var(--blue);
}
.source-name {
    font-weight: 500;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.source-loc { color: var(--faint); white-space: nowrap; }
.source-chip:hover .source-loc { color: var(--blue); }

.thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 26px;
    font-size: 13.5px;
    color: var(--mute);
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--blue-accent);
    animation: thinking 1.3s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

/* Empty chat */
.chat-empty {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 28px;
}
.chat-empty-inner {
    width: 100%;
    max-width: 680px;
    text-align: center;
    animation: fadeUp 0.35s ease both;
}
/* The logo is a block element, so text-align does not center it: do it explicitly. */
.chat-empty-inner .wef-logo { margin-left: auto; margin-right: auto; }
.brand-mark-lg {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-md);
}
.brand-mark-lg span { width: 16px; height: 16px; border-width: 3px; }
.chat-empty-title {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--ink);
}
.chat-empty-sub {
    margin-top: 10px;
    font-size: 15px;
    color: var(--mute);
}
.event-eyebrow {
    margin-top: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--blue);
}
.chat-empty-meta {
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 11px;
    border-radius: 999px;
    background: var(--canvas);
    border: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--mute);
}
.meta-pill svg { width: 13px; height: 13px; color: var(--blue); }
.suggestions {
    margin-top: 36px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    text-align: left;
}
.suggestion {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.suggestion:hover {
    border-color: var(--blue-200);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.suggestion-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--blue-50);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.suggestion-icon svg { width: 16px; height: 16px; }
.suggestion-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.suggestion-desc {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--mute);
}

/* Composer */
.composer-wrap {
    flex-shrink: 0;
    padding: 8px 28px 18px;
    background: var(--surface);
}
.composer {
    max-width: var(--reading-w);
    margin: 0 auto;
    padding: 14px 12px 10px 18px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within {
    border-color: var(--blue-accent);
    box-shadow: var(--shadow-md), var(--ring);
}
.composer-input {
    display: block;
    width: 100%;
    min-height: 26px;
    max-height: 200px;
    padding: 2px 6px 2px 0;
    border: 0;
    background: transparent;
    resize: none;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
}
.composer-input:focus-visible { box-shadow: none; }
.composer-input::placeholder { color: var(--faint); }
.composer-input:disabled { background: transparent; }
.composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}
.composer-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px 0 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.chip-btn svg { width: 14px; height: 14px; color: var(--mute); }
.chip-btn .chip-caret { width: 12px; height: 12px; color: var(--faint); }
.chip-btn:hover,
.chip-btn[aria-expanded="true"] {
    background: var(--hover);
    border-color: var(--line-strong);
}
.chip-icon { display: inline-flex; }
#scopeName {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:hover { background: var(--blue-hover); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.composer-hint {
    max-width: var(--reading-w);
    margin: 9px auto 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--faint);
}

/* Menus (scope & mode) */
.menu-anchor { position: relative; }
.menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    z-index: 60;
    min-width: 280px;
    max-width: 340px;
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: fadeUp 0.15s ease both;
}
.menu-title,
.scope-group {
    padding: 8px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.menu-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-align: left;
    font-size: 13.5px;
    color: var(--ink-2);
    transition: background 0.12s ease;
}
.menu-option:hover { background: var(--hover); }
.menu-option-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--canvas);
    border: 1px solid var(--line);
    color: var(--mute);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.menu-option-icon svg { width: 15px; height: 15px; }
.menu-option-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.menu-option-title { font-weight: 500; color: var(--ink); }
.menu-option-desc { font-size: 12px; line-height: 1.4; color: var(--mute); }
.menu-option-check { width: 16px; height: 16px; color: var(--blue); opacity: 0; }
.mode-option.is-selected .menu-option-check { opacity: 1; }
.mode-option.is-selected .menu-option-icon {
    background: var(--blue-50);
    border-color: var(--blue-100);
    color: var(--blue);
}
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }

.scope-check {
    position: relative;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.scope-option.is-selected .scope-check {
    background: var(--blue);
    border-color: var(--blue);
}
.scope-option.is-selected .scope-check::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #FFFFFF;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.scope-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scope-option.is-selected .scope-label { color: var(--ink); font-weight: 500; }

/* ─────────────────────────── Briefing (structured answers) ─────────────────────────── */

.briefing {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.briefing-banner { display: flex; }
.briefing-badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    color: var(--blue);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.briefing-headline {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.briefing-summary {
    padding: 14px 16px;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue);
    border-radius: var(--radius-sm);
}
.briefing-summary p {
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--ink-2);
}
.briefing-section { --briefing-accent: var(--blue); }
.briefing-section[data-kind="evidence"] { --briefing-accent: var(--speaker-1); }
.briefing-section[data-kind="counterpoints"] { --briefing-accent: var(--speaker-2); }
.briefing-section[data-kind="open"] { --briefing-accent: var(--speaker-3); }
.briefing-section[data-kind="context"] { --briefing-accent: var(--mute); }
.briefing-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--briefing-accent);
}
.briefing-section-title svg { width: 15px; height: 15px; }
.briefing-items {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.briefing-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}
.briefing-item:first-child { border-top: 0; }
.briefing-item-marker {
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    border: 1.5px solid var(--briefing-accent);
    color: var(--briefing-accent);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.briefing-item-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.briefing-item-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.briefing-item-detail { font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.briefing-source {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    height: 24px;
    margin-top: 4px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--canvas);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.briefing-source svg { width: 12px; height: 12px; }
.briefing-source:hover {
    border-color: var(--blue-accent);
    background: var(--blue-50);
    color: var(--blue);
}

.assistant-response .katex { font-size: 1.05em; }
.assistant-response .katex-display {
    margin: 0.55em 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

/* ─────────────────────────── Library (documents & audio) ─────────────────────────── */

.library-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.page {
    width: 100%;
    padding: 28px;
}
.library-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.search-field {
    position: relative;
    width: 100%;
    max-width: 330px;
}
.search-field > svg {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    color: var(--mute);
    pointer-events: none;
    transition: color 0.18s ease;
}
.search-field input {
    width: 100%;
    height: 40px;
    padding: 0 40px 0 40px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--canvas);
    font-size: 13.5px;
    color: var(--ink);
    caret-color: var(--blue);
    box-shadow: inset 0 1px 1px rgba(16, 28, 46, 0.02);
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.search-field input::placeholder { color: var(--faint); }
.search-field input:hover { border-color: var(--line-strong); background: #fff; }
.search-field input:focus {
    background: #fff;
    border-color: var(--blue-accent);
    box-shadow: var(--ring);
    outline: none;
}
.search-field:focus-within > svg { color: var(--blue); }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-field input::-webkit-search-decoration { -webkit-appearance: none; }
.search-clear {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--faint);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.search-clear svg { width: 12px; height: 12px; }
.search-field.has-value .search-clear { opacity: 1; pointer-events: auto; }
.search-clear:hover { background: var(--line); color: var(--ink-2); }
.search-clear:active { background: var(--line-strong); }
.toolbar-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--faint);
    white-space: nowrap;
}
.toolbar-hint svg { width: 14px; height: 14px; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 12px;
}
.doc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.doc-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}
.transcript-open-area {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 46px 16px 16px;
    border-radius: inherit;
}
/* Document cards: the page preview on top (PDF clearly visible), text below.
   Kept deliberately compact so a full row of documents still fits on screen. */
.document-open-area {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 10px 12px;
    border-radius: inherit;
}
.file-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--blue-50);
    color: var(--blue);
}
.file-icon svg { width: 20px; height: 20px; }
.file-icon-audio { background: #EEF3FF; color: #2F6FE0; }
.doc-body { flex: 1; min-width: 0; }

/* Compact first-page preview — the PDF stays readable without dominating the card */
.doc-thumb-mini {
    position: relative;
    width: 100%;
    height: 104px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--canvas);
    border: 1px solid var(--line);
}
.doc-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}
.doc-thumb-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    background: var(--canvas);
}
.doc-thumb-fallback svg { width: 20px; height: 20px; }
.doc-thumb[src]:not([src='']) + .doc-thumb-fallback { display: none; }
.doc-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.doc-meta {
    margin-top: 3px;
    font-size: 12px;
    color: var(--faint);
}
.card-action {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    /* Solid chip so the menu stays visible on top of a page thumbnail */
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.doc-card:hover .card-action,
.card-action:focus-visible { opacity: 1; }

.speaker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}
[data-speaker-slot="0"] { --spk: var(--speaker-0); }
[data-speaker-slot="1"] { --spk: var(--speaker-1); }
[data-speaker-slot="2"] { --spk: var(--speaker-2); }
[data-speaker-slot="3"] { --spk: var(--speaker-3); }
[data-speaker-slot="4"] { --spk: var(--speaker-4); }
[data-speaker-slot="5"] { --spk: var(--speaker-5); }
[data-speaker-slot="6"] { --spk: var(--speaker-6); }
[data-speaker-slot="7"] { --spk: var(--speaker-7); }
.speaker-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px 0 8px;
    border-radius: 999px;
    background: var(--canvas);
    border: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
}
.speaker-chip::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--spk, var(--speaker-0));
}
.speaker-chip.speaker-more {
    color: var(--mute);
    font-weight: 600;
    cursor: default;
    background: var(--surface);
    border-style: dashed;
}
.speaker-chip.speaker-more::before { display: none; }
.video-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: middle;
    margin-left: 2px;
    color: var(--blue);
    font-weight: 600;
}
.video-badge svg { width: 12px; height: 12px; }

.dropzone {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 64px 24px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--canvas);
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover {
    border-color: var(--blue-accent);
    background: var(--blue-50);
}
.dropzone-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 10px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.dropzone-icon svg { width: 22px; height: 22px; }
.dropzone-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.dropzone-sub { font-size: 13px; color: var(--mute); }
.no-results {
    padding: 56px 0;
    text-align: center;
    font-size: 13.5px;
    color: var(--mute);
}

/* ─────────────────────────── Side panels (PDF & transcript) ─────────────────────────── */

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 90;
    width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transition: width 0.3s ease;
}
.side-panel.open { width: 50%; }
.side-panel > * { min-width: 360px; }

.panel-head {
    height: var(--topbar-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 14px 0 24px;
    border-bottom: 1px solid var(--line);
}
.panel-titles { min-width: 0; }
.panel-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    line-height: 1.3;
}
.panel-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.panel-head-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Home-made PDF viewer — pages fitted to the panel width, scroll to read */
.pdf-viewer-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--canvas);
    scrollbar-width: thin;
}
.pdf-status {
    padding: 10px 16px;
    font-size: 12.5px;
    color: var(--faint);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px;
}
.pdf-page {
    display: block;
    width: 100%;
    max-width: 1080px;
    height: auto;
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    /* Fit exactly to the reading width: pixel-perfect, no zoom needed */
    object-fit: contain;
}
.pdf-scroll-guide {
    padding: 8px 16px 12px;
    text-align: center;
    font-size: 11.5px;
    color: var(--faint);
    flex-shrink: 0;
}

.transcript-player {
    flex-shrink: 0;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
}
.tr-video-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 12px;
    margin-bottom: 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tr-video-toggle svg { width: 14px; height: 14px; color: var(--blue); }
.tr-video-toggle:hover { border-color: var(--blue-accent); color: var(--blue); }
.tr-video-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.tr-video {
    display: block;
    width: 100%;
    max-height: 46vh;
    border-radius: 10px;
    background: #000;
    margin-bottom: 14px;
}
/* When the video is shown it becomes the active media: its native controls drive
   playback, the custom audio row steps aside, and the transcript follows the video. */
.transcript-player.video-mode .tr-player-row { display: none; }
.transcript-player.video-mode .tr-no-audio { display: none; }
.transcript-player.video-mode .tr-video { margin-bottom: 0; }
.tr-media-notice {
    margin: 10px 0 0;
    padding: 9px 12px;
    border-radius: 8px;
    background: var(--blue-50);
    color: var(--ink-2);
    font-size: 13px;
    line-height: 1.45;
}
.tr-player-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.tr-play {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--blue);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.tr-play:hover { background: var(--blue-hover); }
.tr-icon-pause { display: none; }
#transcriptPanel.is-playing .tr-icon-play { display: none; }
#transcriptPanel.is-playing .tr-icon-pause { display: block; }
.tr-progress {
    flex: 1;
    padding: 10px 0;
    cursor: pointer;
    touch-action: none;
}
.tr-progress-track {
    height: 4px;
    border-radius: 999px;
    background: var(--line);
}
.tr-progress-fill {
    position: relative;
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--blue);
}
.tr-progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--blue);
    box-shadow: var(--shadow-sm);
    transform: translateY(-50%);
}
.tr-time {
    font-size: 12px;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tr-rate {
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.tr-rate:hover { background: var(--hover); }
.tr-speakers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}
.tr-speakers:empty { display: none; }
.tr-no-audio {
    display: none;
    margin-top: 10px;
    font-size: 12px;
    color: var(--faint);
}
.transcript-player.no-audio .tr-no-audio { display: block; }
.transcript-player.no-audio .tr-player-row { opacity: 0.4; pointer-events: none; }

.transcript-body {
    position: relative; /* segment offsetTop is measured against this box */
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 40vh;
}
.tr-seg {
    position: relative;
    margin-bottom: 4px;
    padding: 13px 16px 13px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.16s ease;
}
/* Sliding accent bar: quiet at rest, revealed on hover, solid when active/cited */
.tr-seg::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 13px;
    bottom: 13px;
    width: 3px;
    border-radius: 999px;
    background: var(--blue-accent);
    opacity: 0;
    transform: scaleY(0.35);
    transform-origin: center;
    transition: opacity 0.16s ease, transform 0.16s ease;
}
.tr-seg:hover { background: var(--canvas); }
.tr-seg:hover::before { opacity: 0.45; transform: scaleY(1); }
.tr-seg:hover .tr-seg-speaker { color: var(--blue); }
.tr-seg:hover .tr-seg-time { color: var(--blue); }
.tr-seg-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 5px;
}
.tr-seg-speaker {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--spk, var(--speaker-0));
    transition: color 0.16s ease;
}
.tr-seg-time {
    font-size: 11.5px;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
    transition: color 0.16s ease;
}
.tr-seg-text {
    font-size: 14px;
    line-height: 1.68;
    color: var(--ink-2);
}
.tr-seg.is-playing { background: var(--blue-50); }
.tr-seg.is-playing::before { opacity: 1; transform: scaleY(1); }
.tr-seg.is-playing .tr-seg-speaker { color: var(--blue); }
.tr-seg.is-source { background: var(--highlight); }
.tr-seg.is-source::before { opacity: 1; transform: scaleY(1); background: var(--blue); }
.tr-seg.is-source-head {
    margin-top: 26px;
}
.tr-seg.is-source-head::after {
    content: 'Cited passage';
    position: absolute;
    top: -18px;
    left: 18px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--blue);
}

/* Keyword knowledge graph */
.tr-keywords {
    flex-shrink: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.tr-keywords-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-2);
    transition: background 0.15s ease;
}
.tr-keywords-toggle:hover { background: var(--canvas); }
.tr-keywords-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tr-keywords-title svg { color: var(--blue); }
.tr-keywords-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    color: var(--blue);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tr-keywords-chevron {
    margin-left: auto;
    color: var(--faint);
    transition: transform 0.2s ease;
}
.tr-keywords.collapsed .tr-keywords-chevron { transform: rotate(-90deg); }
.tr-keywords-body {
    max-height: 280px;
    overflow-y: auto;
    padding: 2px 24px 18px;
}
.tr-keywords.collapsed .tr-keywords-body { display: none; }

/* Keywords: small rounded items with the word only — the full detail lives in the
   per-transcript keywords JSON, ready to be served by an API later. */
.kw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.kw-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.kw-chip:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: #FFFFFF;
}
.kw-chip.has-ts::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--blue-accent);
    flex-shrink: 0;
}
.kw-chip.has-ts:hover::before { background: #FFFFFF; }
.kw-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--blue);
    text-decoration: none;
}
.kw-download svg { width: 14px; height: 14px; }
.kw-download:hover { text-decoration: underline; }

/* ─────────────────────────── File explorer ─────────────────────────── */

.explorer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.explorer-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.crumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    min-width: 0;
    font-size: 14px;
}
.crumb {
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    color: var(--mute);
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}
button.crumb:hover { background: var(--hover); color: var(--blue); }
.crumb.current { color: var(--ink); cursor: default; }
.crumb-sep { color: var(--faint); padding: 0 1px; }
.crumb.is-drop-target {
    background: var(--blue-50);
    color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-accent) inset;
}

.explorer-root {
    position: relative;
    min-height: 120px;
    user-select: none;
    -webkit-user-select: none;
}

/* Rectangle (marquee) selection overlay — fixed to the viewport during the drag */
.marquee-rect {
    position: fixed;
    z-index: 500;
    border: 1px solid var(--blue-accent);
    background: rgba(82, 145, 255, 0.12);
    pointer-events: none;
}
.explorer-item.is-selected {
    position: relative;
    z-index: 1;
    border-color: var(--blue-accent) !important;
    box-shadow: 0 0 0 2px var(--blue-accent);
    background: var(--blue-50);
}

/* Selection action bar — smooth slide/fade in & out (max-height + opacity + transform) */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    max-height: 70px;
    margin: 0 0 16px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--blue-accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    opacity: 1;
    transform: translateY(0);
    overflow: hidden;
    transition:
        max-height 0.3s ease,
        margin 0.3s ease,
        opacity 0.24s ease,
        transform 0.24s ease,
        padding 0.24s ease,
        border-width 0.24s ease;
}
.selection-bar.is-empty {
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}
.sel-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    padding: 0 6px;
    font-variant-numeric: tabular-nums;
}
.selection-bar .sel-btn { height: 32px; padding: 0 12px; font-size: 12.5px; }
.sel-clear { margin-left: auto; }

/* Danger button variant */
.btn.danger {
    background: var(--danger);
    color: #FFFFFF;
    box-shadow: var(--shadow-xs);
}
.btn.danger:hover { background: #9d2f25; }
.btn.danger:disabled { opacity: 0.55; }
.explorer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.explorer-grid:empty { display: none; }

.folder-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 40px 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.folder-card:hover {
    border-color: var(--line-strong);
    background: var(--canvas);
    box-shadow: var(--shadow-sm);
}
.folder-icon {
    display: inline-flex;
    color: var(--blue);
    flex-shrink: 0;
}
.folder-icon svg { width: 22px; height: 22px; }
.folder-name {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.folder-card .card-action,
.explorer-item .card-action { position: absolute; top: 8px; right: 8px; opacity: 0; }
.folder-card:hover .card-action,
.folder-card:focus-within .card-action { opacity: 1; }

.explorer-item.is-dragging { opacity: 0.45; }
.folder-card.is-drop-target,
.dropzone.is-drop-target {
    border-color: var(--blue-accent) !important;
    background: var(--blue-50) !important;
    box-shadow: 0 0 0 2px var(--blue-accent);
}

/* Kebab context menu (fixed, positioned from the click point) */
.explorer-menu {
    position: fixed;
    bottom: auto;
    left: 0;
    top: 0;
    min-width: 180px;
    max-width: 240px;
    max-height: none;
    z-index: 300;
}
.menu-option.is-danger:hover { background: var(--danger-50); }
.menu-option.is-danger .menu-option-title,
.menu-option.is-danger .menu-option-icon { color: var(--danger); }

/* Move modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(16, 28, 46, 0.34);
    backdrop-filter: blur(3px);
}
.modal {
    width: min(440px, 100%);
    max-height: min(560px, 88vh);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeUp 0.18s ease both;
}
.modal-lg { width: min(760px, 100%); }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 16px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.modal-head-actions .btn { height: 32px; font-size: 12.5px; padding: 0 12px; }
.report-head-titles { min-width: 0; }
.report-date { font-size: 12.5px; color: var(--faint); }

/* Send-by-email panel inside the report modal */
.report-email {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--blue-50);
}
.report-email-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-email-label {
    min-width: 52px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--mute);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.report-email-input {
    flex: 1 1 240px;
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
}
.report-email-input:focus { outline: none; border-color: var(--blue-accent); box-shadow: var(--ring); }
.report-email-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-2);
    cursor: pointer;
}
.report-email-check input { accent-color: var(--blue); }
.report-email-send { height: 34px; margin-left: auto; }
.report-email-note,
.report-email-status { margin: 0; font-size: 12.5px; line-height: 1.45; }
.report-email-note { color: var(--mute); }
.report-email-status.is-success { color: var(--success); }
.report-email-status.is-error { color: var(--danger); }

.report-body {
    padding: 20px 24px 28px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.report-empty {
    padding: 12px;
    text-align: center;
    color: var(--mute);
    font-size: 13.5px;
}
/* Preview mirrors the Word template styles (Aptos, accent #0F4761) */
.report-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 36px 44px 40px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: Aptos, "Segoe UI", Calibri, system-ui, sans-serif;
    color: #000;
}
.report-page .report-title { font-family: "Aptos Display", Aptos, "Segoe UI", sans-serif; font-size: 28px; font-weight: 400; letter-spacing: -0.5px; line-height: 1.15; margin: 0 0 6px; }
.report-page .report-subtitle { font-size: 14px; color: #595959; letter-spacing: 0.4px; margin: 0 0 8px; }
.report-page .report-h1 { font-family: "Aptos Display", Aptos, sans-serif; font-size: 20px; font-weight: 400; color: #0F4761; margin: 22px 0 6px; }
.report-page .report-h2 { font-family: "Aptos Display", Aptos, sans-serif; font-size: 16px; font-weight: 400; color: #0F4761; margin: 12px 0 6px; }
.report-page .report-p { font-size: 13px; line-height: 1.6; margin: 0 0 10px; }
.report-page .report-list { margin: 4px 0 10px; padding-left: 22px; }
.report-page .report-list li { font-size: 12px; line-height: 1.55; margin-bottom: 3px; }
.report-page .report-list li.is-bold { font-weight: 700; }
.report-generate { text-align: center; padding: 12px 0 6px; }
.report-generate .report-empty { margin-bottom: 14px; text-align: center; }
.report-sec { margin-bottom: 20px; }
.report-sec-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
.report-sec-p {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink-2);
}
.report-body ul {
    margin: 0 0 10px;
    padding-left: 20px;
}
.report-body li {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink-2);
    margin-bottom: 4px;
}

.autoreport-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 12.5px;
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.autoreport-toggle:hover { background: var(--hover); border-color: var(--line-strong); }
.autoreport-toggle input {
    width: 15px;
    height: 15px;
    accent-color: var(--blue);
    cursor: pointer;
}
.autoreport-toggle.on { border-color: var(--blue-accent); background: var(--blue-50); color: var(--blue); font-weight: 500; }

/* Report action on audio cards: a small pill (icon + label) */
.report-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.report-chip svg { width: 13px; height: 13px; }
.report-chip.is-ready { color: var(--blue); border-color: var(--blue-accent); background: var(--blue-50); }
.report-chip.is-ready:hover { background: var(--blue-accent); color: #fff; }
.report-chip.is-generating { color: var(--mute); background: var(--hover); cursor: default; }
.report-chip.is-generating svg { animation: report-spin 1s linear infinite; }
.report-chip.is-none:hover { border-color: var(--blue-accent); color: var(--blue); }
@keyframes report-spin { to { transform: rotate(360deg); } }

/* Upload progress cards */
.upload-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.doc-card.is-uploading .doc-body { min-width: 0; }
.upload-meta { font-size: 12px; color: var(--mute); }
.upload-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.upload-progress-bar { height: 100%; width: 0%; background: var(--blue); border-radius: 3px; transition: width 0.2s ease; }
.doc-card.is-error .upload-progress-bar { background: var(--red, #d14343); }
.doc-card.is-uploading { opacity: 0.92; }
.modal-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.modal-body {
    padding: 12px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 16px;
    border-top: 1px solid var(--line);
}
.modal-body .field { margin: 4px 10px 6px; }

/* The action dialog (create / rename / delete): no separators, roomier content */
#appModal .modal-head { padding: 20px 20px 6px; border-bottom: none; }
#appModal .modal-body { padding: 4px 12px 6px; }
#appModal .modal-hint { padding: 4px 10px 8px; }
#appModal .modal-body .field { margin: 6px 10px 4px; }
#appModal .modal-foot { padding: 10px 16px 20px; border-top: none; }
.modal-hint,
.modal-empty {
    padding: 6px 10px 10px;
    font-size: 12.5px;
    color: var(--mute);
}
.move-target {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    text-align: left;
    font-size: 13.5px;
    color: var(--ink-2);
    transition: background 0.12s ease;
}
.move-target:hover { background: var(--hover); color: var(--ink); }
.move-target.is-current { background: var(--blue-50); color: var(--blue); font-weight: 500; }
.move-target-icon { display: inline-flex; color: var(--blue); flex-shrink: 0; }
.move-target-icon svg { width: 16px; height: 16px; }

/* ─────────────────────────── Overlays & feedback ─────────────────────────── */

.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(247, 249, 252, 0.84);
    backdrop-filter: blur(6px);
}
.drop-overlay.visible { display: flex; }
.drop-overlay-card {
    width: min(460px, 90vw);
    padding: 44px 36px;
    text-align: center;
    background: var(--surface);
    border: 2px dashed var(--blue-accent);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}
.drop-overlay-card .dropzone-icon { margin: 0 auto 16px; }
.drop-overlay-card h2 {
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
}
.drop-overlay-card p {
    margin-top: 6px;
    font-size: 13.5px;
    color: var(--mute);
}

.notification {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 380px;
    padding: 14px 18px 14px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(14px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.notification.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.notification-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--success-50);
    color: var(--success);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.notification-icon svg { width: 14px; height: 14px; }
.notification.is-error .notification-icon { background: var(--danger-50); color: var(--danger); }
.notification-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.notification-message { margin-top: 2px; font-size: 13px; color: var(--mute); }

/* ─────────────────────────── Login ─────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--canvas);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--ink);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 36px 34px 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}
.login-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.login-sub {
    margin-top: 6px;
    margin-bottom: 26px;
    font-size: 14px;
    color: var(--mute);
}
.field { margin-bottom: 16px; }
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
}
.field-input {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-input::placeholder { color: var(--faint); }
.field-input:focus { border-color: var(--blue-accent); box-shadow: var(--ring); }
.login-card .btn { height: 42px; margin-top: 8px; font-size: 14px; }
.login-error {
    margin-bottom: 18px;
    padding: 10px 13px;
    border: 1px solid #F3D1CD;
    border-radius: var(--radius-sm);
    background: var(--danger-50);
    color: var(--danger);
    font-size: 13px;
}
.login-foot {
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--faint);
}

/* ─────────────────────────── Responsive ─────────────────────────── */

@media (max-width: 900px) {
    .topbar { padding: 0 16px; }
    .messages-list { padding: 24px 16px; }
    .composer-wrap { padding: 8px 16px 14px; }
    .page { padding: 20px 16px 40px; }
    .suggestions { grid-template-columns: 1fr; }
    .side-panel.open { width: 100%; }
    .side-panel > * { min-width: 0; }
    .main-content-area.pdf-open { margin-right: 0; }
    .toolbar-hint { display: none; }
}

/* Touch devices have no hover: the card action menus must stay visible */
@media (hover: none), (pointer: coarse) {
    .explorer-item .card-action,
    .folder-card .card-action { opacity: 1; }
}
