/* === Variables === */
:root {
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-serif: Georgia, serif;
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, Consolas, monospace;
  --font-article-h1: "Cardo", Georgia, serif;
  --font-article-h2: "Cardo", Georgia, serif;
  --font-article-h3: "Cardo", Georgia, serif;
  --bg: #fff;
  --bg-alt: #fafafa;
  --text: #374151;
  --heading: #000;
  --link: #000;
  --border: #f0f0f0;
  --border-alt: #e0e0e0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --glass-bg: rgba(255, 255, 255, .72);
  --glass-border: rgba(0, 0, 0, .06);
  --shadow: 0 4px 12px rgba(0, 0, 0, .06);
  --transition: .25s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

.dark-mode,
:root[dark] {
  --bg: #151515;
  --bg-alt: #1e1e1e;
  --text: #c0c0c0;
  --heading: #eee;
  --link: #fff;
  /* Lighter scientific blue for dark mode */
  --border: #2a2a2a;
  --border-alt: #444;
  --glass-bg: rgba(21, 21, 21, .72);
  --glass-border: rgba(255, 255, 255, .08);
  --shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

.dark-mode .bv-article,
:root[dark] .bv-article {
  color: rgba(255, 255, 255, 0.8);
}

.dark-mode .bv-article a,
:root[dark] .bv-article a {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.dark-mode .article-hero-visual img,
:root[dark] .article-hero-visual img {
  filter: invert(0.85) hue-rotate(180deg);
}

/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font: 17px/1.6 var(--font-body);
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  overflow-x: hidden;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-ui);
  color: var(--heading);
  line-height: 1.3;
  font-weight: 600;
}

p {
  margin-bottom: 16px;
}

ul,
ol {
  padding-left: 1.5em;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  font-family: var(--font-ui);
  font-size: 15px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
  opacity: 0.6;
}

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

pre {
  overflow-x: auto;
}

/* === Layout === */
.global-wrap {
  min-height: 100vh;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px;
}

/* === Home === */
.home {
  max-width: 560px;
  margin: 0 auto;
  padding: 96px 20px 80px;
}

.home__header {
  margin-bottom: 56px;
}

.home__name {
  font-family: var(--font-ui);
  font-size: 24px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -.02em;
  margin-bottom: 12px;
}

.home__bio {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 24px;
  max-width: 480px;
}

.home__links {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  font-size: 17px;
}

.home__links a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition), transform var(--transition);
}

.home__links a:hover {
  color: var(--heading);
  transform: translateY(-1px);
}

/* === Writings list === */
.home__section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: none;
  color: var(--heading);
  margin-bottom: 16px;
}

.home__post {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: opacity var(--transition);
}

.home__post:first-of-type {
  border-top: 1px solid var(--border);
}

.home__post:hover {
  opacity: .7;
}

.home__post-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--heading);
}

/* === Theme Toggle === */
.toggle-theme {
  position: fixed;
  z-index: 5;
  right: calc(32px + var(--safe-right));
  bottom: calc(32px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  background: var(--glass-bg);
  color: var(--heading);
  cursor: pointer;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, box-shadow 0.2s;
  outline: none;
}

.toggle-theme:hover {
  transform: scale(1.1);
  background: var(--bg-alt);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.toggle-theme:active {
  transform: scale(0.95);
}

.toggle-sun,
.toggle-moon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-moon {
  display: none;
}

.dark-mode .toggle-moon {
  display: flex;
}

.dark-mode .toggle-sun {
  display: none;
}

@media(max-width:576px) {
  .toggle-theme {
    right: calc(20px + var(--safe-right));
    bottom: calc(20px + var(--safe-bottom));
    width: 40px;
    height: 40px;
  }
}

/* === Code Copy === */
pre.highlight {
  position: relative;
}

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-ui);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}

/* === Article Layout (bv-article) === */
.bv-article,
.post {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.55;
  color: rgba(0, 0, 0, 0.8);
  max-width: 888px;
  margin-left: max(20px, calc(50% - 410px));
  margin-right: max(20px, calc(50% - 410px));
  overflow-wrap: break-word;
  word-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

.bv-article {
  font-size: 20px;
}

.katex {
  font-size: 1.1em !important;
}

.bv-article h1 {
  font-family: var(--font-article-h1);
  font-size: 50px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.0;
  text-align: center;
  margin: 5rem 0 1rem 0;
  letter-spacing: -0.02em;
  color: var(--heading);
}

.article-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  line-height: 18px;
  color: rgba(0, 0, 0, 0.5);
  padding-top: 12px;
  padding-bottom: 12px;
  margin: 1rem 0 3rem 0;
  font-family: var(--font-ui);
}

