:root {
  --bg: #fdfdfc;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-dim: #55534d;
  --rule: #e2dfd8;
  --accent: #1f5fa9;      /* READ */
  --warn: #c2571f;        /* dense / top-k */
  --muted: #a8a49a;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, kbd, .mono { font-family: var(--mono); font-size: 0.88em; }
code { background: #f1efe9; padding: 0.1em 0.34em; border-radius: 4px; }
pre code { background: none; padding: 0; }

h1, h2, h3 { line-height: 1.22; }
h2 { font-size: 1.55rem; margin: 0 0 1rem; letter-spacing: -0.01em; }
h3 { font-size: 1.12rem; margin: 2rem 0 0.5rem; }

/* ---------- shell ---------- */
.page { display: flex; align-items: flex-start; }

.sidebar {
  flex: 0 0 216px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1.25rem;
  border-right: 1px solid var(--rule);
}
.sidebar .brand { display: block; margin-bottom: 2rem; }
.sidebar .brand img { display: block; width: 118px; height: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.85rem; }
.sidebar nav a {
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 0.18rem 0.5rem;
  margin-left: -0.5rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.sidebar nav a:hover, .sidebar nav a.active { color: var(--text); background: #f2f0ea; }

.content { flex: 1 1 auto; min-width: 0; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 1.75rem; }

section { padding: 3.25rem 0; }
section + section { border-top: 1px solid var(--rule); }

@media (max-width: 900px) {
  .page { display: block; }
  .sidebar {
    position: static; height: auto; width: auto;
    border-right: none; border-bottom: 1px solid var(--rule);
    padding: 0.85rem 1.25rem;
    display: flex; align-items: center; gap: 1.25rem;
    overflow-x: auto; white-space: nowrap;
  }
  .sidebar .brand { margin-bottom: 0; flex: 0 0 auto; }
  .sidebar .brand img { width: 74px; }
  .sidebar nav { flex-direction: row; gap: 1rem; }
  .sidebar nav a { font-size: 0.84rem; font-weight: 400; padding: 0; margin-left: 0; background: none; }
  .sidebar nav a:hover, .sidebar nav a.active { background: none; }
  section { padding: 2.5rem 0; }
}

/* ---------- hero ---------- */
.hero h1 { font-size: 2.15rem; margin: 0 0 0.7rem; letter-spacing: -0.015em; }
.hero .byline { font-size: 1.08rem; margin: 0 0 0.2rem; }
.hero .meta { color: var(--text-dim); font-size: 0.95rem; margin: 0 0 1.4rem; }

.buttons { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 2.2rem; }
.btn {
  display: inline-block;
  padding: 0.5rem 1.05rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent); background: #f4f8fc; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #17497f; border-color: #17497f; color: #fff; }

/* The architecture figure is black line art; it needs a white ground and a
   little breathing room, never a tinted card. */
.figure { margin: 0 0 2rem; }
.figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.figure figcaption {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin-top: 0.7rem;
  max-width: 74ch;
}
.figure--narrow { max-width: 620px; }

/* ---------- stat strip ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.4rem 0;
}
.stat .value { display: block; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .label { display: block; color: var(--text-dim); font-size: 0.86rem; line-height: 1.35; margin-top: 0.15rem; }
.stat .value.up { color: var(--accent); }
.stat .value.down { color: var(--warn); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
th, td { text-align: right; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--rule); }
th:first-child, td:first-child { text-align: left; }
thead th { border-bottom: 2px solid var(--text); font-size: 0.86rem; letter-spacing: 0.02em; }
tbody tr.highlight { background: #f4f8fc; }
tbody tr.highlight td { font-weight: 700; }
td.sig { color: var(--accent); font-weight: 700; }
td.ns { color: var(--muted); }
td .sys { font-family: var(--mono); font-size: 0.88em; }

/* ---------- code ---------- */
pre {
  background: #f7f5f0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
}
.codeblock { position: relative; }
.copy-btn {
  position: absolute; top: 0.55rem; right: 0.55rem;
  padding: 0.25rem 0.6rem;
  font: inherit; font-size: 0.78rem;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--rule); border-radius: 6px;
  cursor: pointer;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- misc ---------- */
.lede { font-size: 1.12rem; }
.claim { margin-bottom: 1.35rem; }
.claim strong { display: block; margin-bottom: 0.15rem; }
ol.limitations, ul.compact { padding-left: 1.2rem; }
ol.limitations li, ul.compact li { margin-bottom: 0.7rem; }
.callout {
  border-left: 3px solid var(--warn);
  padding: 0.15rem 0 0.15rem 1.1rem;
  margin: 1.5rem 0;
  color: var(--text-dim);
}
.tools { width: 100%; }
.tools td:first-child { font-family: var(--mono); font-size: 0.86rem; white-space: nowrap; }
.tools td:last-child { text-align: left; }

.site-footer {
  display: flex; align-items: center; flex-wrap: wrap; gap: 1.1rem;
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem; padding-top: 1.5rem;
  color: var(--text-dim); font-size: 0.92rem;
}
.site-footer img { width: 86px; height: auto; }

/* ---------- dark mode ----------
   The paper figures are black-on-white line art, so they keep a white ground
   in both themes; everything around them inverts. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #1e1e1c;
    --text: #eceae4;
    --text-dim: #a5a199;
    --rule: #33322e;
    --accent: #7fb2e8;
    --warn: #e0975c;
    --muted: #6b6862;
  }
  code { background: #262521; }
  pre { background: #1c1b19; }
  .btn:hover { background: #22262b; }
  .btn--primary { color: #12212f; }
  .btn--primary:hover { background: #a8cbf0; border-color: #a8cbf0; color: #12212f; }
  .sidebar nav a:hover, .sidebar nav a.active { background: #232220; }
  tbody tr.highlight { background: #1d2229; }
  thead th { border-bottom-color: var(--text); }
}
