/*
 * 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;
    --tabbar-h: 64px;
    --reading-w: 940px;
    --composer-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 {
    position: relative;
    display: flex;
    height: 100vh;
    height: 100dvh;
    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;
}
/* Brand lockup (icon + wordmark). `max-width` + `object-fit: contain` keep the
   wide wordmark inside the sidebar/brand box without distorting its ratio. */
.wef-logo {
    display: block;
    width: auto;
    height: 56px;
    max-width: 100%;
    object-fit: contain;
    flex-shrink: 1;
}
.wef-logo-lg {
    height: 60px;
}
/* Small brand lockup shown as a non-interactive mark on the collapsed rail
   (the expand control is the toggle button at the bottom of the panel). */
.wef-logo-sm {
    height: 32px;
}
.sidebar-logo-mark {
    align-items: center;
    justify-content: center;
    padding: 6px;
}
/* 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); }

/* Collapse / expand control. Open: a plain icon button in the head, right of the
   logo. Collapsed: the very same button morphs into a tab that grows out of the
   rail's edge (same surface, no shadow), so it reads as part of the sidebar. */
.sidebar-tab {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--mute);
    cursor: pointer;
    transition: right 0.22s ease, width 0.22s ease, height 0.22s ease,
                border-radius 0.22s ease, background 0.22s ease, color 0.15s ease;
}
.sidebar-tab:hover { background: var(--hover); color: var(--ink); }
.sidebar-tab svg { width: 16px; height: 16px; transition: transform 0.22s ease; }
.sidebar.collapsed .sidebar-tab,
.sidebar-collapsed-init .sidebar .sidebar-tab {
    right: -29px;
    width: 30px;
    height: 38px;
    border: 1px solid var(--line);
    border-left: none;
    border-radius: 0 19px 19px 0;
    background: var(--canvas);
}
.sidebar.collapsed .sidebar-tab:hover,
.sidebar-collapsed-init .sidebar .sidebar-tab:hover { background: var(--canvas); color: var(--ink); }
.sidebar.collapsed .sidebar-tab svg,
.sidebar-collapsed-init .sidebar .sidebar-tab svg { transform: scaleX(-1); }
/* Inverse (concave) fillets: the outline flows from the rail's edge into a smooth
   reverse curve, so the tab reads as a real morph of the sidebar (not an overlay). */
.sidebar-tab::before,
.sidebar-tab::after {
    content: "";
    position: absolute;
    left: 0;
    width: 13px;
    height: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.sidebar-tab::before {
    bottom: 100%;
    background: radial-gradient(circle at 100% 0%, transparent 12px, var(--line) 12px, var(--line) 13px, var(--canvas) 13px);
}
.sidebar-tab::after {
    top: 100%;
    background: radial-gradient(circle at 100% 100%, transparent 12px, var(--line) 12px, var(--line) 13px, var(--canvas) 13px);
}
.sidebar.collapsed .sidebar-tab::before,
.sidebar-collapsed-init .sidebar .sidebar-tab::before,
.sidebar.collapsed .sidebar-tab::after,
.sidebar-collapsed-init .sidebar .sidebar-tab::after { opacity: 1; }

/* Collapsed rail */
.sidebar.collapsed,
.sidebar-collapsed-init .sidebar { width: var(--sidebar-w-collapsed); overflow: visible; }
.sidebar-collapsed-only { display: none !important; }
.sidebar.collapsed .sidebar-label,
.sidebar-collapsed-init .sidebar .sidebar-label,
.sidebar.collapsed .sidebar-expanded-only,
.sidebar-collapsed-init .sidebar .sidebar-expanded-only { display: none !important; }
.sidebar.collapsed .sidebar-collapsed-only,
.sidebar-collapsed-init .sidebar .sidebar-collapsed-only { display: inline-flex !important; }
.sidebar.collapsed .sidebar-head,
.sidebar-collapsed-init .sidebar .sidebar-head { height: var(--topbar-h); position: relative; justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-section,
.sidebar-collapsed-init .sidebar .sidebar-section,
.sidebar.collapsed .sidebar-nav,
.sidebar-collapsed-init .sidebar .sidebar-nav,
.sidebar.collapsed .sidebar-foot,
.sidebar-collapsed-init .sidebar .sidebar-foot { padding-left: 14px; padding-right: 14px; }
.sidebar.collapsed .new-chat-btn,
.sidebar-collapsed-init .sidebar .new-chat-btn { padding: 0; }
.sidebar.collapsed .nav-item,
.sidebar-collapsed-init .sidebar .nav-item { justify-content: center; padding: 0; }
.sidebar.collapsed .user-row,
.sidebar-collapsed-init .sidebar .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%; }

/* 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);
}
.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: 48px 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);
    overflow-wrap: anywhere;
}
.msg-content strong { color: var(--ink); font-weight: 600; }

/* Markdown answers: same building blocks as the document viewer, sized for chat */
.md-answer > :first-child { margin-top: 0; }
.md-answer > :last-child { margin-bottom: 0; }
.md-answer p { margin: 0 0 0.85em; }
.md-answer ul,
.md-answer ol { margin: 0 0 0.85em; padding-left: 1.4em; }
.md-answer li + li { margin-top: 0.2em; }
.md-answer h1,
.md-answer h2,
.md-answer h3,
.md-answer h4 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.35;
    margin: 1.15em 0 0.45em;
}
.md-answer h1 { font-size: 1.28em; }
.md-answer h2 { font-size: 1.18em; }
.md-answer h3 { font-size: 1.07em; }
.md-answer a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.md-answer a:hover { color: var(--blue-hover); }
.md-answer blockquote {
    margin: 0 0 0.85em;
    padding: 0.4em 0.9em;
    color: var(--mute);
    border-left: 3px solid var(--blue-accent);
    background: var(--canvas);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.md-answer blockquote > :last-child { margin-bottom: 0; }
.md-answer code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    padding: 0.15em 0.4em;
    background: var(--hover);
    border-radius: 4px;
}
.md-answer pre {
    margin: 0 0 0.85em;
    padding: 12px 14px;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    overflow-x: auto;
}
.md-answer pre code { padding: 0; background: none; }
.md-answer table {
    border-collapse: collapse;
    display: block;
    width: 100%;
    overflow-x: auto;
    margin: 0 0 0.85em;
}
.md-answer th,
.md-answer td { padding: 6px 10px; border: 1px solid var(--line-strong); text-align: left; vertical-align: top; }
.md-answer thead th { background: var(--canvas); }
.md-answer hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md-answer img { max-width: 100%; height: auto; }
/* KaTeX display blocks should not overflow the bubble */
.md-answer .katex-display { overflow-x: auto; overflow-y: hidden; }

