/* ── Variables ─────────────────────────────────────── */
:root {
  --bg:          oklch(13.5% 0.015 285);
  --sidebar-bg:  oklch(10.5% 0.018 285);
  --surface:     oklch(17.5% 0.016 285);
  --surface-2:   oklch(22%   0.020 285);
  --border:      oklch(27%   0.022 285);
  --border-soft: oklch(20%   0.016 285);
  --text:        oklch(88%   0.008 280);
  --text-2:      oklch(64%   0.018 280);
  --text-muted:  oklch(45%   0.016 280);
  --accent:      oklch(68%   0.115 300);
  --accent-h:    oklch(74%   0.130 300);
  --accent-bg:   oklch(19%   0.032 295);
  --code-bg:     oklch(16%   0.013 285);
  --sidebar-w:   260px;
  --topbar-h:    52px;
  --font:        'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --radius:      6px;
  --radius-lg:   10px;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }

/* ── App shell ─────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border); position: fixed; top: 0; left: 0; bottom: 0; display: flex; flex-direction: column; overflow: hidden; z-index: 20; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Topbar ────────────────────────────────────────── */
.topbar { height: var(--topbar-h); background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 10; flex-shrink: 0; }
.topbar-search-btn { flex: 1; max-width: 380px; height: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--text-muted); font-size: 13.5px; cursor: pointer; transition: border-color 0.15s; }
.topbar-search-btn:hover { border-color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 32px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; border: none; transition: background 0.15s, color 0.15s; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: oklch(60% 0.18 20); border: 1px solid oklch(35% 0.10 20); }
.btn-danger:hover { background: oklch(20% 0.04 20); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { padding: 0; width: 32px; justify-content: center; }
.user-chip { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); padding: 4px 10px; background: var(--surface); border-radius: 999px; border: 1px solid var(--border); }
.user-chip span { font-weight: 500; color: var(--text); }
.page-area { flex: 1; display: flex; justify-content: center; }

/* ── Sidebar ───────────────────────────────────────── */
.sidebar-header { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-bottom: 10px; }
.sidebar-logo-mark { width: 28px; height: 28px; background: var(--accent); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.sidebar-world-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-search-wrap { position: relative; }
.sidebar-search-wrap svg { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.sidebar-search { width: 100%; height: 30px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px 0 28px; font-size: 13px; color: var(--text); cursor: pointer; transition: border-color 0.15s; text-align: left; }
.sidebar-search:hover { border-color: var(--accent); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav-section { margin-bottom: 4px; }
.nav-section-header { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px 5px 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); cursor: pointer; user-select: none; transition: color 0.15s; }
.nav-section-header:hover { color: var(--text-2); }
.nav-section-header svg { transition: transform 0.2s; }
.nav-section-header.collapsed svg { transform: rotate(-90deg); }
.nav-items { padding: 0 6px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 10px; border-radius: var(--radius); font-size: 13.5px; color: var(--text-2); cursor: pointer; text-decoration: none; transition: background 0.12s, color 0.12s; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 20%; bottom: 20%; width: 2px; background: var(--accent); border-radius: 1px; }
.nav-item-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.nav-item.active .nav-item-dot { background: var(--accent); }
.sidebar-footer { padding: 10px 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.sidebar-footer-btn { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius); font-size: 13.5px; color: var(--text-2); cursor: pointer; border: none; background: transparent; text-align: left; width: 100%; transition: background 0.12s, color 0.12s; }
.sidebar-footer-btn:hover { background: var(--surface-2); color: var(--text); }
.sidebar-footer-btn.accent { color: var(--accent); }
.sidebar-footer-btn.accent:hover { background: var(--accent-bg); }

/* ── Article layout ────────────────────────────────── */
.article-wrap { display: flex; gap: 56px; max-width: 1060px; width: 100%; padding: 48px 40px 80px; align-items: flex-start; }
.article-body { flex: 1; min-width: 0; max-width: 720px; }
.article-header { margin-bottom: 32px; }
.article-title { font-size: 2.2rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; color: var(--text); margin-bottom: 12px; }
.article-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--text-muted); }
.article-actions { margin-left: auto; display: flex; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 2px 9px; background: var(--surface-2); border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--text-2); border: 1px solid var(--border); transition: background 0.12s, color 0.12s; }
.tag:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); cursor: pointer; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Markdown content ──────────────────────────────── */
.markdown-body { font-size: 15.5px; line-height: 1.78; color: var(--text); }
.markdown-body > * + * { margin-top: 1.15em; }
.markdown-body h1 { font-size: 1.85rem; font-weight: 600; letter-spacing: -0.02em; margin-top: 2.5em; margin-bottom: 0.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.4em; }
.markdown-body h2 { font-size: 1.45rem; font-weight: 600; margin-top: 2.2em; margin-bottom: 0.4em; }
.markdown-body h3 { font-size: 1.15rem; font-weight: 600; margin-top: 1.8em; margin-bottom: 0.3em; }
.markdown-body h4 { font-size: 1rem; font-weight: 600; margin-top: 1.5em; }
.markdown-body p { text-wrap: pretty; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li + li { margin-top: 0.3em; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body a { color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 0.15s; }
.markdown-body a:hover { border-color: var(--accent); }
.markdown-body a.wiki-link { font-weight: 500; }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding: 0.6em 1em; margin: 1.5em 0; background: var(--accent-bg); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-2); font-style: italic; }
.markdown-body code { font-family: var(--font-mono); font-size: 0.875em; background: var(--code-bg); padding: 0.15em 0.4em; border-radius: 4px; }
.markdown-body pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; overflow-x: auto; margin: 1.5em 0; }
.markdown-body pre code { background: none; padding: 0; font-size: 0.875em; line-height: 1.65; }
.markdown-body table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 1.5em 0; }
.markdown-body th { background: var(--surface-2); font-weight: 600; text-align: left; padding: 8px 14px; border: 1px solid var(--border); }
.markdown-body td { padding: 7px 14px; border: 1px solid var(--border-soft); }
.markdown-body tr:nth-child(even) td { background: var(--surface); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-lg); display: block; cursor: pointer; }
.markdown-body .mermaid { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 20px; margin: 1.5em 0; text-align: center; overflow-x: auto; }
.markdown-body .mermaid svg { max-width: 100%; height: auto; }

