:root {
    --bg: #0d0f0e;
    --sidebar: #111412;
    --surface: #161a17;
    --surface-2: #1b201c;
    --surface-3: #222822;
    --ink: #f1f1e9;
    --soft: #b8bdb2;
    --muted: #727a70;
    --line: #29302a;
    --line-bright: #364137;
    --accent: #cbe86b;
    --accent-ink: #17200e;
    --coral: #ef826b;
    --blue: #83b9dc;
    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'Inter', system-ui, sans-serif;
    --typewriter: 'SFMono-Regular', 'Cascadia Code', 'Roboto Mono', Consolas, 'Liberation Mono', monospace;
    --shadow: 0 22px 60px rgba(0,0,0,.26);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body { font: 13px var(--sans); letter-spacing: -.01em; overflow-x: clip; }
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; appearance: none; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 238px; flex: 0 0 238px; background: var(--sidebar); border-right: 1px solid var(--line); padding: 26px 14px 18px; display: flex; flex-direction: column; }
.brand-lockup { display: flex; align-items: center; gap: 11px; padding: 0 12px 46px; }
.brand-mark { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid var(--accent); color: var(--accent); overflow: hidden; font-size: 0; background: url('/img/authorroom-mark.png') center / cover no-repeat; transform: rotate(-7deg); }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; transform: rotate(7deg) scale(1.24); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.07em; }
.brand-name span { color: var(--soft); font-weight: 400; }
.brand-subtitle { color: var(--muted); font-size: 9px; margin-top: 3px; }
.sidebar-label { color: #697269; font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; padding: 0 12px 11px; }
.main-nav, .book-list { display: grid; gap: 2px; }
.main-nav { margin-bottom: 34px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 12px; background: transparent; color: #8c978c; border-left: 2px solid transparent; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--ink); border-left-color: var(--accent); background: rgba(203,232,107,.06); }
.nav-item i { font-size: 17px; }
.books-label { display: flex; justify-content: space-between; align-items: center; }
.text-button { background: none; color: var(--muted); padding: 0 3px; font-size: 16px; }
.book-link { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 10px 12px; background: none; color: #9aa399; text-align: left; border-left: 2px solid transparent; }
.book-link:hover, .book-link.selected { color: var(--ink); background: rgba(255,255,255,.035); border-left-color: var(--accent); }
.book-link span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-link i { margin-left: auto; color: var(--muted); opacity: 0; }
.book-link:hover i, .book-link.selected i { opacity: 1; }
.book-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; }
.coral { background: var(--coral); } .amber { background: #d8b45d; } .violet { background: #aa8fe9; }
.sidebar-bottom { margin-top: auto; }
.sidebar-bottom > .nav-item { margin-bottom: 16px; }
.profile-card { display: flex; align-items: center; gap: 9px; padding: 16px 8px 0; border-top: 1px solid var(--line); }
.avatar, .mini-avatar { display: grid; place-items: center; border-radius: 50%; background: #806f63; color: #f9efe5; font-weight: 700; }
.avatar { width: 29px; height: 29px; font-size: 9px; }
.profile-copy { display: grid; gap: 3px; min-width: 0; }
.profile-copy strong, .profile-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy strong { font-size: 11px; }
.profile-copy span { color: var(--muted); font-size: 9px; }
.profile-card form { margin-left: auto; }
.profile-menu { padding: 0; background: none; color: var(--muted); font-size: 16px; }

.main-content { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 68px; padding: 0 4vw; border-bottom: 1px solid var(--line); }
.breadcrumbs { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 11px; }
.breadcrumbs strong { overflow: hidden; color: var(--soft); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs i { font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 7px; min-width: 0; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; background: transparent; color: var(--muted); border-radius: 3px; }
.icon-button:hover { color: var(--ink); background: var(--surface-2); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; padding: 0 13px; border-radius: 3px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.primary-button { background: var(--accent); color: var(--accent-ink); }
.primary-button:hover { background: #e2fb8c; }
.ghost-button { background: transparent; border: 1px solid var(--line-bright); color: var(--soft); }
.ghost-button:hover { background: var(--surface-2); color: var(--ink); }
.mobile-menu { display: none; background: none; color: var(--soft); font-size: 20px; }

.workspace-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; max-width: 1420px; padding: 49px 4vw 38px; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
h1 { max-width: 820px; margin-top: 9px; font: 500 clamp(34px, 4vw, 58px)/.95 var(--serif); letter-spacing: -.055em; overflow-wrap: anywhere; }
h2 { font: 500 26px/1 var(--serif); letter-spacing: -.03em; }
.book-meta { margin-top: 12px; color: var(--muted); font-size: 11px; }
.meta-separator { padding: 0 7px; color: var(--line-bright); }

.content-grid { display: grid; grid-template-columns: 228px minmax(480px, 1fr) 286px; width: calc(100% - 8vw); max-width: 1420px; min-height: 680px; margin: 0 4vw 40px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.chapter-panel, .insight-panel { min-width: 0; padding: 26px 18px; background: transparent; }
.chapter-panel { border-right: 1px solid var(--line); }
.insight-panel { border-left: 1px solid var(--line); }
.panel-heading, .insight-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chapter-total, .note-count { margin-left: 4px; color: var(--muted); font: 400 12px var(--sans); vertical-align: middle; }
.small { width: 27px; min-height: 27px; padding: 0; }
.progress-track { height: 2px; margin-top: 25px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.progress-copy { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 9px; }
.chapter-list { display: grid; margin-top: 20px; }
.chapter-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 8px 3px; background: transparent; border-top: 1px solid var(--line); color: #929d92; text-align: left; }
.chapter-item:last-child { border-bottom: 1px solid var(--line); }
.chapter-item:hover, .chapter-item.active { color: var(--ink); background: rgba(255,255,255,.025); }
.chapter-item.active { box-shadow: inset 2px 0 var(--accent); }
.chapter-number { width: 22px; color: var(--muted); font-size: 9px; }
.chapter-copy { display: grid; min-width: 0; gap: 4px; }
.chapter-copy strong { overflow: hidden; font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.chapter-copy small, .chapter-status { color: var(--muted); font-size: 9px; }
.chapter-item > i { margin-left: auto; color: var(--accent); }
.chapter-status { margin-left: auto; }
.notes-link, .all-notes-button { display: flex; align-items: center; gap: 9px; width: 100%; margin-top: 16px; padding: 0 2px; background: none; color: var(--soft); font-size: 11px; text-align: left; }
.notes-link i:last-child, .all-notes-button i { margin-left: auto; color: var(--muted); }

.editor-panel { display: flex; flex-direction: column; min-width: 0; background: #181d19; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 55px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.toolbar-group, .toolbar-right { display: flex; align-items: center; gap: 2px; min-width: 0; }.toolbar-group { position: relative; }
.toolbar-group button { display: grid; place-items: center; min-width: 28px; height: 28px; background: transparent; color: var(--muted); border-radius: 3px; }
.toolbar-group button:hover { background: var(--surface-3); color: var(--ink); }
.toolbar-select { display: flex !important; align-items: center; gap: 5px; width: auto !important; padding: 0 7px; font-size: 10px !important; }
.toolbar-divider { width: 1px; height: 18px; margin: 0 7px; background: var(--line-bright); }
.save-state { margin-right: 12px; color: var(--muted); font-size: 10px; }
.save-dot { display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: var(--accent); }
.save-state.saved { color: var(--muted); }.save-state.saving { color: var(--accent); }.save-state.saving .save-dot { animation: pulse 1s ease-in-out infinite; }.save-state.unsaved { color: #e4bd6b; }.save-state.unsaved .save-dot { background: #e4bd6b; }
.save-button { min-height: 28px; padding: 0 9px; border: 1px solid var(--line-bright); background: transparent; color: var(--soft); font-size: 10px; }.save-button:hover { border-color: var(--accent); color: var(--accent); }.save-button:disabled { cursor: wait; opacity: .8; }@keyframes pulse { 50% { opacity: .35; } }
.format-menu { position: absolute; top: calc(100% + 7px); left: 0; z-index: 10; display: none; min-width: 150px; padding: 5px; border: 1px solid var(--line-bright); background: var(--surface); box-shadow: var(--shadow); }
.format-menu.open { display: grid; }
.format-menu button { display: block; width: 100%; padding: 9px 10px; background: transparent; color: var(--soft); font: 11px var(--sans); text-align: left; }
.format-menu button:hover { background: var(--surface-2); color: var(--ink); }
.writing-surface { flex: 1; min-height: 580px; padding: 68px clamp(34px, 8vw, 120px) 110px; outline: 0; color: #d6d8d0; font: 16px/1.85 var(--typewriter); font-style: normal; overflow-wrap: anywhere; }
.writing-surface h2 { margin: 7px 0 25px; color: var(--ink); font: 500 41px/1 var(--serif); }
.writing-surface p { margin: 0 0 17px; }
.writing-surface .chapter-kicker { margin: 0; color: var(--accent); font: 700 10px var(--sans); letter-spacing: .18em; }
.writing-surface .opening-line { color: #ebebe2; font-style: normal; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; min-height: 43px; padding: 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
kbd { padding: 2px 4px; border: 1px solid var(--line-bright); border-radius: 3px; background: var(--surface-3); font-size: 9px; }

.context-tabs { display: flex; gap: 3px; margin: -26px -18px 25px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.context-tab { padding: 15px 7px 12px; background: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.context-tab.active { border-bottom-color: var(--accent); color: var(--ink); }
.context-view { display: none; }
.context-view.active { display: block; }
.notes-stack { display: grid; gap: 14px; margin-top: 25px; }
.note-card { padding: 13px 0 14px; border-bottom: 1px solid var(--line); background: transparent; }
.note-card p { margin: 10px 0 13px; color: #d3d5ce; font: 16px/1.35 var(--serif); }
.note-card.yellow { border-left: 2px solid #d4b45b; padding-left: 12px; }.note-card.blue { border-left: 2px solid var(--blue); padding-left: 12px; }.note-card.purple { border-left: 2px solid #aa8fe9; padding-left: 12px; }
.note-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.note-top button { background: none; color: var(--muted); }
.note-author { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.mini-avatar { width: 17px; height: 17px; font-size: 7px; }
.plan-mode { display: block; overflow: visible; }
.plan-mode .chapter-panel, .plan-mode .editor-panel { display: none; }
.plan-mode .insight-panel { width: 100%; border: 0; background: transparent; }
.plan-mode .context-tabs { margin: 0 0 24px; padding: 0; }
.plan-canvas { position: relative; min-height: 280px; margin-top: 20px; border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; }
.plan-mode .plan-canvas { height: calc(100vh - 290px); min-height: 560px; }
.plan-node { position: absolute; z-index: 1; width: 165px; padding: 12px; transform: translate(-50%, -50%); border: 1px solid #4e5d38; background: #20291a; color: #edf6d8; box-shadow: 0 12px 22px rgba(0,0,0,.22); }
.plan-node strong { display: block; margin: 5px 0; font-size: 12px; }.plan-node small { color: #a8bb7d; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.plan-node-note { display: block; max-height: 34px; overflow: hidden; color: #c6d3ae; font: 11px/1.45 var(--sans); text-align: left; }
.plan-connect { min-height: 34px; padding: 0 12px; font-size: 10px; }
.plan-help { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; color: var(--muted); font-size: 11px; }
.plan-help span { display: inline-flex; align-items: center; gap: 6px; }
.plan-help i { color: var(--accent); font-size: 14px; }
.plan-lines { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }.plan-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: 17px var(--serif); text-align: center; }
.plan-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 17px; color: var(--muted); font-size: 9px; }.legend-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; }.legend-dot.lime { background: var(--accent); }.legend-dot.coral { background: var(--coral); }.legend-dot.blue { background: var(--blue); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 25px 0; border: 1px solid var(--line); }.metric-grid div { padding: 12px 8px; background: var(--surface-2); }.metric-grid strong { display: block; color: var(--ink); font: 22px var(--serif); }.metric-grid span { color: var(--muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }.streak-badge { margin-top: 6px; color: var(--accent); font-size: 9px; }.analytics-chart { display: flex; align-items: end; gap: 3px; height: 120px; padding: 0 2px; border-bottom: 1px solid var(--line); }.chart-bar { flex: 1; min-height: 3px; background: var(--accent); opacity: .8; }.analytics-caption { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 9px; }
.utility-view { display: none; margin: 0 4vw; padding: 48px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); min-height: 420px; }.utility-view.active { display: block; }.utility-view h2 { margin: 8px 0 12px; font-size: 38px; }.utility-view p { max-width: 480px; color: var(--soft); font: 18px/1.45 var(--serif); }.utility-view .button { margin-top: 25px; }
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 30px; background: radial-gradient(circle at 50% 0, #20291d 0, transparent 42%); }.auth-card { width: min(420px, 100%); padding: 42px 40px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }.auth-brand { padding-bottom: 54px; }.auth-card h1 { margin: 10px 0 12px; font-size: 42px; }.auth-intro { margin-bottom: 29px; color: var(--muted); font-size: 12px; }.auth-card form { display: grid; gap: 17px; }.auth-card label { display: grid; gap: 7px; color: var(--soft); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }.auth-card input { width: 100%; height: 42px; padding: 0 12px; outline: 0; border: 1px solid var(--line-bright); background: var(--bg); color: var(--ink); font: 14px var(--sans); }.auth-card input:focus { border-color: var(--accent); }.auth-submit { width: 100%; height: 42px; margin-top: 8px; }.auth-submit i { margin-left: auto; }.auth-switch { margin-top: 25px; color: var(--muted); font-size: 11px; text-align: center; }.auth-switch a { color: var(--accent); }.form-error { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; padding: 11px; border: 1px solid #734b43; background: #3a2622; color: #f1a896; font-size: 11px; }
.loading-line { padding: 17px 3px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }.editor-placeholder { color: var(--muted) !important; font-style: italic; }
.toast { position: fixed; right: 28px; bottom: 26px; z-index: 5; display: flex; gap: 9px; align-items: center; padding: 12px 16px; background: var(--accent); color: var(--accent-ink); border-radius: 3px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(20px); transition: .25s; }.toast.show { opacity: 1; transform: translateY(0); }
.modal-backdrop { position: fixed; inset: 0; z-index: 6; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.7); }.modal-backdrop.open { display: flex; }.modal-card { position: relative; width: min(430px, 100%); padding: 30px; border: 1px solid var(--line-bright); background: var(--surface-2); box-shadow: var(--shadow); }.modal-card h2 { margin: 8px 0; }.modal-intro { color: var(--muted); font-size: 11px; }.modal-card textarea { display: block; width: 100%; height: 130px; margin: 20px 0; padding: 12px; outline: 0; border: 1px solid var(--line-bright); background: var(--bg); color: var(--ink); font: 16px var(--serif); resize: vertical; }.modal-close { position: absolute; top: 13px; right: 14px; background: none; color: var(--muted); font-size: 18px; }.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.export-card { width: min(520px, 100%); }.export-options { display: grid; gap: 10px; margin-top: 24px; }.export-option { display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; }.export-option:hover { border-color: var(--accent); background: var(--surface-3); }.export-option strong, .export-option small { display: block; }.export-option strong { font-size: 12px; }.export-option small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }.export-option > i { color: var(--muted); }.export-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-bright); color: var(--accent); font-size: 18px; }

.app-view { display: none; }
.app-view.active { display: block; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; max-width: 1420px; padding: 54px 4vw 34px; }
.page-heading h1 { margin-top: 10px; }
.page-heading p { margin-top: 12px; color: var(--muted); font: 17px/1.35 var(--serif); }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: calc(100% - 8vw); max-width: 1420px; margin: 0 4vw; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.library-filter { display: flex; gap: 3px; }
.filter-button { padding: 7px 10px; background: transparent; color: var(--muted); font-size: 10px; }
.filter-button:hover, .filter-button.active { background: var(--surface-2); color: var(--ink); }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; width: calc(100% - 8vw); max-width: 1420px; margin: 28px 4vw 50px; border: 1px solid var(--line); background: var(--line); }
.book-card { position: relative; min-height: 240px; padding: 25px; background: var(--surface); }
.book-card:hover { background: var(--surface-2); }
.book-card-main { display: block; width: 100%; min-height: 184px; padding: 0 34px 0 0; background: transparent; color: var(--ink); text-align: left; }
.book-card-accent { display: block; width: 26px; height: 3px; margin-bottom: 25px; border-radius: 0; }
.book-card h2 { max-width: 270px; margin: 12px 0; overflow-wrap: anywhere; }
.book-card p, .book-card small { display: block; color: var(--muted); font-size: 10px; }
.book-card p span { padding: 0 5px; color: var(--line-bright); }
.book-card small { margin-top: 26px; }
.card-open { position: absolute; right: 19px; bottom: 19px; display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid var(--line-bright); background: transparent; color: var(--soft); }
.card-open:hover { border-color: var(--accent); color: var(--accent); }
.empty-state { grid-column: 1 / -1; padding: 80px 25px; background: var(--surface); text-align: center; }
.empty-mark { margin-bottom: 16px; color: var(--accent); font: 42px var(--serif); }
.empty-state h2 { margin-bottom: 10px; }
.empty-state p { color: var(--muted); font: 16px/1.4 var(--serif); }
.empty-state .button { margin-top: 24px; }
.activity-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; width: calc(100% - 8vw); max-width: 1420px; margin: 0 4vw 28px; border: 1px solid var(--line); background: var(--line); }
.summary-card { min-height: 112px; padding: 20px; background: var(--surface); }
.summary-card span { color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.summary-card strong { display: block; margin-top: 17px; color: var(--ink); font: 34px var(--serif); }
.activity-panel, .settings-panel { width: calc(100% - 8vw); max-width: 1420px; margin: 0 4vw 50px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.activity-panel { padding: 28px; }
.heatmap-panel { overflow: hidden; }
.heatmap-meta { display: flex; justify-content: space-between; gap: 20px; margin: 24px 0 12px; color: var(--muted); font-size: 10px; }
.writing-heatmap { width: 100%; overflow-x: auto; padding-bottom: 4px; }
.heatmap-grid { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 4px; min-width: 900px; }
.heat-cell { width: 13px; height: 13px; border: 1px solid rgba(255,255,255,.035); background: var(--surface-3); }
.heat-cell.level-1 { background: #536735; }.heat-cell.level-2 { background: #789546; }.heat-cell.level-3 { background: #a7c75b; }.heat-cell.level-4 { background: var(--accent); }
.heatmap-months { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 9px; }
.panel-title h2 { margin-top: 8px; }
.library-activity-list { margin-top: 25px; border-top: 1px solid var(--line); }
.activity-row { display: grid; grid-template-columns: 1fr auto 22px; align-items: center; gap: 15px; width: 100%; padding: 15px 4px; border-bottom: 1px solid var(--line); background: transparent; color: var(--soft); text-align: left; }
.activity-row:hover { color: var(--ink); }
.activity-row strong { color: var(--accent); font-size: 10px; font-weight: 500; }
.activity-row i { color: var(--muted); }
.settings-panel { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 23px 27px; }
.settings-panel div { display: grid; gap: 6px; }.settings-panel strong { font-size: 12px; }.settings-panel span { color: var(--muted); font-size: 11px; }
.editor-head { display: grid; grid-template-columns: 1fr minmax(220px, 2fr) 1fr; align-items: center; gap: 20px; width: calc(100% - 8vw); max-width: 1420px; margin: 0 4vw; padding: 36px 0 30px; border-bottom: 1px solid var(--line); }
.back-button { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 8px 0; background: transparent; color: var(--muted); font-size: 10px; }.back-button:hover { color: var(--ink); }.back-button i { font-size: 15px; }
.editor-book-title { min-width: 0; text-align: center; }.editor-book-title h1 { max-width: none; margin-top: 7px; font-size: clamp(30px, 4vw, 52px); }
.editor-head-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }
.action-menu-wrap { position: relative; }.action-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 3; display: none; width: 190px; padding: 5px; border: 1px solid var(--line-bright); background: var(--surface-2); box-shadow: var(--shadow); }.action-menu.open { display: grid; }.action-menu button { display: flex; align-items: center; gap: 9px; padding: 10px; background: transparent; color: var(--soft); font-size: 10px; text-align: left; }.action-menu button:hover { background: var(--surface-3); color: var(--ink); }.action-menu button i { width: 15px; }.action-menu .danger-action:hover { color: #ff9f8b; }
.editor-layout { display: grid; grid-template-columns: 228px minmax(480px, 1fr) 286px; width: calc(100% - 8vw); max-width: 1420px; min-height: 680px; margin: 0 4vw 40px; border-bottom: 1px solid var(--line); }
.editor-layout .chapter-panel, .editor-layout .insight-panel { min-width: 0; padding: 26px 18px; background: transparent; }.editor-layout .chapter-panel { border-right: 1px solid var(--line); }.editor-layout .insight-panel { border-left: 1px solid var(--line); }
.modal-label { display: grid; gap: 7px; margin-top: 20px; color: var(--soft); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }.modal-label input { width: 100%; height: 42px; padding: 0 12px; outline: 0; border: 1px solid var(--line-bright); background: var(--bg); color: var(--ink); font: 14px var(--sans); }.modal-label input:focus, .modal-label textarea:focus { border-color: var(--accent); }.modal-label textarea { margin: 0; }
.danger-button { background: #a94f43; color: #fff2ed; }.danger-button:hover { background: #c26455; }
.toast.error { background: #b45d4e; color: #fff6f2; }.spin { display: inline-block; animation: spin .8s linear infinite; }@keyframes spin { to { transform: rotate(360deg); } }
.plan-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(203,232,107,.25), 0 12px 22px rgba(0,0,0,.22); }
.archived-card { display: flex; flex-direction: column; justify-content: space-between; gap: 25px; min-height: 180px; }.archived-card .button { align-self: flex-start; }
.chapter-item { position: relative; display: flex; align-items: center; gap: 4px; padding-right: 0; }
.chapter-select { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 54px; padding: 8px 3px; background: transparent; color: inherit; text-align: left; }
.chapter-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .15s ease; }.chapter-item:hover .chapter-actions, .chapter-item.active .chapter-actions { opacity: 1; }
.chapter-action { display: grid; place-items: center; width: 25px; height: 25px; background: transparent; color: var(--muted); font-size: 12px; }.chapter-action:hover { color: var(--ink); background: var(--surface-3); }.chapter-action.danger-action:hover { color: #ff9f8b; }

/* The editor is the primary workspace: give it the full viewport and keep its chrome quiet. */
.editor-view { width: 100%; }
.editor-head { width: 100%; max-width: none; margin: 0; padding: 18px 28px 16px; }
.editor-book-title h1 { font-size: clamp(26px, 3vw, 40px); }
.editor-layout { width: 100%; max-width: none; margin: 0; min-height: calc(100vh - 145px); }
.editor-layout .writing-surface { min-height: calc(100vh - 245px); }
.nav-item, .book-link, .button, .filter-button { font-size: 12px; }
.eyebrow, .sidebar-label, .toolbar-group button, .save-state, .progress-copy, .chapter-copy small, .chapter-status, .book-card p, .book-card small, .activity-row strong, .summary-card span, .settings-panel span { font-size: 10px; }
.breadcrumbs, .book-meta, .profile-copy span, .modal-intro, .auth-intro { font-size: 12px; }
.chapter-copy strong, .notes-link, .all-notes-button, .activity-row, .settings-panel strong { font-size: 12px; }
.note-card p { font-size: 17px; }
.note-actions { display: inline-flex; gap: 4px; margin-left: auto; }.note-actions button { padding: 2px; background: transparent; color: var(--muted); }.note-actions button:hover { color: var(--ink); }.note-actions button:last-child:hover { color: #ff9f8b; }

/* Editor viewport: the app chrome stays fixed while only the writing/context columns scroll. */
.editor-view { height: calc(100vh - 68px); overflow: hidden; }
.editor-head { display: flex; align-items: center; width: 100%; max-width: none; margin: 0; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.back-button { flex: 0 0 auto; }
.editor-book-title { flex: 1; min-width: 0; text-align: left; }
.editor-book-title h1 { margin-top: 4px; font-size: clamp(25px, 2.5vw, 36px); }
.editor-head-actions { flex: 0 0 auto; }
.editor-layout { grid-template-columns: minmax(190px, 220px) minmax(0, 1fr) minmax(220px, 300px); height: calc(100% - 82px); min-height: 0; border: 0; overflow: hidden; }
.editor-layout .chapter-panel, .editor-layout .insight-panel, .editor-layout .editor-panel { min-height: 0; height: 100%; overflow-y: auto; }
.editor-layout .editor-panel { overflow: hidden; }
.editor-layout .writing-surface { min-height: 0; height: calc(100% - 98px); overflow-y: auto; }
.editor-layout .editor-footer { flex: 0 0 43px; }
.editor-layout .progress-track, .editor-layout .progress-copy, .editor-layout .notes-link { display: none; }
.editor-head-actions { min-width: 0; }

@media (max-width: 760px) {
    .app-shell, .main-content { width: 100%; max-width: 100%; overflow-x: hidden; }
    .editor-view { height: auto; min-height: calc(100vh - 60px); overflow: visible; }
    .editor-head { display: grid; height: auto; }
    .editor-layout { height: auto; min-height: 0; overflow: visible; }
    .editor-layout .chapter-panel, .editor-layout .insight-panel, .editor-layout .editor-panel { height: auto; overflow: visible; }
    .editor-layout .writing-surface { height: auto; min-height: 530px; overflow: visible; }
}

@media (min-width: 761px) {
    .app-shell { width: 100vw; max-width: 100vw; overflow: visible; }
    .main-content { flex: 1 1 0; width: calc(100vw - 238px); max-width: calc(100vw - 238px); min-width: 0; overflow: visible; }
    .editor-view, .editor-layout { width: 100%; min-width: 0; max-width: 100%; }
    .editor-layout { grid-template-columns: 200px minmax(0, 1fr) minmax(0, 260px); }
    .editor-layout .insight-panel { min-width: 0; overflow-x: hidden; }
    .context-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; overflow: hidden; }
    .context-tab { width: 100%; min-width: 0; padding-left: 2px; padding-right: 2px; font-size: 9px; }
    .editor-layout { grid-template-columns: 200px minmax(0, 1fr); padding-right: 300px; }
    .editor-view, .editor-layout { overflow: visible; }
    .editor-layout .insight-panel { position: fixed; top: 143px; left: calc(100vw - 300px); right: auto; bottom: 0; z-index: 3; display: block; width: 300px; max-width: none; min-width: 0; height: auto; padding: 26px 18px; box-sizing: border-box; border-top: 0; border-right: 0; border-bottom: 0; border-left: 1px solid var(--line); background: var(--bg); overflow-x: hidden; overflow-y: auto; }
}

.editor-context-nav { display: flex; align-items: stretch; gap: 4px; width: 100%; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--bg); }
.editor-context-tab { min-width: 100px; padding: 13px 15px 11px; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.editor-context-tab:hover, .editor-context-tab.active { border-bottom-color: var(--accent); color: var(--ink); }
.editor-layout.context-open { display: block; height: calc(100% - 127px); padding: 0; overflow: auto; }
.editor-layout.context-open .chapter-panel, .editor-layout.context-open .editor-panel { display: none; }
.editor-layout.context-open .insight-panel { position: static; display: block; width: 100%; max-width: none; min-width: 0; height: auto; min-height: calc(100vh - 230px); padding: 38px clamp(24px, 6vw, 100px) 80px; border: 0; background: var(--bg); overflow: visible; }
.editor-layout.context-open .context-view { display: none; max-width: 1180px; margin: 0 auto; }
.editor-layout.context-open .context-view.active { display: block; }
.editor-layout.context-open .context-view .insight-head { align-items: end; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.editor-layout.context-open .context-view h2 { font-size: clamp(32px, 4vw, 52px); }
.editor-layout.context-open .notes-stack { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 30px; }
.editor-layout.context-open .note-card { min-height: 170px; padding: 18px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); }
.editor-layout.context-open .plan-canvas { min-height: calc(100vh - 330px); height: auto; margin-top: 30px; }
.editor-layout.context-open .analytics-chart { height: 240px; margin-top: 35px; }
.editor-layout.context-open .analytics-chart { display: block; height: auto; padding: 0 0 5px; border: 0; overflow-x: auto; }
.editor-layout.context-open .analytics-chart .heatmap-grid { min-width: 900px; }

@media (max-width: 760px) {
    .editor-context-nav { padding: 0 16px; overflow-x: auto; }
    .editor-context-tab { min-width: 92px; padding-left: 10px; padding-right: 10px; }
    .editor-layout.context-open { height: auto; overflow: visible; }
    .editor-layout.context-open .insight-panel { min-height: 600px; padding: 30px 18px 70px; }
    .editor-layout.context-open .notes-stack { grid-template-columns: 1fr; }
}
.writing-surface p, .writing-surface li, .writing-surface blockquote { font-family: var(--typewriter); font-style: normal; }

[data-theme=light] { --bg:#f4f3ee; --sidebar:#e9ebe4; --surface:#fffefa; --surface-2:#f7f7f0; --surface-3:#eef0e7; --ink:#242823; --soft:#596158; --muted:#7c857c; --line:#d9ded5; --line-bright:#c4ccc0; }
@media (max-width: 1180px) { .content-grid { grid-template-columns: 210px minmax(420px,1fr); }.editor-layout { grid-template-columns: 180px minmax(0,1fr) 220px; }.editor-layout .insight-panel { display: block; }.library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 4; width: 238px; transform: translateX(-100%); transition: transform .25s; }.sidebar.open { transform: translateX(0); }.mobile-menu { display: grid; place-items: center; margin-right: 8px; }.topbar { height: 60px; padding: 0 18px; }.breadcrumbs span,.breadcrumbs i { display: none; }.topbar-actions { gap: 2px; }.topbar-actions .button span { display: none; }.topbar-actions .button { padding: 0 9px; }.workspace-head { align-items: flex-start; padding: 32px 18px 25px; }.workspace-head .ghost-button span { display: none; }.page-heading { align-items: flex-start; padding: 34px 18px 24px; }.page-heading .button { margin-top: 5px; }.page-heading p { font-size: 16px; }.library-toolbar, .activity-summary, .activity-panel, .settings-panel { width: calc(100% - 24px); margin-right: 12px; margin-left: 12px; }.library-toolbar { align-items: flex-start; flex-direction: column; gap: 10px; }.library-grid { grid-template-columns: 1fr; width: calc(100% - 24px); margin-right: 12px; margin-left: 12px; }.activity-summary { grid-template-columns: 1fr 1fr; }.editor-head { grid-template-columns: 1fr auto; width: 100%; margin: 0; padding: 14px 16px; }.editor-book-title { grid-column: 1 / -1; grid-row: 1; text-align: left; }.editor-head-actions { grid-column: 1 / -1; grid-row: 2; justify-self: start; }.back-button { grid-column: 1 / -1; grid-row: 3; }.editor-layout { display: block; width: 100%; margin: 0 0 30px; }.editor-layout .chapter-panel { border-right: 0; border-bottom: 1px solid var(--line); }.chapter-list { grid-template-columns: 1fr 1fr; }.chapter-item:nth-child(n+5) { display: none; }.editor-panel { min-height: 640px; }.writing-surface { min-height: 530px; padding: 45px 25px 80px; font-size: 17px; }.writing-surface h2 { font-size: 33px; }.editor-toolbar { padding: 0 8px; }.toolbar-select,.toolbar-divider:nth-of-type(2) { display: none !important; }.editor-layout .insight-panel { display: block; border-left: 0; border-top: 1px solid var(--line); }.plan-mode .plan-canvas { min-height: 440px; height: calc(100vh - 220px); }.plan-node { width: 135px; }.utility-view { margin: 0 12px; padding: 32px 22px; }.settings-panel { align-items: flex-start; flex-direction: column; } }

@media (min-width: 761px) {
    html, body { height: 100%; overflow: hidden; }
    .editor-view { display: flex; flex-direction: column; height: calc(100vh - 68px); min-height: 0; overflow: hidden; }
    .editor-head, .editor-context-nav { flex: 0 0 auto; }
    .editor-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); flex: 1 1 auto; width: 100%; height: auto; min-height: 0; margin: 0; padding: 0; overflow: hidden; }
    .editor-layout:not(.context-open) .insight-panel { display: none; }
    .editor-layout:not(.context-open) .chapter-panel { height: 100%; min-width: 0; overflow-y: auto; }
    .editor-layout:not(.context-open) .editor-panel { height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
    .editor-layout:not(.context-open) .writing-surface { height: calc(100% - 98px); min-height: 0; padding: 32px 34px 64px; overflow-y: auto; }
    .editor-layout.context-open { display: block; flex: 1 1 auto; height: auto; min-height: 0; overflow-y: auto; }
    .editor-layout.context-open .insight-panel { display: block; position: static; width: 100%; max-width: none; min-width: 0; min-height: 100%; padding: 34px clamp(24px, 6vw, 100px) 70px; box-sizing: border-box; }
    .editor-layout.context-open .context-view.active { display: block; width: 100%; max-width: none; margin: 0; }
}

@media (max-width: 760px) {
    html, body { overflow-x: hidden; }
    .editor-layout:not(.context-open) .insight-panel { display: none; }
    .editor-layout:not(.context-open) .writing-surface { padding: 32px 22px 64px; }
}

.chapter-list.locked { opacity: .62; }
.chapter-list.locked .chapter-select, .chapter-list.locked .chapter-action { cursor: wait; }
.chapter-list.locked::after { content: 'Saving changes…'; display: block; padding: 12px 14px; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.plan-field { display: none; }
#add-note { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: auto; min-width: 92px; padding: 0 11px; border: 1px solid var(--line-bright); background: transparent; color: var(--soft); }
#add-note::after { content: 'Add note'; font: 600 10px var(--sans); letter-spacing: .02em; }
#add-note:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
#notes-modal .modal-card { width: min(560px, 100%); }
#notes-modal textarea { min-height: 190px; font: 15px/1.6 var(--typewriter); }
html.has-book-route #library-view { display: none !important; }

/* Final editor sizing: one viewport, no document scroll, and no hidden third column in Writing mode. */
@media (min-width: 761px) {
    html, body { height: 100%; overflow: hidden; }
    .app-shell, .main-content, .editor-view { min-height: 0; }
    .app-view.editor-view { display: none; }
    .app-view.editor-view.active { display: flex; }
    .editor-view { display: flex; flex-direction: column; height: calc(100vh - 68px); overflow: hidden; }
    .editor-head { flex: 0 0 auto; }
    .editor-context-nav { flex: 0 0 auto; }
    .editor-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); flex: 1 1 auto; width: 100%; height: auto; min-height: 0; margin: 0; padding: 0; overflow: hidden; }
    .editor-layout:not(.context-open) .insight-panel { display: none; }
    .editor-layout:not(.context-open) .chapter-panel { min-width: 0; height: 100%; overflow-y: auto; }
    .editor-layout:not(.context-open) .editor-panel { min-width: 0; height: 100%; min-height: 0; overflow: hidden; }
    .editor-layout:not(.context-open) .writing-surface { height: calc(100% - 98px); min-height: 0; padding: 32px 34px 64px; overflow-y: auto; }
    .editor-layout.context-open { display: block; flex: 1 1 auto; height: auto; min-height: 0; overflow-y: auto; }
    .editor-layout.context-open .insight-panel { min-height: 100%; padding: 34px clamp(24px, 6vw, 100px) 70px; }
}

@media (max-width: 760px) {
    html, body { overflow-x: hidden; }
    .app-view.editor-view.active { display: block; }
    .editor-layout:not(.context-open) .insight-panel { display: none; }
    .editor-layout:not(.context-open) .writing-surface { padding: 32px 22px 64px; }
}