.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); }

.msg-attachments { margin-top: 18px; }
.msg-attachments-label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.msg-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 14px;
    background: var(--blue-50);
    border: 1px solid var(--blue-accent);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.msg-attachment svg { width: 15px; height: 15px; }
.msg-attachment:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.thinking {
    font-size: 13.5px;
    color: var(--mute);
}
.thinking-steps {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 2px;
}
.thinking-step {
    display: flex;
    align-items: center;
    gap: 9px;
    line-height: 1.35;
    color: var(--faint);
    transition: color 0.2s ease;
}
.thinking-step-marker {
    position: relative;
    flex: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid var(--line-strong);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.thinking-step.is-active { color: var(--ink); font-weight: 500; }
.thinking-step.is-active .thinking-step-marker {
    border-color: var(--blue);
    background: var(--blue-50);
}
.thinking-step.is-active .thinking-step-marker::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--blue);
    animation: thinking 1.1s ease-in-out infinite;
}
.thinking-step.is-done { color: var(--mute); }
.thinking-step.is-done .thinking-step-marker {
    border-color: var(--success);
    background: var(--success);
}
.thinking-step.is-done .thinking-step-marker::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.thinking-fallback { color: var(--mute); }

/* 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);
    margin-top: 28px;
}
.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(--composer-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);
}
#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(--composer-w);
    margin: 9px auto 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--faint);
}

/* Menus (scope) */
.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-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;
}
.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; }
/* In document cards the preview absorbs the spare height, the text keeps its own */
.document-open-area .doc-body { flex: 0 0 auto; }

/* Compact first-page preview — the PDF stays readable without dominating the card */
.doc-thumb-mini {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 104px;
    flex: 1 0 104px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--canvas);
    border: 1px solid var(--line);
}
.doc-thumb {
    position: absolute;
    inset: 0;
    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; }

/* Speaker chips in the transcript panel can be renamed in place */
.speaker-chip.is-editable { cursor: pointer; }
.speaker-chip.is-editable:hover {
    border-color: var(--spk, var(--blue-accent));
    background: var(--surface);
}
.speaker-chip-edit {
    display: inline-flex;
    align-items: center;
    width: 0;
    opacity: 0;
    overflow: hidden;
    color: var(--spk, var(--blue));
    transition: opacity 0.15s ease, width 0.15s ease;
}
.speaker-chip-edit svg { width: 11px; height: 11px; }
.speaker-chip.is-editable:hover .speaker-chip-edit { width: 12px; opacity: 1; }
/* The chip/label being renamed stays highlighted while the editor is open */
.speaker-chip.is-editing {
    border-color: var(--spk, var(--blue-accent));
    background: var(--surface);
    box-shadow: var(--ring);
}
.speaker-chip.is-editing .speaker-chip-edit { width: 12px; opacity: 1; }
.tr-seg-speaker.is-editing {
    color: var(--blue);
    text-decoration: underline;
    text-decoration-color: var(--blue-accent);
    text-underline-offset: 3px;
}

