body {
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--link);
}

a:hover,
a:focus {
  color: var(--link-hover);
}

:root {
  --table-highlight-bg: color-mix(in srgb, var(--accent) 16%, var(--bg));
  --table-highlight-border: color-mix(in srgb, var(--accent) 58%, var(--faint));
}

:root[data-theme="dark"] {
  --table-highlight-bg: color-mix(in srgb, var(--accent) 26%, var(--bg));
  --table-highlight-border: color-mix(in srgb, var(--accent) 72%, var(--faint));
}

.citation {
  position: relative;
  white-space: nowrap;
}

.citation::after {
  position: absolute;
  left: 50%;
  bottom: 135%;
  z-index: 20;
  width: min(23rem, 82vw);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--faint);
  border-radius: 8px;
  background: var(--soft);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  content: attr(data-cite);
  font-size: 0.85rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.35rem);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: normal;
}

.citation:hover::after,
.citation:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  margin: 0.35em 0 0.2em;
}

h2 {
  font-size: 1.65rem;
  line-height: 1.25;
  margin-top: 2.2em;
}

h3 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin-top: 1.85em;
}

.post-dek {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  margin: 0.45rem 0 0.7rem;
}

.entry-date {
  border-bottom: 1px solid var(--faint);
  color: var(--muted);
  margin-bottom: 2.2em;
  padding-bottom: 1.35rem;
}

.draft-note {
  background: var(--soft);
  border: 1px solid var(--faint);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 1.5rem 0 2rem;
  padding: 0.9rem 1rem;
}

.post-part {
  border-top: 1px solid var(--faint);
  margin-top: 3.6rem;
  padding-top: 1.55rem;
}

.post-part h2 {
  margin-top: 0.1rem;
}

.part-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.result-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.4rem 0 1.8rem;
}

.result-card {
  background: var(--soft);
  border: 1px solid var(--faint);
  border-radius: 8px;
  padding: 1rem;
}

.result-card strong {
  color: var(--text);
  display: block;
  font-size: 1.35rem;
  line-height: 1.15;
  margin-bottom: 0.35rem;
}

.result-card span {
  color: var(--muted);
  display: block;
  font-size: 0.92rem;
  line-height: 1.35;
}

figure {
  margin: 2rem 0;
}

figure img {
  border: 1px solid var(--faint);
  border-radius: 10px;
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
}

figcaption {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.7rem;
}

.table-wrap {
  border: 1px solid var(--faint);
  border-radius: 8px;
  contain: inline-size;
  margin: 1.35rem 0 1.8rem;
  max-width: 100%;
  overflow-x: auto;
}

mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 720px;
  width: 100%;
}

.compact-table table {
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--faint);
  padding: 0.65rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.highlight-row,
tr[style*="#fff2b8"] {
  background: var(--table-highlight-bg);
}

.highlight-row > th,
.highlight-row > td,
tr[style*="#fff2b8"] > th,
tr[style*="#fff2b8"] > td {
  background: var(--table-highlight-bg);
  border-bottom-color: var(--table-highlight-border);
  color: var(--text);
}

.highlight-row > th:first-child,
.highlight-row > td:first-child,
tr[style*="#fff2b8"] > th:first-child,
tr[style*="#fff2b8"] > td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.experiment-details,
.concept-details {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0;
}

.experiment-details {
  margin: -0.7rem 0 1.8rem;
}

.concept-details {
  margin: 0.8rem 0 1.5rem;
}

.caption-details {
  margin-top: 0.65rem;
}

.experiment-details summary,
.concept-details summary,
.caption-details summary {
  cursor: pointer;
  display: inline-block;
  font-weight: 550;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.experiment-details p,
.concept-details p,
.caption-details p {
  margin: 0.65rem 0;
}

.experiment-details p:last-child,
.concept-details p:last-child,
.caption-details p:last-child {
  margin-bottom: 0;
}

.references {
  padding-left: 1.35rem;
  font-size: 0.94rem;
}

.references li {
  margin: 0.55rem 0;
}

@media (max-width: 700px) {
  .citation::after {
    bottom: 1rem;
    left: 50%;
    position: fixed;
    transform: translate(-50%, 0.35rem);
    width: calc(100vw - 2rem);
  }

  .citation:hover::after,
  .citation:focus-visible::after {
    transform: translate(-50%, 0);
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.86rem;
    min-width: 620px;
  }
}