/* ── Infobox ───────────────────────────────────────── */
.infobox { float: right; clear: right; margin: 0 0 24px 32px; width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; font-size: 13px; }
.infobox-img { width: 100%; height: 200px; object-fit: cover; display: block; }
.infobox-img-placeholder { width: 100%; height: 160px; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 48px; font-weight: 700; }
.infobox-name { padding: 12px 14px 8px; font-weight: 600; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.infobox-table { width: 100%; border-collapse: collapse; }
.infobox-table tr { border-bottom: 1px solid var(--border-soft); }
.infobox-table tr:last-child { border-bottom: none; }
.infobox-table th { padding: 6px 8px 6px 14px; font-weight: 500; color: var(--text-muted); width: 38%; vertical-align: top; font-size: 12px; }
.infobox-table td { padding: 6px 14px 6px 8px; color: var(--text-2); vertical-align: top; }
.infobox-table td a { color: var(--accent); }
.edit-mode .infobox { float: none; width: 100%; margin: 0 0 16px; }

/* ── TOC ───────────────────────────────────────────── */
.toc-wrap { width: 210px; flex-shrink: 0; position: sticky; top: calc(var(--topbar-h) + 28px); max-height: calc(100vh - var(--topbar-h) - 56px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.toc-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 10px; }
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.toc-item { display: block; font-size: 13px; line-height: 1.45; color: var(--text-2); padding: 3px 8px; border-radius: 4px; transition: color 0.12s, background 0.12s; text-decoration: none; border-left: 2px solid transparent; cursor: pointer; }
.toc-item:hover { color: var(--text); background: var(--surface-2); }
.toc-item.active { color: var(--accent); border-left-color: var(--accent); }
.toc-item.depth-2 { padding-left: 18px; }
.toc-item.depth-3 { padding-left: 28px; font-size: 12.5px; }

/* ── Backlinks ─────────────────────────────────────── */
.backlinks { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); }
.backlinks-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 12px; }
.backlinks-list { display: flex; flex-wrap: wrap; gap: 8px; }
.backlink-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-2); text-decoration: none; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.backlink-chip:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* ── Draft banner ──────────────────────────────────── */
.draft-banner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: oklch(22% 0.04 60); border: 1px solid oklch(35% 0.06 60); border-radius: var(--radius); margin-bottom: 20px; font-size: 13px; color: oklch(65% 0.08 60); }