/* Speaker rename popover: a small, tidy card anchored to the name */
.speaker-pop {
    position: fixed;
    z-index: 620;
    width: 272px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: ctx-pop 0.13s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.speaker-pop-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 11px;
}
.speaker-pop-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--spk, var(--blue));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--spk, var(--blue)) 18%, transparent);
    flex-shrink: 0;
}
.speaker-pop-title {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--ink);
}
.speaker-pop-input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    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;
}
.speaker-pop-input:focus {
    outline: none;
    border-color: var(--blue-accent);
    box-shadow: var(--ring);
}
.speaker-pop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}
.speaker-pop-actions .btn { height: 34px; font-size: 13px; padding: 0 14px; }
.speaker-pop-hint {
    margin: 10px 0 0;
    font-size: 11.5px;
    color: var(--faint);
    text-align: center;
}
.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;
}
/* Markdown / text documents rendered in the document panel */
.md-doc {
    width: 100%;
    max-width: 1080px;
    padding: 28px 36px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}
.md-doc > :first-child { margin-top: 0; }
.md-doc h1, .md-doc h2, .md-doc h3, .md-doc h4 {
    font-family: var(--font-display);
    color: var(--ink);
    line-height: 1.3;
    margin: 1.4em 0 0.5em;
}
.md-doc h1 { font-size: 1.75em; padding-bottom: 0.3em; border-bottom: 1px solid var(--line); }
.md-doc h2 { font-size: 1.4em; padding-bottom: 0.25em; border-bottom: 1px solid var(--line); }
.md-doc h3 { font-size: 1.18em; }
.md-doc h4 { font-size: 1.05em; }
.md-doc p, .md-doc ul, .md-doc ol, .md-doc blockquote, .md-doc table, .md-doc pre { margin: 0 0 1em; }
.md-doc ul, .md-doc ol { padding-left: 1.6em; }
.md-doc li + li { margin-top: 0.25em; }
.md-doc a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.md-doc a:hover { color: var(--blue-hover); }
.md-doc blockquote {
    padding: 0.5em 1em;
    color: var(--mute);
    border-left: 3px solid var(--blue-accent);
    background: var(--canvas);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.md-doc blockquote > :last-child { margin-bottom: 0; }
.md-doc code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    padding: 0.15em 0.4em;
    background: var(--hover);
    border-radius: 4px;
}
.md-doc pre {
    padding: 12px 14px;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    overflow-x: auto;
}
.md-doc pre code { padding: 0; background: none; }
.md-doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.md-doc th, .md-doc td { padding: 6px 10px; border: 1px solid var(--line-strong); text-align: left; vertical-align: top; }
.md-doc thead th { background: var(--canvas); }
.md-doc hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md-doc img { max-width: 100%; height: auto; }
.md-doc table.md-meta { display: table; font-size: 12.5px; margin-bottom: 1.6em; }
.md-doc table.md-meta th {
    width: 1%;
    white-space: nowrap;
    color: var(--mute);
    font-weight: 500;
    text-transform: capitalize;
    background: var(--canvas);
}
.md-plain {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
}
.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%;
    height: auto;
    /* 16:9 until metadata is loaded, then the video's own ratio */
    aspect-ratio: auto 16 / 9;
    min-height: 200px;
    max-height: 62vh;
    object-fit: contain;
    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;
    /* Let this pane shrink when the player grows (e.g. the video is shown),
       otherwise the transcript would overflow the panel and stop scrolling. */
    min-height: 0;
    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, background 0.16s ease;
}
.tr-seg:hover { background: var(--canvas); }
/* The hover accent follows the speaker's colour, so a green speaker lights up
   green, a blue one blue, instead of everything turning blue. */
.tr-seg:hover::before { opacity: 0.5; transform: scaleY(1); background: var(--spk, var(--blue-accent)); }
.tr-seg:hover .tr-seg-speaker { color: var(--spk, var(--blue)); }
.tr-seg:hover .tr-seg-time { color: var(--spk, 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); background: var(--spk, var(--blue)); }
.tr-seg.is-playing .tr-seg-speaker { color: var(--spk, 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; }

/* ─────────────────────────── Documents drive ─────────────────────────── */
/* Folders, documents and audio recordings in one mini drive: breadcrumb,
   a grey search pill that also hosts the selection controls, a rounded
   "New" button, and a grid of tiles. */

.drive {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    outline: none;
}

.drive-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 30px 32px 6px;
}

.drive-crumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    flex-wrap: wrap;
}
.drive-crumb {
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--mute);
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.drive-crumb:hover { background: var(--hover); color: var(--ink); }
.drive-crumb.is-current { color: var(--ink); }
.drive-crumbs > .drive-crumb.is-current:first-child { padding-left: 2px; }
.drive-crumb.is-current:first-child:hover { background: transparent; cursor: default; }
.drive-crumb.is-drop-target {
    background: var(--blue-50);
    border-color: var(--blue-accent);
    color: var(--blue);
}
.drive-crumb-sep { display: inline-flex; color: var(--faint); }
.drive-crumb-sep svg { width: 15px; height: 15px; }

/* Bar: the grey pill is the search field, with the selection controls on its
   right; the "New" button sits beside it on the same line. */
.drive-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 32px 0;
}

