:root {
  color-scheme: light;
  --canvas: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --text: #13213c;
  --muted: #5d6b82;
  --line: #d8e1ee;
  --line-strong: #bdcbe0;
  --accent: #1268e8;
  --accent-strong: #084aa8;
  --accent-soft: #e9f2ff;
  --violet: #7252c7;
  --code: #f2f5f9;
  --shadow: 0 18px 60px rgba(27, 53, 94, 0.1);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 124px; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, rgba(18, 104, 232, 0.11), transparent 31rem),
    radial-gradient(circle at 94% 7%, rgba(114, 82, 199, 0.09), transparent 27rem),
    var(--canvas);
  color: var(--text);
  font: 16px/1.68 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(189, 203, 224, 0.78);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 28px rgba(32, 56, 91, 0.07);
  backdrop-filter: blur(18px) saturate(145%);
}

.header-inner,
.primary-nav {
  width: min(1380px, calc(100% - 36px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand img { width: 38px; height: 38px; filter: drop-shadow(0 7px 12px rgba(18, 104, 232, 0.22)); }
.brand span { display: grid; line-height: 1.15; }
.brand strong { font-size: 18px; letter-spacing: -0.015em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.repository {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.primary-nav {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 4px;
  overflow: visible;
}

.primary-nav > a,
.docs-menu > summary {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 9px;
  color: #34435d;
  font-size: 13px;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav > a:hover,
.primary-nav > a[aria-current="page"],
.docs-menu > summary:hover,
.docs-menu[open] > summary { background: var(--accent-soft); color: var(--accent-strong); }
.primary-nav > a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }

.docs-menu { position: relative; margin-left: auto; }
.docs-menu > summary { cursor: pointer; list-style: none; }
.docs-menu > summary::-webkit-details-marker { display: none; }

.docs-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: min(860px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 22px;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.docs-menu-panel section { display: grid; align-content: start; gap: 5px; }
.docs-menu-panel h2 { margin: 0 0 7px; color: var(--muted); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.docs-menu-panel a { padding: 6px 8px; border-radius: 7px; color: var(--text); font-size: 13px; line-height: 1.35; text-decoration: none; }
.docs-menu-panel a:hover,
.docs-menu-panel a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }

main { width: min(1280px, calc(100% - 40px)); margin: 34px auto 54px; }

.source-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, #f8fbff, #fbfaff);
  color: var(--muted);
  font-size: 12px;
}

.source-strip span { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.source-strip strong { color: var(--text); }

.document {
  padding: clamp(26px, 4.5vw, 66px);
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.document > :first-child { margin-top: 0; }
.document > :last-child { margin-bottom: 0; }
.document h1 { margin-bottom: 1.1em; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.08; letter-spacing: -0.045em; }
.document h2 { margin-top: 2.2em; font-size: clamp(1.45rem, 2.2vw, 2rem); line-height: 1.2; letter-spacing: -0.025em; }
.document h3 { margin-top: 1.8em; font-size: 1.18rem; }
.document h1,
.document h2 { padding-bottom: .42em; border-bottom: 1px solid var(--line); }
.document p,
.document li { max-width: 88ch; }
.document img { max-width: 100%; height: auto; border-radius: 12px; }

.document table {
  display: table;
  width: 100%;
  margin: 22px 0 30px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  font-size: 14px;
}

.document th,
.document td { padding: 11px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.document th { background: #edf4ff; color: #243a61; font-size: 12px; letter-spacing: .025em; text-transform: uppercase; }
.document tr:last-child td { border-bottom: 0; }
.document th:last-child,
.document td:last-child { border-right: 0; }
.document tbody tr:nth-child(even) { background: #fafcff; }

.document blockquote { margin: 24px 0; padding: 12px 18px; border-left: 4px solid var(--violet); border-radius: 0 10px 10px 0; background: #f8f5ff; color: var(--muted); }
code { padding: .16em .38em; border: 1px solid #e1e7ef; border-radius: 5px; background: var(--code); font-size: .9em; }
pre { padding: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--code); }
pre code { padding: 0; border: 0; }

.diagram-card {
  position: relative;
  margin: 28px 0 38px;
  border: 1px solid #c9d8ec;
  border-radius: 16px;
  background:
    linear-gradient(rgba(18, 104, 232, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 104, 232, .035) 1px, transparent 1px),
    #fbfdff;
  background-size: 24px 24px;
  box-shadow: 0 14px 40px rgba(27, 72, 130, .1);
}

.diagram-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 14px; border-bottom: 1px solid #d7e3f3; background: rgba(238, 245, 255, .92); border-radius: 16px 16px 0 0; }
.diagram-header strong { color: #244470; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.diagram-tools { display: flex; gap: 6px; }
.diagram-tools button { min-width: 34px; height: 30px; padding: 0 9px; border: 1px solid #c2d2e7; border-radius: 8px; background: #fff; color: #234164; cursor: pointer; font: 650 13px/1 inherit; }
.diagram-tools button:hover { border-color: var(--accent); color: var(--accent); }
.diagram-viewport { min-height: 260px; overflow: auto; padding: 18px; }
.diagram-viewport .mermaid { min-width: 760px; transition: width .18s ease; }
.diagram-viewport svg { display: block; width: 100% !important; max-width: none !important; height: auto !important; margin: 0 auto; }
.diagram-error { padding: 22px; color: #8a2b2b; }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; width: min(1280px, calc(100% - 40px)); margin: 0 auto 36px; color: var(--muted); font-size: 12px; }

@media (max-width: 1040px) {
  .primary-nav { overflow-x: auto; scrollbar-width: thin; }
  .docs-menu { position: static; margin-left: 0; }
  .docs-menu-panel { position: fixed; top: 118px; right: 16px; left: 16px; width: auto; grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 720px) {
  .header-inner,
  .primary-nav { width: min(100% - 24px, 1380px); }
  .repository { display: none; }
  .brand small { display: none; }
  .primary-nav > a { padding-inline: 9px; }
  .docs-menu-panel { top: 108px; grid-template-columns: repeat(2, minmax(120px, 1fr)); padding: 18px; }
  main { width: min(100% - 16px, 1280px); margin-top: 16px; }
  .document { padding: 22px 18px; }
  .document table { display: block; overflow-x: auto; white-space: normal; }
  .diagram-viewport { padding: 10px; }
  .diagram-viewport .mermaid { min-width: 640px; }
}
