/* ALFHEIM Article Theory Rail — Portrait + Diagram Inspector (Direction 01)
 * Strictly uses ALFHEIM CSS tokens from appearance.css / article.css so Light
 * (Rosé Pine Dawn), Dark (Kanagawa Wave), Auto, and all 8 film palettes stay harmonious. */

:root {
  --theory-rail-left: 0px;
  --theory-rail-width: 100%;
  --theory-serif: "Iowan Old Style", "Songti SC", "Noto Serif SC", Georgia, "Times New Roman", serif;
}

@media (min-width: 1250px) {
  :root {
    --theory-rail-left: calc(50% + 332px);
    --theory-rail-width: clamp(236px, calc(50vw - 364px), 336px);
  }
}

/* ---------- prose anchor binding (zero layout shift / reflow) ---------- */

.article-copy [data-anchor] {
  position: relative;
  z-index: 1;
}

.article-copy [data-anchor] .theory-term {
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 44%, var(--line));
  padding-bottom: 1px;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition:
    background-color 0.22s ease,
    border-bottom-color 0.22s ease,
    color 0.22s ease;
}

.article-copy [data-anchor] .theory-term:hover {
  border-bottom-style: solid;
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.article-copy [data-anchor].is-theory-active::after {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -14px;
  right: -8px;
  z-index: -1;
  background: color-mix(in srgb, var(--accent) 5.5%, transparent);
  border-left: 2.5px solid var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition:
    background-color 0.22s ease,
    border-left-color 0.22s ease;
}

.article-copy [data-anchor].is-theory-active.is-theory-intense::after {
  background: color-mix(in srgb, var(--accent) 9.5%, transparent);
}

.article-copy li[data-anchor].is-theory-active::after {
  left: calc(-1.4em - 14px);
  right: -8px;
}

.article-copy blockquote[data-anchor].is-theory-active::after {
  left: -1px;
}

.article-copy [data-anchor].is-theory-active .theory-term {
  border-bottom: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--ink);
}

.article-copy [data-anchor].is-theory-pulse {
  animation: theory-anchor-pulse 1.15s ease;
}

@keyframes theory-anchor-pulse {
  0% {
    background-color: color-mix(in srgb, var(--accent) 14%, transparent);
    box-shadow:
      -8px 0 0 color-mix(in srgb, var(--accent) 14%, transparent),
      8px 0 0 color-mix(in srgb, var(--accent) 14%, transparent);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}

@media (min-width: 1250px) {
  .article-copy [data-anchor].is-theory-active::before {
    content: attr(data-theory-badge);
    position: absolute;
    right: calc(100% + 18px);
    top: 3px;
    padding: 1.5px 5px;
    border: 1px solid color-mix(in srgb, var(--accent) 62%, var(--line));
    background: color-mix(in srgb, var(--accent) 11%, var(--bg));
    color: var(--accent);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
    line-height: 1.45;
    white-space: nowrap;
    pointer-events: none;
    border-radius: 1px;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 5%, transparent);
  }

  .article-copy li[data-anchor].is-theory-active::before {
    right: calc(100% + 1.4em + 18px);
  }
}

.theory-rail__pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  padding: 0 5px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 1px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  vertical-align: 0.12em;
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.theory-rail__pin:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.theory-rail__pin.is-active {
  color: var(--bg);
  border-color: var(--accent);
  background: var(--accent);
}

/* ---------- root & 60fps viewport-synced live SVG tether ---------- */

.theory-rail-root {
  pointer-events: none;
}

.theory-rail__tether {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 34;
  overflow: visible;
}

.theory-rail__tether .tr-tether-bracket {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 84%, var(--ink));
  stroke-width: 1.25;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition:
    stroke-width 0.18s ease,
    opacity 0.2s ease,
    stroke 0.18s ease;
}

.theory-rail__tether .tr-tether-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
  transition:
    stroke-width 0.18s ease,
    opacity 0.2s ease;
}

.theory-rail__tether .tr-tether-vertex {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 1;
}

