:root {
  --bg: #fbfaf7;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --accent: #2f5bea;
  --line: #e4e2dc;
  --badge-bg: #e7f6ec;
  --badge-fg: #1b6b3a;
  --bad: #c8453a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151517;
    --fg: #ececee;
    --muted: #9a9aa0;
    --accent: #8aa4ff;
    --line: #2c2c30;
    --badge-bg: #173523;
    --badge-fg: #7fdca1;
    --bad: #ff8a7a;
  }
}

:root[data-theme="dark"] {
  --bg: #151517;
  --fg: #ececee;
  --muted: #9a9aa0;
  --accent: #8aa4ff;
  --line: #2c2c30;
  --badge-bg: #173523;
  --badge-fg: #7fdca1;
  --bad: #ff8a7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 64px 16px 48px;
}

h1 { font-size: 2.2rem; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 48px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: underline; }

.tagline { color: var(--muted); margin: 0 0 14px; }
.badge {
  display: inline-block;
  margin: 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 0.85rem;
  font-weight: 600;
}

.pubs, .plain { list-style: none; padding: 0; margin: 0; }
.pubs li { margin-bottom: 26px; }
.pubs span { display: block; }
.pubs .title { font-weight: 600; }
.pubs .authors, .pubs .venue { color: var(--muted); font-size: 0.92rem; }
.pubs .venue { font-style: italic; }
.pubs .desc { margin-top: 4px; font-size: 0.95rem; }
.pubs .tag { display: inline-block; font-style: normal; }
.pubs .links { margin-top: 2px; font-size: 0.9rem; }
.pubs .links a { margin-right: 12px; }
.plain li { margin-bottom: 6px; }
.note { color: var(--muted); font-size: 0.85rem; margin: 0; }

footer { margin-top: 56px; color: var(--muted); font-size: 0.85rem; }

/* blog */
.back { font-size: 0.9rem; margin: 0 0 32px; }
.post h1 { font-size: 1.9rem; line-height: 1.25; }
.post h2 {
  font-size: 1.2rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  border: 0;
  margin: 36px 0 8px;
  padding: 0;
}
.post .meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 28px; }
.post pre {
  background: color-mix(in srgb, var(--fg) 6%, var(--bg));
  padding: 12px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}
.post code { font-size: 0.92em; }
.post blockquote {
  margin: 20px 0;
  padding: 2px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.posts { list-style: none; padding: 0; margin: 0; }
.posts li { margin-bottom: 22px; }
.posts .title { font-weight: 600; display: block; }
.posts .sub { color: var(--muted); font-size: 0.95rem; }

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.now { margin: 0; }

/* figures */
.fig { margin: 28px 0; }
.fig svg { width: 100%; height: auto; display: block; }
.fig figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.fig text { fill: var(--fg); font: 13px system-ui, -apple-system, "Segoe UI", sans-serif; }
.fig .t-m { fill: var(--muted); }
.fig .t-b { font-weight: 600; }
.fig .t-a { fill: var(--accent); font-weight: 600; }
.fig .t-bad { fill: var(--bad); font-weight: 600; }
.fig .box { fill: none; stroke: var(--fg); stroke-width: 1.5; }
.fig .box-a { fill: color-mix(in srgb, var(--accent) 14%, var(--bg)); stroke: var(--accent); stroke-width: 1.5; }
.fig .box-m { fill: color-mix(in srgb, var(--fg) 6%, var(--bg)); stroke: var(--muted); stroke-width: 1.2; }
.fig .ln { stroke: var(--fg); stroke-width: 1.5; fill: none; }
.fig .ln-a { stroke: var(--accent); stroke-width: 2; fill: none; }
.fig .ln-m { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.fig .ln-bad { stroke: var(--bad); stroke-width: 2; fill: none; }
.fig .dash { stroke-dasharray: 5 4; }
.fig .dot-a { fill: var(--accent); }
.fig .dot-m { fill: var(--muted); }
.fig .dot-bad { fill: var(--bad); }
.fig .fill-a { fill: var(--accent); fill-opacity: 0.28; stroke: var(--accent); stroke-width: 1.2; }
.fig .ah { fill: var(--fg); }
.fig .ah-a { fill: var(--accent); }

/* theme toggle */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.95rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.tbl td:first-child { color: var(--muted); white-space: nowrap; }
.tbl td:nth-child(2) { white-space: nowrap; }
@media (max-width: 560px) { .tbl td:nth-child(2) { white-space: normal; } }

/* phones: keep figure text readable, scroll the figure sideways if needed */
@media (max-width: 640px) {
  .fig { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .fig svg { min-width: 600px; }
}

.callout {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
  border-radius: 0 6px 6px 0;
}

/* Comparison tables scroll within the page on narrow screens. */
.table-scroll { overflow-x: auto; margin: 18px 0; }
.table-scroll .tbl { margin: 0; }
.tbl caption { text-align: left; color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.results td:first-child { color: var(--fg); }
.results td:not(:first-child) { font-variant-numeric: tabular-nums; }
