/* ============================================================
   ICER project page - stylesheet
   ============================================================ */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;450;500;600;700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&display=swap');

/* Theme tokens */
:root {
  --bg:           #f7faf8;
  --bg-elev:      #eef4f0;
  --bg-code:      #e7eee9;
  --fg:           #17211f;
  --fg-muted:     #53625d;
  --fg-soft:      #87958f;
  --rule:         #cbd8d2;
  --rule-soft:    #e0e8e4;
  --accent:       #166b5b;
  --accent-soft:  #3f9b87;
  --warning:      #a33a3a;
  --link:         var(--accent);
  --link-hover:   var(--fg);

  --serif: 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans:  'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;

  --maxw-content: 900px;
  --maxw-page:    1360px;
  --sidebar-w:    220px;
}

[data-theme="dark"] {
  --bg:           #0f1715;
  --bg-elev:      #17221f;
  --bg-code:      #101a17;
  --fg:           #e4ece8;
  --fg-muted:     #9eaca5;
  --fg-soft:      #6f8179;
  --rule:         #2b3a35;
  --rule-soft:    #1f2c28;
  --accent:       #63d2b3;
  --accent-soft:  #2da486;
  --warning:      #f08a8a;
  --link-hover:   var(--fg);
}

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

html { scroll-behavior: smooth; scroll-padding-top: 2rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.62;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

p { margin: 0 0 1.1em 0; }

/* Layout */
.page {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 3rem;
  max-width: var(--maxw-page);
  margin: 0 auto;
  padding: 3rem 2.5rem 6rem;
}

main {
  max-width: var(--maxw-content);
  margin: 0 auto;
  min-width: 0;
  width: 100%;
}

.title { overflow-wrap: break-word; }

/* Sidebar */
.sidebar {
  position: sticky;
  top: 2rem;
  align-self: start;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.5;
}

.sidebar-title {
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-soft);
  margin: 0 0 1rem 0;
  font-weight: 600;
}

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-nav li { margin: 0; }

.sidebar-nav a {
  display: block;
  padding: 0.32rem 0 0.32rem 0.85rem;
  color: var(--fg-muted);
  border-left: 2px solid var(--rule-soft);
  border-bottom: none;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-nav a:hover {
  color: var(--fg);
  border-left-color: var(--fg-soft);
}

.sidebar-nav a.active {
  color: var(--fg);
  border-left-color: var(--accent);
}

.sidebar-nav .sub {
  padding-left: 1.7rem;
  font-size: 0.78rem;
}

.sidebar-external {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule-soft);
}
.sidebar-external a {
  display: block;
  padding: 0.25rem 0;
  color: var(--fg-muted);
  border-bottom: none;
}
.sidebar-external a:hover { color: var(--accent); }

/* Top-right utility cluster */
.utility {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 100;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.icon-btn:hover {
  color: var(--fg);
  border-color: var(--fg-soft);
  border-bottom: 1px solid var(--fg-soft);
}
.icon-btn svg { width: 18px; height: 18px; }

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
  padding-top: 1rem;
}

.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.85rem, 3.4vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: 0;
  width: min(1040px, calc(100% + 6rem));
  margin: 0 0 0.75rem 50%;
  transform: translateX(-50%);
  color: var(--fg);
}

.venue {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--accent);
  margin: 0 0 1.75rem;
  letter-spacing: 0.01em;
}

.header-links {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--fg);
  font-weight: 500;
  transition: all 0.15s;
}
.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}
.pill svg { width: 14px; height: 14px; }

.authors {
  font-family: var(--serif);
  font-size: 1.42rem;
  line-height: 1.55;
  margin: 0.5rem 0 0.3rem;
}
.authors a { color: var(--fg); font-weight: 400; }
.authors sup { font-size: 0.7em; color: var(--accent); margin-left: 0.05em; font-weight: 600; }

.affiliations {
  font-size: 1rem;
  color: var(--fg-muted);
  margin: 0.3rem 0;
  line-height: 1.6;
}
.affiliations sup { color: var(--accent); font-weight: 600; }