.dark-mode .article-meta,
:root[dark] .article-meta {
  color: rgba(255, 255, 255, 0.5);
}

.article-hero-visual {
  display: flex;
  justify-content: center;
  margin: 0;
  color: var(--text);
}

.article-hero-visual svg {
  max-width: 100%;
  height: auto;
}

.meta-column {
  padding: 0 30px;
  border-left: 1px solid var(--border);
  text-align: left;
  transition: border-color var(--transition);
}

.meta-column:first-child {
  border-left: none;
  text-align: left;
}

.meta-name,
.meta-heading {
  font-weight: 300;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.meta-name {
  text-transform: none;
}

.meta-heading {
  text-transform: none;
}

.meta-value {
  font-weight: 300;
}

.meta-link {
  color: inherit !important;
  text-decoration: none !important;
  border-bottom: none !important;
  transition: border-color 0.2s ease;
}

.meta-link:hover {
  border-bottom: 1px solid currentColor !important;
}

.bv-article h2 {
  font-family: var(--font-article-h2);
  font-size: 30px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.25;
  margin: 36px 0 24px;
  letter-spacing: -0.01em;
  color: var(--heading);
  text-transform: none;
}

.bv-article h3 {
  font-family: var(--font-article-h3);
  font-size: 26px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
  margin: 1.25rem 0 0.4rem;
  letter-spacing: -0.01em;
  color: var(--heading);
}

.bv-article h4 {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.1em;
  margin: 1.5rem 0 .4rem;
  color: #6b7280;
}

.bv-article p {
  margin-bottom: 1.0rem;
}

.bv-article p:first-of-type {
  margin-top: 3rem;
  opacity: 0.9;
}

.bv-article a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease;
}

.bv-article a:hover {
  border-bottom-color: var(--link);
}

.bv-article figure,
[id$="-viz"],
[id^="viz-"] {
  --font-body: var(--font-system);
  --font-ui: var(--font-system);
  font-family: var(--font-system);
}

.bv-article figure {
  margin: 1rem 0;
  text-align: center;
}

