/* IKAREM docs — one grid, print hierarchy. Serif display, sans body, mono code.
   Grid: 1240px container, 28px gutters. Topbar, sidebar, content, footer
   all share the same left/right edges. One spacing scale throughout. */
:root {
  --max: 1240px;
  --pad: 28px;
  --topbar-h: 60px;
  --side-w: 248px;
  --measure: 68ch;
  --bg: #0c0c0e;
  --bg2: #131316;
  --panel: #17171b;
  --line: #26262c;
  --ink: #ece9e1;
  --mut: #a7a7b0;
  --dim: #71717c;
  --red: #ff2b2b;
  --red-deep: #c81e1e;
  --green: #3ddc84;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; }
.side, pre, table, .topbar-inner { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.side::-webkit-scrollbar, pre::-webkit-scrollbar, table::-webkit-scrollbar, .topbar-inner::-webkit-scrollbar { width: 10px; height: 10px; }
.side::-webkit-scrollbar-thumb, pre::-webkit-scrollbar-thumb, table::-webkit-scrollbar-thumb, .topbar-inner::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--bg); }
.side::-webkit-scrollbar-track, pre::-webkit-scrollbar-track, table::-webkit-scrollbar-track, .topbar-inner::-webkit-scrollbar-track { background: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--red); color: #fff; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; text-decoration-thickness: 1px; }
a:hover { color: var(--red); text-decoration-color: var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---- topbar: same grid as the page ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(12, 12, 14, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--pad);
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 28px; height: 28px; display: block; }
.brand b { font-family: var(--serif); font-size: 16px; letter-spacing: 3px; font-weight: 700; }
.ver {
  font-family: var(--mono); font-size: 11px; color: var(--bg); background: var(--ink);
  padding: 2px 8px; font-weight: 700; letter-spacing: 1px; text-decoration: none;
  border-radius: 2px; flex: none;
}
.topbar nav { margin-left: auto; display: flex; gap: 2px; align-items: center; flex: none; }
.topbar nav a { text-decoration: none; padding: 7px 12px; font-size: 13.5px; color: var(--mut); border-radius: 3px; white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); background: var(--panel); }
.topbar nav a.on { color: var(--ink); background: var(--panel); box-shadow: inset 0 -2px 0 var(--red); }
.topbar nav a.ext { border: 1px solid var(--line); margin-left: 4px; }
#navtoggle { display: none; }