.drive-selection {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 6px 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--canvas);
    box-shadow: inset 0 1px 1px rgba(16, 28, 46, 0.02);
    cursor: text;
    overflow: hidden;
    isolation: isolate;
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
.drive-selection:hover { border-color: var(--line-strong); }
.drive-selection:focus-within {
    background: var(--surface);
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 4px rgba(82, 145, 255, 0.14), 0 8px 24px -14px rgba(0, 74, 147, 0.45);
}
.drive-selection.has-query:not(:focus-within) {
    background: var(--surface);
    border-color: var(--blue-200);
}
.drive-selection.has-selection {
    background: var(--blue-50);
    border-color: var(--blue-200);
}

.drive-search-icon {
    flex: none;
    display: inline-flex;
    color: var(--faint);
    pointer-events: none;
    transition: color 0.2s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.drive-search-icon svg { width: 17px; height: 17px; }
.drive-selection:focus-within .drive-search-icon {
    color: var(--blue);
    transform: scale(1.12) rotate(-8deg);
}
.drive-selection.is-searching .drive-search-icon { animation: drive-search-pulse 0.9s ease-in-out infinite; color: var(--blue); }
@keyframes drive-search-pulse {
    0%, 100% { transform: scale(1.12) rotate(-8deg); }
    50% { transform: scale(0.94) rotate(6deg); }
}

.drive-search {
    flex: 1;
    min-width: 80px;
    height: 100%;
    padding: 0;
    border: 0;
    outline: none;
    background: none;
    font-size: 14px;
    color: var(--ink);
    caret-color: var(--blue);
}
.drive-search:focus-visible { box-shadow: none; }
.drive-search::placeholder { color: var(--faint); transition: opacity 0.2s ease, transform 0.25s ease; }
.drive-selection:focus-within .drive-search::placeholder { opacity: 0.65; transform: translateX(3px); }
.drive-search::-webkit-search-cancel-button,
.drive-search::-webkit-search-decoration { -webkit-appearance: none; }

/* Animated light sweeping along the bottom edge while a search runs */
.drive-search-glow {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--blue-accent), var(--blue), var(--blue-accent), transparent);
    background-size: 50% 100%;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.2s ease;
}
.drive-selection.is-searching .drive-search-glow {
    opacity: 1;
    animation: drive-search-sweep 0.9s linear infinite;
}
@keyframes drive-search-sweep {
    from { background-position: -60% 0; }
    to { background-position: 160% 0; }
}

.drive-search-results {
    flex: none;
    display: none;
    align-items: center;
    height: 26px;
    padding: 0 11px;
    border-radius: 999px;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    font-size: 12px;
    font-weight: 600;
    color: var(--blue);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.drive-search-results.is-visible { display: inline-flex; animation: drive-pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
.drive-search-results.is-empty { background: var(--hover); border-color: var(--line); color: var(--mute); }
@keyframes drive-pop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.drive-search-clear {
    flex: none;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    color: var(--faint);
    transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}
.drive-search-clear svg { width: 13px; height: 13px; }
.drive-selection.has-value .drive-search-clear { display: inline-flex; animation: drive-pop 0.2s ease; }
.drive-search-clear:hover { background: var(--line); color: var(--ink-2); transform: rotate(90deg); }

.drive-selection-main {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: default;
}
.drive-selection-count {
    padding: 0 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--blue);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    animation: drive-count-in 0.22s ease;
}
@keyframes drive-count-in {
    from { opacity: 0; transform: translateY(3px); }
}
.drive-selection-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    color: var(--mute);
    animation: drive-count-in 0.22s ease;
    transition: background 0.15s ease, color 0.15s ease;
}
.drive-selection-icon svg { width: 15px; height: 15px; }
.drive-selection-icon:hover { background: var(--blue-100); color: var(--blue); }
.drive-selection-icon.is-danger:hover { background: var(--danger-50); color: var(--danger); }
.drive-selection-sep { width: 1px; height: 22px; margin: 0 6px; background: var(--line-strong); }

.drive-select-all {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    margin-left: 10px;
    padding: 0 14px 0 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.drive-select-all::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 9px;
    bottom: 9px;
    width: 1px;
    background: var(--line-strong);
}
.drive-selection.has-selection .drive-select-all { margin-left: 0; }
.drive-selection.has-selection .drive-select-all::before { display: none; }
.drive-select-all input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.drive-select-all:hover { background: var(--hover); }
.drive-select-all:has(input:checked),
.drive-select-all:has(input:indeterminate) { background: var(--blue-100); color: var(--blue); }
/* While a document/transcript panel is open the bar has less room: the
   "select all" control is the first thing to go, the selection actions stay. */
.main-content-area.pdf-open .drive-select-all { display: none; }

/* "New" — rounded primary button with a dropdown (folder / upload) */
.drive-new-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 18px 0 20px;
    border-radius: 999px;
    background: var(--blue);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 20px -12px rgba(0, 74, 147, 0.9);
    transition: background 0.15s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.drive-new-btn svg { width: 17px; height: 17px; }
.drive-new-btn .drive-new-caret { width: 14px; height: 14px; opacity: 0.85; transition: transform 0.18s ease; }
.drive-new-btn:hover { background: var(--blue-hover); transform: translateY(-1px); box-shadow: 0 12px 24px -12px rgba(0, 74, 147, 0.95); }
.drive-new-btn:active { transform: translateY(0); }
.drive-new-btn.is-open { background: var(--blue-hover); box-shadow: 0 0 0 4px rgba(82, 145, 255, 0.22); }
.drive-new-btn.is-open .drive-new-caret { transform: rotate(180deg); }

