:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e2e2e2;
  --soft: #f6f6f6;
  --link: #1a5fb4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111213;
    --fg: #e8e8e8;
    --muted: #a0a0a0;
    --line: #2e2f31;
    --soft: #1b1c1e;
    --link: #7fb0f0;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

main { max-width: 880px; margin: 0 auto; padding: 24px 16px 56px; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; display: block; }

.crumb { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.crumb a { color: var(--muted); }

.logo { text-align: center; margin: 8px 0 6px; }
.logo img { height: 64px; width: auto; display: inline-block; }

h1 { font-size: 26px; line-height: 1.3; text-align: center; margin: 10px 0 8px; font-weight: 600; }
h2 { font-size: 20px; margin: 44px 0 12px; font-weight: 600; }
h3 { font-size: 16px; margin: 24px 0 8px; font-weight: 600; }

.sub { text-align: center; color: var(--muted); margin: 0 0 6px; }
.authors { text-align: center; margin: 6px 0 2px; }
.affil { text-align: center; color: var(--muted); font-size: 14px; margin: 0; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 26px; }
.buttons a, .buttons span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 15px;
  color: var(--fg);
}
.buttons a:hover { border-color: var(--muted); text-decoration: none; }
.buttons span { color: var(--muted); }

/* one short line under the buttons, the same on every category page */
.note { text-align: center; font-size: 14px; color: var(--muted); max-width: 800px; margin: 0 auto 24px; }
.soon { text-align: center; margin: 30px 0; }

/* the BudgetPix paper above the BibTeX entries */
.paper { text-align: center; font-weight: 600; margin: 0 0 4px; }

figure { margin: 22px 0; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; text-align: center; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair > figure { margin: 0; }
@media (max-width: 640px) { .pair { grid-template-columns: 1fr; } }

.table { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 14px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  table { font-size: 14px; }
  th, td { padding: 6px 5px; }
  th { white-space: normal; }
}

pre {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
}

footer { max-width: 880px; margin: 0 auto; padding: 18px 16px 40px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
footer a { color: var(--muted); text-decoration: underline; }

/* the landing page's list of the three categories */
.cats { margin: 30px 0 10px; border-top: 1px solid var(--line); }
.cat { display: grid; grid-template-columns: 64px 1fr 220px; gap: 18px; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--line); color: var(--fg); }
.cat:hover { text-decoration: none; }
.cat:hover .cat-name { text-decoration: underline; }
.cat .mark { width: 64px; height: 64px; }
.cat-name { font-size: 19px; font-weight: 600; }
.cat p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.cat .thumb { width: 220px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.cat .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; background: var(--soft); }
@media (max-width: 640px) {
  .cat { grid-template-columns: 48px 1fr; }
  .cat .mark { width: 48px; height: 48px; }
  .cat .thumb, .cat .thumb.empty { display: none; }
}

/* BudgetPix: affiliations and the budget sliders (kept small) */
.affil-logos { display: flex; justify-content: center; align-items: center; gap: 28px; margin: 10px 0 8px; }
.affil-logos img { height: 34px; width: auto; display: inline-block; }
.demo { max-width: 600px; margin: 14px auto 6px; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.demo-wide { max-width: 880px; }
.demo .pair { grid-template-columns: 1fr 1fr; gap: 8px; }
.demo figure { margin: 0; }
.demo figcaption { font-size: 13px; margin-top: 4px; }
.demo .pair img, .mgrid img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--soft); border-radius: 4px; }
.demo .pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.demo .ex .pair { gap: 4px; }
.demo .ex figcaption { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 640px) { .demo .pairs { grid-template-columns: 1fr; } }
.mgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.mgrid .ref img { outline: 2px solid var(--muted); outline-offset: -2px; }
.demo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 0; }
.demo-tabs { justify-content: center; margin: 0 0 10px; }
.demo-row button {
  font: inherit; font-size: 14px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 11px; cursor: pointer;
}
.demo-row button[aria-pressed="true"] { border-color: var(--fg); }
.demo-row input[type=range] { flex: 1; min-width: 140px; }
.demo-read { font-size: 14px; min-width: 9.5em; font-variant-numeric: tabular-nums; }
.demo-caption { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: -1px; }

/* Budget3D: the interactive viewer (same frame and controls as the BudgetPix sliders) */
.v3d-objs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 10px; }
.v3d-objs button { padding: 0; line-height: 0; border: 1px solid var(--line); border-radius: 6px; background: #000; cursor: pointer; overflow: hidden; }
.v3d-objs button[aria-pressed="true"] { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
.v3d-objs img { display: block; width: 48px; height: 48px; }
.v3d-view { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.v3d-view img, .v3d-frame { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; }
.v3d-frame { background-color: #fff; background-repeat: no-repeat; cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.v3d-frame:active { cursor: grabbing; }
.v3d-frame:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
@supports not (aspect-ratio: 1) { .v3d-frame { height: 0; padding-top: 100%; } }
.v3d-read { min-width: 18em; }
@media (max-width: 640px) { .v3d-view { grid-template-columns: 1fr 1fr; } .v3d-input { display: none; } .v3d-read { min-width: 0; }
  .v3d-objs { gap: 5px; } .v3d-objs img { width: 34px; height: 34px; } }
