/* Awesome Trustworthy Deep Learning: site styles
 * A dark, quiet interface in the style of linear.app: a near-black canvas, text in four
 * grays, translucent hairlines and fills instead of solid boxes, and one indigo accent kept
 * for focus, selection and links inside sentences. Shadows only on things that float.
 * Type: Inter Variable (everything), Geist Mono (ids, repo names, code). See fonts/README.md.
 */

@font-face {
  font-family: 'Inter Variable';
  src: url('fonts/inter.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/geist-mono.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-2: #f8f8f8;
  --surface: #ffffff;
  --raised: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #ececee;
  --hover: rgba(0, 0, 0, 0.022);
  --control: #ffffff;
  --control-hover: #f4f4f5;
  --control-on: #ffffff;
  --ink: #282a30;
  --ink-2: #3c4149;
  --ink-3: #6b6a73;
  --ink-4: #6f6e77;
  --bar: #8f8e98;
  --line: rgba(0, 0, 0, 0.07);
  --line-2: rgba(0, 0, 0, 0.1);
  --line-3: rgba(0, 0, 0, 0.18);

  --accent: #4f5ac4;
  --accent-solid: #5e6ad2;
  --accent-soft: rgba(94, 106, 210, 0.1);
  --accent-line: rgba(94, 106, 210, 0.38);
  --btn-bg: #282a30;
  --btn-bg-hover: #3c4149;
  --btn-ink: #ffffff;
  --mark-bg: #fdeeb0;
  --scrim: rgba(0, 0, 0, 0.22);

  /* Topic identity marks (validated per theme, colorblind-safe in this order); never used for text */
  --t-survey: #a54f04;
  --t-ood: #26a840;
  --t-evasion: #9f0240;
  --t-poisoning: #bc8803;
  --t-privacy: #643bb9;
  --t-fairness: #06a5aa;
  --t-interpretability: #3a74e4;
  --t-alignment: #c63192;
  --t-others: #8f8e98;

  --font-sans: 'Inter Variable', 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;

  --fw-medium: 510;
  --fw-semi: 590;

  --fs-h1: clamp(2.25rem, 4.4vw, 3.5rem);
  --fs-h2: 1.5rem;
  --fs-title: 1.0625rem;
  --fs-read: 15px;
  --fs-ui: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;
  /* Tracking: tighter as type gets larger */
  --ls-display: -0.022em;
  --ls-title: -0.012em;
  --ls-ui: -0.013em;

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --shadow-pop: 0 1px 1px rgba(0, 0, 0, 0.04), 0 3px 8px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.1);
  --shadow-drawer: 0 2px 6px rgba(0, 0, 0, 0.05), 0 16px 56px rgba(0, 0, 0, 0.16);

  --container-w: 1240px;
  --topbar-h: 64px;
  --side-w: 228px;
  --measure: 72ch;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* Motion: hover/state changes, fades and chevrons, the drawer slide */
  --dur-1: 0.1s;
  --dur-2: 0.16s;
  --dur-3: 0.25s;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b6a73' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #08090a;
  --bg-2: #0f1011;
  --surface: #0f1011;
  --raised: #161718;
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.025);
  --control: rgba(255, 255, 255, 0.03);
  --control-hover: rgba(255, 255, 255, 0.07);
  --control-on: rgba(255, 255, 255, 0.1);
  --ink: #f7f8f8;
  --ink-2: #d0d6e0;
  --ink-3: #8a8f98;
  --ink-4: #7c818a;
  --bar: #62666d;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.09);
  --line-3: rgba(255, 255, 255, 0.16);

  --accent: #828fff;
  --accent-soft: rgba(130, 143, 255, 0.14);
  --accent-line: rgba(130, 143, 255, 0.4);
  --btn-bg: #e5e5e6;
  --btn-bg-hover: #ffffff;
  --btn-ink: #08090a;
  --mark-bg: rgba(240, 191, 0, 0.26);
  --scrim: rgba(0, 0, 0, 0.6);

  --t-survey: #c55703;
  --t-ood: #18bc59;
  --t-evasion: #ca0f4d;
  --t-poisoning: #b49206;
  --t-privacy: #7451c2;
  --t-fairness: #33b2b6;
  --t-interpretability: #017ae5;
  --t-alignment: #d1569f;
  --t-others: #8a8f98;

  --shadow-pop: 0 1px 1px rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.24), 0 14px 36px rgba(0, 0, 0, 0.42);
  --shadow-drawer: 0 4px 12px rgba(0, 0, 0, 0.3), 0 20px 64px rgba(0, 0, 0, 0.55);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%238a8f98' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line-3) transparent;
  scrollbar-width: thin;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-ui);
  line-height: 1.5;
  letter-spacing: var(--ls-ui);
  font-feature-settings: 'cv01', 'ss03';
  font-optical-sizing: auto;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

main { flex: 1; }
main:focus { outline: none; }

::selection { background: color-mix(in srgb, var(--accent-solid) 36%, transparent); color: var(--ink); }

h1, h2, h3, h4 { margin: 0; font-weight: inherit; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
button, input, select { font: inherit; font-feature-settings: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
code, pre, kbd { font-family: var(--font-mono); font-variant-ligatures: none; letter-spacing: 0; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 950;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: var(--fw-medium);
  text-decoration: none;
}
.skip-link:focus { top: 10px; }

mark { background: var(--mark-bg); color: var(--ink); padding: 0; border-radius: 2px; }

:where(.subpage-lede, .about-section-head p, .contrib-row p, .display-deck) code {
  font-size: 0.86em;
  padding: 0 4px;
  white-space: nowrap;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

/* --------------------------------------------------------------- primitives */
.container {
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding-inline: clamp(20px, 3.4vw, 40px);
}

.mono-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  color: var(--ink);
}
.mono-label .fn { font-family: var(--font-mono); font-weight: 400; font-size: 12px; color: var(--ink-3); }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c, var(--ink-4));
  flex-shrink: 0;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
  background: var(--c, var(--ink-4));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--control);
  color: var(--ink);
  font-size: var(--fs-ui);
  font-weight: var(--fw-medium);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.btn svg { width: 9px; height: 9px; flex-shrink: 0; opacity: 0.7; }
