/* ==========================================================================
   Ivory Docs — a calm, warm documentation theme for Publii
   ========================================================================== */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-heading: var(--font-serif);
  --heading-weight: 500;
  --heading-tracking: -0.015em;

  --topbar-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 232px;
  --content-w: 740px;
  --radius: 10px;
  --radius-sm: 6px;

  --accent: #8c2f45;
}

/* Light — warm ivory */
:root,
[data-theme="light"] {
  --bg: #faf9f5;
  --bg-elev: #ffffff;
  --bg-subtle: #f0eee6;
  --bg-hover: #ebe9e0;
  --border: #e5e3d9;
  --border-strong: #d6d3c7;
  --text: #141413;
  --text-2: #3d3d3a;
  --muted: #6b6a64;
  --faint: #8f8d85;
  --code-bg: #f3f1ea;
  --code-text: #3d3929;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 8px 24px rgba(20, 20, 19, .06);
  --shadow-lg: 0 24px 64px rgba(20, 20, 19, .18);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-text: var(--accent);
  color-scheme: light;
}

/* Dark — warm charcoal */
[data-theme="dark"] {
  --bg: #1f1e1c;
  --bg-elev: #2a2927;
  --bg-subtle: #2a2927;
  --bg-hover: #33322f;
  --border: #353431;
  --border-strong: #46453f;
  --text: #f2f0e8;
  --text-2: #d9d6cc;
  --muted: #a8a59b;
  --faint: #807e75;
  --code-bg: #262523;
  --code-text: #e6e2d6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 50%, #fff);
  color-scheme: dark;
}

/* Background tone (Theme settings → Appearance → Background tone).
   "warm" = the ivory palette above. "neutral" and "tinted" override it. */
