/* ══════════════════════════════════════════════════════════════════════
   格物知新 WebUI — Design System
   ══════════════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #f7f8fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1d23;
    --bg-sidebar-hover: #2a2d35;
    --bg-sidebar-active: #33363f;

    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-sidebar: #9ca3af;
    --text-sidebar-active: #ffffff;

    --accent: #6366f1;
    --accent-light: #eef2ff;
    --accent-hover: #4f46e5;

    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    --color-idea: #7c3aed;
    --color-project: #2563eb;
    --color-book: #059669;
    --color-paper: #d97706;
    --color-webinfo: #0891b2;
    --color-webnews: #dc2626;

    --sidebar-width: 240px;
    --topbar-height: 56px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

.d-none { display: none !important; }

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

.login-page {
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.28), transparent 32%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.18), transparent 28%),
        linear-gradient(135deg, #111827 0%, #1f2937 45%, #0f172a 100%);
}

.login-shell {
    width: 100%;
    max-width: 560px;
}

.login-panel {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35);
    padding: 2.25rem;
    backdrop-filter: blur(10px);
}

.login-brand {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    flex-shrink: 0;
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.28);
}

.login-kicker {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #4f46e5;
    margin-bottom: 0.45rem;
}

.login-brand h1 {
    margin: 0 0 0.4rem;
    font-size: 1.85rem;
    font-weight: 800;
}

.login-brand p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-note {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid rgba(99, 102, 241, 0.18);
    font-size: 0.9rem;
}

.login-note-soft {
    background: #f8fafc;
    color: #334155;
    border-color: rgba(148, 163, 184, 0.22);
    margin-bottom: 1.35rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.8rem 0.95rem;
    border-radius: 12px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.16);
    font-size: 0.9rem;
}

.btn-login {
    margin-top: 0.5rem;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
    font-size: 0.96rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #4f46e5, #2563eb);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.2);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.25);
}

/* ── Init Page ───────────────────────────────────────────────────────── */

.init-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.init-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    max-width: 520px;
    width: 100%;
}

.init-header {
    text-align: center;
    margin-bottom: 2rem;
}

.init-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.init-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

/* Progress bar */
.init-progress {
    margin-bottom: 2rem;
}