.btn:hover { background: var(--control-hover); }
.btn-primary { background: var(--btn-bg); border-color: transparent; color: var(--btn-ink); }
.btn-primary:hover { background: var(--btn-bg-hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-sm); }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--control);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.copy-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.copy-btn:hover { background: var(--control-hover); color: var(--ink); }

/* Plain links (no decorative arrows) */
.arrow-link {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-ui);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.arrow-link::after { content: '\2197'; margin-left: 4px; font-size: 0.9em; color: var(--ink-4); }
.arrow-link:hover { color: var(--ink); }
.arrow-link:hover::after { color: inherit; }

.text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.text-btn:hover { color: var(--ink); }

/* ------------------------------------------------------------------ top bar */
[data-theme="light"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 180;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-inner {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px clamp(16px, 2.6vw, 36px);
  min-height: var(--topbar-h);
}

.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-mark { display: inline-flex; color: var(--ink); flex-shrink: 0; }
.brand-mark svg { width: 10px; height: 14px; display: block; }
.brand-wordmark { font-size: 15px; font-weight: var(--fw-semi); letter-spacing: var(--ls-title); }

.tabs { display: inline-flex; align-items: center; gap: 2px; }
.tab {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-ui);
  text-decoration: none;
  color: var(--ink-3);
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  justify-self: end;
  width: min(320px, 100%);
  height: 34px;
  padding: 0 6px 0 10px;
  gap: 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--control);
  transition: opacity var(--dur-2) var(--ease), border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.topbar-search:hover { border-color: var(--line-3); }
.topbar-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
body.is-hero-search-visible .topbar-search { opacity: 0; pointer-events: none; }

.search-icon { width: 15px; height: 15px; color: var(--ink-3); flex-shrink: 0; }
.topbar-search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink);
  outline: none;
}
.topbar-search input::placeholder,
.hero-search input::placeholder { color: var(--ink-4); opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--fw-medium);
  line-height: 1;
  color: var(--ink-3);
  flex-shrink: 0;
}

.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  flex-shrink: 0;
}
.search-clear:hover { color: var(--ink); background: var(--surface-3); }
.search-clear svg { width: 11px; height: 11px; }

.topbar-actions { display: inline-flex; align-items: center; gap: 2px; }
.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.topbar-icon-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.mobile-search-btn { display: none; }

/* ------------------------------------------------------------------- intro */
.opening-band { padding: clamp(40px, 5.6vw, 80px) 0 clamp(28px, 3.2vw, 44px); border-bottom: 1px solid var(--line); }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 288px);
  column-gap: clamp(40px, 6vw, 96px);
  max-width: var(--container-w);
}
.intro > * { grid-column: 1; }
.intro-text { max-width: 760px; }

/* Papers per year: quiet gray bars in the style of a Scholar profile */
.intro-years { grid-column: 2; grid-row: 1 / span 3; align-self: end; }
.years-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
#years-label { font-weight: var(--fw-medium); color: var(--ink-2); }
.years-readout { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.years-chart {
  display: flex;
  align-items: stretch;
  height: 72px;
  border-bottom: 1px solid var(--line-2);
}
.yr {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  padding: 0 1.5px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.yr .bar {
  width: 100%;
  max-width: 15px;
  height: var(--h);
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--bar);
  transition: background-color var(--dur-1) var(--ease);
}
.yr:hover .bar, .yr:focus-visible .bar { background: var(--ink); }
.yr:focus-visible { outline-offset: 1px; }
.years-chart.has-sel .yr .bar { background: var(--line-3); }
.years-chart.has-sel .yr[aria-pressed="true"] .bar { background: var(--accent-solid); }
.years-chart.has-sel .yr:hover .bar { background: var(--ink); }
.years-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.intro-years .trends-toggle { margin-top: 12px; }
.tt-narrow { display: none; }

.display-headline {
  font-weight: var(--fw-medium);
  font-size: var(--fs-h1);
  line-height: 1.06;
  letter-spacing: var(--ls-display);
  color: var(--ink);
}
.display-deck {
  margin-top: 18px;
  max-width: 62ch;
  font-size: 1.0625rem;
  line-height: 1.6;
  letter-spacing: -0.011em;
  color: var(--ink-3);
}
.display-deck a { color: var(--accent); text-decoration: none; }
.display-deck a:hover { text-decoration: underline; }

.hero-search { max-width: 760px; margin-top: 28px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--control);
  cursor: text;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.search-field:hover { border-color: var(--line-3); }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hero-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}

.search-help {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-top: 8px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.op-chip {
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0;
  color: var(--ink-2);
}
.op-chip:hover { color: var(--accent); }
.help-sep { width: 1px; height: 10px; background: var(--line-2); align-self: center; }

.masthead-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
  max-width: 760px;
  margin-top: 18px;
}
.quick-starts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.quick-label { font-size: var(--fs-ui); color: var(--ink-3); margin-right: -4px; }
.quick-btn {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-ui);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
}
.quick-btn:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 0.25em; }
.quick-btn .n { font-weight: 400; color: var(--ink-4); font-variant-numeric: tabular-nums; }

