/* ==========================================================================
   wednesday docs — light console, dark code, one violet signal
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-soft: #f5f2ec;
  --panel: #ffffff;
  --ink: #101014;
  --ink-soft: #33313a;
  --muted: #615e69;
  --faint: #8d8a94;
  --line: #e8e4dc;
  --line-strong: #d8d3c8;
  --accent: #5b3fd6;
  --accent-soft: #f0ebff;
  --accent-line: #d9cdfa;
  --good: #157347;
  --warn: #9a5b00;
  --bad: #b42318;
  --code: #121218;
  --code-head: #191921;
  --code-line: #272532;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --topbar: 58px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 82px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

[hidden] { display: none !important; }
body.search-open { overflow: hidden; }
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 300;
  background: var(--ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.skip:focus { left: 12px; }

/* ── TOP BAR ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.03em;
  flex: none;
}
.brand img { width: 24px; height: 24px; }
.brand-pill {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 2px;
}
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 270px;
  height: 34px;
  padding: 0 10px;
  margin-left: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--faint);
  font-size: 12.5px;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search-trigger:hover { border-color: var(--line-strong); background: #f1ede5; }
.search-trigger span { flex: 1; }
kbd {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--faint);
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}
.top-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12.5px;
  color: var(--muted);
}
.top-links a:hover { color: var(--ink); }
.top-version {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
}
.menu-btn {
  display: none;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  flex: none;
}
.menu-btn span { display: block; height: 1.5px; background: var(--ink); margin: 4px 0; border-radius: 2px; }

/* ── SHELL ──────────────────────────────────────────────────────────────── */
.docs-shell {
  max-width: 1520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 220px;
  align-items: start;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: var(--topbar);
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 26px 16px 32px 24px;
  scrollbar-width: thin;
}
.side-group { margin-bottom: 24px; }
.side-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
  padding-left: 10px;
}
.side-items { display: flex; flex-direction: column; gap: 1px; }
.side-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.3px;
  color: var(--muted);
  line-height: 1.35;
  transition: background 0.16s ease, color 0.16s ease;
}
.side-link:hover { background: var(--bg-soft); color: var(--ink); }
.side-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.side-help {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.side-help a {
  display: block;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.side-help a:hover { color: var(--accent); }
.sidebar-scrim { position: fixed; inset: var(--topbar) 0 0; background: rgba(16, 14, 24, 0.36); z-index: 89; }

/* ── MAIN / ARTICLE ─────────────────────────────────────────────────────── */
.doc-main {
  min-width: 0;
  padding: 34px 48px 72px;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 26px;
}
.crumb a:hover { color: var(--accent); }
.doc-article { max-width: 800px; }
.doc-head {
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
}
.doc-head h1 {
  font-size: clamp(34px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.doc-lead {
  margin-top: 14px;
  max-width: 64ch;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--muted);
}

.doc-section h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 50px 0 14px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  scroll-margin-top: 82px;
}
.anchor {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 400;
  color: var(--accent-line);
  opacity: 0;
  transition: opacity 0.16s ease, color 0.16s ease;
}
.doc-section h2:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); }

.doc-article p {
  margin: 0 0 14px;
  max-width: 72ch;
  color: var(--ink-soft);
  line-height: 1.72;
}
.doc-article a:not(.doc-card):not(.page-nav-link):not(.anchor) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.doc-article a:not(.doc-card):not(.page-nav-link):not(.anchor):hover { text-decoration-thickness: 2px; }
.doc-article strong { font-weight: 600; color: var(--ink); }
.doc-article ul, .doc-article ol { margin: 10px 0 18px 20px; }
.doc-article li { margin: 6px 0; color: var(--ink-soft); line-height: 1.65; }
.doc-article li::marker { color: var(--faint); }
.doc-article h3 {
  margin: 30px 0 8px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.doc-article blockquote {
  margin: 20px 0;
  padding: 4px 0 4px 16px;
  border-left: 2px solid var(--accent-line);
  color: var(--muted);
}
.doc-article hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: #4c2fc2;
  background: #f3effb;
  border: 1px solid #e5dcf7;
  border-radius: 4px;
  padding: 0.08em 0.34em;
  white-space: nowrap;
}

