:root {
  color-scheme: light;
  --bg: #faf6ee;
  --surface: #fffdf8;
  --surface-raised: #fffdf8;
  --surface-soft: #f4edde;
  --surface-accent: #f8eeda;
  --text: #2b2721;
  --text-soft: #71685a;
  --text-faint: #998e7d;
  --line: #e7ddc9;
  --line-strong: #d3c6ab;
  --accent: #b45309;
  --accent-strong: #8f4307;
  --accent-soft: #f6e5c9;
  --accent-contrast: #ffffff;
  --danger: #bd3b42;
  --danger-soft: #fbe9e9;
  --warning: #a96617;
  --shadow-sm: 0 1px 2px rgb(84 62 25 / 5%), 0 4px 16px rgb(84 62 25 / 4%);
  --shadow-lg: 0 24px 70px rgb(84 62 25 / 17%);
  --sidebar-width: 286px;
  --topbar-height: 68px;
  --radius: 14px;
  --radius-sm: 9px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1713;
  --surface: #211d17;
  --surface-raised: #262119;
  --surface-soft: #2b251d;
  --surface-accent: #322817;
  --text: #ede6d7;
  --text-soft: #b3a793;
  --text-faint: #8c8170;
  --line: #3b342a;
  --line-strong: #4e4635;
  --accent: #e2a65a;
  --accent-strong: #f2c17e;
  --accent-soft: #40301a;
  --accent-contrast: #2b1d0a;
  --danger: #ef858a;
  --danger-soft: #3b2527;
  --warning: #e2ae6b;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 15%), 0 4px 16px rgb(0 0 0 / 10%);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / 45%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-height) + 24px); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { color: var(--text); background: var(--accent-soft); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent); outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.skip-link { position: fixed; z-index: 200; left: 16px; top: -80px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-contrast); }
.skip-link:focus { top: 12px; }
.muted { color: var(--text-soft); }
.eyebrow { display: block; margin-bottom: 4px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .16em; }
.mobile-only { display: none !important; }

[data-icon], [data-icon] > span { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
[data-icon] svg, [data-icon] > span svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button > svg, .icon-button > svg, .document-kicker > svg, .document-meta svg, .toast > span > svg, .recent-link > span > svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.document-kicker > svg { width: 15px; height: 15px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-soft); transition: background .18s, color .18s, border-color .18s; }
.icon-button:hover { background: var(--surface-soft); color: var(--text); text-decoration: none; }
.icon-button.subtle { width: 30px; height: 30px; border-radius: 8px; }
.icon-button.subtle svg { width: 17px; height: 17px; }
.icon-button.bordered { border-color: var(--line); background: var(--surface); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 650; font-size: 14px; line-height: 1.3; transition: transform .15s, background .18s, border-color .18s; }
.button:hover { text-decoration: none; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--accent); color: var(--accent-contrast); }
.button.primary:hover { background: var(--accent-strong); }
.button.ghost { border-color: var(--line); background: var(--surface); color: var(--text-soft); }
.button.ghost:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-soft); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { filter: brightness(.92); }
.button.compact { min-height: 34px; padding: 6px 10px; font-size: 12px; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; min-height: 21px; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-soft); color: var(--text-faint); font: 11px var(--font-mono); }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s ease; }
.sidebar { position: sticky; z-index: 30; top: 0; display: flex; flex-direction: column; width: var(--sidebar-width); height: 100vh; overflow: hidden; border-right: 1px solid var(--line); background: var(--surface); }
.brand-row { display: flex; align-items: center; justify-content: space-between; min-height: 84px; padding: 20px 20px 14px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-family: var(--font-serif); font-size: 26px; font-weight: 700; letter-spacing: .14em; line-height: 1.2; }
.brand small { display: block; margin-top: 5px; color: var(--text-faint); font-size: 10px; letter-spacing: .1em; }
.brand-mark { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 34% 30%, #f6cd6e, #e0923a 62%, #c9772a); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent), 0 8px 18px color-mix(in srgb, var(--accent) 24%, transparent); }
.brand-mark::before { position: absolute; content: ""; width: 13px; height: 13px; border-radius: 50%; background: rgb(255 250 236 / 95%); }
.brand-mark::after, .brand-mark span { display: none; }
.search-trigger { display: flex; align-items: center; gap: 9px; margin: 0 16px 18px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--text-soft); font-size: 13px; text-align: left; }
.search-trigger > span:nth-child(2) { flex: 1; }
.search-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.search-trigger svg { width: 16px; height: 16px; }
.tree-heading { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 18px 5px 22px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.tree-heading > div { display: flex; }
.tree { flex: 1; min-height: 0; padding: 0 12px 24px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.tree ul { margin: 0; padding: 0; list-style: none; }
.tree ul ul { margin-left: 13px; padding-left: 7px; border-left: 1px solid var(--line); }
.tree-row { display: flex; align-items: center; min-width: 0; border-radius: 8px; }
.tree-row:hover { background: var(--surface-soft); }
.tree-row.active { background: var(--accent-soft); color: var(--accent-strong); }
.tree-link, .tree-directory { display: flex; flex: 1; align-items: center; gap: 7px; min-width: 0; min-height: 35px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 13px; text-align: left; }
.tree-link:hover, .tree-directory:hover { text-decoration: none; }
.tree-link span:last-child, .tree-directory span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-link svg, .tree-directory svg { width: 16px; height: 16px; color: var(--text-faint); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tree-row.active svg { color: var(--accent); }
.tree-toggle { width: 24px; height: 30px; margin-left: -3px; padding: 0; border: 0; background: transparent; color: var(--text-faint); }
.tree-toggle svg { width: 13px; height: 13px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-empty { padding: 24px 10px; color: var(--text-faint); font-size: 13px; text-align: center; }
.tree-skeleton { padding: 8px; }
.tree-skeleton i { display: block; width: 90%; height: 13px; margin: 15px 4px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-soft), var(--line), var(--surface-soft)); background-size: 200%; animation: shimmer 1.4s infinite; }
.tree-skeleton i:nth-child(2) { width: 70%; margin-left: 20px; }
.tree-skeleton i:nth-child(3) { width: 82%; margin-left: 20px; }
.tree-skeleton i:nth-child(4) { width: 65%; }
.tree-skeleton i:nth-child(5) { width: 77%; margin-left: 20px; }
.sidebar-footer { display: flex; align-items: center; gap: 6px; min-height: 64px; padding: 12px 16px; border-top: 1px solid var(--line); }
.live-status { display: flex; flex: 1; align-items: center; gap: 7px; min-width: 0; color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 12%, transparent); }
.live-status.online .status-dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.live-status.offline .status-dot { background: var(--danger); }
.sidebar-collapsed .app-shell { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar-collapsed .sidebar { visibility: hidden; transform: translateX(-100%); }
.sidebar-scrim { display: none; }

.workspace { min-width: 0; min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; height: var(--topbar-height); padding: 0 clamp(20px, 3vw, 44px); border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); }
.topbar-leading, .topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumbs { display: flex; align-items: center; min-width: 0; color: var(--text-faint); font-size: 12px; white-space: nowrap; overflow: hidden; }
.breadcrumbs a, .breadcrumbs span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.breadcrumbs a { color: var(--text-soft); }
.breadcrumbs .separator { flex: 0 0 auto; margin: 0 7px; color: var(--line-strong); }
.breadcrumbs [aria-current="page"] { color: var(--text); }
.view { width: 100%; min-height: calc(100vh - var(--topbar-height) - 74px); }
.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 18px; max-width: 1440px; margin: 30px auto 0; padding: 22px clamp(20px, 3vw, 44px); border-top: 1px solid var(--line); color: var(--text-faint); font-size: 11px; letter-spacing: .04em; text-align: center; }
.site-footer a { color: var(--text-soft); }
.site-footer a:hover { color: var(--accent); }
.page-loading { display: grid; place-items: center; align-content: center; min-height: 55vh; color: var(--text-soft); }
.page-loading p { margin: 16px 0; }
.spinner { display: inline-block; width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.dashboard { position: relative; max-width: 1280px; margin: 0 auto; padding: clamp(42px, 7vw, 88px) clamp(22px, 5vw, 72px) 50px; overflow: hidden; }
.dashboard::before { position: absolute; z-index: -1; top: -160px; right: -100px; width: 520px; height: 520px; border: 1px solid var(--line); border-radius: 50%; box-shadow: 0 0 0 70px color-mix(in srgb, var(--line) 35%, transparent), 0 0 0 140px color-mix(in srgb, var(--line) 18%, transparent); content: ""; }
.dashboard::after { position: absolute; z-index: -1; top: -140px; left: -140px; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 12%, transparent), transparent 68%); content: ""; }
.dashboard-hero { max-width: 760px; }
.dashboard-hero h1 { margin: 12px 0 20px; font-size: clamp(40px, 6vw, 72px); font-weight: 760; letter-spacing: -.065em; line-height: 1.08; }
.dashboard-hero h1 span { background: linear-gradient(105deg, var(--accent-strong), var(--accent) 75%); -webkit-background-clip: text; background-clip: text; color: transparent; font-family: var(--font-serif); font-weight: 500; }
.dashboard-hero > p { max-width: 590px; margin: 0; color: var(--text-soft); font-size: clamp(16px, 2vw, 19px); line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 720px; margin: 52px 0 56px; }
.stat-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--shadow-sm); }
.stat-card strong { display: block; font-size: 28px; letter-spacing: -.04em; }
.stat-card span { color: var(--text-faint); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, .65fr); gap: 20px; }
.panel { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.panel-heading a { font-size: 12px; }
.recent-list, .principle-list { margin: 0; padding: 0; list-style: none; }
.recent-link { display: flex; align-items: center; gap: 13px; padding: 13px 4px; border-bottom: 1px solid var(--line); color: var(--text); }
.recent-list li:last-child .recent-link { border-bottom: 0; }
.recent-link:hover { text-decoration: none; color: var(--accent); }
.recent-link > span:first-child { display: grid; place-items: center; width: 34px; height: 38px; border-radius: 8px; background: var(--surface-soft); color: var(--accent); }
.recent-link > span:last-child { min-width: 0; }
.recent-link strong, .recent-link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-link strong { font-size: 14px; }
.recent-link small { color: var(--text-faint); font-size: 11px; }
.principle-list li { position: relative; padding: 9px 0 9px 22px; color: var(--text-soft); font-size: 13px; }
.principle-list li::before { position: absolute; left: 2px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); content: ""; }
.principle-list strong { display: block; color: var(--text); font-size: 14px; }