/* Grid */
.drive-scroll {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 32px 56px;
}
.drive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    align-content: start;
    transition: opacity 0.18s ease;
}
.drive-grid.is-loading { opacity: 0.55; }
.drive-section-label {
    grid-column: 1 / -1;
    margin: 6px 2px -4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}
.drive-section-label:not(:first-child) { margin-top: 14px; }

.drive.is-lassoing,
.drive.is-lassoing * { user-select: none; }
.drive.is-lassoing .drive-item { pointer-events: none; }
.drive-lasso {
    position: absolute;
    z-index: 5;
    border: 1px solid var(--blue-accent);
    border-radius: 4px;
    background: rgba(82, 145, 255, 0.12);
    pointer-events: none;
}

/* Tiles */
.drive-item {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.15s ease, opacity 0.2s ease;
}
.drive-item:hover { transform: translateY(-1px); }
.drive-item:focus-visible { box-shadow: var(--ring); }
.drive-item.is-selected {
    border-color: var(--blue-accent) !important;
    background: var(--blue-50);
    box-shadow: 0 0 0 1px var(--blue-accent);
}
/* The file whose content is open in the side panel keeps a lasting blue border,
   so the document on the right can always be tied back to its tile on the left. */
.drive-item.is-open {
    border-color: var(--blue-accent) !important;
    box-shadow: 0 0 0 1px var(--blue-accent);
}
.drive-item.is-dragging { opacity: 0.4; }
.drive-item.is-drop-target {
    border-color: var(--blue-accent) !important;
    background: var(--blue-50) !important;
    box-shadow: 0 0 0 3px rgba(82, 145, 255, 0.3);
    transform: scale(1.02);
}
.drive-item.is-renaming { transform: none; }
.drive-item.drop-before { box-shadow: -6px 0 0 -2px var(--blue-accent); }
.drive-item.drop-after { box-shadow: 6px 0 0 -2px var(--blue-accent); }

.folder-card {
    display: flex;
    align-items: center;
    align-self: start;
    gap: 12px;
    min-height: 64px;
    padding: 12px 40px 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
}
.folder-card:hover {
    border-color: var(--line-strong);
    background: var(--canvas);
    box-shadow: var(--shadow-sm);
}
.folder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--blue-50);
    color: var(--blue);
    flex-shrink: 0;
}
.folder-icon svg { width: 20px; height: 20px; fill: rgba(0, 74, 147, 0.1); }
.folder-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.folder-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.folder-meta {
    font-size: 12px;
    color: var(--faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hover checkbox, top-right of each tile (always shown once something is selected) */
.drive-check {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--blue);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.folder-card .drive-check { top: 50%; transform: translateY(-50%); }
.drive-item:hover .drive-check,
.drive-item.is-selected .drive-check,
.drive:has(.drive-item.is-selected) .drive-check { opacity: 1; }

.drive-rename {
    width: 100%;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--blue-accent);
    border-radius: var(--radius-xs);
    background: var(--surface);
    font-size: 13px;
    color: var(--ink);
    box-shadow: var(--ring);
}

.drive-path {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--mute);
    min-width: 0;
}
.drive-path svg { width: 12px; height: 12px; color: var(--blue); }
.drive-path span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drive-item mark,
.speaker-chip mark {
    padding: 0 1px;
    border-radius: 3px;
    background: rgba(82, 145, 255, 0.22);
    color: inherit;
}

.drive-empty,
.drive-empty-drop {
    grid-column: 1 / -1;
}
.drive-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 64px 24px;
    text-align: center;
}

/* Desktop files dragged over the drive */
.drive-drop {
    position: absolute;
    inset: 10px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--blue-accent);
    border-radius: var(--radius-xl);
    background: rgba(242, 247, 254, 0.78);
    backdrop-filter: blur(2px);
    pointer-events: none;
    animation: fadeUp 0.15s ease both;
}
.drive-drop.hidden { display: none; }
.drive-drop.is-targeted { background: rgba(242, 247, 254, 0.35); backdrop-filter: none; }
.drive-drop.is-targeted .drive-drop-card { transform: translateY(-40%) scale(0.92); opacity: 0.9; }
.drive-drop-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 24px 34px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.drive-drop-card .dropzone-icon { margin-bottom: 8px; }
.drive-drop-card strong { font-size: 15px; color: var(--ink); }
.drive-drop-dest { font-size: 13px; font-weight: 500; color: var(--blue); }
.drive-drop-hint { font-size: 12px; color: var(--faint); }

/* Compact stand-in while dragging tiles */
.drive-ghost {
    position: fixed;
    top: -1000px;
    left: -1000px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 240px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--blue-200);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 20px -8px rgba(16, 28, 46, 0.35);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    pointer-events: none;
}
.drive-ghost-thumb {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--blue-50);
    color: var(--blue);
    overflow: hidden;
}
.drive-ghost-thumb svg { width: 18px; height: 18px; }
.drive-ghost-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.drive-ghost-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.drive-ghost-count {
    flex: none;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--blue);
    color: #FFFFFF;
    font-size: 12px;
    line-height: 22px;
    text-align: center;
}

