:root {
  --bg: #070a11;
  --bg-elevated: #0d1220;
  --surface: rgba(16, 23, 39, 0.86);
  --surface-solid: #111827;
  --surface-2: #151e31;
  --text: #e8eefc;
  --muted: #9ba9c4;
  --faint: #687792;
  --line: rgba(139, 165, 214, 0.18);
  --line-strong: rgba(139, 165, 214, 0.34);
  --accent: #72a7ff;
  --accent-2: #9d86ff;
  --accent-3: #37d6bc;
  --danger: #ff8d9b;
  --code: #080d18;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  --header: rgba(7, 10, 17, 0.78);
  --glow-a: rgba(73, 132, 255, 0.22);
  --glow-b: rgba(157, 134, 255, 0.16);
  --radius: 18px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f8ff;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-2: #eef3fd;
  --text: #172033;
  --muted: #53617a;
  --faint: #7d8aa1;
  --line: rgba(51, 75, 118, 0.14);
  --line-strong: rgba(51, 75, 118, 0.27);
  --accent: #235fc5;
  --accent-2: #6749d8;
  --accent-3: #087c70;
  --danger: #b4233a;
  --code: #edf2fb;
  --shadow: 0 18px 55px rgba(58, 76, 112, 0.14);
  --header: rgba(245, 248, 255, 0.82);
  --glow-a: rgba(61, 119, 220, 0.14);
  --glow-b: rgba(115, 77, 217, 0.1);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f8ff;
    --bg-elevated: #ffffff;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --surface-2: #eef3fd;
    --text: #172033;
    --muted: #53617a;
    --faint: #7d8aa1;
    --line: rgba(51, 75, 118, 0.14);
    --line-strong: rgba(51, 75, 118, 0.27);
    --accent: #235fc5;
    --accent-2: #6749d8;
    --accent-3: #087c70;
    --danger: #b4233a;
    --code: #edf2fb;
    --shadow: 0 18px 55px rgba(58, 76, 112, 0.14);
    --header: rgba(245, 248, 255, 0.82);
    --glow-a: rgba(61, 119, 220, 0.14);
    --glow-b: rgba(115, 77, 217, 0.1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 92px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 10% -5%, var(--glow-a), transparent 65%),
    radial-gradient(780px 520px at 95% 8%, var(--glow-b), transparent 68%),
    var(--bg);
  font: 15px/1.72 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-2); }
button, input { font: inherit; }
button { color: inherit; }
img, svg { max-width: 100%; }
::selection { color: #fff; background: #526fd4; }

.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 200;
  padding: 10px 14px; border-radius: 10px; color: #fff; background: #315ba9;
}
.skip-link:focus { top: 12px; }