/* ---- page grid: sidebar and content share a baseline ---- */
.wrap { display: flex; max-width: var(--max); margin: 0 auto; padding: 0 var(--pad); align-items: flex-start; gap: 0; }
.side {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  width: var(--side-w); flex: none;
  padding-top: 76px; padding-bottom: 60px; padding-right: 24px;
  font-size: 13.5px;
  max-height: calc(100vh - var(--topbar-h) - 16px);
  overflow-y: auto;
}
.side ol { list-style: none; margin: 0; padding: 0; }
.side li { margin: 1px 0; }
.side a {
  display: flex; align-items: baseline; gap: 9px; padding: 7px 12px;
  color: var(--mut); text-decoration: none;
  border-left: 2px solid transparent; border-radius: 0 3px 3px 0;
}
.side a:hover { color: var(--ink); }
.side a.on { color: var(--ink); border-left-color: var(--red); }
.side .n { font-family: var(--mono); font-size: 11px; color: var(--dim); flex: none; }
.side a.on .n { color: var(--red); }
.side li.partlabel { padding: 18px 12px 5px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
section.partdiv { border-top: 1px solid var(--line); padding-top: 44px; margin-bottom: 76px; }
section.partdiv h2 { font-size: 34px; }
main { flex: 1; min-width: 0; max-width: 880px; padding-top: 76px; padding-bottom: 170px; }
section { margin: 0 0 116px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
section:last-child { margin-bottom: 0; }
main p, main ul, main ol { max-width: var(--measure); }
.secnum {
  display: flex; align-items: center; gap: 12px;
  color: var(--dim); font-family: var(--mono); font-size: 12px; letter-spacing: 2px;
  margin: 0 0 16px;
}
.secnum::after { content: ""; width: 56px; border-top: 1px solid var(--red); opacity: 0.5; }
h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(44px, 6vw, 84px); line-height: 1.05;
  letter-spacing: -0.015em; margin: 0 0 20px;
  text-wrap: balance; max-width: 16ch;
}
h2 {
  font-family: var(--serif); font-weight: 700;
  font-size: 29px; line-height: 1.25; letter-spacing: -0.01em;
  margin: 0 0 18px; text-wrap: balance; max-width: 26ch;
}
h2.sub { font-family: var(--sans); font-size: 15px; font-weight: 700; letter-spacing: 0; margin: 32px 0 8px; max-width: none; }
h3 { font-size: 16px; margin: 26px 0 8px; }
p { margin: 0 0 18px; }
main ul, main ol { padding-left: 24px; }
main li { margin-bottom: 8px; }
.mut { color: var(--mut); }
.small { font-size: 13.5px; }

/* ---- hero: eyebrow, headline, lede, art, actions, proof ---- */
.hero { border-bottom: 1px solid var(--line); padding-bottom: 68px; }
.hero .kicker {
  display: flex; align-items: center; gap: 12px;
  color: var(--red); font-family: var(--mono); font-size: 12px; letter-spacing: 2.5px;
  margin: 0 0 20px;
}
.hero .kicker::after { content: ""; width: 72px; border-top: 1px solid var(--red); opacity: 0.55; }
.lede { font-family: var(--serif); font-size: 21px; line-height: 1.55; max-width: 34em; margin: 0 0 20px; }
.heroimg { border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); margin: 38px 0 10px; overflow: hidden; max-width: 640px; }
.heroimg svg { display: block; width: 100%; height: auto; }
.artcap { font-size: 12.5px; color: var(--dim); max-width: 640px; margin: 0 0 6px; }
.artcap a { color: var(--dim); }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin: 30px 0 6px; }
.btn {
  display: inline-block; padding: 12px 22px; font-size: 14px; font-weight: 650;
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: transparent;
  border-radius: 4px;
}
.btn:hover { border-color: var(--red); color: var(--ink); }
.btn.pri { background: var(--red); border-color: var(--red); color: #fff; }
.btn.pri:hover { background: var(--red-deep); border-color: var(--red-deep); color: #fff; }
.btn.pri::after { content: " \2192"; }

/* ---- stats band: one row, shared dividers, tabular numerals ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; border-top: 1px solid var(--line); margin: 44px 0 6px; padding-top: 26px; }
.stat { padding: 0; }
.stat b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat b.g { color: var(--green); }
.stat span { display: block; margin-top: 2px; font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--mut); }

/* ---- code ---- */
pre {
  position: relative;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px;
  padding: 18px 20px; overflow-x: auto;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.65; margin: 0 0 24px;
  max-width: 100%;
}
pre code { background: none; border: 0; padding: 0; }
code { font-family: var(--mono); font-size: 0.86em; }
p code, li code, td code { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; white-space: nowrap; }
.tok-k { color: var(--red); }
.tok-s { color: var(--green); }
.tok-c { color: var(--dim); }
.copy {
  position: absolute; top: 8px; right: 8px;
  background: var(--panel); border: 1px solid var(--line); color: var(--mut);
  font-family: var(--mono); font-size: 11px; padding: 4px 10px; cursor: pointer;
  border-radius: 3px;
}
.copy:hover { color: var(--ink); border-color: var(--red); }

/* ---- tables: header row, calm dividers, aligned columns ---- */
table { width: 100%; max-width: 100%; border-collapse: collapse; margin: 0 0 26px; font-size: 14px; }
thead th, th {
  text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: 2px;
  color: var(--mut); font-weight: 700; text-transform: uppercase;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 11px 14px;
}
td { border-bottom: 1px solid var(--line); padding: 13px 16px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel); }

/* ---- callouts ---- */
.note { border: 1px solid var(--line); border-left: 2px solid var(--red); border-radius: 0 6px 6px 0; background: var(--bg2); padding: 16px 20px; margin: 0 0 24px; font-size: 14px; max-width: var(--measure); }
.note b { color: var(--red); }

/* ---- footer: same grid, two aligned groups ---- */
footer { border-top: 1px solid var(--line); padding: 36px 0 60px; color: var(--dim); font-size: 13px; }
footer .wrap { display: flex; gap: 24px; align-items: baseline; }
footer .wrap > span:last-child { margin-left: auto; text-align: right; }
footer a { color: var(--dim); }

@media (max-width: 900px) {
  :root { --pad: 20px; }
  body { font-size: 15px; }
  .topbar-inner { overflow-x: auto; scrollbar-width: none; }
  .topbar-inner::-webkit-scrollbar { display: none; }
  .topbar nav { margin-left: 0; }
  .wrap { flex-direction: column; align-items: stretch; }
  footer .wrap { flex-direction: row; flex-wrap: wrap; row-gap: 8px; }
  footer .wrap > span:last-child { margin-left: 0; text-align: left; }
  .side { position: static; width: auto; max-height: none; padding: 20px 0 0; }
  .side ol { display: flex; flex-wrap: wrap; gap: 6px; }
  .side a { border: 1px solid var(--line); border-radius: 4px; }
  .side a.on { border-color: var(--red); }
  main { padding-top: 36px; padding-bottom: 90px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 20px 24px; }
  .lede { font-size: 19px; }
  table { display: block; overflow-x: auto; border-radius: 6px; }
  h1 { font-size: clamp(40px, 11vw, 56px); }
}
@media (min-width: 901px) {
  .side { padding-right: 32px; }
  main { padding-left: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .topbar, .side, .copy, footer .wrap > span:last-child, .btnrow { display: none; }
  body { background: #fff; color: #161616; font-size: 11pt; line-height: 1.6; }
  .wrap { display: block; max-width: 100%; padding: 0; }
  main { max-width: 100%; padding: 0; }
  h1, h2, h3, p, li, td, th, a, .lede, .mut { color: #161616; }
  a { text-decoration-color: #999; }
  .secnum, .hero .kicker { color: #666; }
  .secnum::after, .hero .kicker::after { border-color: #999; }
  .hero { border: 0; padding-bottom: 12px; }
  .artcap, .artcap a { color: #666; }
  pre {
    background: #f4f4f4; border: 1px solid #ddd; color: #161616;
    white-space: pre-wrap; word-break: break-word; break-inside: avoid;
  }
  p code, li code, td code { background: #efefef; border-color: #ddd; }
  .tok-k, .note b { color: #a00; }
  .tok-s, .stat b.g { color: #060; }
  .tok-c { color: #888; }
  .note { background: #fafafa; }
  table, th, td { border-color: #ddd; }
  th { background: #f4f4f4; color: #555; }
  tbody tr:hover td { background: none; }
  h1, h2, h3 { break-after: avoid; }
  section { margin-bottom: 32px; }
  footer { border-color: #ddd; color: #666; }
  footer a { color: #666; }
}