.contact {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--fg-soft);
  margin-top: 0.4rem;
}

/* Teaser */
.teaser {
  margin: 2.5rem 0;
}
.teaser figure { margin: 0; }
.teaser img,
.teaser .placeholder-figure {
  width: 100%;
  border-radius: 4px;
}
.teaser figcaption {
  margin-top: 0.9rem;
  text-align: center;
  /* font-style: italic; */
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--fg-muted);
}

/* TL;DR */
.tldr {
  font-family: var(--serif);
  font-size: 1.32rem;
  line-height: 1.5;
  font-weight: 500;
  color: var(--fg);
  text-align: left;
  padding: 1.75rem 0 1.75rem 1.5rem;
  border-left: 3px solid var(--accent);
  margin: 2.5rem 0;
}

.tldr strong { font-weight: 600; }

/* Section headings */
section { margin: 3.5rem 0; scroll-margin-top: 2rem; }

h2 {
  font-family: var(--serif);
  font-size: 1.72rem;
  font-weight: 600;
  margin: 0 0 1.2rem 0;
  letter-spacing: 0;
  color: var(--fg);
}

h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 2rem 0 0.6rem 0;
}

h4 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.7rem 0;
  color: var(--fg);
}

/* Abstract (collapsible) */
details.abstract {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-elev);
  padding: 0;
  margin: 1rem 0;
}
details.abstract > summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.25rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
}
details.abstract > summary::-webkit-details-marker { display: none; }
details.abstract > summary::before {
  content: '›';
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--accent);
  display: inline-block;
  transition: transform 0.2s;
  transform: rotate(0deg);
}
details.abstract[open] > summary::before { transform: rotate(90deg); }

.abstract-body {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg);
}
.abstract-body p:last-child { margin-bottom: 0; }

.content-warning {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--warning) 8%, transparent);
  border-left: 3px solid var(--warning);
  font-size: 0.85rem;
  color: var(--warning);
  border-radius: 2px;
}

/* Key Question callout */
.key-question {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.38rem;
  text-align: left;
  padding: 1.45rem 1.6rem;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border-left: 5px solid var(--accent);
  border-radius: 4px;
  margin: 1.7rem 0;
  color: var(--fg);
  line-height: 1.45;
}
.key-question::before {
  content: 'Key Question';
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

/* Framework — figure / algorithm viewer */
.framework-viewer {
  margin: 1.5rem 0;
}

.framework-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.framework-tab {
  min-width: 6.5rem;
  padding: 0.45rem 0.85rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.framework-tab:hover {
  color: var(--fg);
}

.framework-tab.active {
  background: var(--accent);
  color: var(--bg);
}

.framework-panel[hidden] {
  display: none;
}

.framework-panel figure {
  margin: 0;
}

.framework-panel img {
  display: block;
  width: 100%;
  height: auto;
}

.framework-panel figcaption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 0.6rem;
  text-align: center;
}

/* Pseudocode block */
.algo {
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--fg);
  overflow-x: auto;
  white-space: pre;
}
.algo .algo-title {
  display: block;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
  white-space: normal;
}
.algo .kw    { color: var(--accent); font-weight: 500; }
.algo .cmt   { color: var(--fg-soft); font-style: italic; }
.algo .var   { color: var(--fg); }

/* Finding blocks */
.evidence-callout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}
.evidence-callout p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}
.evidence-callout a {
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.finding {
  margin: 2.5rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
}
.finding:first-of-type { border-top: none; padding-top: 0; }

.finding-number {
  font-family: var(--serif);
  font-size: 1.38rem;
  font-weight: 600;
  letter-spacing: 0;
  /* text-transform: uppercase; */
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.finding figure {
  margin: 1.5rem 0 0.5rem;
}
.finding figcaption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 0.6rem;
  text-align: center;
}

/* Placeholder figure (for missing assets) */
.placeholder-figure {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  background: repeating-linear-gradient(
    45deg,
    var(--bg-elev),
    var(--bg-elev) 10px,
    var(--rule-soft) 10px,
    var(--rule-soft) 11px
  );
  border: 1px dashed var(--rule);
  border-radius: 4px;
  color: var(--fg-soft);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
}

.placeholder-table {
  background: var(--bg-elev);
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 1.5rem;
  color: var(--fg-soft);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
}

/* Transfer table */
.transfer-table-wrap {
  width: min(920px, calc(100vw - var(--sidebar-w) - 6rem));
  margin-left: 50%;
  transform: translateX(-50%);
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--rule) 55%, transparent);
}