.progress-track {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

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

.progress-steps {
    display: flex;
    justify-content: space-between;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s;
}

.progress-step.active .step-num {
    background: var(--accent);
    color: white;
}

.progress-step.completed .step-num {
    background: #10b981;
    color: white;
}

.step-text {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Wizard steps */
.wizard-step h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
}

.mbti-intro {
    background: var(--accent-light);
    color: var(--accent);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.mbti-intro i { margin-right: 0.4rem; }

.mbti-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.mbti-option { cursor: pointer; margin: 0; }
.mbti-option input[type="radio"] { display: none; }

.mbti-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.2s;
}

.mbti-card:hover { border-color: var(--accent); }

.mbti-option input:checked + .mbti-card {
    border-color: var(--accent);
    background: var(--accent-light);
}

.mbti-letter {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.mbti-option input:checked + .mbti-card .mbti-letter {
    background: var(--accent);
    color: white;
}

.mbti-info strong { display: block; margin-bottom: 0.25rem; font-size: 0.9rem; }
.mbti-info p { margin: 0; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }

.step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
}

.step-actions.single { justify-content: flex-end; }

.btn-prev, .btn-next, .btn-init, .btn-enter {
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-prev {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

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

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

.btn-init {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.btn-init:hover { opacity: 0.9; }

.confirm-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 0.5rem;
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.confirm-row + .confirm-row { border-top: 1px solid var(--border); }

.confirm-label { color: var(--text-secondary); font-size: 0.9rem; }
.confirm-value { font-weight: 600; }
.confirm-mbti { color: var(--accent); font-size: 1.1rem; letter-spacing: 0.05em; }

.init-success {
    text-align: center;
    padding: 1.5rem 0;
}

.success-icon {
    font-size: 3.5rem;
    color: #10b981;
    margin-bottom: 1rem;
}

.init-success h3 { margin-bottom: 0.5rem; }

.btn-enter {
    background: var(--accent);
    color: white;
    margin-top: 1rem;
    padding: 0.75rem 2rem;
}

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

/* ── App Layout ──────────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand i { font-size: 1.2rem; color: var(--accent); }
.sidebar-logo { width: 1.4rem; height: 1.4rem; object-fit: contain; }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.nav-section { margin-bottom: 0.5rem; }

.nav-section-title {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--accent);
}

.nav-item i { font-size: 1rem; width: 20px; text-align: center; }

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    font-size: 0.72rem;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.nav-badge:empty { display: none; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 0.5rem 0;
}

.nav-item-guide {
    margin-bottom: 0.65rem;
}

.sidebar-credit {
    padding: 0.9rem 1.25rem 0.35rem;
    font-size: 0.72rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.42);
    letter-spacing: 0.04em;
}

/* Mobile */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-sidebar);
    color: white;
    align-items: center;
    padding: 0 1rem;
    z-index: 90;
    gap: 0.75rem;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem;
}

.mobile-title { font-weight: 600; font-size: 1rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 95;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.view {
    display: none;
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.view.active { display: block; }

.view-header {
    margin-bottom: 1.5rem;
}

.view-header h3 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

.view-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 1rem;
}

/* ── Filter Bar ──────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.filter-btn {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }

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

.filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

/* ── Note Cards ──────────────────────────────────────────────────────── */

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.note-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

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

.note-card.type-idea { border-left-color: var(--color-idea); }
.note-card.type-project { border-left-color: var(--color-project); }
.note-card.type-book { border-left-color: var(--color-book); }
.note-card.type-paper { border-left-color: var(--color-paper); }
.note-card.type-webinfo { border-left-color: var(--color-webinfo); }
.note-card.type-webnews { border-left-color: var(--color-webnews); }

.note-card-body {
    padding: 1rem 1.25rem;
}

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

.type-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: white;
}

.type-badge-idea { background: var(--color-idea); }
.type-badge-project { background: var(--color-project); }
.type-badge-book { background: var(--color-book); }
.type-badge-paper { background: var(--color-paper); }
.type-badge-webinfo { background: var(--color-webinfo); }
.type-badge-webnews { background: var(--color-webnews); }

.note-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.note-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card-tldr {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

/* ── Loading / Empty States ──────────────────────────────────────────── */

.loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p { margin-bottom: 1rem; }

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

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

.error-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-webnews);
}

.error-state i { font-size: 3rem; }

/* ── Input Panel ─────────────────────────────────────────────────────── */

.input-panel {
    max-width: 680px;
}

.input-type-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.input-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.input-tab:hover { color: var(--accent); }
.input-tab.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.input-textarea {
    width: 100%;
    min-height: 180px;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-textarea:focus { border-color: var(--accent); }

.input-url {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-url:focus { border-color: var(--accent); }

.input-hint {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2.5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.upload-zone i { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.upload-zone p { margin: 0.5rem 0 0.25rem; font-size: 0.9rem; }
.upload-zone small { font-size: 0.8rem; opacity: 0.7; }

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-top: 0.75rem;
    font-size: 0.88rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--color-webnews);
    cursor: pointer;
    padding: 0.2rem;
    margin-left: auto;
}

.btn-process {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin-top: 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-process:hover { background: var(--accent-hover); }
.btn-process:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Pipeline Steps ──────────────────────────────────────────────────── */

.processing-status {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.processing-status h5 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.pipeline-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.step-item {
    display: flex;
    align-items: flex-start;
    padding: 0.45rem 0;
    font-size: 0.88rem;
    border-left: 2px solid var(--border);
    margin-left: 0.6rem;
    padding-left: 1.2rem;
    position: relative;
}

.step-item:last-child { border-left-color: transparent; }

.step-icon {
    position: absolute;
    left: -0.55rem;
    top: 0.45rem;
    width: 1.1rem;
    text-align: center;
    background: var(--bg-card);
    line-height: 1;
}

.step-done { color: var(--text-primary); }
.step-done .step-icon i { font-size: 1.1rem; color: #10b981; }
.step-running { color: var(--accent); font-weight: 600; }
.step-pending { color: var(--text-muted); }
.step-pending .step-icon i { font-size: 0.7rem; }

.step-detail {
    display: block;
    font-size: 0.76rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.processing-result {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
}

.processing-error {
    color: var(--color-webnews);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
    font-size: 0.88rem;
}

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

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    max-width: 760px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.chat-welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.chat-welcome i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
    color: var(--accent);
    opacity: 0.6;
}

.chat-welcome p { margin: 0.25rem 0; }
.chat-welcome .small { font-size: 0.82rem; }

.chat-bubble {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-bubble.user {
    align-items: flex-end;
}

.chat-bubble.assistant {
    align-items: flex-start;
}

.chat-bubble-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    padding: 0 0.5rem;
}

.chat-bubble-content {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
}

.chat-bubble.user .chat-bubble-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant .chat-bubble-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble.assistant .chat-bubble-content p { margin: 0.4rem 0; }
.chat-bubble.assistant .chat-bubble-content p:first-child { margin-top: 0; }
.chat-bubble.assistant .chat-bubble-content p:last-child { margin-bottom: 0; }

.chat-typing {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chat-typing .spinner-border { width: 1rem; height: 1rem; }

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

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 120px;
    transition: border-color 0.2s;
}

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

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Chat View Tabs ─────────────────────────────────────────────────── */

.chat-view-tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.chat-view-tab {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-view-tab:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.chat-view-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.chat-history-panel {
    max-width: 760px;
}

.chat-history-filter {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.chat-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-log-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-log-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.chat-log-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.chat-log-date {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.chat-log-source {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 500;
}

.chat-log-source.source-new {
    background: #eef2ff;
    color: var(--accent);
}

.chat-log-source.source-archived {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.chat-log-filename {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.chat-log-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat log detail */

.chat-log-detail {
    max-width: 760px;
}

.chat-log-detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.btn-back {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-back:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.chat-log-detail-title {
    font-weight: 600;
    font-size: 1rem;
}

.chat-log-detail-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 500;
}

.chat-log-detail-badge.source-new {
    background: #eef2ff;
    color: var(--accent);
}

.chat-log-detail-badge.source-archived {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.chat-log-detail-body {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    line-height: 1.7;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

/* ── Update Panel ────────────────────────────────────────────────────── */

.update-panel {
    max-width: 600px;
}

.update-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.update-info-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.update-info-card > i {
    font-size: 1.5rem;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.update-info-card strong { display: block; margin-bottom: 0.25rem; font-size: 0.9rem; }
.update-info-card p { margin: 0; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }

.update-stats {
    padding: 0.75rem 1rem;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    color: var(--accent);
}

.btn-update {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-update:hover { background: var(--accent-hover); }
.btn-update:disabled { opacity: 0.5; cursor: not-allowed; }

.update-status {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.88rem;
}

.update-progress {
    display: flex;
    align-items: center;
}

.update-result {
    margin-top: 1rem;
    padding: 1rem;
    background: #ecfdf5;
    border-radius: var(--radius-sm);
    color: #059669;
    font-size: 0.88rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.update-error {
    margin-top: 1rem;
    padding: 1rem;
    background: #fef2f2;
    border-radius: var(--radius-sm);
    color: var(--color-webnews);
    font-size: 0.88rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* ── Note Detail Page ────────────────────────────────────────────────── */

.detail-page {
    min-height: 100vh;
    background: var(--bg-primary);
}

.detail-topbar {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.detail-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s;
}

.detail-back:hover { color: var(--accent); }

.detail-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-mark-read {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-mark-read:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-mark-read.is-read {
    background: #ecfdf5;
    border-color: #059669;
    color: #059669;
}

.btn-delete-note {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    transition: all 0.2s;
}

.btn-delete-note:hover {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

.btn-delete-note:disabled,
.btn-mark-read:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.detail-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem;
}

.note-meta-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.note-type-badge {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    color: white;
}

.note-date { color: var(--text-muted); font-size: 0.82rem; }

.note-tags .tag {
    display: inline-block;
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.note-source-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.source-new { background: #dbeafe; color: #1d4ed8; }
.source-archived { background: #e0e7ff; color: #4338ca; }

.note-detail-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

/* ── Obsidian Content Rendering ──────────────────────────────────────── */

.obsidian-content {
    line-height: 1.8;
    font-size: 0.95rem;
}

.obsidian-content h1 { font-size: 1.5rem; margin-top: 2rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.obsidian-content h2 { font-size: 1.3rem; margin-top: 1.8rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--border-light); }
.obsidian-content h3 { font-size: 1.12rem; margin-top: 1.4rem; }
.obsidian-content h4 { font-size: 1.02rem; margin-top: 1.2rem; }

.obsidian-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.88rem;
}

.obsidian-content table th,
.obsidian-content table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.obsidian-content table th {
    background: var(--bg-primary);
    font-weight: 600;
}

.obsidian-content table tr:nth-child(even) td {
    background: #fafbfc;
}

.obsidian-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
}

.obsidian-content code {
    background: #f1f3f5;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.86em;
}

.obsidian-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
}

.obsidian-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.obsidian-content blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-secondary);
}

.obsidian-content ul, .obsidian-content ol {
    padding-left: 1.5rem;
}

.obsidian-content li { margin-bottom: 0.25rem; }

.obsidian-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.personal-notes-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.personal-notes-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.personal-notes-input {
    resize: vertical;
    min-height: 80px;
    font-size: 0.92rem;
}

/* Callouts */
.callout {
    border-left: 4px solid;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: var(--bg-primary);
}

.callout-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.callout-content { font-size: 0.9rem; }
.callout-content p { margin: 0.3rem 0; }

.callout-abstract, .callout-tldr, .callout-summary { border-left-color: #448aff; background: #eef3ff; }
.callout-abstract .callout-title { color: #1a56db; }

.callout-tip, .callout-hint { border-left-color: #00bfa5; background: #e6f7f3; }
.callout-tip .callout-title { color: #047857; }

.callout-note, .callout-info { border-left-color: #448aff; background: #eef3ff; }
.callout-note .callout-title { color: #1a56db; }

.callout-warning, .callout-caution { border-left-color: #ffa726; background: #fff8e1; }
.callout-warning .callout-title { color: #b45309; }

.callout-danger, .callout-error { border-left-color: #ef5350; background: #fde8e8; }
.callout-danger .callout-title { color: #b91c1c; }

.callout-example { border-left-color: #7c3aed; background: #f3e8ff; }
.callout-example .callout-title { color: #6d28d9; }

.callout-quote, .callout-cite { border-left-color: #6c757d; background: #f3f4f6; }
.callout-quote .callout-title { color: #4b5563; }

/* Wikilinks */
.wikilink {
    color: var(--accent);
    border-bottom: 1px dashed var(--accent);
    cursor: default;
}

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

.sidebar-user {
    margin: 0 0 0.75rem;
    padding: 0.85rem 0.95rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user-label {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.sidebar-user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    word-break: break-word;
}

.sidebar-user-limit {
    margin-top: 0.35rem;
    font-size: 0.72rem;
    color: #fbbf24;
    letter-spacing: 0.03em;
}

.nav-item-logout {
    margin-top: 0.35rem;
    color: #fca5a5;
}

.nav-item-logout:hover {
    color: #fecaca;
}

/* ── Persona View ────────────────────────────────────────────────────── */

.view-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.persona-edit-btn {
    white-space: nowrap;
}

.persona-read {
    max-width: 780px;
}

.persona-editor {
    width: 100%;
    min-height: 500px;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: "SFMono-Regular", "Cascadia Code", "Menlo", monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    background: var(--bg-card);
    transition: border-color 0.2s;
    tab-size: 4;
}

.persona-editor:focus {
    border-color: var(--accent);
}

.persona-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.guide-panel {
    max-width: 860px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

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

@media (max-width: 768px) {
    .login-page {
        padding: 1rem;
    }

    .login-panel {
        padding: 1.35rem;
        border-radius: 18px;
    }

    .login-brand {
        flex-direction: column;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--topbar-height);
    }

    .view {
        padding: 1rem;
    }

    .notes-grid {
        grid-template-columns: 1fr;
    }

    .detail-topbar {
        padding: 0.75rem 1rem;
    }

    .detail-container {
        padding: 1rem;
    }

    .note-detail-title {
        font-size: 1.3rem;
    }

    .chat-container {
        height: calc(100vh - 240px);
    }
}