.theory-rail__tether .tr-tether-chevron {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.theory-rail__tether .tr-tether-dock-stem {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
}

.theory-rail__tether .tr-tether-dock-ring {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.25;
  transition: stroke-width 0.18s ease;
}

.theory-rail__tether .tr-tether-dock-core {
  fill: var(--accent);
}

.theory-rail__tether.is-offscreen .tr-tether-line {
  stroke-dasharray: 3.5 3;
  opacity: 0.66;
}

.theory-rail__tether.is-offscreen .tr-tether-dock-core {
  opacity: 0.55;
}

.theory-rail__tether.is-intense .tr-tether-bracket,
.theory-rail__tether.is-intense .tr-tether-line {
  stroke-width: 1.75;
  opacity: 1;
}

.theory-rail__tether.is-intense .tr-tether-dock-ring {
  stroke-width: 1.7;
}

.theory-rail__tether.is-pulsing .tr-tether-line,
.theory-rail__tether.is-pulsing .tr-tether-bracket {
  stroke-width: 2;
  opacity: 1;
}

@media (max-width: 1249px) {
  .theory-rail__tether {
    display: none;
  }
}

/* ---------- fixed inspector panel (wide desktop, mirroring left TOC) ---------- */

.theory-rail__panel {
  position: fixed;
  left: var(--theory-rail-left);
  width: var(--theory-rail-width);
  top: 50%;
  transform: translateY(-50%);
  max-height: min(660px, calc(100vh - 96px));
  z-index: 35;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--ink) 6%, transparent);
  transition:
    border-color 0.24s ease,
    box-shadow 0.24s ease;
}

.theory-rail__panel.is-pulsing {
  border-color: var(--accent);
}

.theory-rail__progress {
  position: relative;
  height: 2px;
  width: 100%;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  flex-shrink: 0;
}

.theory-rail__progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.theory-rail__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 7px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  flex-shrink: 0;
  min-width: 0;
}

.theory-rail__kicker {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.theory-rail__kicker strong {
  color: var(--accent);
  font-weight: 600;
}

.theory-rail__head-rule {
  flex: 1 1 8px;
  min-width: 8px;
  height: 1px;
  background: color-mix(in srgb, var(--line) 72%, transparent);
}

.theory-rail__year {
  font-family: var(--mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theory-rail__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    color 0.18s ease,
    border-color 0.18s ease;
}

.theory-rail__close:hover {
  color: var(--ink);
  border-color: var(--line);
}

/* ---------- context anchor strip ("对应正文") ---------- */

.theory-rail__ctx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px 12px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  background: color-mix(in srgb, var(--accent) 6.5%, var(--bg));
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color 0.18s ease,
    border-bottom-color 0.18s ease;
}

.theory-rail__ctx:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-bottom-color: color-mix(in srgb, var(--accent) 46%, var(--line));
}

.theory-rail__ctx[data-vis="above"],
.theory-rail__ctx[data-vis="below"] {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-bottom-style: dashed;
  border-bottom-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.theory-rail__ctx-lead {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.theory-rail__ctx-dot {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5.5px;
  height: 5.5px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--accent) 20%, transparent);
}

.theory-rail__ctx[data-vis="above"] .theory-rail__ctx-dot,
.theory-rail__ctx[data-vis="below"] .theory-rail__ctx-dot {
  background: transparent;
  border: 1.3px solid var(--accent);
  box-shadow: none;
}

.theory-rail__ctx-phrase {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 9.8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.theory-rail__ctx-phrase strong {
  color: var(--accent);
  font-weight: 600;
}

.theory-rail__ctx-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1.5px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.35;
  white-space: nowrap;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.theory-rail__ctx:hover .theory-rail__ctx-action {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.theory-rail__ctx[data-vis="above"] .theory-rail__ctx-action,
.theory-rail__ctx[data-vis="below"] .theory-rail__ctx-action {
  border-style: dashed;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--accent);
  font-weight: 500;
}

.theory-rail__ctx[data-vis="above"]:hover .theory-rail__ctx-action,
.theory-rail__ctx[data-vis="below"]:hover .theory-rail__ctx-action {
  border-style: solid;
  background: var(--accent);
  color: var(--bg);
}

/* ---------- panel body: portraits, quote, architectural SVG diagram ---------- */

.theory-rail__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 11px 12px;
  scrollbar-width: none;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.theory-rail__body::-webkit-scrollbar {
  display: none;
}

.theory-rail__body.is-fading {
  opacity: 0;
  transform: translateY(4px);
}

.theory-rail__identity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.theory-rail__p-group {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.theory-rail__p-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--p-size, 50px);
  height: var(--p-size, 50px);
  padding: 2px;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--ink) 24%, var(--line));
  box-shadow: 0 0 0 1px var(--surface);
  flex-shrink: 0;
  transition:
    margin-left 0.25s ease,
    border-color 0.25s ease;
}

.theory-rail__p-slot.is-photo {
  z-index: 2;
}

.theory-rail__p-slot.is-mono {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
}

.theory-rail__p-group.is-multi .theory-rail__p-slot + .theory-rail__p-slot {
  margin-left: -10px;
}

.theory-rail__panel:hover .theory-rail__p-group.is-multi .theory-rail__p-slot + .theory-rail__p-slot {
  margin-left: -3px;
}