.trends-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-ui);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  white-space: nowrap;
}
.trends-toggle:hover { color: var(--ink); }
.trends-toggle .chev { width: 11px; height: 11px; transition: transform var(--dur-2) var(--ease); }
.trends-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Resources & About openers */
.subpage-head { padding: clamp(40px, 5.6vw, 80px) 0 clamp(28px, 3.2vw, 44px); border-bottom: 1px solid var(--line); }
.subpage-head-grid { display: block; }
.subpage-lede { margin-top: 18px; max-width: 62ch; font-size: 1.0625rem; line-height: 1.6; letter-spacing: -0.011em; color: var(--ink-3); }
.subpage-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 18px; }
.subpage-meta { font-size: var(--fs-ui); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.section-display {
  font-weight: var(--fw-medium);
  font-size: var(--fs-h2);
  line-height: 1.33;
  letter-spacing: var(--ls-title);
  color: var(--ink);
}

/* ------------------------------------------------ trends panel */
.trends-panel { background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 32px 0 30px; }
.trends-figure { margin: 0; }
.trends-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; }
.trends-hint { margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-3); }
.trends-head-right { display: flex; align-items: center; gap: 14px; }
.hist-range { display: inline-flex; align-items: center; gap: 12px; font-size: var(--fs-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }

.hist {
  position: relative;
  width: 100%;
  height: 264px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 14px 12px 6px;
  user-select: none;
}
.hist-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hist-svg .grid { stroke: var(--line); stroke-width: 1; }
.hist-svg .axis { stroke: var(--line-3); stroke-width: 1; }
.hist-svg .tick { fill: var(--ink-3); font-family: var(--font-sans); font-size: 11px; font-variant-numeric: tabular-nums; }
.hist-svg .year { fill: var(--ink-3); font-family: var(--font-sans); font-size: 11.5px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.hist-svg .year.on { fill: var(--ink); font-weight: var(--fw-semi); }
.hist-svg .cap { fill: var(--ink); font-family: var(--font-sans); font-size: 11.5px; font-weight: var(--fw-semi); text-anchor: middle; font-variant-numeric: tabular-nums; }
.hist-svg .sel-band { fill: var(--accent-soft); stroke: var(--accent-line); stroke-width: 1; }
.hist-svg .col { transition: opacity var(--dur-2) var(--ease); }
.hist-svg .col.dim { opacity: 0.22; }
.hist-hits { position: absolute; top: 14px; bottom: 6px; display: flex; touch-action: none; }
.hist-hits button { flex: 1; border: 0; padding: 0; background: transparent; cursor: pointer; }

.hist-tip {
  position: absolute;
  z-index: 20;
  transform: translate(-50%, calc(-100% - 8px));
  min-width: 190px;
  padding: 10px 12px 9px;
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  font-size: var(--fs-sm);
}
.tip-head { display: flex; justify-content: space-between; gap: 14px; font-weight: var(--fw-semi); padding-bottom: 6px; margin-bottom: 5px; border-bottom: 1px solid var(--line); color: var(--ink); font-variant-numeric: tabular-nums; }
.tip-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; padding: 1px 0; color: var(--ink-2); }
.tip-row b { font-weight: var(--fw-semi); color: var(--ink); font-variant-numeric: tabular-nums; }
.tip-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--ink-3); }

.trends-foot { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.trends-legend { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.trends-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.trends-legend-item:hover { color: var(--ink); }
.trends-legend-item[aria-pressed="true"] { color: var(--ink); font-weight: var(--fw-semi); text-decoration: underline; text-underline-offset: 0.25em; }
.viz-table summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  list-style: none;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  cursor: pointer;
}
.viz-table summary::-webkit-details-marker { display: none; }
.viz-table summary::after {
  content: '';
  width: 5px;
  height: 5px;
  margin-top: -3px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--dur-2) var(--ease);
}
.viz-table[open] summary::after { margin-top: 3px; transform: rotate(-135deg); }
.viz-table summary:hover { color: var(--ink); }
.viz-table-wrap { margin-top: 10px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); }
.viz-table-wrap table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.viz-table-wrap th, .viz-table-wrap td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.viz-table-wrap tr:last-child td { border-bottom: 0; }
.viz-table-wrap th:first-child, .viz-table-wrap td:first-child { text-align: left; }
.viz-table-wrap th { color: var(--ink-3); font-weight: var(--fw-medium); }

/* ------------------------------------------------ library: sidebar + list */
.library { padding: 28px 0 72px; }
.library-layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  gap: 0 clamp(28px, 3.6vw, 52px);
  align-items: start;
}

.library-side {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
  max-height: calc(100vh - var(--topbar-h) - 40px);
  overflow-y: auto;
  padding: 6px 0 20px;
  scrollbar-width: none;
}
.library-side::-webkit-scrollbar { display: none; }
.side-label { margin: 0 0 8px 10px; font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: 0; color: var(--ink-4); }

