/* ── Fonts ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,400;0,500;1,400&family=Inter:wght@400;500&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
    --bg:         #FAFAF8;
    --ink:        #16181D;
    --secondary:  #5C6470;
    --hairline:   #E4E2DC;
    --accent:     #0F6B66;   /* overridden per-project via inline style */
    --dark-panel: #1C1E24;
    --radius:     4px;

    --font-serif: 'Newsreader', 'Source Serif 4', Georgia, serif;
    --font-ui:    'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --sidebar-w:  280px;
    --strip-h:    36px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
.serif { font-family: var(--font-serif); }
.mono  { font-family: var(--font-mono); font-size: 0.875em; }

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ink);
}

/* ── Corpus strip ─────────────────────────────────────────────────────────── */
.corpus-strip {
    height: var(--strip-h);
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--secondary);
    background: var(--bg);
    flex-shrink: 0;
    overflow: hidden;
}

.corpus-strip__stat {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.corpus-strip__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.7;
}

.corpus-strip__sep {
    color: var(--hairline);
    user-select: none;
}

.corpus-strip__clusters {
    display: flex;
    gap: 4px;
    align-items: center;
    overflow: hidden;
}

.corpus-strip__cluster-seg {
    height: 8px;
    min-width: 4px;
    border-radius: 2px;
    background: var(--accent);
    opacity: 0.4;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-body {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.sidebar__header {
    padding: 16px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar__title {
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
}

.sidebar__nav {
    padding: 8px 0;
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
}

.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    font-size: 13px;
    color: var(--secondary);
    transition: color 0.1s, background 0.1s;
    border-radius: 0;
}

.sidebar__nav a:hover, .sidebar__nav a.active {
    color: var(--ink);
    background: rgba(0,0,0,0.04);
    text-decoration: none;
}

.sidebar__nav a.active {
    color: var(--accent);
}

.sidebar__threads {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.thread-item {
    display: flex;
    align-items: center;
    padding: 7px 16px;
    font-size: 13px;
    color: var(--secondary);
    cursor: pointer;
    gap: 8px;
    transition: background 0.1s, color 0.1s;
}

.thread-item:hover { background: rgba(0,0,0,0.04); color: var(--ink); }
.thread-item.active { background: rgba(0,0,0,0.06); color: var(--ink); font-weight: 500; }

.thread-item__title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__footer {
    padding: 12px 16px;
    border-top: 1px solid var(--hairline);
    flex-shrink: 0;
}

.sidebar__user {
    font-size: 12px;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar__user-name { font-weight: 500; color: var(--ink); }

/* ── Main content area ────────────────────────────────────────────────────── */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.main__body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 40px;
}

.login-card__logo {
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.login-card__title {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 6px;
}

.login-card__sub {
    font-size: 14px;
    color: var(--secondary);
    margin-bottom: 32px;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 6px;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
}

.form-group input:focus, .form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.form-group input::placeholder { color: var(--secondary); opacity: 0.6; }

.form-hint {
    font-size: 12px;
    color: var(--secondary);
    margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost {
    background: transparent;
    color: var(--secondary);
    border: 1px solid var(--hairline);
}
.btn-ghost:hover { color: var(--ink); background: rgba(0,0,0,0.04); }

.btn-danger { background: #B91C1C; color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-icon { width: 32px; padding: 0; border-radius: var(--radius); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
    border-width: 1px;
    border-style: solid;
}

.alert-error   { background: #FEF2F2; color: #7F1D1D; border-color: #FCA5A5; }
.alert-success { background: #F0FDF4; color: #14532D; border-color: #86EFAC; }
.alert-warn    { background: #FFFBEB; color: #78350F; border-color: #FCD34D; }
.alert-info    { background: #EFF6FF; color: #1E3A5F; border-color: #BFDBFE; }

/* ── Dividers ─────────────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--hairline);
    margin: 24px 0;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--hairline);
    font-family: var(--font-mono);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--hairline);
    color: var(--ink);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(0,0,0,0.02); }

.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-ready       { background: #D1FAE5; color: #065F46; }
.badge-processing  { background: #DBEAFE; color: #1E3A8A; }
.badge-uploaded    { background: #F3F4F6; color: #374151; }
.badge-failed      { background: #FEE2E2; color: #7F1D1D; }
.badge-trashed     { background: #F3F4F6; color: #9CA3AF; }
.badge-admin       { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-contributor { background: #EFF6FF; color: #1E3A8A; }
.badge-viewer      { background: #F3F4F6; color: #374151; }

/* ── Source chips ─────────────────────────────────────────────────────────── */
.source-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    animation: chip-in 0.2s ease both;
}

.source-chip:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }

@keyframes chip-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Dark inspection panel (sources, quick-view) ──────────────────────────── */
.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 100;
    display: none;
}

.panel-overlay.open { display: block; }

.panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: 90vw;
    background: var(--dark-panel);
    color: #C9CBD2;
    z-index: 101;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.panel.open { transform: translateX(0); }

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.panel__title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 500;
    color: #E8E9EB;
}

.panel__close {
    background: none;
    border: none;
    color: #6B7280;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}

.panel__close:hover { color: #E8E9EB; }

.panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.panel__section { margin-bottom: 24px; }
.panel__section-label {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6B7280;
    margin-bottom: 8px;
}

.panel__chunk {
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 8px;
    border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
}

/* ── Chat layout ──────────────────────────────────────────────────────────── */
.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.chat-message {
    max-width: 72ch;
    margin: 0 auto 28px;
}

.chat-message--user .chat-message__bubble {
    background: rgba(0,0,0,0.04);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--ink);
}

.chat-message--assistant .chat-message__content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink);
}

.chat-message__role {
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 32px;
    padding: 32px;
    text-align: center;
}

.chat-empty__title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink);
}

.chat-empty__sub {
    font-size: 14px;
    color: var(--secondary);
    max-width: 40ch;
}

.chat-starters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 560px;
    width: 100%;
}

.chat-starter {
    background: var(--bg);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--secondary);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, color 0.15s;
}