:root[data-bg="neutral"]:not([data-theme="dark"]),
:root[data-bg="tinted"]:not([data-theme="dark"]) {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-subtle: #f2f2f3;
  --bg-hover: #ececee;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #6b6b74;
  --faint: #8e8e96;
  --code-bg: #f4f4f5;
  --code-text: #27272a;
}
:root[data-bg="neutral"][data-theme="dark"],
:root[data-bg="tinted"][data-theme="dark"] {
  --bg: #18181a;
  --bg-elev: #232326;
  --bg-subtle: #232326;
  --bg-hover: #2c2c30;
  --border: #2f2f33;
  --border-strong: #3f3f46;
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #7c7c85;
  --code-bg: #1f1f22;
  --code-text: #e4e4e7;
}
/* Tinted: neutral greys with a faint wash of the accent color */
:root[data-bg="tinted"]:not([data-theme="dark"]) {
  --bg: color-mix(in srgb, var(--accent) 4%, #fcfcfc);
  --bg-subtle: color-mix(in srgb, var(--accent) 6%, #f3f3f4);
  --bg-hover: color-mix(in srgb, var(--accent) 8%, #ededef);
  --border: color-mix(in srgb, var(--accent) 10%, #e4e4e7);
  --border-strong: color-mix(in srgb, var(--accent) 12%, #d4d4d8);
  --code-bg: color-mix(in srgb, var(--accent) 5%, #f4f4f5);
}
:root[data-bg="tinted"][data-theme="dark"] {
  --bg: color-mix(in srgb, var(--accent) 6%, #161618);
  --bg-elev: color-mix(in srgb, var(--accent) 7%, #212124);
  --bg-subtle: color-mix(in srgb, var(--accent) 7%, #212124);
  --bg-hover: color-mix(in srgb, var(--accent) 9%, #2a2a2e);
  --border: color-mix(in srgb, var(--accent) 10%, #2e2e33);
  --border-strong: color-mix(in srgb, var(--accent) 12%, #3d3d44);
  --code-bg: color-mix(in srgb, var(--accent) 6%, #1d1d20);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
  scrollbar-gutter: stable; /* keep the scrollbar space reserved so content does not shift when search locks scrolling */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 6px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand__logo { height: 26px; width: auto; display: block; }
.brand__name { white-space: nowrap; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  height: 36px;
  margin-left: 24px;
  padding: 0 8px 0 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--faint);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.search-trigger__label { flex: 1; text-align: left; }

.topbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}


.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }

[data-theme="light"] .i-moon,
[data-theme="dark"] .i-sun { display: none; }

.topbar__menu-btn,
.topbar__search-mobile { display: none; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.layout {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}
.layout--toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }

.main { min-width: 0; }
.content {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 48px 32px 32px;
}
.is-home .content,
.is-tags .content { max-width: 960px; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  border-right: 1px solid var(--border);
}
.sidebar__inner {
  height: 100%;
  overflow-y: auto;
  padding: 28px 16px 48px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-backdrop { display: none; }

.sidenav__group + .sidenav__group,
.sidenav__list--root + .sidenav__group,
.sidenav__group + .sidenav__list--root { margin-top: 24px; }

.sidenav__heading {
  display: block;
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
}
a.sidenav__heading:hover { color: var(--accent-text); }

.sidenav__list { list-style: none; margin: 0; padding: 0; }
.sidenav__list .sidenav__list {
  margin: 2px 0 4px 14px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.sidenav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin: 1px 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  transition: color .12s, background .12s;
}
.sidenav__link:hover { color: var(--text); background: var(--bg-hover); }
.sidenav__link.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  font-weight: 500;
}

.sidenav__toggle { list-style: none; }
.sidenav__toggle::-webkit-details-marker { display: none; }
.sidenav__chev { flex-shrink: 0; transition: transform .15s; opacity: .7; }
details[open] > .sidenav__toggle .sidenav__chev { transform: rotate(90deg); }

/* --------------------------------------------------------------------------
   Table of contents
   -------------------------------------------------------------------------- */
.toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.toc__inner {
  height: 100%;
  overflow-y: auto;
  padding: 48px 20px 48px 8px;
  scrollbar-width: none;
}
.toc__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  border-left: 1px solid var(--border);
  transition: color .12s, border-color .12s;
}
.toc li.toc--h3 a { padding-left: 24px; }
.toc li a:hover { color: var(--text); }
.toc li a.is-active { color: var(--accent-text); border-left-color: var(--accent); }

/* --------------------------------------------------------------------------
   Homepage
   -------------------------------------------------------------------------- */
.hero { padding: 24px 0 40px; }
.hero__title {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.12;
  letter-spacing: var(--heading-tracking);
}
.hero__text {
  margin: 0;
  max-width: 600px;
  font-size: 18px;
  color: var(--muted);
}
.hero__search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  height: 48px;
  margin-top: 28px;
  padding: 0 12px 0 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--faint);
  font-size: 15px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.hero__search:hover { border-color: var(--border-strong); }
.hero__search span { flex: 1; text-align: left; }

.section { margin-top: 8px; }
.section__title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 20px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.card__eyebrow { font-size: 12px; font-weight: 500; color: var(--accent-text); }
.card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.card__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--faint);
}
.card__arrow { opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; color: var(--accent); }
.card:hover .card__arrow { opacity: 1; transform: none; }

/* Lists (tag / author pages) */
.list { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--border); }
.list__item a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.list__item a:hover .list__title { color: var(--accent-text); }
.list__title { font-weight: 600; transition: color .12s; }
.list__text { font-size: 14px; color: var(--muted); }

.author { display: flex; gap: 20px; align-items: center; }
.author__avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  font-size: 14px;
}
.pager__count { color: var(--faint); }
.pager__link {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  font-weight: 500;
}
.pager__link:hover { border-color: var(--border-strong); }

/* --------------------------------------------------------------------------
   Document header / footer
   -------------------------------------------------------------------------- */
.doc__header { margin-bottom: 32px; }
.doc__eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-text);
}
.doc__title {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: clamp(30px, 4vw, 38px);
  line-height: 1.18;
  letter-spacing: var(--heading-tracking);
}
.doc__lead {
  margin: 12px 0 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}
.doc__lead p { margin: 0; }
.doc__meta {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--faint);
}
.doc__meta a:hover { color: var(--text); }
.doc__meta .dot { margin: 0 6px; }
.doc__meta a.doc__author {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 2px;
}
.doc__meta a.doc__author:hover { color: var(--accent-text); text-decoration-color: currentColor; }

.doc__figure { margin: 0 0 32px; }
.doc__figure img { border-radius: var(--radius); border: 1px solid var(--border); display: block; }
.doc__figure figcaption { margin-top: 8px; font-size: 13px; color: var(--faint); text-align: center; }

.doc__footer { margin-top: 56px; }
.doc__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-subtle);
  border-radius: 999px;
  transition: color .12s, background .12s;
}
.chip:hover { color: var(--text); background: var(--bg-hover); }
.doc__updated { margin: 20px 0 0; font-size: 13px; color: var(--faint); }

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.prevnext__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.prevnext__link:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.prevnext__link--next { grid-column: 2; text-align: right; }
.prevnext__label { font-size: 12px; color: var(--faint); }
.prevnext__title { font-weight: 600; font-size: 15px; }

.prevnext:not(:has(.prevnext__link)) { display: none; }

.site-footer {
  margin-top: 64px;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--faint);
}
.site-footer p { margin: 0; }