.chapter-strip { display: flex; flex-direction: column; gap: 1px; }
.spot-tab {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: var(--fs-ui);
  line-height: 1.3;
  color: var(--ink-2);
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.spot-tab[data-spot-pillar=""] { grid-template-columns: minmax(0, 1fr) auto; }
.spot-tab .n { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.spot-tab:hover { background: var(--surface-2); color: var(--ink); }
.spot-tab[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); font-weight: var(--fw-medium); }
.spot-tab[aria-pressed="true"] .n { color: var(--ink-2); font-weight: 400; }
.spot-tab.is-zero { color: var(--ink-4); }
.spot-tab.is-zero .dot { opacity: 0.35; }

.library-main { min-width: 0; }

.library-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  padding-top: 4px;
  margin-bottom: 14px;
}
.library-opener-main { min-width: 0; flex: 1 1 380px; }
#library-heading { display: flex; align-items: center; gap: 10px; }
#library-heading .dot { width: 10px; height: 10px; }
.library-count { margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
/* Topic description: its own full-width row under the title and controls */
.topic-inline { flex: 1 0 100%; min-width: 0; margin-top: -4px; }
.topic-inline:not([hidden]) { animation: fade-in var(--dur-2) var(--ease) both; }
.topic-inline p { max-width: 68ch; margin-bottom: 8px; font-size: var(--fs-read); line-height: 1.6; letter-spacing: -0.011em; color: var(--ink-3); }

.library-top-right { display: flex; align-items: flex-end; }
.library-display-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.library-toolbar {
  position: relative;
  z-index: 120;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 961px) {
  .library-toolbar { position: sticky; top: var(--topbar-h); }
}

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 6px 0; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.popover-wrap { position: relative; }

.filter-btn,
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.filter-btn:hover,
.toggle-pill:hover,
.filter-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.filter-btn.has-val,
.toggle-pill[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.filter-btn-val { font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.filter-btn-val:empty { display: none; }
.filter-btn .chev { width: 10px; height: 10px; color: var(--ink-3); transition: transform var(--dur-2) var(--ease); }
.filter-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.filter-sep { width: 1px; height: 16px; margin: 0 6px; background: var(--line-2); }
.toggle-pill .n { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.toggle-pill[aria-pressed="true"] .n { color: inherit; }
.toggle-pill::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-3);
  border-radius: 4px;
  background: var(--control);
  flex-shrink: 0;
}
.toggle-pill[aria-pressed="true"]::before {
  border-color: var(--accent-solid);
  background: var(--accent-solid) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 5.2l2 2 4-4.4' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 10px;
}

.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--surface-2); }
.segmented button {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.segmented button:hover { color: var(--ink); }
.seg-icon { display: none; width: 16px; height: 16px; }
.segmented button[aria-checked="true"] { background: var(--control-on); color: var(--ink); font-weight: var(--fw-medium); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.08); }

select {
  -webkit-appearance: none;
  appearance: none;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--control) var(--chev) no-repeat right 9px center / 10px 10px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
select:hover { border-color: var(--line-3); color: var(--ink); }
select option { background: var(--raised); color: var(--ink); }

/* Popovers */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 160;
  width: 300px;
  padding: 10px;
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--dur-1) var(--ease) both;
}
.popover-wide { width: min(380px, calc(100vw - 32px)); }
#pop-years { width: min(300px, calc(100vw - 32px)); }
.popover.align-right { left: auto; right: 0; }
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.popover-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink); }
.popover-scroll { max-height: 280px; overflow-y: auto; padding: 2px; }

.facet-topics { display: flex; flex-direction: column; }
.facet-topic {
  display: grid;
  grid-template-columns: 14px 7px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--fs-sm);
  text-align: left;
  color: var(--ink-2);
}
.facet-topic:hover { background: var(--surface-2); color: var(--ink); }
.facet-topic.zero { opacity: 0.45; }
.facet-topic .box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid var(--line-3);
  border-radius: 4px;
  background: var(--control);
  color: transparent;
}
.facet-topic .box svg { width: 9px; height: 9px; }
.facet-topic[aria-pressed="true"] { color: var(--ink); font-weight: var(--fw-medium); }
.facet-topic[aria-pressed="true"] .box { background: var(--accent-solid); border-color: var(--accent-solid); color: #ffffff; }
.facet-count { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }

.year-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.year-presets .chip { justify-content: center; }
.year-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.field-label { display: block; margin-bottom: 4px; font-size: var(--fs-xs); color: var(--ink-3); }
.year-range select { width: 100%; }
.year-dash { padding-bottom: 7px; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip,
.chip-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--control);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.chip:hover,
.chip-more:hover { border-color: var(--line-3); color: var(--ink); background: var(--control-hover); }
.chip .n { font-size: 11.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip[aria-pressed="true"] .n { color: inherit; }
.chip-more { border-style: dashed; }

/* Active filters */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 12px; }
.active-filters:empty { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 2px 0 9px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--ink);
}
.pill .k { font-weight: 400; color: var(--ink-3); }
.pill button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-3);
}
.pill button:hover { background: var(--surface-3); color: var(--ink); }
.pill button svg { width: 9px; height: 9px; }
.reset-btn { padding: 0 8px; }

/* -------------------------------------------------- paper entries */
.paper-list { margin-top: 2px; }
.group { margin-top: 28px; }
.group:first-child { margin-top: 18px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin-inline: -12px;
  padding: 6px 12px;
  border-radius: var(--r);
  background: var(--surface-2);
}
.group-head h3 { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink); }
.group-head .n { font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Rows share one hover treatment: a faint rounded fill that bleeds past the text column */
.paper,
.paper-row,
.tb-card,
.dir-row,
.sched-row,
.essay-row,
.media-row { position: relative; isolation: isolate; }
.paper::before,
.paper-row::before,
.tb-card::before,
.dir-row::before,
.sched-row::before,
.essay-row::before,
.media-row::before {
  content: '';
  position: absolute;
  inset: 0 -12px;
  z-index: -1;
  border-radius: var(--r);
  background: transparent;
  transition: background-color var(--dur-1) var(--ease);
  pointer-events: none;
}
@media (hover: hover) {
  .paper:hover::before { background: var(--hover); }
  .paper-row:hover::before,
  .tb-card:hover::before,
  .dir-row:hover::before,
  .sched-row:hover::before,
  .essay-row:hover::before,
  .media-row:hover::before { background: var(--surface-2); }
}

.paper { display: block; padding: 22px 0 22px; border-bottom: 1px solid var(--line); }
.paper[data-read="true"] .paper-title a { color: var(--ink-3); }

.paper-gutter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  margin-bottom: 7px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.gutter-chapter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.gutter-chapter .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gutter-chapter:hover .nm { color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; }
.gutter-id { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0; }
.gutter-venue { color: var(--ink-2); font-weight: var(--fw-medium); }

.paper-body { min-width: 0; max-width: 80ch; }
.paper-title {
  font-size: var(--fs-title);
  font-weight: var(--fw-semi);
  line-height: 1.4;
  letter-spacing: var(--ls-title);
  margin-bottom: 4px;
  text-wrap: pretty;
}
.paper-title a { padding-block: 3px; color: var(--ink); text-decoration: none; }
.paper-title a:hover { text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 0.25em; }

.paper-authors { margin-bottom: 9px; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-3); }
.paper-authors .more { font-size: var(--fs-xs); white-space: nowrap; }