/* ── CODE BLOCKS ────────────────────────────────────────────────────────── */
.code-block {
  margin: 18px 0 24px;
  border: 1px solid var(--code-line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code);
  box-shadow: 0 10px 30px rgba(27, 22, 48, 0.08);
}
.code-head {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 12px;
  background: var(--code-head);
  border-bottom: 1px solid var(--code-line);
}
.code-dots { display: inline-flex; gap: 4px; }
.code-dots i { width: 7px; height: 7px; border-radius: 50%; background: #3a3746; }
.code-lang {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8f8a9f;
}
.code-copy {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9b96aa;
  border: 1px solid #34313f;
  border-radius: 4px;
  padding: 3px 7px;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.code-copy:hover { color: #fff; border-color: #555064; }
.code-copy.copied { color: #7ee2a8; border-color: #2f6a4a; }
.code-block pre {
  padding: 17px 19px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.4px;
  line-height: 1.85;
  color: #e7e4f1;
  tab-size: 2;
}
.code-block code {
  font-family: var(--mono);
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}
.tok-comment { color: #7e7a8d; }

/* ── CALLOUTS ───────────────────────────────────────────────────────────── */
.callout {
  margin: 22px 0;
  padding: 15px 18px;
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
}
.callout strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
}
.callout p { margin: 0; font-size: 13.5px; line-height: 1.62; color: var(--ink-soft); }
.callout.warn { border-color: #f0d9b5; border-left-color: #b8760a; background: #fdf6e9; }
.callout.warn strong { color: var(--warn); }
.callout.good { border-color: #cde9d8; border-left-color: var(--good); background: #f1faf5; }
.callout.good strong { color: var(--good); }

/* ── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap {
  margin: 18px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13.2px; }
th {
  text-align: left;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  background: #f7f4ee;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0ece5;
  color: var(--ink-soft);
  vertical-align: top;
  line-height: 1.5;
}
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

/* ── DOC CARDS ──────────────────────────────────────────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin: 24px 0 4px;
}
.doc-card {
  display: flex;
  flex-direction: column;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color 0.2s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.doc-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(33, 25, 68, 0.07);
}
.doc-card-kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.doc-card strong { font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em; }
.doc-card > span:not(.doc-card-kicker):not(.doc-card-arrow) {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.doc-card-arrow { margin-top: auto; padding-top: 14px; color: var(--accent); font-size: 14px; align-self: flex-end; }

/* ── PAGE NAV / META ────────────────────────────────────────────────────── */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.page-nav-link:hover { border-color: var(--accent-line); background: #fdfcff; }
.page-nav-link span {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.page-nav-link strong { font-size: 13.5px; font-weight: 500; }
.page-nav-link.next { text-align: right; align-items: flex-end; }
.page-nav-empty { display: block; }
.doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  font-size: 11.5px;
  color: var(--faint);
}
.doc-meta a:hover { color: var(--accent); }
.doc-footer {
  max-width: 760px;
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  color: var(--faint);
}
.doc-footer a:hover { color: var(--accent); }

/* ── TOC ────────────────────────────────────────────────────────────────── */
.toc {
  position: sticky;
  top: var(--topbar);
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 42px 20px 40px 8px;
}
.toc > p {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
  margin-bottom: 10px;
}
.toc ul { list-style: none; border-left: 1px solid var(--line); }
.toc li a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 11px;
  border-left: 1px solid transparent;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.toc-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.toc-foot a { font-size: 11.5px; color: var(--faint); }
.toc-foot a:hover { color: var(--accent); }

/* ── SEARCH ─────────────────────────────────────────────────────────────── */
.search-modal { position: fixed; inset: 0; z-index: 200; }
.search-scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 14, 24, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.search-panel {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  margin: 11vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 40px 100px rgba(20, 15, 40, 0.28);
  overflow: hidden;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
}
.search-field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
}
.search-field input::placeholder { color: var(--faint); }
.search-title { display: none; }
.search-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.search-hint { padding: 18px 14px; font-size: 12.5px; color: var(--faint); }
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
}
.search-result:hover, .search-result.selected { background: var(--accent-soft); }
.search-result .sr-section {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}
.search-result strong { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.search-result p { margin-top: 2px; font-size: 11.8px; line-height: 1.45; color: var(--muted); }
.search-empty { padding: 18px 14px; font-size: 12.5px; color: var(--muted); }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
  .doc-main { padding-right: 40px; }
}

@media (max-width: 900px) {
  .menu-btn { display: block; }
  .search-trigger { width: auto; flex: 1; max-width: 220px; }
  .search-trigger kbd { display: none; }
  .top-links a:first-child { display: none; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--topbar);
    bottom: 0;
    left: 0;
    width: 290px;
    max-height: none;
    background: var(--panel);
    z-index: 90;
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 20px 0 60px rgba(20, 15, 40, 0.12);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim { display: block; }
  body.sidebar-open { overflow: hidden; }
  .doc-main { padding: 28px 24px 64px; }
  .doc-article { max-width: none; }
}

@media (max-width: 600px) {
  .topbar-inner { padding: 0 14px; gap: 10px; }
  .brand-name { display: none; }
  .search-trigger { max-width: none; }
  .top-links { gap: 12px; }
  .top-links a:nth-child(2) { display: none; }
  .top-version { display: none; }
  .doc-head h1 { font-size: 32px; }
  .doc-lead { font-size: 15.5px; }
  .doc-section h2 { font-size: 21px; margin-top: 40px; }
  .doc-grid { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav-link.next { text-align: left; align-items: flex-start; }
  .doc-footer { flex-direction: column; gap: 6px; }
  .doc-meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .code-block pre { font-size: 11.3px; padding: 14px 14px; }
  .table-wrap { border-radius: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .topbar, .sidebar, .toc, .page-nav, .doc-meta, .search-modal { display: none !important; }
  .docs-shell { display: block; }
  .doc-main { padding: 0; }
  body { background: #fff; }
  .code-block { break-inside: avoid; }
}