/* Upload / transcription progress tiles */
.upload-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.drive-pending .doc-body { min-width: 0; }
.drive-pending { cursor: default; animation: fadeUp 0.2s ease both; }
.upload-meta { font-size: 12px; color: var(--mute); }
.upload-progress { position: relative; 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; }
.upload-progress.is-indeterminate .upload-progress-bar {
    width: 40% !important;
    animation: drive-indeterminate 1.3s ease-in-out infinite;
}
@keyframes drive-indeterminate {
    from { transform: translateX(-100%); }
    to { transform: translateX(260%); }
}
.drive-pending.is-error .upload-progress-bar { background: var(--danger); animation: none; width: 100% !important; }
.drive-pending.is-error .upload-meta { color: var(--danger); }

/* ─────────────────────────── Context menus ─────────────────────────── */

.ctx-menu {
    position: fixed;
    z-index: 600;
    min-width: 220px;
    max-width: 300px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: ctx-pop 0.11s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes ctx-pop {
    from { opacity: 0; transform: scale(0.97) translateY(-2px); }
    to { opacity: 1; transform: none; }
}
.ctx-item {
    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, color 0.12s ease;
}
.ctx-item svg { width: 16px; height: 16px; color: var(--mute); }
.ctx-item:hover:not(:disabled),
.ctx-item:focus-visible { background: var(--hover); color: var(--ink); box-shadow: none; }
.ctx-item:hover:not(:disabled) svg { color: var(--blue); }
.ctx-item:disabled { opacity: 0.45; cursor: default; }
.ctx-item.is-danger,
.ctx-item.is-danger svg { color: var(--danger); }
.ctx-item.is-danger:hover:not(:disabled) { background: var(--danger-50); }
.ctx-item.is-danger:hover:not(:disabled) svg { color: var(--danger); }
.ctx-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-hint { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.ctx-icon-gap { width: 16px; flex: none; }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.ctx-heading {
    padding: 8px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.ctx-item + .ctx-heading { padding-top: 6px; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11.5px; }

/* ─────────────────────────── Chat scope picker ─────────────────────────── */

.chip-btn.is-scoped {
    border-color: var(--blue-200);
    background: var(--blue-50);
    color: var(--blue);
}
.chip-btn.is-scoped svg { color: var(--blue); }

.menu.scope-picker {
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: none;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.menu.scope-picker.hidden { display: none; }
.scope-head { padding: 6px 6px 0; }
.scope-all {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--ink-2);
    text-align: left;
    transition: background 0.12s ease;
}
.scope-all:hover { background: var(--hover); }
.scope-all.is-selected .scope-label { color: var(--ink); font-weight: 500; }
.scope-crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    margin: 4px 6px 0;
    padding: 6px 4px 6px;
    border-top: 1px solid var(--line);
}
.scope-crumb {
    padding: 3px 7px;
    border-radius: var(--radius-xs);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--mute);
    transition: background 0.12s ease, color 0.12s ease;
}
.scope-crumb:hover { background: var(--hover); color: var(--blue); }
.scope-crumb.is-current { color: var(--ink); }
.scope-crumb-sep { display: inline-flex; color: var(--faint); }
.scope-crumb-sep svg { width: 12px; height: 12px; }
.scope-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 0 6px 6px;
}
.scope-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 3px 6px 3px 4px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--ink-2);
    cursor: pointer;
    transition: background 0.12s ease;
    animation: fadeUp 0.15s ease both;
}
.scope-row:hover { background: var(--hover); }
.scope-row.is-selected { background: var(--blue-50); }
.scope-row.is-selected .scope-row-name { color: var(--ink); font-weight: 500; }
.scope-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--radius-xs);
}
.scope-tick:hover:not(:disabled) { background: var(--blue-100); }
.scope-tick:disabled { cursor: default; }
.scope-row.is-selected .scope-check,
.scope-all.is-selected .scope-check {
    background: var(--blue);
    border-color: var(--blue);
}
.scope-row.is-selected .scope-check::after,
.scope-all.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-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 7px;
    background: var(--canvas);
    color: var(--mute);
}
.scope-row.is-folder .scope-row-icon { background: var(--blue-50); color: var(--blue); }
.scope-row-icon.is-audio { background: #EEF3FF; color: #2F6FE0; }
.scope-row-icon svg { width: 14px; height: 14px; }
.scope-row-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scope-row-meta {
    font-size: 11.5px;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}
.scope-row-enter {
    display: inline-flex;
    color: var(--faint);
    transition: transform 0.15s ease, color 0.15s ease;
}
.scope-row-enter svg { width: 15px; height: 15px; }
.scope-row.is-folder:hover .scope-row-enter { color: var(--blue); transform: translateX(2px); }
.scope-empty {
    padding: 18px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--mute);
}
.scope-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 8px 8px 14px;
    border-top: 1px solid var(--line);
    background: var(--canvas);
}
.scope-count {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: var(--mute);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scope-foot-btn {
    height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
    transition: background 0.12s ease, color 0.12s ease;
}
.scope-foot-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.scope-foot-btn:disabled { opacity: 0.4; cursor: default; }
.scope-foot-btn.is-primary { background: var(--blue); color: #FFFFFF; }
.scope-foot-btn.is-primary:hover { background: var(--blue-hover); color: #FFFFFF; }

/* 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; }

/* 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; display: flex; flex-direction: column; gap: 2px; }
.report-date { font-size: 12.5px; color: var(--faint); }

/* Report modal: wide reading surface, document on a soft canvas */
.modal-report {
    width: min(1080px, 100%);
    height: min(920px, 92vh);
    max-height: none;
}
.report-head {
    padding: 14px 16px 14px 20px;
    background: var(--surface);
}
.report-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.report-head-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--blue-50);
    color: var(--blue);
    border: 1px solid var(--blue-100);
    flex-shrink: 0;
}
.report-head-icon svg { width: 19px; height: 19px; }
.report-head .modal-title { font-size: 15.5px; line-height: 1.25; }

.report-actions { gap: 10px; }
.report-actions .btn { height: 36px; font-size: 13px; padding: 0 14px; }
.report-actions .btn-primary.is-active { background: var(--blue-hover); box-shadow: var(--ring); }
.report-actions-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 2px; }