.chat-starter:hover { border-color: var(--accent); color: var(--ink); }

/* ── Chat input bar ───────────────────────────────────────────────────────── */
.chat-input-bar {
    border-top: 1px solid var(--hairline);
    padding: 16px 32px;
    flex-shrink: 0;
}

.chat-mode-control {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    justify-content: center;
}

.chat-mode-btn {
    padding: 3px 10px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: transparent;
    font-size: 12px;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.chat-mode-btn.active, .chat-mode-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 180px;
    padding: 10px 14px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.15s;
    overflow-y: auto;
}

.chat-input:focus { outline: none; border-color: var(--accent); }

/* ── Page header (for /files, /admin, /account) ───────────────────────────── */
.page-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--hairline);
}

.page-header__title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink);
}

.page-header__sub {
    font-size: 14px;
    color: var(--secondary);
    margin-top: 4px;
}

/* ── Account page ─────────────────────────────────────────────────────────── */
.account-card {
    max-width: 480px;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.text-secondary { color: var(--secondary); }
.text-mono      { font-family: var(--font-mono); font-size: 0.875em; }
.text-sm        { font-size: 13px; }
.text-xs        { font-size: 11px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Thread delete button ─────────────────────────────────────────────────── */
.thread-item__del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: var(--radius);
    flex-shrink: 0;
    transition: opacity 0.1s, color 0.1s;
}
.thread-item:hover .thread-item__del { opacity: 1; }
.thread-item__del:hover { color: #B91C1C; }

/* ── Scrollable main (non-chat pages) ─────────────────────────────────────── */
.main--scroll {
    height: 100%;
    overflow-y: auto;
    padding: 28px 32px 48px;
}

/* ── Page sections ────────────────────────────────────────────────────────── */
.page-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0;
}

.section { margin-bottom: 40px; }

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: var(--font-mono);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hairline);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hairline);
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar__search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Input (generic) ──────────────────────────────────────────────────────── */
.input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--ink);
    font-size: 13px;
    appearance: none;
    transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-sm { height: 30px; font-size: 12px; padding: 0 8px; }