/* ── Lightbox ──────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 100; background: oklch(0% 0 0 / 0.85); display: flex; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(8px); }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-lg); box-shadow: 0 32px 80px oklch(0% 0 0 / 0.5); }
.lightbox-close { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; color: var(--text); font-size: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ── Homepage ──────────────────────────────────────── */
.homepage { flex: 1; }
.home-hero { padding: 64px 56px 48px; border-bottom: 1px solid var(--border); background: linear-gradient(165deg, var(--surface) 0%, var(--bg) 60%); display: flex; align-items: flex-end; gap: 48px; }
.home-hero-text { flex: 1; }
.home-world-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 14px; }
.home-world-name { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); margin-bottom: 16px; }
.home-tagline { font-size: 17px; color: var(--text-2); max-width: 520px; line-height: 1.6; }
.home-hero-actions { display: flex; gap: 10px; margin-top: 28px; }
.home-body { padding: 48px 56px 80px; max-width: 1100px; }
.home-section { margin-bottom: 56px; }
.home-section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.home-section-title { font-size: 15px; font-weight: 600; color: var(--text); }
.home-section-link { font-size: 13px; color: var(--accent); }
.page-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.page-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; text-decoration: none; display: block; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; cursor: pointer; }
.page-card:hover { border-color: var(--accent); box-shadow: 0 4px 20px oklch(68% 0.115 300 / 0.12); transform: translateY(-1px); }
.page-card-title { font-size: 14.5px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.page-card-meta { font-size: 12.5px; color: var(--text-muted); }
.page-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.recent-list { display: flex; flex-direction: column; gap: 0; }
.recent-item { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); text-decoration: none; transition: background 0.1s; cursor: pointer; }
.recent-item:last-child { border-bottom: none; }
.recent-item:hover .recent-item-title { color: var(--accent); }
.recent-item-icon { width: 32px; height: 32px; background: var(--surface-2); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--text-muted); flex-shrink: 0; }
.recent-item-title { font-size: 14px; font-weight: 500; color: var(--text); }
.recent-item-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.recent-item-time { margin-left: auto; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.category-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.category-pill { padding: 6px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--text-2); text-decoration: none; transition: all 0.12s; cursor: pointer; display: inline-block; }
.category-pill:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* ── Live block editor ─────────────────────────────── */
.block-wrap { position: relative; }
.block-wrap + .block-wrap { margin-top: 1.15em; }
.drag-handle { position: absolute; left: -26px; top: 3px; opacity: 0; cursor: grab; color: var(--text-muted); font-size: 15px; line-height: 1; user-select: none; padding: 2px 4px; border-radius: 3px; transition: opacity 0.15s, background 0.12s; }
.block-wrap:hover .drag-handle { opacity: 1; }
.drag-handle:hover { background: var(--surface-2); color: var(--text-2); }
.drag-handle:active { cursor: grabbing; }
.block-dragging { opacity: 0.35; }
.drop-line { height: 2px; background: var(--accent); border-radius: 1px; margin: 2px 0; }
.live-block { display: block; cursor: text; min-height: 1.6em; border-radius: 4px; }
.live-block:hover { outline: 1px solid var(--border-soft); outline-offset: 4px; }
.live-block-active { outline: none !important; }
.live-empty { color: var(--text-muted); font-style: italic; }
/* Textarea styles matching rendered block types */
.seg-ta { width: 100%; background: transparent; border: none; outline: none; resize: none; overflow: hidden; font-family: var(--font); font-size: 15.5px; line-height: 1.78; color: var(--text); caret-color: var(--accent); display: block; padding: 0; border-left: 2px solid var(--accent); padding-left: 10px; margin-left: -12px; }
.seg-ta-h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.seg-ta-h2 { font-size: 1.45rem; font-weight: 600; line-height: 1.3; }
.seg-ta-h3 { font-size: 1.15rem; font-weight: 600; line-height: 1.4; }
.seg-ta-bq { color: var(--text-2); font-style: italic; padding-left: 1.6em; }
.seg-ta-code { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.65; }

