/* OpenRain Command Centre */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,300;8..60,400;8..60,600;8..60,700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --sand: #f5f0e8;
    --sand-dark: #e8e0d4;
    --warm-white: #faf8f5;
    --cream: #f9f6f1;
    --terra: #c4703f;
    --terra-light: #d4884f;
    --terra-muted: rgba(196, 112, 63, 0.12);
    --deep: #1a1612;
    --deep-raised: #241e18;
    --deep-hover: #2c2418;
    --text: #2c2418;
    --text-secondary: #6b5d4f;
    --text-tertiary: #a09484;
    --border: #ddd5c8;
    --glass: rgba(250, 248, 245, 0.82);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(26, 22, 18, 0.06), 0 1px 2px rgba(26, 22, 18, 0.04);
    --shadow-md: 0 4px 12px rgba(26, 22, 18, 0.08), 0 2px 4px rgba(26, 22, 18, 0.04);
    --shadow-lg: 0 8px 32px rgba(26, 22, 18, 0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--sand);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    font-family: 'Source Serif 4', Georgia, serif;
}

a { color: var(--terra); text-decoration: none; }
a:hover { color: var(--terra-light); }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--deep);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar-brand {
    padding: 28px 24px 24px;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

.sidebar-nav { list-style: none; flex: 1; padding: 0 12px; }

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav li a {
    display: block;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.sidebar-nav li a:hover {
    color: rgba(255, 255, 255, 0.8);
    background: var(--deep-raised);
    text-decoration: none;
}

.sidebar-nav li a.active {
    color: #fff;
    background: var(--terra);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-user {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

.sidebar-logout {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.2s;
}

.sidebar-logout:hover { color: rgba(255, 255, 255, 0.7); }

/* ── Content ── */
.content-header {
    padding: 32px 40px 0;
}

.content-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.content-body {
    padding: 24px 40px 40px;
}

.header-role {
    display: inline-block;
    margin-left: 14px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

/* ── Login ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--deep);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(196, 112, 63, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(196, 112, 63, 0.05) 0%, transparent 50%);
}

.login-card {
    background: var(--warm-white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    letter-spacing: -0.01em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-tertiary);
    margin-bottom: 32px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-error {
    background: rgba(196, 63, 63, 0.08);
    color: #a0453a;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(196, 63, 63, 0.15);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    background: var(--warm-white);
    color: var(--text);
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.4;
}

.btn:hover {
    background: var(--cream);
    border-color: var(--sand-dark);
    text-decoration: none;
}

.btn-primary {
    background: var(--terra);
    color: #fff;
    border-color: var(--terra);
}

.btn-primary:hover {
    background: var(--terra-light);
    border-color: var(--terra-light);
    color: #fff;
}

.btn-secondary {
    background: var(--warm-white);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--cream);
}

.btn-full { width: 100%; }

.btn-small {
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="time"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--warm-white);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
}

.form-row .form-group { margin-bottom: 0; }

.form-stack { max-width: 720px; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    background: var(--warm-white);
}

.form-fieldset legend {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 15px;
    font-weight: 600;
    padding: 0 8px;
    color: var(--text);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
}

.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--terra); }

.textarea-code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
    resize: vertical;
    background: var(--deep) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border-color: var(--deep-raised) !important;
    border-radius: var(--radius) !important;
    padding: 16px !important;
}

.textarea-code:focus {
    border-color: var(--terra) !important;
}

.upload-form .form-row { align-items: end; }

/* ── Tables ── */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--warm-white);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table thead th {
    background: var(--cream);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(221, 213, 200, 0.5);
    font-size: 14px;
    color: var(--text-secondary);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: var(--cream); }

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 16px;
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 15px;
}

/* ── Stats grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--warm-white);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-value {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 6px;
}

/* ── Status indicators ── */
.status-online { color: #5a8a4a; }
.status-offline { color: var(--terra); font-size: 0.8em; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-dot.status-online { background: #5a8a4a; box-shadow: 0 0 6px rgba(90, 138, 74, 0.4); }
.status-dot.status-offline { background: var(--terra); opacity: 0.6; }

/* ── Cards ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.agent-card {
    display: flex;
    flex-direction: column;
    background: var(--warm-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.25s ease;
    color: var(--text);
    overflow: hidden;
}

.agent-card:hover {
    border-color: var(--terra);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.agent-card-link {
    display: block;
    padding: 24px 24px 16px;
    color: var(--text);
    flex: 1;
}

.agent-card-link:hover { text-decoration: none; color: var(--text); }

.agent-card-actions {
    display: flex;
    gap: 8px;
    padding: 0 24px 20px;
}

.agent-card-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.agent-card-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--terra);
    margin-bottom: 10px;
}

.agent-card-model {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-tertiary);
    background: var(--cream);
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.agent-card-meta { margin-top: 12px; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: 100px;
    background: var(--terra-muted);
    color: var(--terra);
    border: 1px solid rgba(196, 112, 63, 0.2);
}

/* ── Tools display ── */
.tools-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

/* ── Section ── */
.section {
    margin-bottom: 32px;
}

.section h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ── Tabs (Alpine.js) ── */
.tab-container { margin-bottom: 24px; }

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    letter-spacing: 0.01em;
}

.tab-btn:hover { color: var(--text-secondary); }

.tab-btn.active {
    color: var(--terra);
    border-bottom-color: var(--terra);
}

[x-cloak] { display: none !important; }

.tab-bar-secondary {
    margin-top: -8px;
    margin-bottom: 20px;
    border-bottom-color: var(--sand-dark);
}

.tab-bar-secondary .tab-btn {
    padding: 8px 18px;
    font-size: 14px;
}

/* ── Integrations ── */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.integration-card {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.integration-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.integration-card h3 {
    font-size: 1rem;
    font-weight: 600;
}

.integration-card .text-muted {
    font-size: 14px;
    line-height: 1.5;
}

/* ── Workshop ── */
.workshop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.workshop-card {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.workshop-card h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.workshop-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.workshop-placeholder {
    padding: 20px;
    background: var(--cream);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    font-size: 14px;
    color: var(--text-tertiary);
    text-align: center;
    font-style: italic;
}

.workshop-controls {
    margin-bottom: 16px;
}

.workshop-result {
    margin-top: 16px;
    padding: 12px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.workshop-result .table {
    margin: 0;
    font-size: 14px;
}

.workshop-result .table td {
    padding: 4px 8px;
    border: none;
}

.workshop-log {
    margin-top: 16px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--deep);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.workshop-log:empty {
    display: none;
}

.workshop-log-line {
    color: #b0a898;
}

.workshop-log-line.log-ok {
    color: #7ec87e;
}

.workshop-log-line.log-error {
    color: #e07070;
}

.workshop-log-line.log-info {
    color: #b0a898;
}

.workshop-console-input {
    display: flex;
    gap: 6px;
}

.workshop-console-input input {
    flex: 1;
    padding: 6px 10px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 13px;
    background: var(--deep);
    color: #e0d8cc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

.workshop-console-input input:focus {
    border-color: var(--terra);
}

.workshop-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.workshop-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--sand-dark);
    border-radius: 4px;
    overflow: hidden;
}

.workshop-progress-fill {
    height: 100%;
    background: var(--terra);
    border-radius: 4px;
    transition: width 0.2s ease;
}

.workshop-progress-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

/* ── Notice ── */
.notice {
    padding: 12px 16px;
    background: var(--terra-muted);
    border-left: 3px solid var(--terra);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ── Log detail (HTMX) ── */
.log-detail { padding: 14px 0; }

.log-message {
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    gap: 12px;
    line-height: 1.6;
}

.log-user {
    background: var(--terra-muted);
    border: 1px solid rgba(196, 112, 63, 0.12);
}

.log-assistant {
    background: var(--cream);
    border: 1px solid var(--border);
}

.log-role {
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    min-width: 64px;
    color: var(--text-tertiary);
    padding-top: 2px;
}

.log-text {
    flex: 1;
    color: var(--text-secondary);
}

/* ── Model providers ── */
.provider-block {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

.provider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
}

.provider-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.provider-info h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

.provider-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--cream);
    padding: 3px 10px;
    border-radius: 100px;
    border: 1px solid var(--border);
}

.provider-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge-active {
    background: rgba(90, 138, 74, 0.12);
    color: #5a8a4a;
    border-color: rgba(90, 138, 74, 0.2);
}

.badge-inactive {
    background: var(--sand);
    color: var(--text-tertiary);
    border-color: var(--border);
}

/* Provider config row */
.provider-config {
    padding: 16px 24px;
    background: var(--cream);
    border-top: 1px solid rgba(221, 213, 200, 0.5);
    border-bottom: 1px solid rgba(221, 213, 200, 0.5);
}

.config-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.config-field {
    flex: 0 0 280px;
}

.config-field-wide {
    flex: 1;
    min-width: 280px;
}

.config-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.config-field input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background: var(--warm-white);
    color: var(--text);
    transition: border-color 0.2s;
}

.config-field input:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.config-field input::placeholder {
    color: var(--text-tertiary);
}

.config-hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-fields {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.config-actions {
    display: flex;
    gap: 8px;
}

.config-status {
    margin-top: 10px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
}

.config-status-ok {
    background: rgba(90, 138, 74, 0.1);
    color: #5a8a4a;
    border: 1px solid rgba(90, 138, 74, 0.2);
}

.config-status-error {
    background: rgba(160, 69, 58, 0.08);
    color: #a0453a;
    border: 1px solid rgba(160, 69, 58, 0.15);
}

/* Models list */
.models-list {
    padding: 8px 24px 16px;
}

.models-empty {
    padding: 20px 0;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
}

.model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(221, 213, 200, 0.3);
}

.model-row:last-of-type { border-bottom: none; }

.model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-name {
    font-weight: 500;
    color: var(--text);
}

.model-id {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-tertiary);
    background: var(--cream);
    padding: 2px 8px;
    border-radius: 4px;
}

.btn-enabled {
    color: #5a8a4a;
    background: rgba(90, 138, 74, 0.1);
    border-color: rgba(90, 138, 74, 0.2);
}

.btn-enabled:hover {
    background: rgba(90, 138, 74, 0.18);
}

.btn-danger {
    color: #a0453a;
    border-color: rgba(160, 69, 58, 0.25);
    background: rgba(160, 69, 58, 0.06);
}

.btn-danger:hover {
    background: rgba(160, 69, 58, 0.12);
    border-color: rgba(160, 69, 58, 0.35);
}

.btn-muted {
    color: var(--text-tertiary);
    background: var(--sand);
    border-color: var(--border);
}

/* ── Chat ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.chat-header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-body {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    padding-bottom: 0 !important;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 16px;
    scroll-behavior: smooth;
}

.chat-welcome {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
    font-size: 15px;
}

.chat-welcome strong {
    color: var(--text-secondary);
}

.chat-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    max-width: 80%;
}

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-msg-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    padding: 0 2px;
}

.chat-msg-text {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-user .chat-msg-text {
    background: var(--terra);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-user .chat-msg-role {
    text-align: right;
}

.chat-msg-assistant .chat-msg-text {
    background: var(--warm-white);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-msg-error {
    align-self: center;
    background: rgba(160, 69, 58, 0.08);
    border: 1px solid rgba(160, 69, 58, 0.2);
    color: #a0453a;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    max-width: 90%;
}

.chat-msg-tool {
    align-self: center;
    background: rgba(196, 112, 63, 0.08);
    border: 1px solid rgba(196, 112, 63, 0.2);
    color: var(--terra);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    max-width: 90%;
}
.chat-msg-tool .chat-msg-role {
    font-size: 11px;
    color: var(--text-tertiary);
}

.tool-file-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    color: inherit;
    padding: 4px 0;
}
.tool-file-link:hover {
    color: var(--terra);
}
.tool-file-name {
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--terra-light);
    text-underline-offset: 2px;
}
.tool-file-meta {
    font-size: 12px;
    color: var(--text-tertiary);
}

.chat-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--terra);
    animation: statusPulse 1.2s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes statusPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.tool-inline-status {
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(196, 112, 63, 0.08);
    border-left: 3px solid var(--terra);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px;
    color: var(--terra);
    font-style: italic;
}

/* Typing dots animation */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-wrap {
    padding: 16px 0;
    border-top: 1px solid var(--border);
    background: var(--sand);
}

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

.chat-form textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    background: var(--warm-white);
    color: var(--text);
    max-height: 160px;
    transition: border-color 0.2s;
}

.chat-form textarea:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.chat-form textarea::placeholder {
    color: var(--text-tertiary);
}

.chat-form .btn {
    padding: 12px 24px;
    flex-shrink: 0;
}

/* ── Libraries ── */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.library-card {
    display: block;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.25s ease;
    color: var(--text);
}

.library-card:hover {
    border-color: var(--terra);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.library-card-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.library-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.library-card-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.header-with-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.create-form-block {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

/* Access grid */
.access-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.access-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.access-agent {
    font-size: 14px;
    color: var(--text);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 100px;
    background: var(--sand);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    margin-right: 4px;
    margin-bottom: 4px;
}

.tag-agent {
    background: var(--terra-muted);
    color: var(--terra);
    border-color: rgba(196, 112, 63, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.tag-agent:hover {
    background: rgba(160, 69, 58, 0.12);
    color: #a0453a;
    border-color: rgba(160, 69, 58, 0.25);
}

.tag-add {
    background: var(--cream);
    color: var(--terra);
    border-color: var(--border);
    cursor: pointer;
    font-weight: 700;
    padding: 2px 10px;
    transition: all 0.2s;
}

.tag-add:hover {
    background: var(--terra-muted);
    border-color: var(--terra);
}

/* Tool config grid */
.tools-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s;
}

.tool-check:hover {
    border-color: var(--terra);
}

.tool-check input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.tool-check-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
}

.tool-check-info .text-muted {
    font-size: 13px;
}

/* ── Tool management page ── */
.tool-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-card {
    display: block;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all 0.2s ease;
    color: var(--text);
}

.tool-card:hover {
    border-color: var(--terra);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: var(--text);
}

.tool-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tool-card-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.tool-card-id {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.tool-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.tool-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-card-agents {
    font-size: 13px;
    color: var(--text-tertiary);
}

.tool-agents-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-danger {
    background: rgba(196, 63, 63, 0.08);
    color: #a0453a;
    border: 1px solid rgba(196, 63, 63, 0.2);
    margin-left: auto;
}

.btn-danger:hover {
    background: rgba(196, 63, 63, 0.15);
    color: #8a3530;
}

.inline-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    background: var(--warm-white);
    color: var(--text);
    vertical-align: middle;
}

/* Add item tabs */
.add-item-tabs {
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.add-item-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.add-item-form .form-row {
    margin-bottom: 16px;
}

/* ── Debug trace ── */
.debug-trace {
    background: var(--deep);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    overflow-x: auto;
}

.debug-trace-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.debug-trace .debug-trace-title {
    color: rgba(255, 255, 255, 0.5);
}

.debug-entry {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.7);
    align-items: flex-start;
}

.debug-entry:last-child { border-bottom: none; }

.debug-time {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
    min-width: 60px;
}

.debug-type {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 130px;
    text-align: center;
}

.debug-conversation-start .debug-type { background: rgba(74, 138, 90, 0.2); color: #7bc88a; }
.debug-system-prompt .debug-type { background: rgba(100, 120, 180, 0.2); color: #8ea4e0; }
.debug-library-access .debug-type { background: rgba(180, 140, 60, 0.2); color: #d4b85a; }
.debug-user-message .debug-type { background: rgba(196, 112, 63, 0.2); color: var(--terra-light); }
.debug-llm-request .debug-type { background: rgba(100, 160, 200, 0.2); color: #78bce0; }
.debug-llm-response .debug-type { background: rgba(74, 138, 90, 0.2); color: #7bc88a; }
.debug-llm-error .debug-type { background: rgba(200, 80, 70, 0.2); color: #e07878; }
.debug-conversation-end .debug-type { background: rgba(140, 140, 140, 0.2); color: rgba(255, 255, 255, 0.4); }
.debug-memory-load .debug-type { background: rgba(160, 100, 200, 0.2); color: #c090e0; }
.debug-memory-save .debug-type { background: rgba(160, 100, 200, 0.2); color: #c090e0; }

.debug-detail {
    flex: 1;
    word-break: break-word;
}

.debug-detail strong { color: rgba(255, 255, 255, 0.9); }
.debug-detail code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 6px;
    border-radius: 3px;
}

.debug-preview {
    display: block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 60px;
    overflow: hidden;
}

.debug-error-text { color: #e07878; }

/* ── Audit log ── */
.audit-action {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.audit-auth { background: rgba(100, 120, 180, 0.1); color: #5a7abf; }
.audit-agent { background: rgba(196, 112, 63, 0.1); color: var(--terra); }
.audit-library { background: rgba(180, 140, 60, 0.1); color: #a08030; }
.audit-library_item { background: rgba(180, 140, 60, 0.1); color: #a08030; }
.audit-access { background: rgba(74, 138, 90, 0.1); color: #4a8a5a; }
.audit-settings { background: rgba(140, 100, 160, 0.1); color: #8a60a0; }
.audit-provider { background: rgba(100, 160, 200, 0.1); color: #4a90b0; }
.audit-model { background: rgba(100, 160, 200, 0.1); color: #4a90b0; }
.audit-models { background: rgba(100, 160, 200, 0.1); color: #4a90b0; }

.audit-detail-cell {
    position: relative;
    max-width: 300px;
}

.audit-detail-json {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--deep);
    color: rgba(255, 255, 255, 0.7);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

.audit-filter .config-row {
    align-items: center;
}

/* ── Memory ── */
.memory-summary-block {
    background: var(--deep);
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 15px;
    line-height: 1.7;
    padding: 20px 24px;
    border-radius: var(--radius);
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.memory-summary-empty {
    background: var(--deep);
    border-radius: var(--radius);
    padding: 40px 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 15px;
}

.memory-stale-notice {
    background: rgba(180, 140, 60, 0.1);
    border-left: 3px solid #a08030;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 10px 16px;
    margin-bottom: 16px;
    line-height: 1.6;
}

.pending-facts {
    /* Container for pending review tab content */
}

.fact-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.fact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(221, 213, 200, 0.5);
    background: var(--warm-white);
}

.fact-row:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.fact-row:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
    border-bottom: none;
}

.fact-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.fact-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 4px;
}

.fact-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.category-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: 100px;
}

.category-preference {
    background: var(--terra-muted);
    color: var(--terra);
    border: 1px solid rgba(196, 112, 63, 0.2);
}

.category-personal {
    background: rgba(100, 120, 180, 0.1);
    color: #5a7abf;
    border: 1px solid rgba(100, 120, 180, 0.2);
}

.category-task {
    background: rgba(74, 138, 90, 0.1);
    color: #4a8a5a;
    border: 1px solid rgba(74, 138, 90, 0.2);
}

.category-knowledge {
    background: rgba(140, 100, 160, 0.1);
    color: #8a60a0;
    border: 1px solid rgba(140, 100, 160, 0.2);
}

.category-decision {
    background: rgba(180, 140, 60, 0.1);
    color: #a08030;
    border: 1px solid rgba(180, 140, 60, 0.2);
}

.category-general {
    background: var(--sand);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.memory-agent-select {
    width: auto;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--warm-white);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.memory-agent-select:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.bulk-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--cream);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.fact-edit-form {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex: 1;
}

.fact-edit-form textarea {
    min-height: 60px;
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--warm-white);
    color: var(--text);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fact-edit-form textarea:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.memory-mode-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--cream);
    padding: 3px 10px;
    border-radius: 100px;
    border: 1px solid var(--border);
}

/* ── Filesystem browser ── */
.fs-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 0;
    font-size: 14px;
    font-weight: 500;
    flex-wrap: wrap;
}

.fs-breadcrumbs a {
    color: var(--terra);
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.fs-breadcrumbs a:hover {
    background: var(--terra-muted);
    text-decoration: none;
}

.fs-breadcrumb-sep {
    color: var(--text-tertiary);
    margin: 0 2px;
}

.fs-breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

.fs-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.fs-toolbar-left,
.fs-toolbar-right {
    display: flex;
    gap: 6px;
    align-items: center;
}

.fs-inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    margin-top: 8px;
}

.fs-inline-form input[type="text"] {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--warm-white);
    color: var(--text);
    flex: 1;
    max-width: 300px;
}

.fs-inline-form input:focus {
    outline: none;
    border-color: var(--terra);
    box-shadow: 0 0 0 3px var(--terra-muted);
}

.fs-dropzone {
    position: relative;
    min-height: 200px;
}

.fs-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(196, 112, 63, 0.08);
    border: 2px dashed var(--terra);
    border-radius: var(--radius);
    z-index: 5;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.fs-drop-overlay-inner {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--terra);
    padding: 24px 32px;
    background: var(--warm-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.fs-table {
    margin-top: 0;
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.fs-table thead th {
    padding: 10px 16px;
}

.fs-table tbody td {
    padding: 8px 16px;
}

.fs-entry {
    font-weight: 500;
    color: var(--text);
}

.fs-folder::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 14px;
    margin-right: 8px;
    background: var(--terra);
    border-radius: 2px 4px 4px 4px;
    vertical-align: middle;
    position: relative;
    top: -1px;
    clip-path: polygon(0 20%, 40% 20%, 45% 0, 100% 0, 100% 100%, 0 100%);
}

a.fs-folder { color: var(--text); }
a.fs-folder:hover { color: var(--terra); text-decoration: none; }

.fs-file::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 17px;
    margin-right: 8px;
    border: 1.5px solid var(--text-tertiary);
    border-radius: 2px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.fs-actions {
    white-space: nowrap;
    text-align: right;
}

.fs-bulk-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.fs-empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-tertiary);
}

.fs-empty p:first-child {
    font-family: 'Source Serif 4', serif;
    font-size: 1.1rem;
    font-style: italic;
    margin-bottom: 8px;
}

.fs-upload-progress {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    gap: 12px;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
    display: none;
}

.fs-upload-progress.active {
    display: flex;
}

.fs-upload-bar {
    flex: 1;
    height: 6px;
    background: var(--sand);
    border-radius: 3px;
    overflow: hidden;
}

.fs-upload-fill {
    height: 100%;
    width: 0%;
    background: var(--terra);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Clickable file links */
a.fs-file { color: var(--text); cursor: pointer; }
a.fs-file:hover { color: var(--terra); text-decoration: none; }

/* Select mode */
.fs-select-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--terra-muted);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--terra);
}

.fs-check-col {
    width: 30px;
    text-align: center;
}

/* Context menu */
.fs-ctx {
    position: fixed;
    z-index: 100;
    background: var(--warm-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 4px 0;
}

.fs-ctx-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s;
}

.fs-ctx-item:hover {
    background: var(--sand);
}

.fs-ctx-danger {
    color: #a0453a;
}

.fs-ctx-danger:hover {
    background: rgba(160, 69, 58, 0.08);
}

.fs-ctx-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* File preview overlay */
.fs-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(26, 22, 18, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.fs-preview-panel {
    background: var(--warm-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fs-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.fs-preview-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fs-preview-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
    min-height: 200px;
}

.fs-preview-text {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    tab-size: 4;
}

.fs-preview-img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.fs-preview-iframe {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: 4px;
}

.fs-preview-audio {
    width: 100%;
    margin-top: 24px;
}

.fs-preview-video {
    width: 100%;
    max-height: 70vh;
    border-radius: 4px;
}

.fs-preview-unknown {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}

.fs-preview-unknown p {
    margin-bottom: 16px;
    font-family: 'Source Serif 4', serif;
    font-style: italic;
}

/* Move dialog */
.fs-move-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(26, 22, 18, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.fs-move-panel {
    background: var(--warm-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 400px;
}

.fs-move-panel h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
}

/* ── Utilities ── */
.text-muted { color: var(--text-tertiary); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: 64px;
        overflow: hidden;
    }

    .sidebar-brand {
        font-size: 0;
        padding: 24px 0;
        text-align: center;
    }

    .sidebar-brand::first-letter {
        font-size: 1.2rem;
    }

    .sidebar-nav { padding: 0 8px; }

    .sidebar-nav li a {
        padding: 10px;
        font-size: 0;
        text-align: center;
    }

    .sidebar-footer { display: none; }
    .content { margin-left: 64px; }
    .content-header, .content-body { padding-left: 20px; padding-right: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Benchmark ── */
.benchmark-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

.benchmark-setup { min-width: 0; }

.benchmark-controls {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.benchmark-results { min-width: 0; overflow: hidden; }

.model-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.model-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
}

.model-check-row:hover { background: var(--terra-muted); }
.model-check-row input[type="checkbox"] { cursor: pointer; accent-color: var(--terra); }

.benchmark-status {
    padding: 10px 14px;
    background: var(--terra-muted);
    border-left: 3px solid var(--terra);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.benchmark-table-wrap { overflow-x: auto; }

.benchmark-table th { white-space: nowrap; font-size: 0.8rem; }
.benchmark-table td { white-space: nowrap; vertical-align: middle; }

.bench-cell {
    cursor: pointer;
    padding: 6px 10px !important;
}
.bench-cell:hover { background: var(--terra-muted); }

.bench-pass { color: #2e7d32; font-weight: 600; font-size: 0.8rem; margin-right: 4px; }
.bench-fail { color: #c62828; font-weight: 600; font-size: 0.8rem; margin-right: 4px; }
.bench-ms   { color: var(--text-tertiary); font-size: 0.75rem; }

.bench-pending { color: var(--text-tertiary); font-size: 0.85rem; padding: 6px 10px !important; }

.bench-row-active { background: var(--cream); }

.bench-response-group {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bench-response-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--sand-dark);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 600;
}

.bench-response-item {
    border-bottom: 1px solid var(--border);
}
.bench-response-item:last-child { border-bottom: none; }

.bench-response-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    font-size: 0.8rem;
    background: var(--cream);
}

.bench-item-pass .bench-response-item-header { border-left: 3px solid #2e7d32; }
.bench-item-fail .bench-response-item-header { border-left: 3px solid #c62828; }

.bench-response-body {
    padding: 12px 14px;
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--warm-white);
    font-family: 'Courier New', monospace;
    border-left: 3px solid transparent;
}

.bench-item-pass .bench-response-body { border-left-color: rgba(46, 125, 50, 0.15); }
.bench-item-fail .bench-response-body  { border-left-color: rgba(198, 40, 40, 0.15); }

@media (max-width: 900px) {
    .benchmark-layout { grid-template-columns: 1fr; }
}