.paper-digest-wrap { max-width: var(--measure); margin-bottom: 10px; }
.paper-digest-text {
  font-size: var(--fs-read);
  line-height: 1.6;
  letter-spacing: -0.011em;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.paper[data-expanded="true"] .paper-digest-text { color: var(--ink-2); display: block; -webkit-line-clamp: unset; overflow: visible; }
.paper-digest-text a { color: var(--accent); }

.paper-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.paper-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.lnk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--control);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
  color: var(--ink-2);
  white-space: nowrap;
}
.lnk svg { width: 8px; height: 8px; color: var(--ink-4); }
.lnk:hover { color: var(--ink); background: var(--control-hover); border-color: var(--line-3); }
.lnk-ghost { border-color: transparent; background: transparent; font-weight: 400; color: var(--ink-3); }
.lnk-ghost:hover { color: var(--ink); background: var(--control-hover); border-color: transparent; }
.digest-toggle svg { width: 9px; height: 9px; transition: transform var(--dur-2) var(--ease); }
.paper[data-expanded="true"] .digest-toggle svg { transform: rotate(180deg); }

.paper-kws { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
/* A quiet middle dot centered in the gap between keywords, so multi-word
   phrases read as units. It takes no layout space (wrapping is unchanged)
   and trails its keyword, so a wrapped row never starts with a separator. */
.paper-kws .kw { position: relative; }
.paper-kws .kw:not(:last-child)::after {
  content: '\00B7';
  content: '\00B7' / '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 4px;
  text-align: center;
  color: var(--ink-4);
  pointer-events: none;
}
.kw {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink-3);
  text-align: left;
  text-underline-offset: 0.2em;
}
.kw:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-3); }
.kw.on { color: var(--accent); font-weight: var(--fw-medium); }

/* Compact rows: the whole row opens the paper; on wide screens each is one line */
.paper-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 6px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.paper-row[data-read="true"] .row-title a { color: var(--ink-3); }
.row-date { display: inline-flex; align-items: center; flex-direction: row-reverse; justify-content: flex-end; gap: 12px; font-size: var(--fs-sm); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.row-rom { display: inline-flex; }
.row-main { min-width: 0; }
.row-title { font-size: var(--fs-ui); font-weight: var(--fw-medium); line-height: 1.45; text-wrap: pretty; }
.row-title a { text-decoration: none; color: var(--ink); }
.row-title a::after { content: ''; position: absolute; inset: 0 -12px; }
.row-sub { margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: var(--fs-sm); color: var(--ink-3); }
.row-venue { color: var(--ink-2); }
.row-actions { position: relative; z-index: 1; display: flex; gap: 2px; flex-shrink: 0; margin-right: -9px; }
.row-actions .lnk { border-color: transparent; background: transparent; font-weight: 400; color: var(--ink-3); }
.row-actions .lnk:hover { background: var(--control-hover); color: var(--ink); }
@media (min-width: 1081px) {
  .paper-row { align-items: center; min-height: 42px; padding: 5px 0; }
  .row-main { display: flex; align-items: center; gap: 14px; }
  .row-title { flex: 0 1 auto; min-width: 0; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Authors and venue share what the title leaves. A part that cannot fit wraps onto a
     second, clipped line, so a long title hides it instead of leaving a stray letter. */
  .row-sub { flex: 1 1 0; min-width: 0; height: 20px; margin: 0; gap: 0; line-height: 20px; overflow: hidden; white-space: nowrap; }
  .row-sub::before { content: ''; width: 1px; height: 20px; }
  .row-sub > span:first-of-type { flex: 1 1 110px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .row-venue { margin-left: 14px; }
}

.empty { padding: 56px 0; text-align: left; }
.empty h3 { margin-bottom: 6px; font-size: 1.25rem; font-weight: var(--fw-medium); letter-spacing: var(--ls-title); }
.empty p { margin-bottom: 18px; font-size: var(--fs-ui); color: var(--ink-3); }
.empty .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Pagination */
.pagination { margin-top: 24px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.page-meta,
.page-jump { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.page-nav { display: flex; align-items: center; gap: 2px; }
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.page-btn svg { width: 10px; height: 10px; }
.page-btn:hover:not(:disabled):not([aria-current="page"]) { background: var(--surface-2); color: var(--ink); }
.page-btn[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: var(--fw-medium); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-step { padding: 0 10px; }
.page-ellipsis { padding: 0 2px; color: var(--ink-4); }
.page-jump { justify-self: end; }

/* ------------------------------------------------------------- RESOURCES */
.res-wrap {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  gap: 0 clamp(28px, 3.6vw, 52px);
  align-items: start;
  padding-top: 28px;
  padding-bottom: 72px;
}
.res-controls {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.res-atlas { display: flex; flex-direction: column; gap: 1px; }
.res-atlas::before { content: 'Formats'; margin: 0 0 8px 10px; font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: 0; color: var(--ink-4); }
.res-atlas-cell,
.res-dom-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-ui);
  color: var(--ink-2);
  text-decoration: none;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.res-atlas-cell:hover,
.res-dom-btn:hover { background: var(--surface-2); color: var(--ink); }
.res-atlas-cell[aria-selected="true"],
.res-dom-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); font-weight: var(--fw-medium); }
.res-atlas-cell[aria-selected="true"] .res-atlas-n,
.res-dom-btn[aria-pressed="true"] .res-dom-n { color: var(--ink-2); }
.res-atlas-top { display: contents; }
.res-atlas-name { font: inherit; color: inherit; }
.res-atlas-n,
.res-dom-n { font-size: var(--fs-xs); font-weight: 400; color: var(--ink-4); font-variant-numeric: tabular-nums; }

.res-domain-bar { display: flex; flex-direction: column; gap: 1px; padding-top: 14px; border-top: 1px solid var(--line); }
.res-domain-label { margin: 0 0 8px 10px; font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: 0; color: var(--ink-4); }

.res-body { min-width: 0; }
.res-section { margin-top: 48px; }
.res-section:first-child { margin-top: 0; }
.res-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-2);
}
.res-sec-head h2 { font-size: 1.25rem; font-weight: var(--fw-medium); line-height: 1.33; letter-spacing: var(--ls-title); color: var(--ink); }
.res-sec-head p { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-3); }
.res-sec-count { font-size: var(--fs-sm); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.res-sub { margin-top: 20px; }
.res-sub-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; font-size: var(--fs-xs) !important; color: var(--ink-4) !important; }
.res-sub-head .rule { flex: 1; height: 1px; background: var(--line); }

.res-toolboxes,
.res-directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.tb-card,
.dir-row { border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.tb-card { display: flex; flex-direction: column; padding: 14px 0 13px; }
.tb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.tb-head h4 { font-size: 15px; font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--ls-title); color: var(--ink); }
.tb-card p { max-width: 68ch; margin-bottom: 8px; font-size: var(--fs-sm); line-height: 1.55; color: var(--ink-3); }
.tb-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0; color: var(--ink-3); }
.tb-repo { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.tb-repo svg, .dir-host svg { width: 12px; height: 12px; flex-shrink: 0; }
.res-dom-tag { font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
/* The subgroup heading already names the domain; don't repeat it on every card */
.res-sub-head + .res-toolboxes .res-dom-tag,
.one-domain .res-dom-tag { display: none; }
.res-atlas-cell.is-zero, .res-dom-btn.is-zero { color: var(--ink-4); }
.arrow { width: 12px; height: 12px; flex-shrink: 0; color: var(--ink-4); }
a:hover .arrow { color: var(--ink-2); }

.dir-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; min-width: 0; }
.dir-main { min-width: 0; }
.dir-title { display: block; overflow-wrap: anywhere; font-size: var(--fs-ui); font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--ls-title); color: var(--ink); }
.dir-host { margin-top: 1px; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0; color: var(--ink-3); overflow-wrap: anywhere; }