.reader { max-width: 1460px; margin: 0 auto; padding: 38px clamp(20px, 3vw, 44px) 60px; }
.document-header { max-width: 1060px; margin: 0 auto 30px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.document-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.document-header h1 { margin: 0 0 14px; font-size: clamp(30px, 4.3vw, 50px); font-weight: 740; letter-spacing: -.045em; line-height: 1.2; overflow-wrap: anywhere; }
.document-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; color: var(--text-faint); font-size: 12px; }
.document-meta span { display: inline-flex; align-items: center; gap: 6px; }
.document-meta svg { width: 14px; height: 14px; }
.document-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.document-actions .divider { width: 1px; margin: 5px 3px; background: var(--line); }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: clamp(28px, 4vw, 64px); max-width: 1300px; margin: 0 auto; }
.reader-layout.without-toc { grid-template-columns: minmax(0, 1fr); max-width: 1100px; }
.document-main { min-width: 0; }
.toc-column { min-width: 0; }
.toc { position: sticky; top: calc(var(--topbar-height) + 28px); max-height: calc(100vh - var(--topbar-height) - 56px); padding-left: 18px; border-left: 1px solid var(--line); overflow: auto; }
.toc-title { margin: 0 0 12px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.toc a { display: block; padding: 5px 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
.toc a:hover, .toc a.active { color: var(--accent); text-decoration: none; }
.toc a.level-3 { padding-left: 13px; }
.toc a.level-4 { padding-left: 25px; }
.toc-empty { color: var(--text-faint); font-size: 12px; }
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 900px; margin: 48px auto 0; }
.prev-next a { display: flex; flex-direction: column; justify-content: center; min-height: 92px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.prev-next a:hover { border-color: var(--accent); text-decoration: none; }
.prev-next a.next { align-items: flex-end; text-align: right; }
.prev-next small { color: var(--text-faint); font-size: 11px; }
.prev-next strong { margin-top: 5px; font-size: 14px; }

.markdown-body { color: var(--text); font-size: 16px; line-height: 1.85; overflow-wrap: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { position: relative; margin: 2em 0 .75em; font-weight: 700; letter-spacing: -.025em; line-height: 1.4; scroll-margin-top: calc(var(--topbar-height) + 24px); }
.markdown-body h1 { font-size: 2em; }
.markdown-body h2 { margin-top: 2.4em; padding-bottom: .45em; border-bottom: 1px solid var(--line); font-size: 1.55em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1.08em; }
.markdown-body p { margin: 1em 0; }
.markdown-body a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
.markdown-body a:hover { text-decoration-color: var(--accent); }
.markdown-body blockquote { margin: 1.5em 0; padding: 4px 20px; border-left: 3px solid var(--accent); background: var(--surface-accent); color: var(--text-soft); }
.markdown-body blockquote > :first-child { margin-top: 10px; }
.markdown-body blockquote > :last-child { margin-bottom: 10px; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li { margin: .35em 0; }
.markdown-body li::marker { color: var(--accent); }
.markdown-body .task-list-item { list-style: none; margin-left: -1.4em; }
.markdown-body .task-list-item input { width: 15px; height: 15px; margin: 0 8px 0 0; accent-color: var(--accent); vertical-align: -2px; }
.markdown-body hr { height: 1px; margin: 2.5em 0; border: 0; background: var(--line); }
.markdown-body img { max-height: 75vh; margin: 1.5em auto; border-radius: 10px; box-shadow: var(--shadow-sm); }
.markdown-body img.zoomable { cursor: zoom-in; }
.markdown-body code { padding: .16em .4em; border-radius: 5px; background: var(--surface-soft); color: var(--accent-strong); font: .87em var(--font-mono); }
.markdown-body pre { position: relative; max-width: 100%; margin: 1.5em 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); overflow: auto; line-height: 1.65; tab-size: 2; }
.markdown-body pre code { padding: 0; background: transparent; color: inherit; font-size: 13px; }
.code-block { position: relative; }
.code-block pre { margin: 0; }
.code-block { margin: 1.5em 0; }
.code-copy { position: absolute; z-index: 2; top: 9px; right: 9px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text-soft); font-size: 11px; opacity: 0; transition: opacity .18s; }
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy svg { width: 14px; height: 14px; }
.heading-anchor { position: absolute; left: -1.1em; top: .12em; padding: 0 .2em; color: var(--text-faint); font-size: .75em; font-weight: 400; opacity: 0; }
.markdown-body h1:hover .heading-anchor, .markdown-body h2:hover .heading-anchor, .markdown-body h3:hover .heading-anchor, .markdown-body h4:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
.table-wrapper { max-width: 100%; margin: 1.5em 0; border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
.markdown-body table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.55; }
.markdown-body th, .markdown-body td, .data-table th, .data-table td { padding: 10px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; }
.markdown-body th, .markdown-body td { overflow-wrap: anywhere; }
.data-table th, .data-table td { white-space: nowrap; }
.markdown-body th:last-child, .markdown-body td:last-child, .data-table th:last-child, .data-table td:last-child { border-right: 0; }
.markdown-body tr:last-child td, .data-table tr:last-child td { border-bottom: 0; }
.markdown-body th, .data-table th { background: var(--surface-soft); color: var(--text); font-weight: 650; }
.markdown-body tbody tr:hover, .data-table tbody tr:hover { background: var(--surface-accent); }
.data-table th { position: sticky; z-index: 1; top: 0; }
.data-table td { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.table-note { margin: -10px 0 22px; color: var(--text-faint); font-size: 11px; }
.math-block { max-width: 100%; padding: 8px 0; overflow-x: auto; }
.mermaid-block, .chart-block { position: relative; min-height: 100px; margin: 1.6em 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.mermaid-block .mermaid { min-width: 0; padding-bottom: 6px; overflow: auto; }
.mermaid-block svg { max-width: none; height: auto; margin: 0 auto; }
.chart-canvas { width: 100%; height: 390px; }
.visual-zoom { position: absolute; z-index: 2; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text-soft); font-size: 11px; opacity: 0; transition: opacity .18s; }
.visual-zoom svg { width: 13px; height: 13px; }
.mermaid-block:hover .visual-zoom, .chart-block:hover .visual-zoom, .visual-zoom:focus-visible { opacity: 1; }
@media (hover: none) { .visual-zoom { opacity: 1; } }
.zoom-overlay { position: fixed; z-index: 400; inset: 0; display: flex; flex-direction: column; background: rgb(9 17 12 / 62%); backdrop-filter: blur(6px); }
.zoom-dialog { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.zoom-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; color: #fff; }
.zoom-hint { font-size: 12px; opacity: .75; }
.zoom-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.zoom-actions .icon-button { border-color: rgb(255 255 255 / 28%); background: rgb(255 255 255 / 10%); color: #fff; }
.zoom-actions .icon-button:hover { background: rgb(255 255 255 / 22%); color: #fff; }
.zoom-stage { display: grid; flex: 1; min-height: 0; padding: 8px 24px 28px; overflow: auto; }
.zoom-stage > svg, .zoom-stage > img, .zoom-chart-canvas { margin: auto; padding: 16px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); }
.zoom-stage > img { max-width: none; }
.visual-loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; background: var(--surface); color: var(--text-faint); font-size: 12px; }
.visual-error { padding: 16px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.visual-error pre { margin: 10px 0 0; white-space: pre-wrap; }
.text-document { margin: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: 13px/1.75 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.html-preview { width: 100%; min-height: 68vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.pdf-preview { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.image-preview { display: grid; place-items: center; min-height: 240px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.image-preview img { max-height: 75vh; object-fit: contain; }
.workbook-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.workbook-controls label { display: grid; gap: 5px; color: var(--text-soft); font-size: 11px; }
.workbook-controls select { min-width: 120px; padding: 7px 30px 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); }
.workbook-controls .chart-type-control { margin-left: auto; }
.workbook-table { max-height: 480px; margin-bottom: 20px; }
.workbook-chart { height: 360px; margin: 18px 0; }

.directory-page { max-width: 1100px; margin: 0 auto; padding: 48px clamp(20px, 5vw, 64px); }
.directory-heading { margin-bottom: 28px; }
.directory-heading h1 { margin: 8px 0; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.04em; overflow-wrap: anywhere; }
.directory-heading p { color: var(--text-soft); }
.directory-list { display: grid; gap: 10px; }
.directory-item { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .18s, transform .18s; }
.directory-item:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.directory-item-icon { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 42px; border-radius: 9px; background: var(--surface-soft); color: var(--accent); }
.directory-item-main { flex: 1; min-width: 0; color: var(--text); }
.directory-item-main:hover { text-decoration: none; }
.directory-item-main strong, .directory-item-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-item-main small { margin-top: 3px; color: var(--text-faint); font-size: 11px; }
.item-actions { display: flex; flex: 0 0 auto; gap: 1px; }
.empty-state, .error-state { display: grid; place-items: center; max-width: 650px; min-height: 50vh; margin: 0 auto; padding: 60px 24px; text-align: center; }
.empty-state.compact { min-height: 220px; padding: 30px 20px; }
.empty-illustration { position: relative; display: grid; place-items: center; width: 82px; height: 82px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); color: var(--accent); transform: rotate(-4deg); }
.empty-illustration svg { width: 34px; height: 34px; }
.empty-state h1, .empty-state h2, .error-state h1 { margin: 0 0 10px; font-size: 26px; letter-spacing: -.03em; }
.empty-state p, .error-state p { max-width: 480px; margin: 0 0 24px; color: var(--text-soft); }
.error-code { color: var(--accent); font: 12px var(--font-mono); letter-spacing: .16em; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.modal { width: calc(100% - 32px); max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-lg); overflow: auto; }
.modal::backdrop { background: rgb(9 17 12 / 56%); backdrop-filter: blur(5px); }
.modal[open] { animation: modal-in .18s ease-out; }
.small-modal { max-width: 480px; }
.medium-modal { max-width: 720px; }
.modal-card { padding: 26px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.modal-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.modal-heading .icon-button { margin: -6px -8px 0 0; }
.path-context { margin: -5px 0 18px; color: var(--text-faint); font: 11px/1.5 var(--font-mono); overflow-wrap: anywhere; }
.field { display: grid; gap: 7px; margin: 16px 0; color: var(--text-soft); font-size: 12px; font-weight: 600; }
.field input, .field select { width: 100%; min-height: 43px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--text); font-size: 14px; font-weight: 400; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 15%, transparent); }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { margin: 12px 0 0; padding: 9px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 12px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.segmented button { min-width: 72px; padding: 6px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-soft); font-size: 12px; }
.segmented button.active, .segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.search-modal { max-width: 680px; margin-top: min(14vh, 130px); overflow: hidden; vertical-align: top; }
.search-box { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.search-box > span { color: var(--text-faint); }
.search-box input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 17px; }
.search-box input::placeholder { color: var(--text-faint); }
.key-button { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--text-faint); font: 11px var(--font-mono); }
.search-meta { padding: 10px 20px 6px; color: var(--text-faint); font-size: 11px; }
.search-results { min-height: 120px; max-height: min(55vh, 460px); padding: 5px 10px 12px; overflow-y: auto; }
.search-result { display: block; width: 100%; padding: 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; }
.search-result:hover, .search-result.selected { background: var(--surface-accent); }
.search-result strong { display: block; margin-bottom: 3px; font-size: 14px; }
.search-result .result-path { display: block; margin-bottom: 5px; color: var(--text-faint); font: 10px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .result-snippet { display: -webkit-box; color: var(--text-soft); font-size: 12px; line-height: 1.55; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.search-result mark { padding: 0 2px; border-radius: 3px; background: var(--accent-soft); color: var(--accent-strong); }
.search-help { display: flex; gap: 20px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-soft); color: var(--text-faint); font-size: 10px; }
.search-help span { display: flex; align-items: center; gap: 4px; }
.search-placeholder { display: grid; place-items: center; min-height: 120px; padding: 20px; color: var(--text-faint); font-size: 13px; text-align: center; }

.drop-zone { display: grid; place-items: center; min-height: 190px; padding: 24px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-soft); text-align: center; cursor: pointer; transition: border-color .18s, background .18s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: var(--surface-accent); }
.drop-zone > span { margin-bottom: 12px; color: var(--accent); }
.drop-zone > span svg { width: 34px; height: 34px; }
.drop-zone strong { font-size: 14px; }
.drop-zone small { margin-top: 5px; color: var(--text-faint); font-size: 11px; }
.file-selection { max-height: 160px; margin: 14px 0 0; padding: 0; list-style: none; overflow: auto; }
.file-selection li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 3px; border-bottom: 1px solid var(--line); color: var(--text-soft); font-size: 12px; }
.file-selection li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-selection li span:last-child { flex: 0 0 auto; color: var(--text-faint); }

.editor-modal { width: calc(100% - 32px); max-width: 1440px; height: calc(100dvh - 36px); max-height: none; overflow: hidden; }
.editor-card { display: flex; flex-direction: column; height: 100%; padding: 22px 24px; }
.editor-heading { flex: 0 0 auto; margin-bottom: 12px; }
.editor-heading h2 { font-size: 20px; }
.editor-heading .path-context { margin: 3px 0 0; }
.editor-toolbar { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.editor-status { color: var(--text-faint); font-size: 11px; }
.editor-status.dirty { color: var(--warning); }
.editor-workspace { flex: 1; min-height: 0; }
.editor-pane { width: 100%; height: 100%; }
#editor-content { width: 100%; height: 100%; min-height: 250px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; outline: 0; background: var(--surface-soft); color: var(--text); font: 13px/1.75 var(--font-mono); resize: none; tab-size: 2; }
#editor-content:focus { border-color: var(--accent); }
.preview-pane { padding: 20px clamp(16px, 4vw, 48px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: auto; }
.editor-actions { flex: 0 0 auto; margin-top: 14px; }
.editor-actions .muted { margin-right: auto; font-size: 11px; }
.trash-list { max-height: 55vh; margin-top: 20px; overflow: auto; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.trash-item-icon { color: var(--text-faint); }
.trash-item-main { flex: 1; min-width: 0; }
.trash-item-main strong, .trash-item-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-item-main strong { font-size: 13px; }
.trash-item-main small { color: var(--text-faint); font: 10px var(--font-mono); }
.trash-item-actions { display: flex; gap: 6px; }
.confirm-modal { text-align: center; }
.confirm-symbol { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.confirm-symbol svg { width: 25px; height: 25px; }
.confirm-modal h2 { margin: 0 0 10px; font-size: 21px; }
.confirm-modal p { margin: 0; overflow-wrap: anywhere; }
.confirm-modal .modal-actions { justify-content: center; }

.toast-region { position: fixed; z-index: 150; right: 22px; bottom: 22px; display: grid; gap: 10px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease-out; pointer-events: auto; }
.toast > span:first-child { margin-top: 2px; color: var(--accent); }
.toast.error > span:first-child { color: var(--danger); }
.toast.warning > span:first-child { color: var(--warning); }
.toast > span:nth-child(2) { flex: 1; }
.toast button { width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--text-faint); }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: .18s; }
.back-to-top { position: fixed; z-index: 18; right: 24px; bottom: 24px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-raised); color: var(--text-soft); box-shadow: var(--shadow-sm); }
.back-to-top:hover { color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1050px) {
  .reader-layout { grid-template-columns: minmax(0, 1fr); max-width: 900px; }
  .toc-column { position: relative; order: -1; }
  .toc { position: relative; top: auto; max-height: none; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .toc-title { margin: 0; cursor: pointer; }
  .toc nav { display: none; margin-top: 10px; }
  .toc.expanded nav { display: block; }
  .toc a { display: inline-block; margin-right: 14px; }
  .toc a.level-3, .toc a.level-4 { padding-left: 0; }
  .heading-anchor { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 60px; }
  .mobile-only { display: inline-flex !important; }
  .app-shell, .sidebar-collapsed .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(86vw, 310px); visibility: hidden; transform: translateX(-102%); transition: transform .22s ease, visibility .22s; box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .sidebar-collapsed .sidebar { transform: translateX(-102%); }
  .sidebar-open .sidebar-scrim { position: fixed; z-index: 29; inset: 0; display: block; border: 0; background: rgb(9 17 12 / 45%); }
  .topbar { padding: 0 14px; }
  .topbar-leading { gap: 3px; }
  .topbar-actions { gap: 0; }
  #search-trigger { display: none; }
  .breadcrumbs a, .breadcrumbs span { max-width: 105px; }
  .breadcrumbs .separator { margin: 0 4px; }
  .dashboard { padding-top: 40px; }
  .dashboard-hero h1 { font-size: clamp(38px, 12vw, 58px); }
  .dashboard::before { right: -330px; opacity: .7; }
  .stats-grid { margin: 38px 0; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 23px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .reader { padding: 26px 17px 45px; }
  .document-header { margin-bottom: 22px; }
  .document-actions { gap: 6px; }
  .document-actions .button { min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .markdown-body { font-size: 15px; line-height: 1.8; }
  .markdown-body pre { padding: 17px 14px; }
  .code-copy { opacity: 1; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next a { min-height: 76px; }
  .directory-page { padding-top: 32px; }
  .directory-item { gap: 9px; padding: 12px; }
  .directory-item-icon { width: 34px; height: 38px; }
  .item-actions .move-action, .item-actions .order-action { display: none; }
  .modal-card { padding: 22px 19px; }
  .search-modal { margin-top: 18px; }
  .search-help { gap: 10px; }
  .search-help span:last-child { display: none; }
  .editor-modal { width: 100%; max-width: none; height: 100dvh; max-height: none; border-radius: 0; }
  .editor-card { padding: 16px 13px; }
  .editor-actions .muted { display: none; }
  .editor-status { font-size: 10px; }
  .workbook-controls .chart-type-control { margin-left: 0; }
  .workbook-controls label { flex: 1 1 40%; }
  .workbook-controls select { width: 100%; min-width: 0; }
  .chart-canvas { height: 320px; }
  .site-footer { padding: 20px; }
  .back-to-top { right: 16px; bottom: 16px; }
  .toast-region { right: 16px; bottom: 16px; }
}

@media (max-width: 420px) {
  .breadcrumbs a:first-child + .separator, .breadcrumbs a:first-child { display: none; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 13px 10px; }
  .stat-card span { font-size: 10px; }
  .panel { padding: 18px; }
  .document-actions .divider { display: none; }
  .trash-item { flex-wrap: wrap; }
  .trash-item-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  :root, html[data-theme="dark"] { --bg: #fff; --surface: #fff; --text: #111; --text-soft: #444; --line: #ddd; }
  body { background: #fff; }
  .app-shell { display: block; }
  .sidebar, .topbar, .site-footer, .document-actions, .toc-column, .prev-next, .back-to-top, .toast-region, .code-copy { display: none !important; }
  .reader, .directory-page, .dashboard { max-width: none; padding: 0; }
  .reader-layout { display: block; }
  .document-header { max-width: none; }
  .markdown-body { color: #111; font-size: 11pt; }
  .markdown-body pre, .table-wrapper, .mermaid-block, .chart-block { break-inside: avoid; }
  .mermaid-block svg { max-width: 100% !important; }
  .visual-zoom, .zoom-overlay { display: none !important; }
  .markdown-body a { color: #111; }
  .html-preview, .pdf-preview { min-height: 90vh; }
}

.quick-links { display: flex; gap: 8px; margin: -6px 16px 16px; }
.quick-link { display: flex; flex: 1; align-items: center; justify-content: center; gap: 7px; padding: 8px 10px; border-radius: 9px; color: var(--text-soft); font-size: 12px; transition: background .18s, color .18s; }
.quick-link:hover { background: var(--surface-soft); color: var(--accent); text-decoration: none; }
.quick-link svg { width: 15px; height: 15px; }
.doc-tag { padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; }
.archive-page { max-width: 880px; margin: 0 auto; padding: 48px clamp(20px, 5vw, 64px) 60px; }
.archive-year { margin-bottom: 36px; }
.archive-year > h2 { display: flex; align-items: baseline; gap: 12px; margin: 0 0 6px; color: var(--accent); font-family: var(--font-serif); font-size: 34px; font-weight: 600; }
.archive-year > h2 span { color: var(--text-faint); font-family: var(--font-sans); font-size: 12px; }
.archive-month h3 { margin: 20px 0 4px; color: var(--text-faint); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.archive-month ul { margin: 0; padding: 0; list-style: none; }
.archive-item { position: relative; display: flex; align-items: baseline; gap: 12px; padding: 8px 0 8px 20px; border-left: 1px solid var(--line); }
.archive-item::before { position: absolute; left: -4px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); content: ""; }
.archive-item time { flex: 0 0 auto; color: var(--text-faint); font: 12px var(--font-mono); }
.archive-item a { flex: 1; min-width: 0; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.archive-item a:hover { color: var(--accent); }
.archive-item small { flex: 0 0 auto; color: var(--text-faint); font-size: 11px; }
@media (max-width: 640px) { .archive-item small { display: none; } }

.hidden-badge { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid var(--accent); border-radius: 5px; color: var(--accent); font-size: 10px; line-height: 1.6; vertical-align: middle; }
.tree-link .hidden-badge, .tree-directory .hidden-badge { flex: 0 0 auto; margin-left: auto; }
.audit-list { display: grid; gap: 2px; max-height: 55vh; overflow: auto; }
.audit-row { display: grid; grid-template-columns: 148px 84px minmax(0, 1fr) auto; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 12px; align-items: baseline; }
.audit-row time { color: var(--text-faint); font: 11px var(--font-mono); }
.audit-event { color: var(--accent-strong); font-weight: 600; }
.audit-detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.audit-ip { color: var(--text-faint); font: 10px var(--font-mono); }

.tree-row.drag-source { opacity: .45; }
.tree-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tree-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.tree-row.drop-inside { outline: 1px dashed var(--accent); background: var(--accent-soft); }
.tree-root-drop { display: none; margin: 10px 4px 8px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--text-faint); font-size: 12px; text-align: center; }
.tree.dragging .tree-root-drop { display: block; }
.tree-root-drop.drop-inside { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.directory-item-main .doc-tag { margin-left: 6px; }
