/* csv_plus documentation. Palette derived from the package logo. */
:root {
  --sb: 280px; --toc: 236px; --topbar: 56px;
  --bg: #fff; --bg-soft: #f6f8fb; --fg: #191c21; --muted: #55606e; --faint: #6d7887;
  --line: #e1e7ef; --line-soft: #edf2f8;
  --accent: #1257b8; --accent-soft: #e6effc; --accent-line: #2e7bea;
  --code-bg: #f6f8fb; --code-fg: #1d2228; --sel: #cfe0f7;
  --tok-key: #8a1f78; --tok-str: #0b6b74; --tok-num: #8a4b12; --tok-com: #5f6d65;
  --tok-cls: #1a56a0; --tok-ann: #8a4b12;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #13161a; --bg-soft: #181c22; --fg: #e7ecf2; --muted: #a2aebd; --faint: #8a95a4;
    --line: #252c35; --line-soft: #1e242b;
    --accent: #6aa8f5; --accent-soft: #16202e; --accent-line: #2e7bea;
    --code-bg: #191e25; --code-fg: #e1e8f0; --sel: #1d3a5c;
    --tok-key: #eaa6dc; --tok-str: #6fd3dd; --tok-num: #e6b98d; --tok-com: #8b9891;
    --tok-cls: #97c8f5; --tok-ann: #e6b98d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar) + 16px);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "kern", "liga";
}

::selection { background: var(--sel); }
a { color: var(--accent); text-underline-offset: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; border-radius: 3px; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; color: var(--fg); text-decoration: none; letter-spacing: -.012em;
}
.brand img { width: 24px; height: 24px; border-radius: 5px; display: block; }
.ver {
  font: 500 11.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted); border: 1px solid var(--line); padding: 4px 7px; border-radius: 99px;
}
.topbar .grow { flex: 1; }
.topbar .ext {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 7px;
  color: var(--muted); text-decoration: none; font-size: 14px;
}
.topbar .ext:hover { color: var(--fg); background: var(--bg-soft); }
.menu {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: -6px;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--fg); cursor: pointer;
}
.menu:hover { background: var(--bg-soft); border-color: var(--line); }

/* --- shell --- */
.shell { display: grid; grid-template-columns: var(--sb) minmax(0, 1fr) var(--toc); align-items: start; }

/* --- sidebar --- */
.sidebar {
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar));
  overflow-y: auto; padding: 26px 14px 40px 20px;
  border-right: 1px solid var(--line); scrollbar-width: thin;
}
.sidebar h2 {
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .09em; text-transform: uppercase; color: var(--faint);
  margin: 26px 0 9px; padding: 0 10px; border: 0;
}
.sidebar h2:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block; padding: 7px 10px; border-radius: 7px;
  color: var(--muted); text-decoration: none; font-size: 14.5px; line-height: 1.4;
  transition: background .12s ease, color .12s ease;
}
.sidebar a:hover { color: var(--fg); background: var(--bg-soft); }
.sidebar a[aria-current=page] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* --- content --- */
.content { min-width: 0; padding: 38px 56px 96px; }
.content > article { max-width: 74ch; }

h1 {
  font-size: clamp(28px, 3.4vw, 38px); line-height: 1.18;
  letter-spacing: -.025em; margin: 0 0 .35em; font-weight: 700; text-wrap: balance;
}
.lede { font-size: 18.5px; line-height: 1.6; color: var(--muted); margin: 0 0 2em; }
h2 {
  font-size: 23px; line-height: 1.3; letter-spacing: -.017em;
  margin: 2.6em 0 .7em; font-weight: 660; text-wrap: balance;
  scroll-margin-top: calc(var(--topbar) + 20px);
}
h3 { font-size: 17px; margin: 2em 0 .5em; font-weight: 640; letter-spacing: -.008em; }
.anchor {
  margin-left: .4em; color: var(--line); text-decoration: none;
  font-weight: 400; opacity: 0; transition: opacity .12s;
}
h2:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); }

p, li { margin: 0 0 1.05em; }
li { margin-bottom: .42em; }
ul, ol { padding-left: 1.3em; }
strong { font-weight: 640; }
p code, li code, td code {
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  padding: .08em .26em; border-radius: 5px; font-size: .875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: break-word;
}

/* --- code --- */
.codeblock { position: relative; margin: 0 0 1.5em; }
pre {
  background: var(--code-bg); border: 1px solid var(--line); color: var(--code-fg);
  margin: 0; padding: 16px 18px; border-radius: 10px; overflow-x: auto;
  font-size: 13.5px; line-height: 1.62; tab-size: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.copy {
  position: absolute; top: 9px; right: 9px;
  font: 500 12px/1 inherit; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
  cursor: pointer; opacity: 0; transition: opacity .13s ease, color .13s ease;
}
.codeblock:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--fg); }
.copy.done { color: var(--accent); border-color: var(--accent-line); opacity: 1; }

.tok-key { color: var(--tok-key); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-com { color: var(--tok-com); font-style: italic; }
.tok-cls { color: var(--tok-cls); }
.tok-ann { color: var(--tok-ann); }

/* --- tables --- */
.tablewrap { overflow-x: auto; margin: 0 0 1.5em; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
th {
  font-weight: 620; color: var(--muted); font-size: 12.5px;
  letter-spacing: .03em; text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }

/* --- guide index --- */
.guides { list-style: none; padding: 0; margin: 0 0 1.6em; }
.guides li { margin: 0; border-bottom: 1px solid var(--line-soft); }
.guides li:last-child { border-bottom: 0; }
.guides a { display: flex; gap: 14px; align-items: baseline; padding: 13px 4px; text-decoration: none; border-radius: 7px; }
.guides a:hover { background: var(--bg-soft); }
.guides .t { font-weight: 600; color: var(--fg); min-width: 11.5em; }
.guides .d { color: var(--muted); font-size: 14.5px; }

/* --- next --- */
.next {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 3em; padding-top: 1.3em; border-top: 1px solid var(--line);
}
.next a {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 15px;
  border: 1px solid var(--line); border-radius: 9px; text-decoration: none;
  font-size: 14.5px; font-weight: 550; transition: border-color .13s, box-shadow .13s;
}
.next a:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }

/* --- on this page --- */
.toc {
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar));
  overflow-y: auto; padding: 38px 20px 40px 4px;
}
.toc h2 {
  font-size: 11px; font-weight: 600; line-height: 1;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 10px; border: 0;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block; padding: 5px 0 5px 12px; border-left: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.45;
  transition: color .12s, border-color .12s;
}
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--accent); border-left-color: var(--accent-line); font-weight: 550; }

/* --- footer --- */
.pagefoot {
  margin-top: 4em; padding-top: 1.4em; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.pagefoot a { color: var(--muted); }

/* --- adaptation --- */
@media (max-width: 1180px) {
  :root { --toc: 0px; }
  .toc { display: none; }
  .content { padding: 34px 44px 88px; }
}

@media (max-width: 900px) {
  :root { --sb: 0px; }
  .menu { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: var(--topbar) auto 0 0; width: 290px; max-width: 86vw;
    z-index: 39; background: var(--bg); transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.22, .68, .35, 1); box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .scrim {
    position: fixed; inset: var(--topbar) 0 0 0; background: rgba(10, 18, 14, .42);
    z-index: 38; opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
  .content { padding: 28px 22px 80px; }
  .lede { font-size: 17px; }
}

@media (max-width: 520px) {
  .ver { display: none; }
  .topbar .ext span { display: none; }
  .guides a { flex-direction: column; gap: 3px; }
  .guides .t { min-width: 0; }
}