.sched-row,
.essay-row,
.media-row { border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.sched-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto 12px; align-items: baseline; gap: 6px 18px; padding: 11px 0; }
.sched-row > .arrow { grid-column: -2; }
.sched-venue { font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sched-venue.is-series { color: var(--ink); }
.sched-title { font-size: var(--fs-ui); font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--ls-title); color: var(--ink); }

.essay-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; }
.essay-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.pub-badge { font-size: var(--fs-sm); color: var(--ink-3); }
.pub-badge.is-distill { color: var(--ink-2); }
.essay-title { font-size: 15px; font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--ls-title); color: var(--ink); }

.media-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto 12px; align-items: baseline; gap: 4px 18px; padding: 11px 0; }
.fmt-badge { font-size: var(--fs-sm); color: var(--ink-3); }
.media-title { display: block; font-size: var(--fs-ui); font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--ls-title); color: var(--ink); }
.media-sub { display: block; margin-top: 1px; font-size: var(--fs-sm); color: var(--ink-3); }
.media-meta { font-size: var(--fs-sm); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- ABOUT */
.about-wrap { padding-top: 36px; padding-bottom: 72px; }
.about-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-2);
}
.about-section-head h2 { display: inline-flex; align-items: baseline; gap: 10px; font-size: 1.25rem; font-weight: var(--fw-medium); line-height: 1.33; letter-spacing: var(--ls-title); color: var(--ink); }
.about-section-head p { margin-top: 2px; max-width: 64ch; font-size: var(--fs-sm); color: var(--ink-3); }
.h-count { font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.contrib-ledger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 clamp(28px, 3.6vw, 52px);
  margin-bottom: 56px;
}
.contrib-row { padding: 16px 0; border-bottom: 1px solid var(--line); }
.contrib-row-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 4px; }
.contrib-row h3 { font-size: 15px; font-weight: var(--fw-medium); letter-spacing: var(--ls-title); color: var(--ink); }
.contrib-row-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.contrib-row p { font-size: var(--fs-ui); line-height: 1.6; color: var(--ink-3); }