/* ── Slash command menu ────────────────────────────── */
.slash-menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 300px; box-shadow: 0 12px 40px oklch(0% 0 0 / 0.45); z-index: 200; overflow: hidden; max-height: 340px; overflow-y: auto; }
.slash-option { display: flex; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--border-soft); }
.slash-option:last-child { border-bottom: none; }
.slash-option:hover, .slash-option.sel { background: var(--accent-bg); }
.slash-icon { width: 28px; height: 28px; background: var(--surface-2); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-2); flex-shrink: 0; font-family: var(--font-mono); }
.slash-label { font-size: 14px; font-weight: 500; color: var(--text); }
.slash-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── Editor chrome ─────────────────────────────────── */
.edit-banner { display: flex; align-items: center; gap: 12px; padding: 8px 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.edit-banner-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); }
.edit-title-input { width: 100%; background: transparent; border: none; outline: none; font-family: var(--font); font-size: 2.2rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; color: var(--text); margin-bottom: 12px; border-bottom: 2px solid transparent; transition: border-color 0.15s; }
.edit-title-input:focus { border-bottom-color: var(--accent); }
.tag-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1; }
.tag-add-input { background: none; border: none; outline: none; font-family: var(--font); font-size: 12px; color: var(--text-muted); min-width: 80px; }
.wikilink-dropdown { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 12px 40px oklch(0% 0 0 / 0.4); min-width: 280px; max-width: 360px; overflow: hidden; z-index: 200; max-height: 300px; overflow-y: auto; }
.wikilink-option { display: flex; flex-direction: column; padding: 8px 14px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--border-soft); }
.wikilink-option:last-child { border-bottom: none; }
.wikilink-option:hover, .wikilink-option.selected { background: var(--accent-bg); }
.wikilink-option-title { font-size: 14px; font-weight: 500; color: var(--text); }
.wikilink-option-slug { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Search overlay ────────────────────────────────── */
.search-overlay { position: fixed; inset: 0; z-index: 50; background: oklch(0% 0 0 / 0.55); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; backdrop-filter: blur(6px); }
.search-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 580px; box-shadow: 0 24px 64px oklch(0% 0 0 / 0.35); overflow: hidden; }
.search-input-wrap { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.search-input-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.search-input { flex: 1; height: 52px; background: transparent; border: none; outline: none; font-family: var(--font); font-size: 16px; color: var(--text); }
.search-input::placeholder { color: var(--text-muted); }
.search-result { display: block; padding: 12px 18px; text-decoration: none; border-bottom: 1px solid var(--border-soft); transition: background 0.1s; cursor: pointer; }
.search-result:hover, .search-result.selected { background: var(--surface-2); }
.search-result-title { font-size: 14.5px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.search-result-context { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-slug { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }
.search-empty { padding: 32px 18px; text-align: center; color: var(--text-muted); font-size: 14px; }
.search-hint { padding: 8px 18px; font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; }
.search-hint kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }

/* ── Login / setup modals ──────────────────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: oklch(0% 0 0 / 0.4); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 380px; padding: 32px; box-shadow: 0 24px 64px oklch(0% 0 0 / 0.15); }
.modal-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.modal-subtitle { font-size: 13.5px; color: var(--text-2); margin-bottom: 28px; }
.form-field { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-input { width: 100%; height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; font-size: 14.5px; color: var(--text); font-family: var(--font); transition: border-color 0.15s; }
.form-input:focus { outline: none; border-color: var(--accent); }
.form-error { font-size: 12.5px; color: oklch(60% 0.18 20); margin-top: 5px; }

/* ── Setup page ────────────────────────────────────── */
.setup-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.setup-card { max-width: 420px; width: 100%; }
.setup-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.setup-logo-mark { width: 36px; height: 36px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; font-weight: 700; }
.setup-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 8px; }
.setup-desc { font-size: 14.5px; color: var(--text-2); margin-bottom: 32px; line-height: 1.6; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh; text-align: center; color: var(--text-muted); gap: 12px; padding: 40px; }
.empty-state-title { font-size: 1.1rem; font-weight: 500; color: var(--text-2); }
.empty-state-desc { font-size: 14px; max-width: 340px; line-height: 1.6; }

/* ── Settings ──────────────────────────────────────── */
.settings-wrap { max-width: 620px; margin: 0 auto; padding: 48px 40px 80px; width: 100%; }
.settings-section { margin-bottom: 48px; }
.settings-section-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.settings-section-desc { font-size: 13.5px; color: var(--text-2); margin-bottom: 20px; }
.settings-divider { height: 1px; background: var(--border); margin: 48px 0; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.user-row-name { font-size: 14px; font-weight: 500; flex: 1; }
.user-row-role { font-size: 12.5px; color: var(--text-muted); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }

/* ── History panel ─────────────────────────────────── */
.history-panel { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 280px; background: var(--sidebar-bg); border-left: 1px solid var(--border); overflow-y: auto; z-index: 30; padding: 20px; transform: translateX(100%); transition: transform 0.25s; }
.history-panel.open { transform: translateX(0); }
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 14px; font-weight: 600; color: var(--text); }
.history-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s; }
.history-item:hover { border-color: var(--accent); }

/* ── Misc ──────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
@media print { .sidebar,.topbar,.toc-wrap,.article-actions,.backlinks,.history-panel { display: none !important; } .main { margin-left: 0 !important; } .article-wrap { padding: 0; max-width: 100%; gap: 0; } .markdown-body { font-size: 11pt; line-height: 1.6; color: #000; } body { background: #fff; color: #000; } }