/* Dual monogram seals sit side-by-side with a crisp gap so glyphs never occlude each other. */
.theory-rail__p-group.is-multi.is-all-mono {
  gap: 4px;
}

.theory-rail__p-group.is-multi.is-all-mono .theory-rail__p-slot + .theory-rail__p-slot,
.theory-rail__panel:hover .theory-rail__p-group.is-multi.is-all-mono .theory-rail__p-slot + .theory-rail__p-slot {
  margin-left: 0;
}

/* Mixed mono + photo stack nudges the leading seal slightly away from the overlapping photo edge. */
.theory-rail__p-group.is-mixed .theory-rail__p-slot.is-mono:first-child .theory-rail__portrait-mono {
  padding-right: 4px;
}

.theory-rail__panel:hover .theory-rail__p-group.is-mixed .theory-rail__p-slot.is-mono:first-child .theory-rail__portrait-mono {
  padding-right: 0;
}

.theory-rail__panel:hover .theory-rail__p-slot {
  border-color: color-mix(in srgb, var(--accent) 56%, var(--line));
}

.theory-rail__panel:hover .theory-rail__p-slot.is-mono {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line));
}

.theory-rail__portrait {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 5%, var(--bg));
  user-select: none;
}

/* Intentional editorial bookplate / index seal styling for non-portrait anchors. */
.theory-rail__portrait.is-monogram {
  background: linear-gradient(
    155deg,
    color-mix(in srgb, var(--accent) 9%, var(--surface)) 0%,
    color-mix(in srgb, var(--ink) 4%, var(--bg)) 100%
  );
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--accent) 56%, transparent);
  transition:
    box-shadow 0.24s ease,
    background-color 0.24s ease;
}

.theory-rail__panel:hover .theory-rail__portrait.is-monogram {
  box-shadow: inset 0 2px 0 var(--accent);
}

.theory-rail__portrait.is-concept-plate {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}

.theory-rail__portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  filter: grayscale(100%) contrast(1.08) sepia(10%);
  transition:
    filter 0.32s ease,
    transform 0.32s ease;
}

.theory-rail__panel:hover .theory-rail__portrait-img {
  filter: grayscale(58%) contrast(1.12) sepia(6%);
  transform: scale(1.03);
}

.theory-rail__portrait-mono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  font-family: var(--theory-serif);
  font-size: max(11px, calc(var(--portrait-size, 44px) * 0.31));
  font-weight: 500;
  letter-spacing: 0.07em;
  color: var(--ink);
  line-height: 1;
  transition:
    padding-right 0.25s ease,
    border-color 0.25s ease,
    color 0.25s ease;
}

.theory-rail__portrait.is-monogram .theory-rail__portrait-mono {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  color: color-mix(in srgb, var(--ink) 88%, var(--accent));
}

.theory-rail__portrait.is-concept-plate .theory-rail__portrait-mono {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.theory-rail__portrait-mono[data-mono-script="cjk"][data-mono-len="1"] {
  font-family: var(--theory-serif);
  font-size: max(15px, calc(var(--portrait-size, 44px) * 0.42));
  letter-spacing: 0;
}

.theory-rail__portrait-mono[data-mono-script="cjk"][data-mono-len="2"] {
  font-family: var(--theory-serif);
  font-size: max(11px, calc(var(--portrait-size, 44px) * 0.27));
  letter-spacing: 0.03em;
}

.theory-rail__portrait-mono[data-mono-script="cjk"][data-mono-len="3"] {
  font-family: var(--sans);
  font-size: max(9px, calc(var(--portrait-size, 44px) * 0.22));
  letter-spacing: 0;
}

.theory-rail__portrait-mono[data-mono-script="latin"][data-mono-len="3"] {
  font-family: var(--mono);
  font-size: max(9.5px, calc(var(--portrait-size, 44px) * 0.24));
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Placed after .theory-rail__portrait-mono with higher specificity so real photos never leak monogram text. */
.theory-rail__portrait.has-photo .theory-rail__portrait-mono {
  display: none;
}

.theory-rail__titles {
  flex: 1 1 auto;
  min-width: 0;
}

.theory-rail__concept-zh {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.32;
  color: var(--ink);
  overflow-wrap: break-word;
}

.theory-rail__concept-en {
  margin-top: 2px;
  font-family: var(--theory-serif);
  font-style: italic;
  font-size: 10.8px;
  line-height: 1.35;
  color: var(--ink-2);
  overflow-wrap: break-word;
}

.theory-rail__scholars {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9.4px;
  line-height: 1.4;
  color: color-mix(in srgb, var(--ink-2) 92%, var(--ink));
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theory-rail__quote {
  margin: 0 0 10px;
  padding: 2px 0 2px 10px;
  border-left: 1.5px solid var(--accent);
}

.theory-rail__quote-en {
  font-family: var(--theory-serif);
  font-style: italic;
  font-size: 11.6px;
  line-height: 1.52;
  color: var(--ink);
  overflow-wrap: break-word;
}

.theory-rail__quote-src {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 8.8px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theory-rail__diagram-card {
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  padding: 7px 9px 8px;
}

.theory-rail__diagram-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  min-width: 0;
}

.theory-rail__diagram-kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.theory-rail__diagram-title {
  font-size: 10.2px;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theory-rail__diagram-svg {
  width: 100%;
  overflow: hidden;
}

.theory-rail__diagram-svg svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  user-select: none;
}

.theory-rail__diagram-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 90px;
  padding: 12px;
  border: 1px dashed color-mix(in srgb, var(--line) 85%, transparent);
  text-align: center;
}

.theory-rail__diagram-fallback-num {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.theory-rail__diagram-fallback-title {
  font-size: 11px;
  color: var(--ink-2);
}

.theory-rail__finding {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  font-size: 11.2px;
  line-height: 1.52;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- footer: index dots, DOI link ---------- */

.theory-rail__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-top: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  background: color-mix(in srgb, var(--bg) 68%, var(--surface));
  flex-shrink: 0;
  min-width: 0;
}

.theory-rail__dots {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
}

.theory-rail__dot {
  width: 5px;
  height: 5px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-2) 34%, transparent);
  cursor: pointer;
  transition:
    width 0.22s ease,
    background-color 0.22s ease;
}

.theory-rail__dot:hover {
  background: var(--ink);
}

.theory-rail__dot.is-active {
  width: 14px;
  background: var(--accent);
}

.theory-rail__doi {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  max-width: 112px;
  padding: 0 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    border-color 0.18s ease,
    color 0.18s ease,
    background-color 0.18s ease;
}

.theory-rail__doi > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.theory-rail__doi > svg {
  flex-shrink: 0;
}

a.theory-rail__doi:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}

