:root {
    --bg: #0e0e0e;
    --surface: #141414;
    --border: #222;
    --text: #d4d4d4;
    --text-muted: #555;
    --text-dim: #888;
    --active: #f0f0f0;
    --mono: 'DM Mono', monospace;
    --sans: 'DM Sans', sans-serif;
}

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

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }

.app { display: flex; height: 100vh; overflow: hidden; padding-top: 80px; }

.sidebar { width: 220px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 28px 20px 20px; border-bottom: 1px solid var(--border); }
#sidebar-title { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
#sidebar-subtitle { display: block; font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--active); margin-top: 4px; }

.nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav::-webkit-scrollbar { display: none; }

.nav-section { display: flex; flex-direction: column; gap: 2px; }

.nav-chapter { width: 100%; background: none; border: none; display: flex; align-items: center; gap: 10px; padding: 9px 20px; cursor: pointer; color: var(--text-muted); font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; text-align: left; transition: color 0.15s; position: relative; }
.nav-chapter:hover { color: var(--text-dim); }
.nav-chapter.active { color: var(--active); }
.nav-chapter.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 2px; height: 16px; background: var(--active); border-radius: 0 1px 1px 0; }
.nav-chapter .num { color: var(--text-muted); font-size: 9px; opacity: 0.5; min-width: 16px; }
.nav-chapter .check { margin-left: auto; width: 5px; height: 5px; border-radius: 50%; background: #2a4a2a; flex-shrink: 0; opacity: 0; }
.nav-chapter.sub-chapter { padding-left: 36px; }
.nav-chapter.sub-chapter::before { left: 4px; }
.nav-chapter.sub-chapter::after { 
    content: ''; 
    position: absolute; 
left: 20px;
    top: 40%; 
    transform: translateY(-50%);
    width: 8px; 
    height: 6px;
    border-left: 1px solid var(--text-dim);
    border-bottom: 1px solid var(--text-dim);
    opacity: 0.4;
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar { display: flex; align-items: center; padding: 0 32px; height: 56px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.chapter-title { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--text-dim); text-transform: uppercase; }

.content-area { flex: 1; overflow: hidden; display: flex; }

.view-pane { flex: 1; overflow-y: auto; padding: 48px 56px; }
.view-pane::-webkit-scrollbar { width: 4px; }
.view-pane::-webkit-scrollbar-track { background: transparent; }
.view-pane::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.view-pane h1 { font-family: var(--sans); font-weight: 400; color: var(--active); font-size: 26px; margin-bottom: 16px; }
.view-pane h2 { font-family: var(--sans); font-weight: 400; color: var(--active); font-size: 18px; margin-top: 32px; margin-bottom: 14px; border-top: 1px solid var(--border); padding-top: 24px; }
.view-pane p { color: var(--text); font-weight: 300; margin-bottom: 14px; max-width: 720px; line-height: 1.75; }
.view-pane code { font-family: var(--mono); font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 2px; padding: 1px 6px; color: var(--text-dim); }
.view-pane pre { background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 18px 20px; margin-bottom: 20px; overflow-x: auto; max-width: 720px; }
.view-pane pre code { background: none; border: none; padding: 0; color: var(--text); }
.view-pane ul, .view-pane ol { margin-bottom: 14px; padding-left: 20px; max-width: 720px; }
.view-pane li { margin-bottom: 6px; line-height: 1.75; }

.state-loading { color: var(--text-muted); }
.state-error { color: #7a3a3a; }