:root {
    --bg: #0d0d0f;
    --surface: #17171a;
    --surface-hover: #1e1e22;
    --accent: #5b8def;
    --accent-hover: #75a1f5;
    --accent-tint: rgba(91, 141, 239, 0.14);
    --text: #e4e4e7;
    --text-muted: #8b8b93;
    --border: #26262b;
    --danger: #e5484d;
    --danger-tint: rgba(229, 72, 77, 0.14);
    --success: #30a46c;
    --success-tint: rgba(48, 164, 108, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem 0.75rem; flex-shrink: 0; overflow-y: auto; }
.content { flex: 1; overflow-y: auto; padding: 2rem; }

.public-layout { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { padding: 1.25rem 2rem; border-bottom: 1px solid var(--border); }
.public-header .brand { text-decoration: none; }
.public-content { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 2rem; }
.landing-hero { max-width: 640px; text-align: center; margin: 4rem auto; }
.landing-hero h1 { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 1rem; }
.landing-tagline { color: var(--text-muted); font-size: 1.05rem; line-height: 1.6; margin-bottom: 2rem; }
.landing-actions { display: flex; gap: 0.75rem; justify-content: center; }
.landing-actions .btn { padding: 0.6rem 1.4rem; font-size: 0.95rem; }

.icon { width: 16px; height: 16px; vertical-align: -3px; flex-shrink: 0; }

.brand { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; padding: 0 0.4rem; font-size: 1rem; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.brand-icon { display: inline-flex; color: var(--accent); }
.brand-icon .icon { width: 18px; height: 18px; vertical-align: -4px; }

.nav-link { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.6rem; border-radius: 5px; color: var(--text-muted); text-decoration: none; margin-bottom: 1px; font-size: 0.85rem; font-weight: 500; transition: background 0.1s, color 0.1s; }
.nav-link .icon { color: currentColor; opacity: 0.8; }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--accent-tint); color: var(--accent-hover); }
.nav-section { font-size: 0.68rem; text-transform: uppercase; color: var(--text-muted); margin: 1.1rem 0 0.35rem; padding: 0 0.6rem; letter-spacing: 0.06em; font-weight: 600; opacity: 0.7; }

.sidebar-account { margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.nav-link-button { width: 100%; background: none; border: none; font: inherit; text-align: left; cursor: pointer; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-title { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }
.page-title:focus, .page-title:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-tint); border-radius: 4px; }

.btn { padding: 0.4rem 0.85rem; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-size: 0.83rem; font-weight: 500; transition: background 0.1s, border-color 0.1s, opacity 0.1s; }
.btn-primary { background: var(--accent); color: #0b0d12; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-muted); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-sm { padding: 0.22rem 0.55rem; font-size: 0.78rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; margin-bottom: 0.6rem; }
.card-title { font-weight: 600; margin-bottom: 0.25rem; font-size: 0.95rem; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.3rem; }
.card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.form-group { margin-bottom: 0.75rem; }
label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; font-weight: 500; }
input, textarea, select { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 0.45rem 0.6rem; color: var(--text); font-size: 0.88rem; font-family: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea { resize: vertical; min-height: 80px; }

.inline-form { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; margin-bottom: 1rem; }

.badge { display: inline-flex; align-items: center; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.badge-accent { background: var(--accent-tint); color: var(--accent-hover); }
.badge-muted { background: var(--surface-hover); color: var(--text-muted); }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; text-align: center; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.25rem; }

.loading { color: var(--text-muted); padding: 2rem; text-align: center; font-size: 0.88rem; }
.error { color: var(--danger); padding: 0.5rem; font-size: 0.85rem; }
.empty { color: var(--text-muted); text-align: center; padding: 2rem; font-size: 0.88rem; }

.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; }

.chapter-content { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; font-family: Georgia, serif; line-height: 1.7; white-space: pre-wrap; }

.timeline-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.timeline-column { min-width: 0; }
.timeline-column-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem; }
.timeline-column-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.drag-card { cursor: grab; transition: border-color 0.1s, opacity 0.1s, background 0.1s; }
.drag-card.dragging { opacity: 0.4; cursor: grabbing; }
.drag-card.drag-over { border-color: var(--accent); background: var(--accent-tint); }
.drag-handle { color: var(--text-muted); margin-right: 0.4rem; letter-spacing: -2px; }
@media (max-width: 900px) { .timeline-split { grid-template-columns: 1fr; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; margin-top: 1.5rem; }
.nav-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1.1rem; text-align: center; text-decoration: none; color: var(--text); display: block; transition: border-color 0.15s, background 0.15s; }
.nav-card:hover { border-color: var(--accent); background: var(--surface-hover); color: var(--text); }
.nav-card-icon { color: var(--accent); margin-bottom: 0.6rem; display: flex; justify-content: center; }
.nav-card-icon .icon { width: 22px; height: 22px; }
.nav-card-label { font-size: 0.85rem; font-weight: 600; }

.recent-list { list-style: none; }
.recent-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.recent-item:last-child { border-bottom: none; }

.diag-group { margin-bottom: 1.5rem; }
.diag-group-title { font-weight: 700; margin-bottom: 0.5rem; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; color: var(--text-muted); }

.chat-container { display: flex; flex-direction: column; height: calc(100vh - 200px); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-message { display: flex; }
.chat-message.user { justify-content: flex-end; }
.chat-message.assistant { justify-content: flex-start; }
.chat-bubble { max-width: 75%; padding: 0.6rem 0.9rem; border-radius: 8px; white-space: pre-wrap; line-height: 1.5; font-size: 0.88rem; }
.chat-message.user .chat-bubble { background: var(--accent); color: #0b0d12; border-bottom-right-radius: 2px; }
.chat-message.assistant .chat-bubble { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.chat-typing { color: var(--text-muted); font-style: italic; }
.proposal-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.25rem 0; }
.proposal-card { margin-bottom: 0; border-color: var(--accent); }
.chat-input-bar { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input-bar textarea { flex: 1; min-height: 44px; max-height: 140px; resize: vertical; }
.chat-input-bar .btn { align-self: flex-end; }

@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { width: 180px; } }