.template-stack { display: flex; flex-direction: column; gap: 14px; padding-top: 16px; }
.code-card { overflow: hidden; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); }
.code-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line); }
.code-card pre { margin: 0; padding: 12px 14px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.code-card pre .ln { display: block; padding-left: var(--hang); text-indent: calc(-1 * var(--hang)); }

.contrib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; padding-top: 10px; }
.contrib-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.contrib-card:hover { background: var(--surface-2); }
.contrib-avatar,
.contrib-avatar-fallback { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.contrib-avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: var(--fw-medium); }
.contrib-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0; line-height: 1.3; }
.contrib-name { display: block; font-size: var(--fs-ui); font-weight: var(--fw-medium); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contrib-commits { display: block; font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.contrib-role { color: var(--ink); font-weight: var(--fw-medium); }
.contrib-note { margin-top: 14px; font-size: var(--fs-sm); color: var(--ink-3); }
.contrib-note a { color: var(--accent); text-decoration: none; }
.contrib-note a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- PAPER DRAWER */
.drawer { position: fixed; inset: 0; z-index: 600; display: flex; justify-content: flex-end; }
.drawer-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade-in var(--dur-2) var(--ease) both; }
.drawer-panel {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100% - 16px));
  height: calc(100% - 16px);
  margin: 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  box-shadow: var(--shadow-drawer);
  padding: 0 clamp(22px, 3.4vw, 40px) 48px;
  outline: none;
  animation: drawer-in var(--dur-3) var(--ease) both;
}
.drawer-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 calc(-1 * clamp(22px, 3.4vw, 40px)) 24px;
  padding: 10px clamp(22px, 3.4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.drawer-meta { min-width: 0; }
.drawer-meta .gutter-chapter { margin: 0; }
.drawer-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.drawer-nav { display: inline-flex; align-items: center; gap: 2px; }
.drawer-pos { padding: 0 6px; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.drawer-nav-btn,
.drawer-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
}
.drawer-nav-btn svg { width: 11px; height: 11px; }
.drawer-close-btn svg { width: 12px; height: 12px; }
.drawer-nav-btn:hover,
.drawer-close-btn:hover { background: var(--surface-2); color: var(--ink); }
.drawer-nav-btn.is-disabled { opacity: 0.3; pointer-events: none; }

.drawer-dateline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 10px; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.drawer-title { margin-bottom: 12px; font-size: clamp(1.5rem, 2.2vw, 1.75rem); font-weight: var(--fw-medium); line-height: 1.25; letter-spacing: -0.018em; color: var(--ink); }
.drawer-authors { margin-bottom: 20px; font-size: var(--fs-ui); line-height: 1.6; color: var(--ink-3); }
/* Keep each name with its trailing comma; lines break only between authors */
.author-item { white-space: nowrap; }
.author-link { padding: 0; border: 0; background: transparent; line-height: inherit; color: var(--ink-2); text-decoration: none; }
.author-link:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 0.25em; }
.drawer-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.drawer-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.drawer-section .mono-label { margin-bottom: 8px; color: var(--ink-3); }
.drawer-digest { font-size: 1rem; line-height: 1.65; letter-spacing: -0.011em; color: var(--ink-2); }
.drawer-digest a { color: var(--accent); }

