:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #14213d;
  --muted: #66758c;
  --line: #dce4ef;
  --accent: #4f46e5;
  --accent-strong: #3730a3;
  --accent-soft: #eef2ff;
  --shadow: 0 18px 48px rgb(31 41 55 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, .button { font: inherit; }
button { cursor: pointer; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 68px; padding: .75rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid rgb(220 228 239 / 86%); background: rgb(255 255 255 / 86%); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-size: 1rem; font-weight: 700; }
.brand img { width: 34px; height: 34px; border-radius: 10px; object-fit: contain; box-shadow: 0 5px 14px rgb(79 70 229 / 15%); }
.brand b { color: var(--accent); font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.button, button { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: .55rem .8rem; font-size: .82rem; font-weight: 650; transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease; }
.button:hover, button:hover { border-color: #a5b4fc; background: var(--accent-soft); color: var(--accent-strong); transform: translateY(-1px); }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; box-shadow: 0 8px 18px rgb(79 70 229 / 20%); }
.button.primary:hover { background: var(--accent-strong); color: white; }
.button.secondary { background: var(--panel); }
.mobile-only { display: none; }

.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar { position: sticky; top: 68px; align-self: start; height: calc(100vh - 68px); overflow: auto; padding: 1.25rem 1rem 2rem; border-right: 1px solid var(--line); background: rgb(255 255 255 / 70%); }
.sidebar-title { margin: 0 .6rem 1rem; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-group { margin: 0 0 1.15rem; }
.nav-group h2 { margin: 0 .6rem .35rem; color: var(--muted); font-size: .72rem; font-weight: 750; }
.nav-group ul { display: grid; gap: .15rem; margin: 0; padding: 0; list-style: none; }
.nav-link { display: block; padding: .5rem .65rem; border-radius: 8px; color: #4b5b73; font-size: .82rem; line-height: 1.35; }
.nav-link:hover { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link.active { background: #e0e7ff; color: var(--accent-strong); font-weight: 750; box-shadow: inset 3px 0 var(--accent); }
.content { min-width: 0; padding: clamp(1.5rem, 4vw, 4rem) clamp(1rem, 6vw, 6rem); }
.doc-article { max-width: 860px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); }
.doc-article > article { max-width: none !important; }
.doc-article nav { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: 1.5rem; color: var(--muted); font-size: .78rem; }
.doc-article nav a:hover { color: var(--accent); }
.doc-article header { margin-bottom: 2.25rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.doc-article h1 { margin: .75rem 0 1rem; color: var(--text); font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.1; letter-spacing: -.04em; }
.doc-article h2 { margin: 2.4rem 0 .8rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--text); font-size: 1.55rem; }
.doc-article h3 { margin: 1.7rem 0 .6rem; color: var(--text); font-size: 1.15rem; }
.doc-article p, .doc-article li { color: #43536b; font-size: 1rem; line-height: 1.85; }
.doc-article strong { color: var(--text); }
.doc-article a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.doc-article ul, .doc-article ol { padding-left: 1.5rem; }
.doc-article blockquote { margin: 1.25rem 0; padding: 1rem 1.15rem; border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--accent-soft); }
.doc-article blockquote p { margin: 0; color: #373f68; }
.doc-article code { padding: .15rem .4rem; border-radius: 6px; background: #f1f5f9; color: #be185d; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; }
.doc-article pre { overflow: auto; margin: 1rem 0; padding: 1rem 1.15rem; border: 1px solid #263452; border-radius: 12px; background: #111a2e; color: #e0e7ff; line-height: 1.65; }
.doc-article pre code { padding: 0; background: transparent; color: inherit; }
.doc-article img { display: block; max-width: 100%; height: auto; margin: 1rem auto; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px rgb(31 41 55 / 10%); }
.doc-article hr { border: 0; border-top: 1px solid var(--line); }
.page-footer { max-width: 860px; margin: 1.25rem auto 0; color: var(--muted); font-size: .78rem; line-height: 1.6; text-align: center; }
.page-footer a { color: var(--accent-strong); text-decoration: underline; }
.editor-toolbar { max-width: 860px; margin: 0 auto 1rem; padding: .75rem 1rem; border: 1px solid #c7d2fe; border-radius: 12px; background: #eef2ff; color: #3730a3; font-size: .82rem; }
.editor-toolbar button { margin-right: .65rem; padding: .35rem .65rem; border-color: #a5b4fc; background: #fff; color: #3730a3; }
.editor-toolbar button:nth-last-child(-n+2) { color: #64748b; border-color: #cbd5e1; }
.draft-restored .doc-article { box-shadow: 0 0 0 3px rgb(99 102 241 / 10%), var(--shadow); }
.editor-tip { float: right; color: #6366f1; }
.doc-article.editing { outline: 3px solid rgb(99 102 241 / 18%); outline-offset: 4px; }
.sidebar.editing { outline: 3px solid rgb(99 102 241 / 18%); outline-offset: -3px; background: #eef2ff; }
.doc-article.editing [contenteditable] { outline: 1px dashed #a5b4fc; }

.index-main { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 7vw, 6rem) 0 3rem; }
.hero { max-width: 760px; padding: clamp(1.5rem, 5vw, 3.5rem); border: 1px solid #c7d2fe; border-radius: 26px; background: radial-gradient(circle at 100% 0, #e0e7ff, transparent 42%), var(--panel); box-shadow: var(--shadow); }
.hero-kicker, .eyebrow { color: var(--accent-strong); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: .8rem 0 1rem; font-size: clamp(2.3rem, 6vw, 4.8rem); line-height: 1.02; letter-spacing: -.065em; }
.hero p { max-width: 660px; color: var(--muted); font-size: 1.05rem; line-height: 1.8; }
.hero-actions { display: flex; gap: .65rem; flex-wrap: wrap; margin-top: 1.5rem; }
.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; margin-top: 1.5rem; }
.index-card { display: grid; gap: .45rem; min-height: 110px; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 8px 24px rgb(31 41 55 / 4%); }
.index-card:hover { border-color: #a5b4fc; background: #fafaff; transform: translateY(-2px); }
.index-card strong { font-size: 1rem; }
.index-card span:last-child { color: var(--muted); font-size: .78rem; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 68px auto 0 0; z-index: 15; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 50px rgb(15 23 42 / 16%); }
  body.menu-open .sidebar { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .content { padding: 1.25rem .8rem 2rem; }
  .doc-article { padding: 1.2rem; border-radius: 16px; }
  .editor-tip { float: none; display: block; margin-top: .35rem; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .top-actions button, .top-actions .button { flex: 1; }
  .doc-article h1 { font-size: 2rem; }
  .doc-article p, .doc-article li { font-size: .95rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
/* Removed title dividers also apply to restored browser drafts. */
#doc-article header { border-bottom: 0 !important; padding-bottom: 0 !important; }
