:root {
  --shell-sidebar: #0f172a;
  --shell-sidebar-muted: #a8b8cd;
  --shell-sidebar-border: rgba(148, 163, 184, .22);
  --shell-topbar: #1e293b;
  --workspace: #f3f7f9;
  --panel: #fff;
  --panel-muted: #eaf0f5;
  --border: #d8e0e7;
  --text: #102a43;
  --muted: #475569;
  --primary: #102a43;
  --primary-hover: #0b1f33;
  --focus: #0369a1;
  --radius: 8px;
  --shadow: 0 14px 30px rgba(15, 23, 42, .16);
  --sidebar-width: 272px;
  --topbar-height: 72px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; font: 16px/1.65 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--workspace); color: var(--text); }
body.nav-open { overflow: hidden; }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
button { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; }
button:hover { background: var(--panel-muted); }
button:disabled { opacity: .6; cursor: wait; }
a { color: var(--primary); text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { color: var(--text); background: #bae6fd; }
input { caret-color: var(--primary); }
mark { color: var(--text); background: #fef08a; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: white; padding: 10px 18px; }
.skip-link:focus { top: 12px; }
.layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }
#guideSidebar { position: sticky; top: 0; align-self: start; width: var(--sidebar-width); height: 100svh; display: flex; flex-direction: column; padding: 18px 12px; background: var(--shell-sidebar); color: #e2e8f0; z-index: 30; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; border-bottom: 1px solid var(--shell-sidebar-border); }
.brand-mark { width: 40px; height: 40px; object-fit: contain; flex: 0 0 auto; filter: brightness(0) invert(1); }
.brand-copy { display: grid; min-width: 0; line-height: 1.2; }
.brand-name { color: #f8fafc; font-size: 20px; font-weight: 700; }
.brand-subtitle { color: var(--shell-sidebar-muted); font-size: 12px; margin-top: 4px; }
#sidebar { flex: 1; min-height: 0; overflow: auto; padding: 18px 0; scrollbar-width: thin; scrollbar-color: #475569 transparent; }
.group { margin: 0 0 24px; }
.group h2 { margin: 0 10px 6px; color: var(--shell-sidebar-muted); font-size: 12px; font-weight: 600; }
.page-link { display: block; padding: 8px 10px; margin: 3px 0; border-radius: var(--radius); color: #e2e8f0; font-size: 14px; line-height: 1.5; text-decoration: none; }
.page-link:hover { background: #1e293b; color: white; }
.page-link.active { background: #e2e8f0; color: var(--shell-sidebar); font-weight: 700; }
.plan-badge { display: inline-block; margin-inline-start: 0.5rem; padding: 0 0.35rem; border: 1px solid currentColor; border-radius: 0.25rem; font-size: 0.7rem; font-weight: 600; vertical-align: middle; }
#guideSidebar :focus-visible, .topbar :focus-visible { outline-color: #7dd3fc; }
main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto minmax(180px, 1fr) minmax(100px, 164px); gap: 20px; align-items: center; padding: 14px 28px; background: var(--shell-topbar); color: #f8fafc; min-height: 72px; }
.topbar-title { color: #e2e8f0; text-decoration: none; font-size: 14px; font-weight: 600; }
.icon-button { display: none; width: 40px; height: 40px; flex-shrink: 0; padding: 8px; align-items: center; justify-content: center; border-color: #64748b; color: #f8fafc; background: transparent; }
.icon-button:hover { background: #334155; }
#navClose { margin-left: auto; }
#search { position: relative; min-width: 0; max-width: 620px; width: 100%; justify-self: center; }
.search-field { display: flex; position: relative; border-radius: var(--radius); background: white; }
#searchInput { border: 0; width: 100%; min-width: 0; height: 44px; padding: 8px 100px 8px 14px; border-radius: var(--radius); color: var(--text); background: transparent; font-size: 16px; }
#searchInput::placeholder { color: var(--muted); opacity: 1; }
#searchInput:focus-visible { outline-offset: 2px; }
.search-submit { position: absolute; right: 0; top: 0; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; }
#searchShortcut { position: absolute; right: 48px; align-self: center; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: inherit; font-size: 11px; line-height: 1.7; pointer-events: none; }
#langSelect { position: static; height: 42px; width: 100%; min-width: 0; padding: 0 8px; border: 1px solid #cbd5e1; border-radius: var(--radius); color: var(--text); background: #f8fafc; font-size: 14px; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; width: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(560px, calc(100dvh - var(--topbar-height) - 20px)); overflow: hidden; background: var(--panel); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow); }
#searchOptions { overflow-y: auto; overscroll-behavior: contain; }
#hitCount { font-size: 13px; color: var(--muted); margin: 0; padding: 12px 16px 8px; }
.search-result { display: block; color: var(--text); text-decoration: none; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-result:hover, .search-result[aria-selected="true"] { background: var(--panel-muted); }
.search-result-title { display: block; font-size: 15px; font-weight: 650; line-height: 1.5; }
.search-result-meta, .search-result-snippet { display: block; margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--muted); }
#searchActions { padding: 12px 16px; }
#searchActions:empty { display: none; }
#searchActions p { margin: 0 0 10px; font-size: 14px; }
#searchActions button { width: 100%; text-align: left; }
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) 210px; grid-template-areas: "article outline"; gap: 40px; width: min(1200px, calc(100% - 56px)); margin: 0 auto; padding: 36px 0 48px; align-items: start; }
#content { grid-area: article; min-width: 0; outline: none; overflow-wrap: anywhere; scroll-margin-top: calc(var(--topbar-height) + 24px); }
#content > :is(p, ul, ol, blockquote, h1, h2, h3, h4) { max-width: 72ch; }
#content h1, #content h2, #content h3 { line-height: 1.25; letter-spacing: 0; scroll-margin-top: calc(var(--topbar-height) + 24px); }
#content h1 { margin: 0 0 20px; font-size: 32px; }
#content h2 { margin: 38px 0 12px; font-size: 23px; }
#content h3 { margin: 28px 0 10px; font-size: 19px; }
#content h4 { margin: 24px 0 8px; font-size: 17px; }
#content p { margin: 12px 0; }
#content li { margin: 8px 0; }
#content ul, #content ol { padding-left: 1.4em; }
#content a { font-weight: 600; }
#content a:hover { text-decoration-thickness: 2px; }
#content blockquote { margin: 20px 0; padding: 12px 18px; background: #e6edf3; border-radius: var(--radius); }
#content hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.table-scroll { overflow-x: auto; margin: 16px 0 24px; }
#content table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); line-height: 1.6; }
#content th, #content td { padding: 12px; border: 1px solid var(--border); vertical-align: top; min-width: 100px; }
#content th { text-align: left; background: #e9f0f5; }
#content img { display: block; max-width: 100%; height: auto; }
.image-zoom { display: block; width: 100%; padding: 0; margin: 20px 0; overflow: hidden; border-color: var(--border); background: white; text-align: left; }
.image-zoom img { width: 100%; }
.image-zoom span { display: block; font-size: 13px; font-weight: 600; padding: 8px 12px; background: var(--panel-muted); }
#content em { color: var(--muted); }
.page-outline { grid-area: outline; position: sticky; top: calc(var(--topbar-height) + 28px); max-height: calc(100svh - var(--topbar-height) - 56px); overflow: auto; font-size: 14px; border-left: 1px solid var(--border); padding-left: 18px; }
.page-outline summary { font-weight: 650; margin-bottom: 12px; }
.section-link { display: block; color: var(--muted); line-height: 1.5; padding: 7px 0; text-decoration: none; }
.section-link.level-3 { padding-left: 12px; font-size: 13px; }
.section-link:hover, .section-link.active-section { color: var(--text); text-decoration: underline; }
.section-link.active-section { font-weight: 650; }
.code-block { position: relative; margin: 18px 0; }
pre { overflow: auto; background: var(--shell-sidebar); color: #e2e8f0; padding: 52px 18px 18px; border-radius: var(--radius); font-size: 14px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
p code, li code, td code { background: #e2e8f0; padding: 1px 4px; border-radius: 4px; font-size: .9em; }
.copy-code-button { position: absolute; right: 10px; top: 10px; font-size: 13px; padding: 4px 10px; }
.guide-message { padding: 20px; border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); max-width: 72ch; }
.guide-message p:first-child { margin-top: 0; }
.search-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 22px 0; }
.search-toolbar label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.search-toolbar select { max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.search-summary { color: var(--muted); }
.full-result { padding: 20px 0; border-top: 1px solid var(--border); }
.full-result > p, .full-result .section-result { max-width: 72ch; }
#content .full-result h2 { margin: 0 0 8px; font-size: 21px; }
.full-result details { margin-top: 12px; }
.full-result summary { font-size: 14px; font-weight: 600; }
.full-result .section-result { display: block; padding: 10px 0; }
.section-result small { display: block; font-size: 14px; color: var(--muted); font-weight: 400; }
.footer { width: min(1200px, calc(100% - 56px)); margin: 0 auto; border-top: 1px solid var(--border); padding: 22px 0; font-size: 13px; color: var(--muted); }
.nav-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 26; }
#imageDialog { width: min(96vw, 1800px); max-width: 96vw; max-height: 94dvh; padding: 0; border: 0; border-radius: var(--radius); color: var(--text); background: white; box-shadow: var(--shadow); }
#imageDialog::backdrop { background: rgba(15, 23, 42, .75); }
.image-toolbar { display: flex; align-items: start; gap: 20px; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
#imageCaption { margin: 6px 0; font-size: 14px; }
.image-toolbar button { flex-shrink: 0; }
.image-viewport { overflow: auto; max-height: 76dvh; }
#expandedImage { display: block; max-width: none; }
@media (max-width: 1200px) {
  .reader-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "outline" "article"; gap: 28px; max-width: 900px; }
  .page-outline { position: static; max-height: none; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
  .page-outline summary { margin: 0; }
  .page-outline[open] summary { margin-bottom: 10px; }
  .topbar-title { display: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) minmax(100px, 156px); }
}
@media (max-width: 820px) {
  .layout { display: block; }
  #guideSidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: min(320px, calc(100vw - 40px)); visibility: hidden; }
  body.nav-open #guideSidebar { transform: translateX(0); visibility: visible; }
  .icon-button { display: inline-flex; }
  .topbar { grid-template-columns: 40px minmax(0, 1fr) minmax(100px, 156px); gap: 12px; padding: 12px 16px; }
  .reader-layout, .footer { width: calc(100% - 32px); }
  #searchShortcut { display: none; }
  #searchInput { padding-right: 42px; }
  #content h1 { font-size: 28px; }
  #content h2 { font-size: 22px; }
}
@media (max-width: 560px) {
  .topbar { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 12px 16px; }
  .topbar-title { display: none; }
  #langSelect { grid-row: 1; grid-column: 2; width: auto; max-width: 200px; justify-self: end; }
  #search { grid-column: 1 / -1; grid-row: 2; }
  .reader-layout { padding-top: 24px; gap: 22px; }
  #content h1 { font-size: 27px; }
  #content th, #content td { padding: 10px; }
  .image-toolbar { flex-wrap: wrap; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}


.reader-layout:has(#pageOutline[hidden]) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "article"; max-width: 1050px; }

.article-pagination { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.article-pagination a { display: grid; gap: 4px; text-decoration: none; }
.article-pagination span { color: var(--muted); font-size: 13px; font-weight: 400; }
.article-pagination a:hover strong { text-decoration: underline; }
