/* Palette: the dashboard's own zinc tokens (dashboard/src/index.css), so the
   site and the product it describes look like one thing. */
:root {
  --bg: hsl(240 10% 3.9%);
  --bg-soft: hsl(240 6% 7%);
  --card: hsl(240 6% 9%);
  --fg: hsl(0 0% 98%);
  --muted: hsl(240 5% 64.9%);
  --border: hsl(240 3.7% 15.9%);
  --accent: hsl(173 70% 48%);
  --accent-dim: hsl(173 50% 22%);
  /* The logo's own amber (logo/kanea-mark-dark.svg). It is deliberately not
     --accent: the mark carries one fixed colour across every surface, and
     recolouring it per theme would make it a different logo on each. */
  --mark: #f2b544;
  --shadow: 0 1px 2px hsl(0 0% 0% / .4), 0 8px 24px hsl(0 0% 0% / .25);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: hsl(0 0% 100%);
    --bg-soft: hsl(240 5% 97.5%);
    --card: hsl(0 0% 100%);
    --fg: hsl(240 10% 3.9%);
    --muted: hsl(240 4% 42%);
    --border: hsl(240 6% 89%);
    --accent: hsl(173 80% 27%);
    --accent-dim: hsl(173 60% 92%);
    /* logo/kanea-mark-light.svg — the same amber, darkened for contrast on
       white. Same hue, so it still reads as one mark. */
    --mark: #e09b1a;
    --shadow: 0 1px 2px hsl(240 10% 4% / .06), 0 8px 24px hsl(240 10% 4% / .06);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'rlig' 1, 'calt' 1;
}
a { color: inherit; }
code, pre, kbd { font-family: var(--mono); }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 24px; }
section { padding: 72px 0; border-top: 1px solid var(--border); }
section:first-of-type { border-top: 0; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 1.65rem; margin-bottom: 8px; }
h3 { font-size: 1rem; letter-spacing: -0.01em; }
.lede { color: var(--muted); max-width: 62ch; margin: 0 0 36px; }
.eyebrow {
  font: 600 .72rem/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
header .wrap { display: flex; align-items: center; gap: 24px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.02em; text-decoration: none; }
.brand svg { display: block; }
/* Scoped to the header: the docs sidebar is a <nav> too, and an unscoped
   `display: flex` here laid its whole table of contents out in one row. */
header nav { margin-left: auto; display: flex; gap: 22px; align-items: center; font-size: .9rem; }
header nav a { color: var(--muted); text-decoration: none; }
header nav a:hover { color: var(--fg); }
@media (max-width: 720px) { header nav .hide-sm { display: none; } }

/* ---------- hero ---------- */
.hero { padding: 92px 0 76px; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); font-weight: 680; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.sub { font-size: 1.12rem; color: var(--muted); max-width: 60ch; margin: 20px 0 32px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.badge {
  font: 500 .76rem/1 var(--mono);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--bg-soft);
}
.badge.on { color: var(--accent); border-color: var(--accent-dim); }

/* ---------- install command ---------- */
.cmd {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); box-shadow: var(--shadow);
  max-width: 640px; overflow: hidden;
}
.cmd pre {
  margin: 0; padding: 14px 16px; flex: 1;
  overflow-x: auto; font-size: .875rem; line-height: 1.5;
}
.cmd pre .p { color: var(--accent); user-select: none; }
.cmd button {
  border: 0; border-left: 1px solid var(--border);
  background: transparent; color: var(--muted);
  font: 500 .8rem var(--sans); padding: 0 16px; cursor: pointer;
  white-space: nowrap;
}
.cmd button:hover { color: var(--fg); background: var(--card); }
.cmd-note { font-size: .82rem; color: var(--muted); margin: 12px 0 0; }
.cmd-note a { color: var(--accent); }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; text-decoration: none;
  font-size: .9rem; font-weight: 550;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg);
}
.btn:hover { border-color: var(--muted); }
/* The one loud button wears the logo's own amber (--mark), white on top. */
.btn.primary { background: var(--mark); border-color: var(--mark); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }

/* ---------- grids ---------- */
.grid { display: grid; gap: 18px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .g3, .g2 { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); padding: 20px;
}
.card h3 { margin-bottom: 6px; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
.card .tag {
  display: inline-block; font: 500 .7rem/1 var(--mono);
  color: var(--accent); margin-bottom: 10px; letter-spacing: .06em; text-transform: uppercase;
}

/* ---------- code window ---------- */
.window {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); overflow: hidden; box-shadow: var(--shadow);
}
.window .bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  font: 500 .78rem var(--mono); color: var(--muted);
}
.window .bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--border); display: block; }
.window pre { margin: 0; padding: 18px; overflow-x: auto; font-size: .82rem; line-height: 1.65; }
.c { color: var(--muted); }             /* comment  */
.k { color: var(--accent); }            /* keyword  */
.s { color: hsl(35 85% 60%); }          /* string   */
@media (prefers-color-scheme: light) { .s { color: hsl(25 80% 36%); } }

/* ---------- steps ---------- */
ol.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
ol.steps li { counter-increment: s; position: relative; padding: 0 0 26px 44px; }
ol.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 1px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 .8rem var(--mono);
  color: var(--accent); background: var(--accent-dim);
  border: 1px solid var(--border);
}
ol.steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 13.5px; top: 34px; bottom: 4px;
  width: 1px; background: var(--border);
}
ol.steps h3 { margin-bottom: 4px; }
ol.steps p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
pre.plain {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); font-size: .82rem; line-height: 1.6;
}

/* ---------- table ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 460px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
td code { font-size: .84rem; color: var(--accent); }

/* ---------- docs list ---------- */
.docs { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 620px) { .docs { grid-template-columns: 1fr; } }
.doc {
  display: flex; align-items: baseline; gap: 12px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; background: var(--card);
}
.doc:hover { border-color: var(--muted); }
.doc b { font-family: var(--mono); font-weight: 600; font-size: .88rem; }
.doc span { color: var(--muted); font-size: .86rem; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--border); padding: 34px 0 56px; color: var(--muted); font-size: .86rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: center; }
footer a { color: var(--muted); }
footer .sp { margin-left: auto; }

.note {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 16px; color: var(--muted); font-size: .92rem;
  max-width: 68ch;
}

/* ================= docs ================= */
/* The docs pages share every token above; what they add is a two-column shell,
   a sidebar that knows which page it is on, and denser prose. */

.docs-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  padding: 44px 0 96px;
}
@media (max-width: 900px) {
  .docs-shell { grid-template-columns: 1fr; gap: 0; padding-top: 28px; }
}

.sidebar { position: sticky; top: 82px; font-size: .9rem; }
.sidebar nav {
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 6px;
}
.sidebar a.part {
  font-weight: 600; color: var(--fg);
  margin-top: 16px; padding-left: 10px;
}
.sidebar a.part:first-child { margin-top: 0; }
.sidebar a.sub { padding-left: 22px; font-size: .855rem; }
.sidebar a.sub[aria-current] { background: var(--accent-dim); }

/* On a narrow screen the contents collapse behind a button — a 39-entry list
   above the first paragraph is not navigation, it is a wall. */