.transfer-table-wrap:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 3px;
}

.transfer-table {
  width: 100%;
  min-width: 760px;
  border-spacing: 0;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--fg);
}

.transfer-table th,
.transfer-table td {
  padding: 0.5rem 0.62rem;
  border-bottom: 1px solid var(--rule-soft);
  text-align: center;
  white-space: nowrap;
  font-size: 0.94rem;
}

.transfer-table thead th {
  background: var(--bg-elev);
  color: var(--fg-muted);
  /* font-size: 0.72rem; */
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
}

.transfer-table thead tr:first-child th {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}

.transfer-table tbody th {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  text-align: left;
}

.transfer-table tbody tr:hover th,
.transfer-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}

.transfer-table tbody tr:last-child th,
.transfer-table tbody tr:last-child td {
  border-bottom: none;
}

.transfer-table .commercial-group {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-elev));
}

.transfer-table .open-group {
  background: color-mix(in srgb, var(--fg-soft) 9%, var(--bg-elev));
}

.transfer-table td:nth-child(3) {
  border-left: 1px solid var(--rule);
}

.transfer-table td:nth-child(5) {
  border-left: 1px solid var(--rule);
}

.transfer-table .group-start {
  border-left: 1px solid var(--rule);
}

.transfer-table .method-divider th,
.transfer-table .method-divider td,
.transfer-table .ours-row th,
.transfer-table .ours-row td {
  border-top: 1px solid var(--rule);
}

.transfer-table .ours-row th,
.transfer-table .ours-row td {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.transfer-table .best {
  color: var(--fg);
  font-weight: 700;
}

.transfer-table .second {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

/* ---------- Iteration table ---------- */
.iter-table-wrap {
  width: min(780px, calc(100vw - var(--sidebar-w) - 6rem));
  margin-left: 50%;
  transform: translateX(-50%);
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--rule) 55%, transparent);
}

.iter-table-wrap:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 3px;
}

.iter-table {
  width: 100%;
  min-width: 680px;
  border-spacing: 0;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--fg);
}

.iter-table th,
.iter-table td {
  padding: 0.56rem 0.68rem;
  border-bottom: 1px solid var(--rule-soft);
  text-align: center;
  white-space: nowrap;
  font-size: 0.94rem;
}

.iter-table thead th {
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
}

.iter-table thead th:first-child {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}

.iter-table tbody th {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  text-align: left;
}

.iter-table tbody tr:hover th,
.iter-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}

.iter-table tbody tr:last-child th,
.iter-table tbody tr:last-child td {
  border-bottom: none;
}

.iter-table th:nth-child(2),
.iter-table td:nth-child(2) {
  border-left: 1px solid var(--rule);
}

/* ---------- Results table ---------- */
.results-table-wrap {
  width: min(980px, calc(100vw - var(--sidebar-w) - 6rem));
  margin-left: 50%;
  transform: translateX(-50%);
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--rule) 55%, transparent);
}

.results-table-wrap:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 3px;
}

.results-table {
  width: 100%;
  min-width: 810px;
  border-spacing: 0;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--fg);
}

.results-table th,
.results-table td {
  padding: 0.38rem 0.43rem;
  border-bottom: 1px solid var(--rule-soft);
  text-align: center;
  white-space: nowrap;
  font-size: 0.92rem;
}

.results-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.results-table thead tr:first-child th {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}

.results-table tbody th {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  text-align: left;
}

.results-table tbody th[scope="rowgroup"] {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1rem;
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid var(--rule-soft);
}