/* 404 */
.notfound { padding-top: clamp(40px, 9vh, 96px); }
.notfound__header { position: relative; }
.notfound__code {
  margin: 0 0 -0.12em;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: clamp(88px, 16vw, 148px);
  line-height: 1;
  letter-spacing: -0.04em;
  color: transparent;
  background: linear-gradient(160deg, var(--accent-text) 10%, color-mix(in srgb, var(--accent) 30%, var(--bg)) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  user-select: none;
}
.notfound .doc__lead { max-width: 52ch; }
.notfound__path {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}
.notfound__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.notfound__actions .btn { gap: 8px; }
.btn__kbd {
  margin-left: 4px;
  padding: 1px 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-subtle);
}
@media (hover: none) { .btn__kbd { display: none; } }
.notfound__suggest { margin: 22px 0 0; font-size: 15px; color: var(--muted); }
.notfound__suggest-btn {
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: var(--accent-text);
  background: none;
  border: 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  cursor: pointer;
}
.notfound__suggest-btn:hover { border-bottom-style: solid; }
.notfound__section { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); }
.notfound__topics { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.notfound__topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color .15s, color .15s, background .15s;
}
.notfound__topic:hover { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); }
.notfound__topic-count {
  min-width: 20px;
  padding: 1px 6px;
  font-size: 12px;
  text-align: center;
  color: var(--faint);
  background: var(--bg-subtle);
  border-radius: 999px;
}
.btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-elev);
  cursor: pointer;
}
.btn:hover { border-color: var(--border-strong); }
.btn--primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn--primary:hover { opacity: .9; }

/* --------------------------------------------------------------------------
   Prose
   -------------------------------------------------------------------------- */
.prose { color: var(--text-2); font-size: 16px; line-height: 1.75; }
.prose > :first-child { margin-top: 0; }