/* Segmented download control (Word | PDF) */
.report-download {
    display: inline-flex;
    align-items: stretch;
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.report-download:not(:has(.report-dl-btn:not(.hidden))) { display: none; }
.report-dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 13px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.report-dl-btn:not(.hidden) ~ .report-dl-btn:not(.hidden) { border-left: 1px solid var(--line); }
.report-dl-btn svg { width: 15px; height: 15px; color: var(--mute); transition: color 0.15s ease; }
.report-dl-btn:hover { background: var(--blue-50); color: var(--blue); }
.report-dl-btn:hover svg { color: var(--blue); }
.report-dl-btn:focus-visible { box-shadow: inset var(--ring); }

/* Send-by-email panel inside the report modal */
.report-email {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 20px 14px 70px;
    border-bottom: 1px solid var(--line);
    background: var(--blue-50);
    animation: fadeUp 0.16s ease both;
}
.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 {
    flex: 1;
    min-height: 0;
    padding: 32px 32px 48px;
    overflow-y: auto;
    scrollbar-width: thin;
    background: var(--canvas);
}
.report-empty {
    padding: 12px;
    text-align: center;
    color: var(--mute);
    font-size: 13.5px;
}
/* Preview mirrors the Word template styles (Aptos, accent #0F4761) — do not restyle */
.report-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 36px 44px 40px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    font-family: Aptos, "Segoe UI", Calibri, system-ui, sans-serif;
    color: #000;
    animation: fadeUp 0.2s ease both;
}
.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: 48px 0 6px; }
.report-generate .report-empty { margin-bottom: 14px; text-align: center; }

@media (max-width: 720px) {
    .modal-report { height: 100%; }
    .report-head { flex-wrap: wrap; }
    .report-head-icon, .report-actions-sep { display: none; }
    .report-email { padding-left: 20px; }
    .report-body { padding: 16px 12px 32px; }
    .report-page { padding: 32px 24px 40px; }
}
.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;
    max-width: 100%;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    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; flex-shrink: 0; }
.report-chip > span { overflow: hidden; text-overflow: ellipsis; }
.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); } }

.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);
    margin-bottom: 22px;
}
.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); }
/* Multi-line name field (rename dialog): a long name wraps and stays fully readable */
.field-textarea {
    height: auto;
    min-height: 84px;
    max-height: 260px;
    padding: 10px 13px;
    line-height: 1.45;
    resize: vertical;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: inherit;
}
.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) {
    .drive-toolbar { padding: 20px 16px 4px; }
    .drive-bar { padding: 8px 16px 0; }
    .drive-scroll { padding: 18px 16px 40px; }
    .drive-select-all span { display: none; }
    .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; }
}

/* ─────────────────────────── Mobile bottom navigation ─────────────────────────── */

.mobile-tabbar,
.mobile-backdrop { display: none; }