.results-table tbody tr {
  position: relative;
  outline: none;
  transform-origin: center;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.results-table tbody tr:hover,
.results-table tbody tr:focus-within {
  filter: drop-shadow(0 7px 14px color-mix(in srgb, var(--fg) 10%, transparent));
  transform: scale(1.01);
  z-index: 2;
}

.results-table tbody tr:hover th,
.results-table tbody tr:hover td,
.results-table tbody tr:focus-within th,
.results-table tbody tr:focus-within td {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}

.results-table tbody tr:nth-child(6) th,
.results-table tbody tr:nth-child(6) td {
  border-bottom: 1px solid var(--rule);
}

.results-table .icer-col,
.results-table td.best {
  background: color-mix(in srgb, var(--accent) 9%, var(--bg));
}

.results-table td.best {
  color: var(--fg);
  font-weight: 700;
}

.results-table td.second {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

.results-table .adv-row th,
.results-table .adv-row td {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}

.results-table .adv-row td.best {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}

.results-table .adv-row td:last-child {
  position: relative;
  outline: none;
}

.results-table .adv-row td:last-child:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -2px;
}

.table-callout {
  position: absolute;
  top: 0;
  right: 0.75rem;
  z-index: 3;
  padding: 0.42rem 0.58rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--rule));
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg-elev) 94%, var(--accent));
  color: var(--accent);
  font-family: var(--serif);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--fg) 16%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.25rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.table-callout.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Discussion list */
ol.discussion {
  padding-left: 0;
  list-style: none;
  counter-reset: disc;
}
ol.discussion > li {
  counter-increment: disc;
  position: relative;
  padding: 1rem 0 1rem 3.2rem;
  border-bottom: 1px solid var(--rule-soft);
}
ol.discussion > li:last-child { border-bottom: none; }
ol.discussion > li::before {
  content: counter(disc, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1.05rem;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}
ol.discussion li strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.18rem;
  display: block;
  margin-bottom: 0.3rem;
}

/* Closing tagline */
.tagline {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  text-align: center;
  line-height: 1.45;
  color: var(--accent);
  padding: 2.5rem 1rem;
  margin: 3rem 0 0.5rem;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}
.tagline + .tagline-sub {
  text-align: center;
  font-size: 0.88rem;
  color: var(--fg-muted);
  margin: 0.5rem 0 2.5rem;
  font-style: italic;
}

/* BibTeX */
.bibtex-wrap {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 1rem 0;
}
.bibtex-wrap pre {
  margin: 0;
  padding: 1.1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--fg);
  overflow-x: auto;
}
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { color: var(--fg); border-color: var(--fg-soft); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* Footer */
footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule-soft);
  font-size: 0.8rem;
  color: var(--fg-soft);
  text-align: center;
}