.progress {
  position: fixed; top: 0; left: 0; z-index: 160; width: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.site-header {
  position: sticky; top: 0; z-index: 120;
  border-bottom: 1px solid var(--line);
  background: var(--header);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.header-inner {
  width: min(1240px, calc(100% - 36px)); min-height: 66px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  font-weight: 800; letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line-strong);
  border-radius: 10px; color: #fff; background: linear-gradient(135deg, #377cf1, #7457e8 62%, #26bba7);
  box-shadow: 0 8px 28px rgba(75, 112, 232, 0.25); font: 800 13px/1 ui-monospace, monospace;
}
.brand small { color: var(--faint); font-size: 11px; font-weight: 650; letter-spacing: 0.08em; }
.desktop-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.desktop-nav a {
  padding: 8px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 13px;
}
.desktop-nav a:hover, .desktop-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.language-link {
  padding: 7px 9px; border: 1px solid transparent; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700;
}
.language-link:hover { border-color: var(--line); color: var(--text); background: var(--surface-2); }
.icon-button, .search-button, .copy-button, .demo-button, .theme-option {
  border: 1px solid var(--line); background: var(--surface); box-shadow: none; cursor: pointer;
}
.icon-button { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.icon-button:hover, .search-button:hover, .copy-button:hover, .demo-button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.search-button {
  min-width: 152px; height: 38px; padding: 0 10px 0 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px;
}
kbd {
  margin-left: auto; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; color: var(--faint); background: var(--bg-elevated); font: 11px/1.5 ui-monospace, monospace;
}
.menu-button { display: none; }

.page-shell {
  width: min(1240px, calc(100% - 36px)); margin: 0 auto;
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 54px; padding: 44px 0 76px;
}
.page-shell.no-sidebar { display: block; max-width: 1060px; }
.sidebar { position: sticky; top: 94px; align-self: start; max-height: calc(100vh - 118px); overflow: auto; }
.sidebar-title { margin: 0 0 8px; color: var(--faint); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.sidebar a { display: block; padding: 7px 10px; border-left: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 13px; }
.sidebar a:hover, .sidebar a.active { color: var(--accent); border-color: var(--accent); background: linear-gradient(90deg, var(--glow-a), transparent); }
.sidebar-group + .sidebar-group { margin-top: 20px; }

main { min-width: 0; }
.hero { padding: 28px 0 40px; }
.eyebrow { color: var(--accent-3); font: 750 12px/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: 0.09em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.035em; }
h1 { max-width: 900px; margin: 12px 0 18px; font-size: clamp(38px, 7vw, 76px); }
.doc-title { font-size: clamp(34px, 5vw, 55px); }
h2 { margin: 52px 0 18px; font-size: clamp(25px, 3.6vw, 36px); }
h3 { margin: 30px 0 12px; font-size: 20px; }
p { margin: 0 0 16px; }
.lead { max-width: 780px; color: var(--muted); font-size: clamp(17px, 2.2vw, 21px); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 43px; padding: 0 17px;
  border: 1px solid var(--line-strong); border-radius: 11px; color: var(--text); background: var(--surface);
  text-decoration: none; font-weight: 700; font-size: 14px;
}
.button.primary { border-color: transparent; color: white; background: linear-gradient(115deg, #2f73dd, #6d54db); }
.button:hover { transform: translateY(-1px); box-shadow: var(--shadow); color: inherit; }
.hero-note { margin-top: 16px; color: var(--faint); font-size: 12px; }

.section { margin-top: 54px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.card h2, .card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card-label { color: var(--accent-3); font: 700 11px/1.4 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.card-value { margin: 7px 0 5px; font-size: 29px; font-weight: 800; letter-spacing: -.04em; }
.card-meta { color: var(--muted); font-size: 13px; }
.feature-list { padding: 0; margin: 0; list-style: none; }
.feature-list li { position: relative; padding: 8px 0 8px 22px; border-bottom: 1px solid var(--line); }
.feature-list li:last-child { border-bottom: 0; }
.feature-list li::before { content: "↳"; position: absolute; left: 1px; color: var(--accent-3); }

.callout { margin: 24px 0; padding: 18px 20px; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 12px; background: var(--surface-2); }
.callout.warning { border-left-color: var(--danger); }
.callout strong { display: block; margin-bottom: 5px; }

pre {
  position: relative; margin: 18px 0 24px; padding: 18px 20px; overflow: auto;
  border: 1px solid var(--line); border-radius: 13px; background: var(--code); color: var(--text);
  font: 13px/1.75 ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
:not(pre) > code { padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--accent-3); background: var(--surface-2); font-size: .9em; }
.copy-button { position: absolute; top: 9px; right: 9px; padding: 5px 9px; border-radius: 7px; color: var(--muted); font-size: 11px; }
.copy-button.copied { color: var(--accent-3); }

.table-wrap { overflow-x: auto; margin: 18px 0 28px; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--surface-2); font-size: 12px; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }

.demo {
  margin-top: 32px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 22px;
  background: linear-gradient(150deg, var(--surface), var(--bg-elevated)); box-shadow: var(--shadow);
}
.demo-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.demo-dots { display: flex; gap: 6px; }
.demo-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.demo-title { margin-right: auto; color: var(--muted); font: 12px/1.4 ui-monospace, monospace; }
.demo-button { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 12px; }
.demo-body { padding: 20px; }
.demo-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.demo-kpi { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.demo-kpi span { display: block; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.demo-kpi b { display: block; margin-top: 5px; font-size: 20px; }
.demo-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(230px, .7fr); gap: 14px; margin-top: 14px; }
.demo-panel { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.demo-panel h3 { margin: 0 0 14px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.demo-chart { height: 190px; display: flex; align-items: end; gap: 8px; padding: 18px 4px 26px; border-bottom: 1px solid var(--line); }
.demo-bar { position: relative; flex: 1; min-width: 8px; height: var(--h); border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); transform-origin: bottom; }
.demo-bar::after { content: attr(data-label); position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); color: var(--faint); font-size: 9px; }
.demo-bar:hover { filter: brightness(1.18); }
.demo-legend { display: grid; gap: 10px; }
.demo-legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.demo-legend-row i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.demo-legend-row span { color: var(--muted); }
.demo-legend-row b { font-variant-numeric: tabular-nums; }
.demo-note { margin-top: 12px; color: var(--faint); font-size: 11px; }

.arch-flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: stretch; margin: 25px 0; }
.arch-node { position: relative; padding: 16px 12px; border: 1px solid var(--line); border-radius: 12px; text-align: center; background: var(--surface); font-size: 13px; }
.arch-node:not(:last-child)::after { content: "→"; position: absolute; right: -10px; top: 50%; z-index: 2; transform: translate(50%, -50%); color: var(--accent); }

.search-modal { position: fixed; inset: 0; z-index: 180; display: none; align-items: flex-start; justify-content: center; padding: 10vh 18px 18px; background: rgba(3, 6, 12, .68); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.search-modal.open { display: flex; }
.search-panel { width: min(650px, 100%); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface-solid); box-shadow: var(--shadow); }
.search-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search-input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 16px; }
.search-results { max-height: 54vh; overflow: auto; padding: 8px; }
.search-result { display: block; padding: 11px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.search-result:hover, .search-result.active { background: var(--surface-2); }
.search-result b { display: block; }
.search-result span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.search-empty { padding: 28px; color: var(--muted); text-align: center; }
.search-help { padding: 8px 14px 12px; color: var(--faint); font-size: 11px; }

.theme-menu { position: fixed; z-index: 150; display: none; width: 150px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-solid); box-shadow: var(--shadow); }
.theme-menu.open { display: grid; }
.theme-option { padding: 8px 10px; border: 0; border-radius: 8px; text-align: left; }
.theme-option:hover, .theme-option.active { background: var(--surface-2); color: var(--accent); }

.mobile-panel { display: none; }
.site-footer { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 26px 0 44px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }

.not-found { min-height: calc(100vh - 180px); display: grid; place-items: center; text-align: center; }
.not-found-code { font: 900 clamp(84px, 22vw, 220px)/.8 ui-monospace, monospace; color: transparent; -webkit-text-stroke: 1px var(--line-strong); text-shadow: 0 0 60px var(--glow-a); }

@media (max-width: 1040px) {
  .desktop-nav { display: none; }
  .header-actions { margin-left: auto; }
  .menu-button { display: grid; }
  .mobile-panel {
    position: fixed; inset: 66px 0 auto; z-index: 110; display: none; padding: 14px 18px 20px;
    border-bottom: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow);
  }
  .mobile-panel.open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .mobile-panel a { padding: 10px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; }
  .mobile-panel a:hover, .mobile-panel a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
}

@media (max-width: 820px) {
  .page-shell { display: block; padding-top: 30px; }
  .sidebar { display: none; }
  .grid.three { grid-template-columns: 1fr 1fr; }
  .demo-kpis { grid-template-columns: 1fr 1fr; }
  .demo-grid { grid-template-columns: 1fr; }
  .arch-flow { grid-template-columns: 1fr; }
  .arch-node:not(:last-child)::after { content: "↓"; top: auto; right: 50%; bottom: -10px; transform: translate(50%, 50%); }
}

@media (max-width: 600px) {
  .header-inner, .page-shell, .site-footer { width: min(100% - 24px, 1240px); }
  .brand small, .search-button span { display: none; }
  .search-button { min-width: 40px; width: 40px; padding: 0; justify-content: center; }
  .search-button kbd { display: none; }
  .grid, .grid.three { grid-template-columns: 1fr; }
  .hero { padding-top: 16px; }
  h1 { font-size: 43px; }
  .demo-body { padding: 12px; }
  .demo-kpis { grid-template-columns: 1fr 1fr; }
  .demo-kpi b { font-size: 16px; }
  .demo-chart { gap: 5px; }
  th, td { padding: 9px 10px; }
  .mobile-panel.open { grid-template-columns: 1fr; }
}

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

@media print {
  .site-header, .sidebar, .progress, .copy-button, .site-footer { display: none !important; }
  body { color: #111; background: #fff; }
  .page-shell { display: block; width: 100%; padding: 0; }
  a { color: #111; }
  .card, pre, .callout, .table-wrap { break-inside: avoid; box-shadow: none; }
}
