/* === LifeTiming Knowledge Base — Design System === */
@font-face {
    font-family: 'Aeonik-Lifetiming';
    src: url('../fonts/AeonikLifetiming-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}
@font-face {
    font-family: 'Aeonik-Lifetiming';
    src: url('../fonts/AeonikLifetiming-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Aeonik-Lifetiming';
    src: url('../fonts/AeonikLifetiming-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

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

:root {
    --accent: #FB7B34;
    --accent-hover: #FF9F53;
    --accent-light: #FF9C5E;
    --accent-subtle: rgba(251, 123, 52, 0.08);
    --secondary: #6467C3;

    --bg: #F1E8E4;
    --surface: #ffffff;
    --surface-alt: #FBF9F9;
    --surface-raised: #F6F4F3;
    --primary: #FB7B34;
    --primary-hover: #FF9F53;
    --danger: #DC180C;
    --danger-hover: #b91c1c;
    --text: #0F0F0F;
    --text-secondary: #7E716D;
    --border: #E6E6E6;
    --border-hover: #FF9C5E;
    --divider: #F2EEED;
    --success: #139E19;
    --success-bg: #e8f5e9;
    --warning: #E59A00;
    --error: #DC180C;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-pill: 24px;

    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.06);

    --font: 'Aeonik-Lifetiming', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font);
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navbar */
.navbar {
    background: #0F0F0F;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 52px;
    gap: 4rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo {
    height: 18px;
    filter: brightness(0) invert(1);
}

.nav-brand-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
}

.sphere-mark {
    flex-shrink: 0;
}

.nav-brand-product {
    font-weight: 500;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.nav-right {
    margin-left: auto;
}

.nav-link {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    font-weight: 500;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
}

.nav-link.active {
    background: var(--accent);
    color: white;
}

/* Container */
.container {
    max-width: 1440px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Upload section */
.upload-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.upload-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.upload-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
}

.form-group input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-primary:disabled {
    background: #f5c9a8;
    cursor: not-allowed;
}

.btn-download {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    text-decoration: none;
}

.btn-download:hover {
    background: var(--accent);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

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

/* Icon buttons for table actions */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    vertical-align: middle;
}

.btn-icon-download {
    color: var(--text-secondary);
}

.btn-icon-download:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.btn-icon-delete {
    color: var(--text-secondary);
}

.btn-icon-delete:hover {
    background: rgba(220, 24, 12, 0.08);
    color: var(--danger);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* Status messages */
.status-message {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.status-message.success { color: var(--success); }
.status-message.error { color: var(--error); }
.status-message.info { color: var(--accent); }

/* Documents table */
.documents-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.documents-section h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

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

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-uploaded { background: rgba(100, 103, 195, 0.12); color: var(--secondary); }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-chunked { background: #fef3c7; color: #92400e; }
.badge-embedded { background: #d1fae5; color: #065f46; }
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-enriched { background: #d1fae5; color: #065f46; }

/* Batch actions bar */
.batch-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--accent-subtle);
    border: 1px solid rgba(251, 123, 52, 0.2);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.selection-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Checkbox column */
.th-checkbox {
    width: 36px;
    text-align: center;
}

.td-checkbox {
    text-align: center;
}

.data-table tbody tr.selected {
    background: var(--accent-subtle);
}

/* Context menu */
.context-menu {
    position: fixed;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 160px;
    padding: 0.25rem 0;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: var(--bg);
}

.context-menu-danger {
    color: var(--danger);
}

.context-menu-danger:hover {
    background: #fee2e2;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.drop-zone-icon {
    font-size: 2rem;
    color: var(--text-secondary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.drop-zone-text {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.drop-zone-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Queued file row */
.badge-queued { background: #f3e8ff; color: #7c3aed; }
.badge-uploading { background: rgba(100, 103, 195, 0.12); color: var(--secondary); }

.btn-cancel {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.btn-cancel:hover {
    background: var(--bg);
    color: var(--danger);
    border-color: var(--danger);
}

/* Processing progress */
.status-progress {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 120px;
}

.progress-bar-wrapper {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.processing-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.3rem;
}

/* Loading and empty states */
.loading, .empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* ==================== Tags ==================== */

/* Tag filter bar */
.tag-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tag-filter-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tag-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Tag pills */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    background: rgba(100, 103, 195, 0.1);
    color: var(--secondary);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.tag-pill-sm {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
}

.tag-pill-remove {
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.tag-pill-remove:hover {
    opacity: 1;
}

/* Tag input + dropdown wrapper */
.tag-input-wrapper {
    position: relative;
}

.tag-input-inline {
    display: inline-block;
}

.tag-input {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    outline: none;
    width: 140px;
    background: var(--surface);
}

.tag-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.tag-input-sm {
    width: 60px;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    border-radius: 9999px;
    transition: width 0.15s ease;
}

.tag-input-sm:focus {
    width: 120px;
}

/* Tag dropdown */
.tag-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    min-width: 180px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: 2px;
}

.tag-dropdown-item {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.1s;
}

.tag-dropdown-item:hover {
    background: var(--bg);
}

.tag-dropdown-create {
    color: var(--accent);
    font-style: italic;
    border-top: 1px solid var(--border);
}

/* Tags in table */
.tags-cell {
    max-width: 280px;
}

.doc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

/* Chat layout with system panel */
.chat-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 130px);
    position: relative;
}

/* Chat */
.chat-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--surface-raised);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Explain button and box */
.explain-wrapper {
    margin-top: 0.5rem;
}

.btn-explain {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.15rem 0;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.btn-explain:hover {
    opacity: 1;
    color: var(--accent);
}

.btn-explain.active {
    opacity: 1;
    color: var(--accent);
}

.explain-box {
    display: none;
    margin-top: 0.4rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.explain-box.open {
    display: block;
}

.explain-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 0.75rem;
}

.explain-sources {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.explain-sources-label {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.explain-source-item {
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.explain-source-num {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.explain-source-link {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
}

.explain-source-link:hover {
    text-decoration: underline;
    color: var(--accent);
}

.explain-source-sim {
    color: var(--text-secondary);
    font-size: 0.7rem;
    opacity: 0.7;
}

.explain-source-type {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(100, 103, 195, 0.12);
    color: var(--secondary);
}

.message-sources {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.message-sources strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.chat-form input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    outline: none;
}

.chat-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.thinking {
    display: inline-block;
    color: var(--text-secondary);
    font-style: italic;
}

.thinking::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* System Panel */
.system-panel {
    position: relative;
    display: flex;
    width: 0;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

.system-panel.open {
    width: 420px;
}

.system-toggle {
    position: absolute;
    left: -32px;
    top: 12px;
    width: 32px;
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    z-index: 10;
    padding: 0;
}

.system-toggle:hover {
    background: var(--bg);
    color: var(--text);
}

.toggle-arrow {
    font-size: 0.65rem;
    transition: transform 0.25s ease;
}

.system-panel.open .toggle-arrow {
    transform: rotate(180deg);
}

.toggle-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.system-panel-content {
    width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.system-panel.open .system-panel-content {
    opacity: 1;
}

.system-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.system-panel-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

.system-clear {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.system-clear:hover {
    background: var(--border);
    color: var(--text);
}

.system-entries {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.8rem;
}

.system-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem 1rem;
    font-style: italic;
}

.system-entry {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.system-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: var(--bg);
    cursor: pointer;
    user-select: none;
}

.system-entry-header:hover {
    background: var(--border);
}

.system-entry-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.system-entry-badge {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.system-entry-badge.embeddings {
    background: rgba(100, 103, 195, 0.12);
    color: var(--secondary);
}

.system-entry-badge.reasoning {
    background: #ede9fe;
    color: #5b21b6;
}

.system-entry-badge.chat {
    background: #d1fae5;
    color: #065f46;
}

.system-entry-status {
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 600;
}

.system-entry-body {
    display: none;
    padding: 0.5rem 0.6rem;
    border-top: 1px solid var(--border);
}

.system-entry.expanded .system-entry-body {
    display: block;
}

.system-entry-section {
    margin-bottom: 0.5rem;
}

.system-entry-section:last-child {
    margin-bottom: 0;
}

.system-entry-section-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.system-entry-json {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.72rem;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* Knowledge View */
.knowledge-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 720px;
}

.knowledge-section h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.knowledge-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.knowledge-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.knowledge-form select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    background: var(--surface);
    color: var(--text);
}

.knowledge-form select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.knowledge-statement-group {
    flex: none;
}

.knowledge-form textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
}

.knowledge-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.knowledge-recent {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 720px;
}

.knowledge-recent h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.knowledge-entries-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.knowledge-entry-card {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
}

.knowledge-entry-card .knowledge-entry-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.knowledge-type-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(100, 103, 195, 0.12);
    color: var(--secondary);
}

.knowledge-type-badge.view { background: #fef3c7; color: #92400e; }
.knowledge-type-badge.idea { background: #d1fae5; color: #065f46; }
.knowledge-type-badge.hypothesis { background: #ede9fe; color: #5b21b6; }
.knowledge-type-badge.possibility { background: #fce7f3; color: #9d174d; }
.knowledge-type-badge.conjecture { background: #ffedd5; color: #9a3412; }
.knowledge-type-badge.assumption { background: #f1f5f9; color: #475569; }
.knowledge-type-badge.proposition { background: #ccfbf1; color: #134e4a; }

.knowledge-entry-statement {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
}

/* Chat knowledge confirmation */
.message.knowledge-confirm {
    align-self: flex-start;
    background: #d1fae5;
    color: #065f46;
    border-bottom-left-radius: 2px;
}

.knowledge-confirm-type {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
    opacity: 0.8;
}

/* Reasoning display in system panel */
.reasoning-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.reasoning-item {
    padding: 0.25rem 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.8rem;
}

.reasoning-stats {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
}

.reasoning-stats span {
    padding: 0.15rem 0.5rem;
    background: var(--bg);
    border-radius: 4px;
}

.reasoning-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.reasoning-entity {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
}

.reasoning-entity small {
    font-weight: 400;
    opacity: 0.7;
}

/* ==================== Sys Debug Button & Pane ==================== */

.btn-sys {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.03em;
}

.btn-sys:hover {
    background: #334155;
    color: #e2e8f0;
}

.btn-sys.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* The debug pane - fixed right side */
.sys-pane {
    position: fixed;
    top: 56px;
    right: 0;
    width: 520px;
    height: calc(100vh - 56px);
    background: #0f172a;
    color: #e2e8f0;
    border-left: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 100;
}

.sys-pane.open {
    transform: translateX(0);
}

body.sys-open .container {
    margin-right: 520px;
    transition: margin-right 0.25s ease;
}

.sys-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.sys-pane-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    letter-spacing: 0.03em;
}

.sys-pane-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sys-status {
    font-size: 0.7rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: #1e293b;
    color: #64748b;
}

.sys-status.connected {
    color: #4ade80;
    background: #052e16;
}

.sys-clear-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.7rem;
}

.sys-clear-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

.sys-close-btn {
    background: none;
    border: 1px solid #334155;
    color: #64748b;
    font-size: 1rem;
    line-height: 1;
    padding: 0.15rem 0.4rem;
}

.sys-close-btn:hover {
    background: #334155;
    color: #f87171;
}

.sys-pane-entries {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
}

.sys-empty {
    color: #475569;
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* Individual trace entry */
.sys-trace-entry {
    border: 1px solid #1e293b;
    border-radius: 4px;
    overflow: hidden;
    background: #0f172a;
}

.sys-trace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background: #1e293b;
    cursor: pointer;
    user-select: none;
    gap: 0.5rem;
}

.sys-trace-header:hover {
    background: #334155;
}

.sys-trace-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    flex: 1;
}

.sys-trace-badge {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.sys-trace-badge.chat { background: #065f46; color: #6ee7b7; }
.sys-trace-badge.embed { background: #1e3a5f; color: #7dd3fc; }
.sys-trace-badge.error { background: #7f1d1d; color: #fca5a5; }

.sys-trace-name {
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sys-trace-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.sys-trace-status {
    font-size: 0.65rem;
    font-weight: 600;
}

.sys-trace-status.ok { color: #4ade80; }
.sys-trace-status.err { color: #f87171; }

.sys-trace-duration {
    color: #64748b;
    font-size: 0.65rem;
}

/* Expandable body */
.sys-trace-body {
    display: none;
    border-top: 1px solid #1e293b;
}

.sys-trace-entry.expanded .sys-trace-body {
    display: block;
}

.sys-trace-section {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid #1e293b;
}

.sys-trace-section:last-child {
    border-bottom: none;
}

.sys-trace-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.sys-trace-json {
    color: #cbd5e1;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.35;
}

.sys-trace-json .json-key { color: #7dd3fc; }
.sys-trace-json .json-string { color: #86efac; }
.sys-trace-json .json-number { color: #fbbf24; }
.sys-trace-json .json-bool { color: #c084fc; }
.sys-trace-json .json-null { color: #64748b; }

/* ==================== Login Page ==================== */

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

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-elevated);
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-logo {
    height: 32px;
    margin-bottom: 1rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
}

.login-sphere-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.25rem 0 1.5rem;
}

.login-sphere-text {
    font-weight: 500;
    font-size: 1.1rem;
    color: var(--text);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.login-field {
    text-align: left;
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.login-field input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(251, 123, 52, 0.15);
}

.login-error {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.login-btn {
    width: 100%;
    padding: 0.7rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}