.bv-article figure img,
.bv-article figure object[type="image/svg+xml"] {
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

.bv-article figure img[src*=".svg"],
.bv-article figure object[type="image/svg+xml"] {
  opacity: 0.666;
  /* Match #000 vectors to #555 var(--text) light mode */
}

.bv-article figcaption {
  font-size: 14px;
  color: var(--text);
  margin-top: 8px;
  font-style: italic;
}

.bv-article .l-body {
  max-width: 100%;
  margin: 1.5rem auto !important;
}

.bv-article .l-page {
  max-width: 110%;
  margin-left: -5%;
}

.bv-article .l-screen-inset {
  max-width: 130%;
  margin-left: -15%;
}

.bv-article ol,
.bv-article ul {
  margin-bottom: 1.25rem;
}



.bv-article .l-body {
  max-width: 100%;
  margin: 1.5rem auto !important;
}

.bv-article table {
  margin: 0.75rem auto;
}

.compact-table table {
  width: auto;
  margin: 0.75rem auto;
}

.compact-table th,
.compact-table td {
  padding: 4px 12px;
  text-align: center;
}

.bv-article th {
  background: var(--bg-alt);
  font-weight: 600;
}

.bv-article .bv-sidenote {
  float: right;
  clear: right;
  width: 200px;
  margin: 0 -240px 8px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.bv-article .bv-sidenote-number {
  font-size: 11px;
  vertical-align: super;
  font-weight: 600;
  color: var(--heading);
}

@media(max-width:992px) {
  .bv-article .bv-sidenote {
    float: none;
    width: 100%;
    margin: 8px 0 16px;
    padding: 12px;
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
  }

  .bv-article .l-page,
  .bv-article .l-screen-inset {
    max-width: 100%;
    margin-left: 0;
  }
}

/* === Mobile Article Styles === */
@media(max-width:768px) {
  .bv-article {
    padding: 0 20px;
    font-size: 16px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .bv-article h1 {
    font-size: 40px;
    margin: 2rem 0 1.25rem;
    word-break: break-word;
    hyphens: auto;
  }

  .bv-article h2 {
    font-size: 22px;
    margin: 1.5rem 0 .6rem;
  }

  .bv-article h3 {
    font-size: 19px;
  }

  .bv-article h4 {
    font-size: 16px;
  }

  .bv-article p {
    overflow-wrap: break-word;
  }

  .bv-article figure {
    margin: 1.25rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bv-article figure img,
  .bv-article figure object[type="image/svg+xml"] {
    max-width: 100%;
    height: auto;
  }

  .bv-article .definition,
  .bv-article .theorem {
    padding: 14px 16px;
    overflow-x: auto;
  }

  .bv-article table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .bv-article .l-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bv-article ol,
  .bv-article ul {
    padding-left: 1.2em;
  }

  .bv-footer {
    padding: 1.5rem 20px;
  }

  .footer-container {
    padding: 0;
  }

  .markdown-code,
  .citation-block {
    font-size: 11px;
    padding: 12px;
  }
}

@media(max-width:480px) {
  .bv-article {
    padding: 0 14px;
    font-size: 15px;
  }

  .bv-article h1 {
    font-size: 24px;
    margin: 1.5rem 0 1rem;
  }

  .bv-article h2 {
    font-size: 20px;
  }

  .bv-footer {
    padding: 1.25rem 14px;
  }
}

/* Prevent KaTeX math from overflowing on any screen */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
  max-width: 100%;
}

.katex-display>.katex {
  max-width: 100%;
  padding-bottom: 2px;
}

.bv-article .bv-section-label {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}

.bv-article .definition,
.bv-article .theorem {
  margin: 1.5rem 0;
  padding: 16px 20px;
  background: var(--bg-alt);
  border-left: 3px solid var(--border-alt);
  border-radius: var(--radius-sm);
}

/* === Inline citation / footnote markers === */
.bv-article .citation,
.bv-article .footnote {
  display: inline-block;
  cursor: pointer;
  position: relative;
  line-height: inherit;
  vertical-align: baseline;
  padding: 0 1px;
}

.bv-article .ref-marker {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.45;
  vertical-align: super;
  transition: all 0.2s ease;
  padding: 0 1px;
}

.bv-article .citation:hover .ref-marker,
.bv-article .footnote:hover .ref-marker {
  opacity: 1;
  color: var(--link);
}

/* Flash animation when clicking to scroll to reference */
.ref-flash {
  animation: refFlash 1.1s ease forwards;
}

@keyframes refFlash {
  0% {
    background-color: transparent;
  }

  15% {
    background-color: rgba(100, 100, 100, 0.18);
  }

  60% {
    background-color: rgba(100, 100, 100, 0.10);
  }

  100% {
    background-color: transparent;
  }
}

.definition {
  background: var(--bg-alt);
  border-left: 4px solid var(--border-alt);
  padding: 0.8rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.definition p {
  margin: 0 !important;
}

/* === Article Footer === */
.bv-footer {
  margin-top: 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: border-color var(--transition);
}

.bv-footer p {
  font-family: inherit;
  font-style: normal;
}

.footer-container {
  max-width: 100%;
  /* Take full width of the already-aligned parent */
  margin: 0;
}

.footer-section {
  margin-bottom: 1.5rem;
}

.footer-section h3 {
  font-family: inherit;
  font-style: normal;
  font-size: 18px;
  margin-bottom: 12px;
}

.footer-list {
  font-size: 15px;
  line-height: 1.6;
  padding-left: 1.25em;
  /* Precisely align text with paragraph margin */
  margin: 0;
}

.reference-item {
  margin-bottom: 8px;
  transition: background-color 0.4s ease;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin-left: -4px;
}

.markdown-code,
.citation-block {
  background: var(--bg-alt);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

/* === Visualization Controls === */
.bv-step-btn,
.bv-basis-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--heading);
  cursor: pointer;
}

.bv-step-btn:hover,
.bv-basis-btn:hover {
  background: var(--bg-alt);
}

.bv-basis-btn.is-selected {
  border-color: var(--heading);
  background: var(--bg-alt);
  font-weight: 600;
}

:root[dark] .bv-basis-btn.is-selected {
  border-color: #fff;
}

.bv-analysis-label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* === K-Maps === */
.kmap-container {
  display: inline-block;
}

.kmap-table {
  border-collapse: collapse;
}

.kmap-table td {
  width: 40px;
  height: 40px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 18px;
  border: 1px solid var(--border);
}

.kmap-table .kmap-header {
  background: var(--bg-alt);
  font-weight: 600;
  font-size: 14px;
}

.kmap-table .kmap-one {
  font-weight: 700;
  color: var(--heading);
}

.kmap-covering {
  position: absolute;
  border: 2.5px solid;
  border-radius: 8px;
  pointer-events: none;
}

.kmap-cell-label {
  font-size: 11px;
  opacity: .6;
  position: absolute;
  bottom: 2px;
  right: 4px;
}

.function-label {
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
}

:root[dark] .kmap-table td {
  border-color: #444;
}

/* === K-map SVG Styles === */
.kmap-border {
  fill: none;
  stroke: var(--heading);
  stroke-width: 1.5;
}

.kmap-line {
  stroke: var(--heading);
  stroke-width: 1;
}

.kmap-line-thin {
  stroke: var(--border);
  stroke-width: 0.5;
}

/* === SVG Figure Dark Mode === */
.dark-mode .bv-article figure img[src*=".svg"],
:root[dark] .bv-article figure img[src*=".svg"],
.dark-mode .bv-article figure object[type="image/svg+xml"],
:root[dark] .bv-article figure object[type="image/svg+xml"] {
  filter: invert(1) hue-rotate(180deg);
  opacity: 0.73;
  /* Match inverted vectors exactly to #c0c0c0 var(--text) */
}

/* === Simon / QPE Viz === */
.simon-highlight-row {
  background: rgba(0, 0, 0, .1) !important;
}

.simon-highlight-active {
  background: rgba(0, 0, 0, .15) !important;
}

:root[dark] .simon-highlight-row {
  background: rgba(255, 255, 255, .05) !important;
}

:root[dark] .simon-highlight-active {
  background: rgba(255, 255, 255, .1) !important;
}

.ticks {
  font: 10px sans-serif;
}

.track,
.track-inset,
.track-overlay {
  stroke-linecap: round;
}

.track {
  stroke: #e6e6e6;
  stroke-opacity: .5;
  stroke-width: 10px;
}

.track-inset {
  stroke: #e6e6e6;
  stroke-width: 8px;
}

.track-overlay {
  pointer-events: stroke;
  stroke-width: 50px;
  stroke: transparent;
  cursor: pointer;
}

.handle {
  fill: #ff9800;
  stroke: #e65100;
  stroke-width: 1.5px;
  cursor: pointer;
}

.figtext {
  font: bold 13px/18px "Helvetica Neue", sans-serif;
  color: #333;
}

.ticktext {
  font: 11px "Helvetica Neue", sans-serif;
  fill: #999;
}

/* === Table of Contents / Scrollspy === */
.toc-nav {
  position: fixed;
  top: 18vh;
  left: max(20px, calc(50% - 410px - 280px));
  width: 220px;
  font-family: var(--font-ui);
  z-index: 10;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.4;
  margin-bottom: 16px;
  padding-left: 12px;
}

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

.toc-nav ul ul {
  padding-left: 12px;
  margin-top: 2px;
  margin-bottom: 2px;
  position: relative;
  display: none;
}

.toc-nav a.active+ul {
  display: block;
}

.toc-nav ul ul::before {
  display: none;
}

.toc-nav ul ul a {
  padding: 5px 12px;
  font-size: 12.5px;
  opacity: 0.5;
}


.toc-nav ul ul a:hover,
.bv-article .toc-nav ul ul a:hover {
  transform: translateX(2px);
  background: transparent;
}

.toc-nav ul ul a.active,
.bv-article .toc-nav ul ul a.active {
  background: transparent;
  box-shadow: none;
  font-weight: 500;
  opacity: 0.9;
  transform: translateX(2px);
}

.toc-nav ul ul a.active::after {
  display: none;
}

.toc-nav a {
  display: flex;
  align-items: flex-start;
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  text-decoration: none;
  border-radius: 0;
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  position: relative;
  opacity: 0.55;
  border: none;
  border-bottom: none !important;
}

.bv-article .toc-nav a {
  text-decoration: none;
  color: var(--text);
  border-bottom: none !important;
}


.toc-nav a:hover,
.bv-article .toc-nav a:hover {
  color: var(--link);
  opacity: 1;
  transform: translateX(4px);
}

.toc-nav a.active,
.bv-article .toc-nav a.active {
  color: var(--link);
  opacity: 1;
  font-weight: 500;
  transform: translateX(4px);
}




.toc-nav a.active::after {
  display: none;
}

@media (max-width: 1400px) {
  .toc-nav {
    display: none;
  }
}

/* === Citation / Footnote Tooltip === */
#citation-tooltip {
  position: absolute;
  z-index: 1000;
  max-width: 340px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--glass-border);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(4px);
}

#citation-tooltip.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#citation-tooltip::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
  border: inherit;
  border-right: 0;
  border-bottom: 0;
  left: var(--arrow-left, 50%);
}

#citation-tooltip[data-placement="top"]::after {
  bottom: -6px;
  transform: translateX(-50%) rotate(225deg);
}

#citation-tooltip[data-placement="bottom"]::after {
  top: -6px;
  transform: translateX(-50%) rotate(45deg);
}

#citation-tooltip a {
  color: var(--link);
  font-weight: 500;
  text-decoration-thickness: 1px;
}

#citation-tooltip em {
  font-style: italic;
  opacity: 1;
}

/* Dark mode refinements */
:root[dark] #citation-tooltip {
  background: rgba(25, 25, 25, 0.85);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}