.related { list-style: none; padding: 0; margin: 0; }
.related li a {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  text-decoration: none;
  font-size: var(--fs-ui);
  line-height: 1.45;
  color: var(--ink-2);
}
.related li a .dot { transform: translateY(-2px); }
.related li a:hover { color: var(--ink); }
.related li a .y { font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.drawer-foot { margin-top: 26px; padding-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.drawer-foot .mono-label { margin-right: 4px; color: var(--ink-3); }
.source-note { margin-top: 12px; font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------------------------------------------------------- FOOTER & CHROME */
.site-footer { margin-top: auto; border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-direction: column; gap: 10px; padding-top: 22px; padding-bottom: 26px; font-size: var(--fs-sm); color: var(--ink-3); }
.footer-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 32px; }
.footer-id { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.footer-brand { font-size: var(--fs-ui); font-weight: var(--fw-medium); color: var(--ink); }
.footer-desc { font-size: var(--fs-sm); color: var(--ink-3); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.footer-links a { font-size: var(--fs-sm); color: var(--ink-3); text-decoration: none; transition: color var(--dur-1) var(--ease); }
.footer-links a:hover { color: var(--ink); }
.footer-prov { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.footer-prov a { color: var(--ink-2); text-decoration-color: var(--line-3); }
.footer-prov a:hover { color: var(--ink); }
.footer-commit { font-family: var(--font-mono); }

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink-2);
  box-shadow: var(--shadow-pop);
  animation: fade-in var(--dur-2) var(--ease) both;
}
.back-to-top:hover { color: var(--ink); border-color: var(--line-3); }
.back-to-top svg { width: 14px; height: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 700;
  padding: 9px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-pop);
  animation: toast-in var(--dur-2) var(--ease) both;
}

.noscript,
.load-error { max-width: 680px; margin: 40px auto; padding: 18px; border: 1px solid var(--line-2); border-radius: var(--r); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* Text links fade their color like the rest of the interface */
.lnk, .kw, .author-link, .op-chip, .quick-btn, .arrow { transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease); }
.trends-panel:not([hidden]) { animation: fade-in var(--dur-2) var(--ease) both; }

/* ------------------------------------------------------------ RESPONSIVE */
@media (max-width: 1080px) {
  :root { --side-w: 200px; }
  .intro { display: block; }
  .intro-years { margin-top: 14px; }
  .years-head, .years-chart, .years-axis, .tt-wide { display: none; }
  .tt-narrow { display: inline; }
  .intro-years .trends-toggle { margin-top: 0; }
  .topbar-search { width: min(260px, 100%); }
}

/* Below 960px the sidebars turn into horizontal scrollers above the content */
@media (max-width: 960px) {
  .library-layout,
  .res-wrap { grid-template-columns: minmax(0, 1fr); }
  .library-side,
  .res-controls { position: static; max-height: none; overflow: visible; padding: 0; }
  .side-label { display: none; }
  .chapter-strip,
  .res-atlas,
  .res-domain-bar {
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(-1 * clamp(20px, 3.4vw, 40px));
    padding: 0 clamp(20px, 3.4vw, 40px) 2px;
  }
  .chapter-strip::-webkit-scrollbar,
  .res-atlas::-webkit-scrollbar,
  .res-domain-bar::-webkit-scrollbar { display: none; }
  /* Fade whichever edge has more items past it (data-fade is set by app.js) */
  .chapter-strip[data-fade="r"],
  .res-atlas[data-fade="r"],
  .res-domain-bar[data-fade="r"] {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent);
  }
  .chapter-strip[data-fade="l"],
  .res-atlas[data-fade="l"],
  .res-domain-bar[data-fade="l"] {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 56px);
    mask-image: linear-gradient(to right, transparent, #000 56px);
  }
  .chapter-strip[data-fade="lr"],
  .res-atlas[data-fade="lr"],
  .res-domain-bar[data-fade="lr"] {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent);
  }
  .chapter-strip { margin-bottom: 16px; }
  .spot-tab,
  .res-atlas-cell,
  .res-dom-btn { width: auto; flex: 0 0 auto; display: inline-flex; gap: 8px; white-space: nowrap; border: 0; }
  .spot-tab[aria-pressed="true"],
  .res-atlas-cell[aria-selected="true"],
  .res-dom-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }
  .res-atlas::before { display: none; }
  .res-controls { gap: 8px; margin-bottom: 28px; }
  .res-domain-bar { border-top: 0; padding-top: 0; align-items: center; }
  .res-domain-label { margin: 0 4px 0 0; align-self: center; white-space: nowrap; }

  .contrib-ledger { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 24px; }
  .tabs { justify-content: flex-start; }
  .mobile-search-btn { display: inline-flex; }
  .topbar-search {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
    margin-bottom: 10px;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .topbar.search-open .topbar-search { display: flex; }
  .topbar-search .search-kbd { display: none; }

  .library-top-right { width: 100%; order: 2; }
  .topic-inline { order: 1; }
  .res-toolboxes,
  .res-directory { grid-template-columns: 1fr; }

  .sched-row { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .sched-row .sched-venue { grid-column: 1; grid-row: 1; }
  .sched-row .res-dom-tag { grid-column: 2; grid-row: 1; justify-self: end; }
  .sched-row .sched-title { grid-column: 1 / -1; grid-row: 2; }
  .sched-row .arrow { display: none; }
  .media-row { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .media-row .fmt-badge { grid-column: 1; grid-row: 1; }
  .media-row .media-meta { grid-column: 2; grid-row: 1; justify-self: end; min-width: 0; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
  .media-row > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .media-row .arrow { display: none; }

  /* Compact rows stack: date and links on one line, the title below */
  .paper-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; padding: 8px 0 12px; }
  .row-main { grid-column: 1 / -1; grid-row: 2; }
  .pagination { grid-template-columns: 1fr; justify-items: start; }
  .page-jump { justify-self: start; }
}

@media (max-width: 700px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; }
  .brand { height: 50px; }
  .topbar-actions { height: 50px; }
  .tabs { grid-column: 1 / -1; order: 3; justify-content: flex-start; height: 40px; margin-left: -10px; }
  .topbar-search { order: 4; margin-top: 8px; }
  .drawer-panel { width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; }
  .drawer-pos { display: none; }
}

@media (max-width: 560px) {
  .opening-band, .subpage-head { padding-top: 32px; }
  .display-deck, .subpage-lede { margin-top: 14px; font-size: 1rem; line-height: 1.55; }
  .hero-search { margin-top: 22px; }
  .search-kbd { display: none !important; }
  .help-sep, .search-help > span:last-child { display: none; }
  .search-help { gap: 2px 8px; }
  .library-top-right, .library-display-controls { width: 100%; }
  /* density (as icons), grouping and sort share one row */
  .library-display-controls { flex-wrap: nowrap; }
  .library-display-controls .segmented { flex: 0 0 auto; }
  .library-display-controls .segmented button { display: inline-flex; align-items: center; padding: 0 9px; }
  .seg-icon { display: block; }
  .seg-label { display: none; }
  .library-display-controls .select-wrap { flex: 1 1 auto; min-width: 0; }
  .library-display-controls select { width: 100%; padding: 0 24px 0 9px; background-position: right 8px center; }
  .filter-sep { display: none; }
  .page-nav { flex-wrap: wrap; }
  .page-step span { display: none; }
  .contrib-row-actions { gap: 4px 14px; }
  .back-to-top { right: 14px; bottom: 14px; }
}

/* Below 360px the operators only fit on one row without their label
   (the row keeps aria-label="Search operators") */
@media (max-width: 359px) {
  .search-help > span:first-child { display: none; }
}

/* Minimum target sizes for inline links (WCAG 2.2: 24px; larger on touch) */
.op-chip, .quick-btn, .trends-toggle, .footer-links a, .gutter-chapter { display: inline-flex; align-items: center; min-height: 24px; }
.quick-btn { gap: 5px; }
.pill button { width: 24px; height: 24px; }
@media (pointer: coarse) {
  .op-chip, .quick-btn, .trends-toggle, .footer-links a, .text-btn, .lnk { min-height: 32px; }
  .op-chip { min-width: 28px; justify-content: center; padding: 0 3px; }
}

/* Print: a clean reading list (full digests, no chrome) */
@media print {
  /* Dark is the default theme, so paper needs its own light values */
  :root,
  [data-theme="dark"] {
    color-scheme: light;
    --bg: #fff; --bg-2: #fff; --surface: #fff; --raised: #fff; --control: #fff; --surface-2: #f2f2f2; --surface-3: #e8e8e8;
    --ink: #000; --ink-2: #222; --ink-3: #444; --ink-4: #555; --accent: #000;
    --line: #ddd; --line-2: #ccc; --line-3: #aaa;
  }
  .topbar, .skip-link, .opening-band, .trends-panel, .library-side, .library-toolbar, .library-top-right,
  .active-filters, .pagination, .back-to-top, .toast, .drawer, .site-footer, .paper-links .lnk-ghost, .digest-toggle,
  .view-resources .res-controls, .subpage-meta-row { display: none !important; }
  .library { padding: 0; }
  .library-layout, .res-wrap { display: block; }
  .paper, .paper-row, .tb-card, .sched-row, .media-row, .essay-row, .dir-row { break-inside: avoid; }
  .paper-digest-text { display: block; -webkit-line-clamp: unset; overflow: visible; }
  .paper-body, .paper-digest-wrap { max-width: none; }
  .lnk { height: auto; padding: 0; border: 0; }
  .lnk, .paper-title a { color: #000; text-decoration: none; }
  .paper-links .lnk[href]::after { content: ' (' attr(href) ')'; font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: #555; }
  mark { background: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