/* ── Badges (semantic variants) ───────────────────────────────────────────── */
.badge--ok    { background: #D1FAE5; color: #065F46; }
.badge--info  { background: #DBEAFE; color: #1E3A8A; }
.badge--warn  { background: #FEF9C3; color: #713F12; }
.badge--error { background: #FEE2E2; color: #7F1D1D; }

/* ── Table classes ────────────────────────────────────────────────────────── */
.table { width: 100%; }
.table--compact tbody td { padding: 7px 12px; }

.table-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    padding: 0;
}
.table-link:hover { text-decoration: underline; }

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin-bottom: 4px;
}

/* ── Action group (inline button row) ─────────────────────────────────────── */
.action-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ── Button additions ─────────────────────────────────────────────────────── */
.btn-secondary {
    background: rgba(0,0,0,0.06);
    color: var(--ink);
    border: 1px solid var(--hairline);
}
.btn-secondary:hover { background: rgba(0,0,0,0.1); }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11px; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* ── Dropzone ─────────────────────────────────────────────────────────────── */
.dropzone {
    border: 2px dashed #B8B6B0;
    border-radius: 8px;
    padding: 36px 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 28px;
    background: #F4F3F0;
}
.dropzone:hover, .dropzone.drag-over {
    border-color: var(--accent);
    background: #EEF6F5;
}
.dropzone__inner { pointer-events: none; }
.dropzone__icon { font-size: 32px; margin-bottom: 10px; color: var(--secondary); line-height: 1; }
.dropzone__label { font-size: 15px; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.dropzone__link { color: var(--accent); text-decoration: underline; }
.dropzone__hint { font-size: 12px; color: var(--secondary); margin-top: 6px; font-family: var(--font-mono); letter-spacing: 0.02em; }

/* ── Staging rows ─────────────────────────────────────────────────────────── */
.staging-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
    background: #FAFAF8;
}
.staging-row:first-child { border-top: 1px solid var(--hairline); border-radius: 4px 4px 0 0; }
.staging-row:last-child { border-bottom: none; border-radius: 0 0 4px 4px; }
.staging-row__name { flex: 1; color: var(--ink); font-family: var(--font-mono); font-size: 12px; }
.staging-row__status { flex-shrink: 0; }

/* ── Chat rows & bubbles ──────────────────────────────────────────────────── */
.chat-row {
    max-width: 72ch;
    margin: 0 auto 24px;
}

.chat-row--user { text-align: right; }

.chat-bubble {
    display: inline-block;
    text-align: left;
    font-size: 14px;
    line-height: 1.65;
}

.chat-bubble--user {
    background: rgba(0,0,0,0.05);
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 85%;
    white-space: pre-wrap;
}

.chat-bubble--assistant {
    width: 100%;
    color: var(--ink);
    font-size: 15px;
}

.chat-bubble--assistant p { margin-bottom: 10px; }
.chat-bubble--assistant p:last-child { margin-bottom: 0; }
.chat-bubble--assistant code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
}

.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chat-status { text-align: center; color: var(--secondary); font-size: 13px; padding: 24px; }
.chat-status-inline { font-size: 13px; }
.chat-error { max-width: 72ch; margin: 0 auto 16px; color: #B91C1C; font-size: 13px; }

/* ── Stat grid (admin) ────────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.stat-card {
    padding: 20px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--bg);
}

.stat-card__value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 4px;
}

.stat-card__label {
    font-size: 12px;
    color: var(--secondary);
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal__title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 20px;
}

.modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ── Panel body styles ────────────────────────────────────────────────────── */
.panel-meta {
    font-size: 12px;
    color: #6B7280;
    margin-bottom: 12px;
}

.panel-text {
    font-size: 13px;
    line-height: 1.7;
    color: #C9CBD2;
    white-space: pre-wrap;
    font-family: var(--font-mono);
}

.panel-loading { color: #6B7280; font-size: 13px; }
.text-error { color: #B91C1C; }
.text-center { text-align: center; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