@media (max-width: 768px) {
    /* The app leaves room for the anchored tab bar (and the iOS home indicator) */
    .main-content-area {
        padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    }

    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 86;
        display: flex;
        align-items: stretch;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding: 0 4px env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: saturate(1.6) blur(12px);
        -webkit-backdrop-filter: saturate(1.6) blur(12px);
        border-top: 1px solid var(--line);
        box-shadow: 0 -4px 16px rgba(16, 28, 46, 0.04);
    }
    .mobile-tabbar > .tab-item,
    .tab-anchor { flex: 1 1 0; min-width: 0; }
    .tab-anchor { position: relative; display: flex; }

    .tab-item {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 2px;
        color: var(--mute);
        font-size: 11.5px;
        font-weight: 500;
        line-height: 1.2;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.15s ease;
    }
    .tab-item > span:last-child {
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .tab-item svg {
        width: 22px;
        height: 22px;
        box-sizing: content-box;
        padding: 3px 14px;
        border-radius: 999px;
        transition: background 0.15s ease, color 0.15s ease;
    }
    .tab-item:active svg { background: var(--hover); }
    .tab-item.is-active,
    .tab-item.is-open { color: var(--blue); font-weight: 600; }
    .tab-item.is-active svg,
    .tab-item.is-open svg { background: var(--blue-50); }
    /* While a sheet is open, only its own tab is highlighted */
    .mobile-tabbar.has-sheet .tab-item.is-active:not(.is-open) { color: var(--mute); font-weight: 500; }
    .mobile-tabbar.has-sheet .tab-item.is-active:not(.is-open) svg { background: transparent; }

    /* Closed side panels must not leave a hairline on the right edge */
    .side-panel:not(.open) { border-left: 0; box-shadow: none; }

    /* "New chat" mirrors the primary button of the desktop sidebar */
    .tab-item-new { color: var(--blue); font-weight: 600; }
    .tab-item-new svg,
    .tab-item-new:active svg {
        background: var(--blue);
        color: #FFFFFF;
        box-shadow: var(--shadow-sm);
    }

    .tab-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
        border: 2px solid transparent;
        transition: border-color 0.15s ease;
    }
    .tab-item.is-open .tab-avatar { border-color: var(--blue-accent); }

    .tab-account-menu {
        left: auto;
        right: 4px;
        bottom: calc(100% + 10px);
        min-width: 220px;
    }
    .tab-account-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
    .tab-account-link {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 40px;
        padding: 0 10px;
        border-radius: var(--radius-sm);
        color: var(--danger);
        font-size: 14px;
        font-weight: 500;
        text-decoration: none;
    }
    .tab-account-link svg { width: 18px; height: 18px; }
    .tab-account-link:active { background: var(--danger-50); }

    /* The sidebar becomes a "History" drawer opened from the tab bar */
    .mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 84;
        background: rgba(16, 28, 46, 0.34);
        animation: fadeUp 0.15s ease both;
    }
    .mobile-backdrop[hidden] { display: none !important; }

    .sidebar,
    .sidebar.collapsed {
        position: fixed;
        top: 0;
        left: 0;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        z-index: 85;
        width: min(86vw, 320px);
        border-right: 1px solid var(--line);
        box-shadow: var(--shadow-lg);
        transform: translateX(-105%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.25s ease, visibility 0s;
    }
    /* Always show the expanded drawer, whatever the desktop collapse state */
    .sidebar.collapsed .sidebar-head { height: auto; position: relative; padding: 16px 0; }
    .sidebar.collapsed .brand.sidebar-expanded-only { display: flex !important; }
    .sidebar.collapsed p.sidebar-expanded-only,
    .sidebar.collapsed div.sidebar-expanded-only { display: block !important; }
    .sidebar .sidebar-collapsed-only,
    .sidebar.collapsed .sidebar-collapsed-only,
    .sidebar .sidebar-section,
    .sidebar .sidebar-nav,
    .sidebar .sidebar-foot,
    .sidebar-tab { display: none !important; }
    .sidebar .brand { padding: 0 20px; }
    .sidebar .sidebar-divider { margin-top: 0; }
    .sidebar .conv-list { padding-bottom: 16px; }
    .conv-item { padding-top: 10px; padding-bottom: 10px; }

    /* Keyboard hints are meaningless on touch screens */
    .composer-hint { display: none; }
    .composer-wrap { padding-bottom: 10px; }

    /* 16px inputs stop iOS from zooming in on focus */
    .composer-input,
    .drive-search,
    .field-input { font-size: 16px; }

    .notification {
        left: 12px;
        right: 12px;
        max-width: none;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

@media (max-width: 360px) {
    .tab-item { font-size: 10.5px; }
    .tab-item svg { padding: 3px 10px; }
}

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

/* Accounts admin panel */
.accounts-page { justify-content: flex-start; }
.accounts-card { max-width: 760px; }
.accounts-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.accounts-head .login-title { margin-bottom: 0; }
.accounts-card .accounts-head .btn,
.accounts-card .accounts-row .btn,
.accounts-card .accounts-create .btn { margin-top: 0; height: 38px; }
.accounts-section { font-size: 13px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: 0.04em; margin: 22px 0 10px; }
.accounts-create { display: flex; gap: 8px; }
.accounts-create .field-input { flex: 1; height: 38px; }
.accounts-success { margin-bottom: 18px; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--success-50); color: var(--success); font-size: 13px; }
.accounts-list { list-style: none; padding: 0; margin: 0; }
.accounts-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.accounts-who { display: flex; align-items: center; gap: 10px; }
.accounts-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.accounts-reset { display: flex; gap: 6px; }
.accounts-reset .field-input { width: 160px; height: 38px; }
.accounts-off { color: var(--faint); font-weight: 400; }
@media (max-width: 600px) { .accounts-create { flex-direction: column; } }
.my-account-card { max-width: 480px; }