.theory-rail__doi.is-static {
  color: var(--ink-2);
  border-color: color-mix(in srgb, var(--line) 72%, transparent);
}

/* ---------- narrow screen pill & bottom-right sheet (< 1250px) ---------- */

.theory-rail__pill {
  display: none;
}

@media (max-width: 1249px) {
  .theory-rail__pill {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 38;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 35px;
    max-width: calc(100vw - 32px);
    padding: 7px 12px;
    pointer-events: auto;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 95%, var(--bg));
    color: var(--ink);
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--ink) 10%, transparent);
    transition:
      bottom 0.28s ease,
      border-color 0.2s ease;
  }

  .theory-rail__pill:hover {
    border-color: var(--ink);
  }

  .theory-rail__pill strong {
    color: var(--accent);
    font-weight: 600;
  }

  .theory-rail__pill.is-hidden {
    display: none;
  }

  .theory-rail-root.has-floating-nav .theory-rail__pill {
    bottom: 60px;
  }

  .theory-rail__panel {
    left: auto;
    right: 16px;
    top: auto;
    bottom: 16px;
    z-index: 45;
    width: min(420px, calc(100vw - 32px));
    max-height: min(70vh, calc(100vh - 104px));
    transform: translateY(10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      bottom 0.28s ease,
      opacity 0.2s ease,
      transform 0.2s ease,
      visibility 0.2s;
  }

  .theory-rail-root.has-floating-nav .theory-rail__panel {
    bottom: 60px;
    max-height: min(66vh, calc(100vh - 140px));
  }

  .theory-rail__panel.is-mobile-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .theory-rail__close {
    display: inline-flex;
  }
}

/* ---------- reduced motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
  .article-copy [data-anchor].is-theory-active::after,
  .article-copy [data-anchor].is-theory-pulse,
  .theory-rail__tether .tr-tether-bracket,
  .theory-rail__tether .tr-tether-line,
  .theory-rail__ctx,
  .theory-rail__body,
  .theory-rail__progress-fill,
  .theory-rail__dot,
  .theory-rail__p-slot,
  .theory-rail__portrait.is-monogram,
  .theory-rail__portrait-mono,
  .theory-rail__portrait-img,
  .theory-rail__pill,
  .theory-rail__panel {
    transition: none;
    animation: none;
  }
}

@media print {
  .theory-rail-root,
  .theory-rail__tether,
  .theory-rail__panel,
  .theory-rail__pill,
  .theory-rail__pin {
    display: none !important;
  }

  .article-copy [data-anchor]::before,
  .article-copy [data-anchor]::after {
    display: none !important;
  }

  .article-copy [data-anchor] .theory-term {
    border-bottom: none !important;
    background: none !important;
  }
}