/* Mobile */
@media (max-width: 900px) {
  html,
  body { overflow-x: hidden; }
  .page {
    grid-template-columns: minmax(0, 1fr);
    padding: 2rem 1.25rem 4rem;
    gap: 1rem;
  }
  .sidebar {
    position: static;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--rule-soft);
    padding-bottom: 1rem;
  }
  /* On mobile, the sidebar toggle replaces the static title label */
  .sidebar-title { display: none; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fg-soft);
    font-weight: 600;
  }
  .sidebar-toggle::after { content: '▾'; transition: transform 0.2s; }
  .sidebar:not(.expanded) .sidebar-toggle::after { transform: rotate(-90deg); }
  .sidebar:not(.expanded) .sidebar-nav,
  .sidebar:not(.expanded) .sidebar-external { display: none; }
  .sidebar-nav { margin-top: 0.8rem; }
  .utility { top: 1rem; right: 1rem; gap: 0.35rem; }
  .icon-btn { width: 34px; height: 34px; }
  .title {
    width: 100%;
    margin-left: 0;
    transform: none;
    font-size: clamp(1.4rem, 5.5vw, 1.9rem);
    padding: 0 0.5rem;
  }
  .header { padding-top: 0; margin-bottom: 2rem; }
  .header-links { gap: 0.4rem; }
  .pill { font-size: 0.8rem; padding: 0.4rem 0.8rem; }
  .authors { font-size: 1rem; padding: 0 0.5rem; }
  .affiliations { font-size: 0.8rem; padding: 0 0.5rem; }
  .tldr { font-size: 1.1rem; padding: 1.25rem 0 1.25rem 1rem; }
  h2 { font-size: 1.35rem; }
  .key-question { font-size: 1.25rem; padding: 1.2rem 1.25rem; }
  .evidence-callout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.95rem 1rem;
  }
  .evidence-callout a {
    justify-self: start;
    white-space: normal;
  }
  .tagline { font-size: 1.15rem; }
  .framework-tabs { width: 100%; }
  .framework-tab { flex: 1; min-width: 0; }
  .algo { font-size: 0.72rem; }
  .results-table-wrap {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
  .transfer-table-wrap {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
  .iter-table-wrap {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
  .results-table {
    font-size: 0.68rem;
  }
  .transfer-table {
    font-size: 0.78rem;
  }
  .iter-table {
    font-size: 0.78rem;
  }
}

@media (min-width: 901px) {
  .sidebar-toggle { display: none; }
}

/* Qualitative subpage */
.q-banner {
  background: color-mix(in srgb, var(--warning) 8%, var(--bg-elev));
  border: 1px solid var(--warning);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  max-width: 75ch;
  color: var(--warning);
  line-height: 1.55;
}
.q-banner strong { font-weight: 600; display: block; margin-bottom: 0.4rem; font-size: 1.15rem; }

.q-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.q-card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-elev);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.q-card:hover { border-color: var(--fg-soft); transform: translateY(-2px); }

.q-card-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-code);
  cursor: pointer;
  overflow: hidden;
}
.q-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(28px) saturate(0.4);
  transition: filter 0.3s;
}
.q-card.revealed .q-card-thumb img {
  filter: none;
}
.q-card-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  transition: opacity 0.2s;
}
.q-card.revealed .q-card-mask { opacity: 0; pointer-events: none; }

.q-card-meta { display: none; }

.q-section-title { font-size: 0.9rem; }

.q-card-label {
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg);
}

/* Qualitative peek modal */
.q-peek {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.q-peek[hidden] { display: none; }

.q-peek-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 35%, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(2px);
}

.q-peek-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.q-peek-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s;
}
.q-peek-close:hover { background: var(--bg-code); }
.q-peek-close svg { width: 1.1rem; height: 1.1rem; }

.q-peek-body {
  display: grid;
  grid-template-columns: minmax(0, 44%) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.q-peek-image {
  position: relative;
  min-height: 320px;
  background: var(--bg-code);
  cursor: pointer;
}
.q-peek-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: blur(28px) saturate(0.4);
  transition: filter 0.3s;
}
.q-peek-image.revealed img { filter: none; }
.q-peek-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  transition: opacity 0.2s;
}
.q-peek-image.revealed .q-peek-mask { opacity: 0; pointer-events: none; }

.q-peek-meta {
  margin: 0;
  padding: 1.5rem 1.6rem;
  overflow-y: auto;
}
.q-peek-meta dt {
  font-family: var(--sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
  margin-top: 1rem;
}
.q-peek-meta dt:first-child { margin-top: 0; }
.q-peek-meta dd {
  margin: 0.3rem 0 0 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--fg);
  word-break: break-word;
}

@media (max-width: 640px) {
  .q-peek { padding: 0; }
  .q-peek-panel { max-height: 100vh; height: 100vh; height: 100dvh; width: 100%; border-radius: 0; }
  /* Block flow (not grid) so the image + prompt stack at their natural
     heights; flex:1 + min-height:0 lets the body own the scroll instead of
     the grid squashing rows into the fixed panel height. */
  .q-peek-body { display: block; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .q-peek-image { aspect-ratio: 1 / 1; min-height: 0; }
  .q-peek-meta { overflow-y: visible; }
  /* The backdrop is no longer tappable when the panel fills the screen,
     so make the close button unmistakable. */
  .q-peek-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 2.4rem;
    height: 2.4rem;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    border: 1px solid var(--rule);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  }
  .q-peek-close svg { width: 1.3rem; height: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .q-card:hover { transform: none; }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 2rem 0 1rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
}