.toc-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: sticky; top: 58px; z-index: 5;
    margin-bottom: 24px; padding: 10px 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .toc-toggle {
    display: block; width: 100%; text-align: left;
    padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-soft); color: var(--fg);
    font: 550 .9rem var(--sans); cursor: pointer;
  }
  .toc-toggle::after { content: " ▾"; color: var(--muted); }
  .sidebar.open .toc-toggle::after { content: " ▴"; }
  .sidebar nav { display: none; max-height: 62vh; margin-top: 10px; }
  .sidebar.open nav { display: block; }
}
.sidebar h4 {
  font: 600 .7rem/1 var(--mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 10px;
}
.sidebar h4:first-child { margin-top: 0; }
.sidebar a {
  display: block; padding: 5px 10px; margin-left: -10px;
  border-radius: 6px; text-decoration: none; color: var(--muted);
}
.sidebar a:hover { color: var(--fg); background: var(--bg-soft); }
.sidebar a[aria-current="page"] {
  color: var(--accent); background: var(--accent-dim); font-weight: 550;
}

.prose { min-width: 0; max-width: 76ch; }
.prose h1 { font-size: 2.1rem; margin: 0 0 12px; }

/* Three levels, because the docs are one document: h2 is a part (Overview,
   Architecture, …), h3 a section within it, h4 a block or subsection. */
.prose h2 {
  font-size: 1.9rem; margin: 84px 0 20px;
  padding-top: 30px; border-top: 2px solid var(--accent-dim);
  scroll-margin-top: 78px; letter-spacing: -.025em;
}
.prose h2:first-of-type { margin-top: 56px; }
.prose h3 {
  font-size: 1.32rem; margin: 46px 0 12px;
  padding-top: 20px; border-top: 1px solid var(--border);
  scroll-margin-top: 78px;
}
.prose h4 { font-size: 1.02rem; margin: 30px 0 8px; scroll-margin-top: 78px; }
.prose > p:first-of-type { font-size: 1.05rem; color: var(--muted); }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose li::marker { color: var(--muted); }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.prose code {
  font-size: .875em; padding: 1px 5px; border-radius: 5px;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose .window, .prose .tablewrap, .prose pre.plain { margin: 0 0 18px; }
.prose table code { border: 0; background: none; padding: 0; }
.prose td, .prose th { vertical-align: top; }
.prose th:first-child, .prose td:first-child { white-space: nowrap; }

/* A rule reference: the identifier stays with the sentence it governs. */
.rule {
  display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.rule:last-child { border-bottom: 0; }
.rule > b {
  font: 600 .8rem/1.6 var(--mono); color: var(--accent);
}
.rule > div { min-width: 0; }
.rule p { margin: 0 0 8px; font-size: .94rem; }
.rule p:last-child { margin-bottom: 0; }
@media (max-width: 560px) {
  .rule { grid-template-columns: 1fr; gap: 4px; }
}

/* Callouts. Two kinds: a fact worth pausing on, and a trap. */
.callout {
  border: 1px solid var(--border); border-left-width: 2px;
  border-left-color: var(--accent);
  border-radius: 8px; background: var(--bg-soft);
  padding: 14px 18px; margin: 0 0 18px; font-size: .93rem;
}
.callout p { margin: 0 0 8px; }
.callout p:last-child { margin: 0; }
.callout b.label {
  display: block; font: 600 .7rem/1 var(--mono);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 7px;
}
.callout.warn { border-left-color: hsl(35 85% 55%); }
.callout.warn b.label { color: hsl(35 85% 55%); }
@media (prefers-color-scheme: light) {
  .callout.warn { border-left-color: hsl(25 80% 42%); }
  .callout.warn b.label { color: hsl(25 80% 42%); }
}

/* Page-to-page navigation at the foot of every doc. */
.pagenav {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border);
}
.pagenav a {
  flex: 1 1 220px; padding: 14px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; background: var(--card);
}
.pagenav a:hover { border-color: var(--muted); }
.pagenav small {
  display: block; color: var(--muted); font-size: .76rem;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 3px;
}
.pagenav b { font-weight: 600; }

/* An ASCII diagram is a <pre>; it must scroll rather than reflow. */
.diagram {
  margin: 0 0 18px; padding: 20px; overflow-x: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: .74rem; line-height: 1.5; white-space: pre;
}
@media (max-width: 620px) { .diagram { font-size: .62rem; padding: 14px; } }