.prose h2, .prose h3, .prose h4 {
  position: relative;
  color: var(--text);
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
.prose h2 {
  margin: 2.4em 0 .7em;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: var(--heading-tracking);
}
.prose h3 {
  margin: 2em 0 .6em;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.prose h4 { margin: 1.8em 0 .5em; font-size: 16px; font-weight: 600; }

.heading-anchor {
  position: absolute;
  left: -1.3em;
  padding-right: .4em;
  color: var(--faint);
  font-family: var(--font-sans);
  font-weight: 400;
  opacity: 0;
  transition: opacity .12s;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }

.prose p { margin: 0 0 1.25em; }

.prose a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .12s, color .12s;
}
.prose a:hover { color: var(--accent-text); text-decoration-color: var(--accent); }

.prose strong { color: var(--text); font-weight: 600; }

.prose ul, .prose ol { margin: 0 0 1.25em; padding-left: 1.4em; }
.prose li { margin: .35em 0; padding-left: .2em; }
.prose li::marker { color: var(--faint); }
.prose ol li::marker { font-size: .92em; }

.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

.prose img { border-radius: var(--radius); }
.prose figure { margin: 2em 0; }
.prose figcaption { margin-top: 8px; font-size: 13px; color: var(--faint); text-align: center; }

/* Callouts — blockquotes, plus optional .note / .tip / .warning / .danger classes */
.prose blockquote,
.prose .note, .prose .info, .prose .tip, .prose .warning, .prose .danger {
  margin: 1.6em 0;
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-2);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prose blockquote > :last-child,
.prose .note > :last-child, .prose .info > :last-child, .prose .tip > :last-child,
.prose .warning > :last-child, .prose .danger > :last-child { margin-bottom: 0; }
.prose blockquote { border-left: 3px solid var(--accent); border-radius: 4px var(--radius) var(--radius) 4px; }
.prose .tip { background: color-mix(in srgb, #3f8f5a 9%, var(--bg)); border-color: color-mix(in srgb, #3f8f5a 30%, var(--border)); }
.prose .note, .prose .info { background: color-mix(in srgb, #4a6fa5 9%, var(--bg)); border-color: color-mix(in srgb, #4a6fa5 30%, var(--border)); }
.prose .warning { background: color-mix(in srgb, #c4932b 11%, var(--bg)); border-color: color-mix(in srgb, #c4932b 35%, var(--border)); }
.prose .danger { background: color-mix(in srgb, #c0453a 9%, var(--bg)); border-color: color-mix(in srgb, #c0453a 32%, var(--border)); }

/* Code */
.prose code {
  font-family: var(--font-mono);
  font-size: .86em;
  padding: .15em .4em;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.prose a code { color: inherit; }

.code-block { position: relative; margin: 1.6em 0; }
.prose pre {
  margin: 1.6em 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  tab-size: 2;
}
.code-block pre { margin: 0; }
.prose pre code {
  padding: 0;
  font-size: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); }
.copy-btn.is-copied { color: var(--accent-text); opacity: 1; }

/* Tables */
.table-wrap { margin: 1.6em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.55; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { font-weight: 600; color: var(--text); background: var(--bg-subtle); }
.prose tr:last-child td { border-bottom: 0; }

/* Publii editor helpers */
.prose .align-left { float: left; margin: 0 1.5em 1em 0; }
.prose .align-right { float: right; margin: 0 0 1em 1.5em; }
.prose .align-center { text-align: center; }
.prose .post__image--full, .prose .post__image--wide { margin-left: 0; margin-right: 0; }
.prose .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 2em 0; }
.prose .gallery img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.prose iframe, .prose video { max-width: 100%; border-radius: var(--radius); }

/* --------------------------------------------------------------------------
   Search modal
   -------------------------------------------------------------------------- */
.search[hidden] { display: none; }
.search {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
}
.search__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 19, .35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .15s ease-out;
}
.search__dialog {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

.search__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  color: var(--faint);
}
.search__input {
  flex: 1;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.search__input::placeholder { color: var(--faint); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__esc { cursor: pointer; }

.search__results { overflow-y: auto; padding: 8px; flex: 1; }
.search__empty { margin: 0; padding: 28px 12px; text-align: center; font-size: 14px; color: var(--faint); }

.search__item {
  display: block;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.search__item.is-selected { background: var(--bg-hover); }
.search__item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.search__item-title svg { flex-shrink: 0; color: var(--faint); }
.search__item.is-selected .search__item-title svg { color: var(--accent); }
.search__item-text {
  margin-top: 2px;
  padding-left: 24px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search__item mark {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 3px;
  padding: 0 1px;
}

.search__footer {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--faint);
}
.search__footer kbd { margin-right: 3px; padding: 2px 5px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1240px) {
  .layout--toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .layout, .layout--toc { grid-template-columns: minmax(0, 1fr); }

  .topbar__menu-btn, .topbar__search-mobile { display: inline-grid; }
  .search-trigger { display: none; }
  .topbar__inner { padding: 0 12px; gap: 8px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(300px, 86vw);
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(20, 20, 19, .3);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-open { overflow: hidden; }


  .content { padding: 32px 20px 24px; }
  .heading-anchor { display: none; }
}

@media (max-width: 560px) {
  .prevnext { grid-template-columns: 1fr; }
  .prevnext__link--next { grid-column: 1; }
  .search { padding-top: 0; }
  .search__dialog { max-height: 100vh; height: 100vh; max-width: none; border-radius: 0; border: 0; }
  .search__footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .sidebar, .toc, .prevnext, .site-footer, .copy-btn { display: none !important; }
  .layout, .layout--toc { display: block; }
  .content { max-width: none; padding: 0; }
}

/* --------------------------------------------------------------------------
   Social buttons (header) + tag groups (sidebar)
   -------------------------------------------------------------------------- */
.topbar__social,
.sidebar__mobile-social { display: flex; align-items: center; gap: 2px; }
.topbar__social { margin-right: 4px; padding-right: 8px; border-right: 1px solid var(--border); }
.topbar__social:not(:has(a)) { display: none; }


.sidebar__mobile-social { display: none; }

summary.sidenav__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  margin: 0 0 2px;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
}
summary.sidenav__heading:hover { background: var(--bg-hover); }
.sidenav__tag + .sidenav__tag { margin-top: 12px; }

@media (max-width: 900px) {
  .topbar__social { display: none; }
  .sidebar__mobile-social:has(a) {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0 16px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border);
  }
}

/* ==========================================================================
   Pages — focused, wide layout for project / research pages
   ========================================================================== */
:root {
  --page-text: 760px;    /* reading column */
  --page-wide: 1180px;   /* [wide] blocks, columns, galleries */
  --page-gutter: clamp(20px, 4vw, 40px);
}

/* Sidebar becomes a drawer on every screen size; the menu button opens it */
.is-page .layout { display: block; max-width: none; }
.is-page .topbar__menu-btn { display: inline-grid; }
.is-page .sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  width: min(var(--sidebar-w), 86vw);
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
}
.is-page.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .22s ease; }
.is-page .sidebar-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(20, 20, 19, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.is-page.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
.is-page.sidebar-open { overflow: hidden; }

/* Breakout column system.
   .page-doc is a size container, so 100cqi = full content width anywhere inside.
   Text sits in a centered column of --page-text; .sc--wide / .sc--full break out. */
.is-page .content { max-width: none; padding: 48px 0 32px; }
.page-doc {
  container-type: inline-size;
  --pad: max(var(--page-gutter), (100cqi - var(--page-text)) / 2);
  --wide-out: max(0px, min((100cqi - var(--page-text)) / 2 - var(--page-gutter), (var(--page-wide) - var(--page-text)) / 2));
}
.page-doc > :not(.prose),
.is-page .site-footer {
  max-width: calc(var(--page-text) + 2 * var(--page-gutter));
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
}
.is-page .site-footer { max-width: calc(var(--page-wide) + 2 * var(--page-gutter)); border-top: 0; }
.is-page .site-footer::before { content: ""; display: block; border-top: 1px solid var(--border); margin-bottom: 24px; }
.is-page .site-footer { padding-top: 0; }

.page-prose,
.page-prose .sc-band { padding-left: var(--pad); padding-right: var(--pad); }

.page-prose > .sc--wide,
.page-prose > .post__image--wide,
.page-prose > .gallery-wrapper--wide,
.page-prose > .wide,
.sc-band > .sc--wide,
.sc-band > .post__image--wide,
.sc-band > .gallery-wrapper--wide,
.sc-band > .wide {
  margin-left: calc(-1 * var(--wide-out));
  margin-right: calc(-1 * var(--wide-out));
}
.page-prose > .sc--full,
.page-prose > .post__image--full,
.page-prose > .gallery-wrapper--full,
.page-prose > .full {
  margin-left: calc(-1 * var(--pad));
  margin-right: calc(-1 * var(--pad));
}
.page-prose > .post__image--full img,
.page-prose > .sc-video.sc--full video,
.page-prose > .sc-block.sc--full > figure img { border-radius: 0; border-left: 0; border-right: 0; }
.page-prose > .sc--full > figcaption,
.page-prose > .post__image--full > figcaption { padding: 0 var(--pad); }

/* Teaser (featured image) */
.page-doc > .page-teaser { margin-bottom: 40px; }
.page-doc > .page-teaser--wide { max-width: calc(var(--page-wide) + 2 * var(--page-gutter)); }
.page-doc > .page-teaser--full { max-width: none; padding: 0; }
.page-doc > .page-teaser--full img { border-radius: 0; border-left: 0; border-right: 0; width: 100%; }
.page-teaser img { width: 100%; }

/* Project header */
.page--project .page-header {
  max-width: calc(var(--page-wide) + 2 * var(--page-gutter));
  margin-bottom: 40px;
  padding-top: 16px;
  text-align: center;
}
.page--project .doc__title {
  max-width: 920px;
  margin: 0 auto;
  font-size: clamp(32px, 4.6vw, 52px);
  line-height: 1.12;
  text-wrap: balance;
}
.page--project .doc__lead { max-width: 720px; margin-left: auto; margin-right: auto; text-wrap: balance; }
.page-header__kicker {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.page-header__authors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 22px 0 0;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
}
.page--project .page-header__authors { justify-content: center; max-width: 960px; margin-left: auto; margin-right: auto; }
.page-header__author { white-space: nowrap; }
.page-header__author a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
.page-header__author a:hover { color: var(--accent-text); text-decoration-color: currentColor; }
.page-header sup { font-size: .62em; margin-left: 1px; color: var(--muted); font-feature-settings: "tnum"; }
.page-header__affils {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--muted);
}
.page-header__affils sup { margin: 0 2px 0 0; }
.page-header__affils a:hover { color: var(--text); }
.page-header__notes { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 4px 0 0; font-size: 13px; color: var(--faint); }
.page-header__notes:empty { display: none; }
.page--project .page-header__affils,
.page--project .page-header__notes { justify-content: center; }
.page-header__links { margin-top: 26px; }
.page--project .page-header__links { justify-content: center; }
.page--project .doc__meta { margin-top: 18px; }

/* Floating table of contents on pages */
.toc--float {
  position: fixed;
  z-index: 30;
  height: auto;
  top: calc(var(--topbar-h) + 32px);
  right: 24px;
  width: 220px;
  max-height: calc(100vh - var(--topbar-h) - 64px);
}
.toc--float .toc__inner { padding: 0; max-height: inherit; }
.toc-fab { display: none; }

@media (max-width: 1659px) {
  /* Not enough margin for a rail: open it from a floating button */
  .toc-fab:not([hidden]) {
    position: fixed;
    z-index: 35;
    right: 20px;
    bottom: 20px;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elev);
    color: var(--muted);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: color .15s, border-color .15s;
  }
  .toc-fab:hover, .toc-open .toc-fab { color: var(--accent-text); border-color: var(--border-strong); }
  .toc--float {
    top: auto;
    bottom: 74px;
    right: 20px;
    width: min(300px, calc(100vw - 40px));
    max-height: min(60vh, 520px);
    padding: 16px 16px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .15s, transform .15s, visibility 0s linear .15s;
  }
  .toc-open .toc--float { opacity: 1; visibility: visible; transform: none; transition: opacity .15s, transform .15s; }
  .toc--float .toc__inner { overflow-y: auto; max-height: calc(min(60vh, 520px) - 28px); }
}
@media (max-width: 1240px) {
  .is-page .toc.toc--float { display: block; }
}

/* ==========================================================================
   Page components (shortcodes) — work in posts too, at text width
   ========================================================================== */
.prose .sc-columns,
.prose .sc-grid,
.prose .sc-gallery,
.prose .sc-stats,
.prose .sc-tabs,
.prose .sc-card,
.prose .sc-block,
.prose .sc-band,
.prose .sc-video,
.prose .sc-embed,
.prose .sc-compare,
.prose .sc-buttons { margin-top: 2em; margin-bottom: 2em; }

.prose [class^="sc-"] > :first-child,
.prose .sc-col > :first-child,
.prose .sc-tabs__panel > :first-child { margin-top: 0; }
.prose [class^="sc-"] > :last-child,
.prose .sc-col > :last-child,
.prose .sc-tabs__panel > :last-child { margin-bottom: 0; }

/* Columns & grid */
.sc-columns, .sc-grid {
  display: grid;
  grid-template-columns: var(--sc-cols, repeat(2, minmax(0, 1fr)));
  gap: 28px 36px;
  align-items: start;
}
.sc-grid { gap: 20px; }
.sc-columns--center { align-items: center; }
.sc-columns--bottom { align-items: end; }
.sc-columns--tight { gap: 12px 16px; }
.sc-columns--loose { gap: 40px 64px; }
.sc-col { min-width: 0; }
.sc-grid > p:has(> figure) { display: contents; }
.prose .sc-col figure, .prose .sc-grid figure { margin: 0 0 1em; }
.prose .sc-grid > figure, .prose .sc-grid > p { margin: 0; }
.sc-col h3:first-child, .sc-col h4:first-child { margin-top: 0; }

/* Gallery (shortcode + Publii's gallery block) */
.sc-gallery {
  display: grid;
  grid-template-columns: repeat(var(--sc-cols, 3), minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.sc-gallery > p { display: contents; }
.prose .sc-gallery figure { margin: 0; }
.prose .sc-gallery img { display: block; width: 100%; border-radius: var(--radius-sm); cursor: zoom-in; }
.sc-gallery--square img { aspect-ratio: 1; object-fit: cover; }
.prose .sc-gallery figcaption { margin-top: 6px; font-size: 12.5px; text-align: left; }

.prose .gallery-wrapper { margin: 2em 0; }
.prose .gallery-wrapper .gallery { margin: 0; }
.prose .gallery[data-columns] { grid-template-columns: repeat(var(--g-cols, 3), minmax(0, 1fr)); }
.prose .gallery[data-columns="1"] { --g-cols: 1; }
.prose .gallery[data-columns="2"] { --g-cols: 2; }
.prose .gallery[data-columns="4"] { --g-cols: 4; }
.prose .gallery[data-columns="5"] { --g-cols: 5; }
.prose .gallery[data-columns="6"] { --g-cols: 6; }
.prose .gallery[data-columns="7"] { --g-cols: 7; }
.prose .gallery[data-columns="8"] { --g-cols: 8; }
.prose .gallery__item { margin: 0; }
.prose .gallery__item a { display: block; cursor: zoom-in; }
.prose .gallery__item img { display: block; border-radius: var(--radius-sm); }
.prose .gallery__item figcaption { margin-top: 4px; font-size: 12.5px; }

/* Lightbox-able standalone figures on pages */
.is-page .page-prose figure.post__image img,
.is-page .page-prose .sc-col figure img { cursor: zoom-in; }

/* Video & embeds */
.prose .sc-video video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border-radius: var(--radius);
}
.prose .sc-video video:not([controls]) { background: transparent; }
.sc-embed__frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
.prose .sc-embed__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; }
.prose .sc-video figcaption, .prose .sc-embed figcaption, .prose .sc-compare figcaption { margin-top: 10px; }
.sc-col .sc-video, .sc-col .sc-embed, .sc-grid .sc-video, .sc-grid .sc-embed { margin: 0 0 1em; }

/* Before / after comparison slider */
.sc-compare__stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  user-select: none;
  touch-action: pan-y;
  background: var(--bg-subtle);
}
.prose .sc-compare__img img { display: block; width: 100%; height: auto; border-radius: 0; margin: 0; pointer-events: none; }
.sc-compare__img--b {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 0 var(--pos));
}
.sc-compare__img--b img { width: 100%; height: 100% !important; object-fit: cover; }
.sc-compare__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
  pointer-events: none;
}
.sc-compare__handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 7l-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 20px no-repeat;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.sc-compare__range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  -webkit-appearance: none;
  appearance: none;
}
.sc-compare__range:focus-visible ~ .sc-compare__handle::after,
.sc-compare__stage:has(.sc-compare__range:focus-visible) .sc-compare__handle::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.sc-compare__label {
  position: absolute;
  top: 12px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  pointer-events: none;
}
.sc-compare__label--a { left: 12px; }
.sc-compare__label--b { right: 12px; }

/* Tabs — libadwaita-style toggle group: tinted track, raised selected chip */
.sc-tabs__list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 0;
  border-radius: 11px;
}
.sc-tabs__tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: color-mix(in srgb, var(--text) 72%, transparent);
  box-shadow: none;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.sc-tabs__tab:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.sc-tabs__tab:active { background: color-mix(in srgb, var(--text) 10%, transparent); }
.sc-tabs__tab[aria-selected="true"],
.sc-tabs__tab[aria-selected="true"]:hover {
  color: var(--accent-text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 1px rgba(0, 0, 0, .06);
}
[data-theme="dark"] .sc-tabs__tab[aria-selected="true"],
[data-theme="dark"] .sc-tabs__tab[aria-selected="true"]:hover {
  background: color-mix(in srgb, #fff 15%, transparent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.sc-tabs__tab:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.sc-tabs__list {
  display: flex;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 18px;
}
.sc-tabs__tab { font-size: 14px; padding: 6px 16px; }
.sc-tabs__panel[hidden] { display: none; }

/* Link buttons ("pills") */
.sc-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.sc-buttons--center { justify-content: center; }
.prose .sc-buttons a.pill, .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px 0 14px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 999px;
  text-decoration: none;
  transition: background .15s, color .15s, transform .15s, box-shadow .15s;
}
.prose .sc-buttons a.pill:hover, a.pill:hover { color: var(--bg); background: var(--accent); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.pill .ic { flex-shrink: 0; }
/* Page header links: a lighter accent on hover (the raw accent reads too dark) */
.page-header__links a.pill:hover {
  background: color-mix(in srgb, var(--accent) 75%, #fff);
  border-color: color-mix(in srgb, var(--accent) 75%, #fff);
}
[data-theme="dark"] .page-header__links a.pill:hover { background: var(--accent-text); border-color: var(--accent-text); }
.pill.is-disabled { color: var(--faint); background: transparent; border-color: var(--border-strong); border-style: dashed; cursor: default; }

/* Stats: a list of "**94%** success rate" items */
.sc-stats ul, .sc-stats ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.prose .sc-stats li {
  margin: 0;
  padding: 18px 18px 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.prose .sc-stats li::marker { content: ""; }
.prose .sc-stats li strong:first-child, .prose .sc-stats li b:first-child {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: var(--heading-tracking);
  color: var(--accent-text);
  font-feature-settings: "tnum", "lnum";
}

/* Card */
.sc-card {
  padding: 22px 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.prose .sc-card__title { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }

/* Band: full-bleed tinted section */
.prose .sc-band {
  padding-top: 48px;
  padding-bottom: 48px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.prose .sc-band--accent { background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
.prose .sc-band--dark { background: #161615; color: #e9e7df; border-color: #161615; }
.prose .sc-band--dark h2, .prose .sc-band--dark h3, .prose .sc-band--dark strong { color: #fff; }
.prose .sc-band + .sc-band { margin-top: -2em; border-top: 0; }
/* Posts have no room to bleed: show the band as a rounded box */
.is-post .prose .sc-band { padding: 24px; border: 1px solid var(--border); border-radius: 14px; }

/* Lightbox */
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 72px;
  background: rgba(12, 12, 11, .92);
  animation: fade .15s ease-out;
}
.lightbox__figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.lightbox__img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.lightbox__caption { margin-top: 12px; max-width: 760px; font-size: 14px; color: rgba(255, 255, 255, .78); text-align: center; }
.lightbox__caption:empty { display: none; }
.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.lightbox__btn:hover { background: rgba(255, 255, 255, .18); }
.lightbox__close { top: 14px; right: 14px; }
.lightbox__prev { left: 14px; top: 50%; margin-top: -22px; }
.lightbox__next { right: 14px; top: 50%; margin-top: -22px; }
.lightbox__btn[hidden] { display: none; }
.lightbox__count { position: absolute; top: 24px; left: 24px; font-size: 13px; color: rgba(255, 255, 255, .6); font-feature-settings: "tnum"; }

/* Responsive components */
@media (max-width: 760px) {
  .sc-columns { grid-template-columns: minmax(0, 1fr) !important; }
  .sc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .sc-gallery { grid-template-columns: repeat(min(var(--sc-cols, 3), 2), minmax(0, 1fr)); }
  .page--project .page-header { text-align: left; }
  .page--project .page-header__authors,
  .page--project .page-header__affils,
  .page--project .page-header__notes,
  .page--project .page-header__links { justify-content: flex-start; }
  .lightbox { padding: 56px 8px; }
  .lightbox__prev, .lightbox__next { top: auto; bottom: 14px; margin-top: 0; }
}
@media (max-width: 900px) {
  .is-page .content { padding: 32px 0 24px; }
}

@media print {
  .toc-fab, .lightbox { display: none !important; }
  .is-page .sidebar { display: none !important; }
}
