.utility-right { align-items: center; gap: clamp(12px, 2vw, 28px); }
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.3 var(--mono);
  white-space: nowrap;
}
.theme-switch[hidden] { display: none; }
.theme-switch:hover { border-color: var(--blue); color: var(--blue); }
.nav { justify-content: space-between; gap: 10px 24px; overflow: visible; flex-wrap: wrap; }
.nav-primary, .nav-secondary {
  display: flex;
  flex-wrap: wrap;
  column-gap: clamp(16px, 2vw, 32px);
  align-items: center;
}
.nav-primary a, .nav-secondary a { display: inline-flex; align-items: center; min-height: 44px; }
.nav-primary a { font-weight: 700; }
.nav-secondary .search-link { margin-left: 0; }
.desk-directory {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 36px;
}
.desk-directory a { display: grid; gap: 8px; text-decoration: none; border-top: 1px solid var(--line); padding: 12px 0; min-width: 0; }
.desk-directory strong { font-size: 19px; }
.desk-directory span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.desk-links { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 0 0 36px; color: var(--blue); }
.desk-links a { display: inline-flex; min-height: 44px; align-items: center; }

:root[data-theme="cyberpunk"] {
  color-scheme: dark;
  --paper: #0f1020;
  --ink: #f2efff;
  --muted: #b9b4d2;
  --line: #5d5385;
  --blue: #7bffe3;
  --pale: #251e3b;
  --glow: #ff56bd;
}
:root[data-theme="red-scare"] {
  color-scheme: dark;
  --paper: #231b14;
  --ink: #ffebc4;
  --muted: #cfbb9e;
  --line: #8a6750;
  --blue: #ff9987;
  --pale: #3c271f;
  --sans: 'Courier New', monospace;
  --glow: #d35343;
}
:root[data-theme="cryptids"] {
  color-scheme: dark;
  --paper: #101c18;
  --ink: #f1eddb;
  --muted: #bdcbbd;
  --line: #607967;
  --blue: #d0ec9e;
  --pale: #22352b;
  --glow: #c8d685;
}
:root[data-theme="poet"] {
  color-scheme: light;
  --paper: #efe3ce;
  --ink: #2d2431;
  --muted: #655058;
  --line: #ad927b;
  --blue: #743a62;
  --pale: #e6d4bd;
  --glow: #8a5264;
}

:root[data-theme]:not([data-theme="news"]) {
  background: var(--paper);
}
:root[data-theme]:not([data-theme="news"]) ::selection {
  background: var(--blue);
  color: var(--paper);
}
:root[data-theme]:not([data-theme="news"]) .network,
:root[data-theme]:not([data-theme="news"]) .type-panel {
  background: var(--pale);
  color: var(--ink);
  border: 1px solid var(--line);
}
:root[data-theme]:not([data-theme="news"]) .network :is(.eyebrow,p,figcaption),
:root[data-theme]:not([data-theme="news"]) input::placeholder,
:root[data-theme]:not([data-theme="news"]) textarea::placeholder { color: var(--muted); }
:root[data-theme]:not([data-theme="news"]) .prose a,
:root[data-theme]:not([data-theme="news"]) .network a:hover { color: var(--blue); }
:root[data-theme]:not([data-theme="news"]) :is(.skip,.submit-button:hover) { color: var(--paper); }
:root[data-theme]:not([data-theme="news"]) :is(.case-filters,.discussion-main) select {
  appearance: auto;
  background: var(--paper);
  padding-right: 14px;
}
:root[data-theme="cyberpunk"] .masthead { border-bottom: 2px solid var(--glow); }
:root[data-theme="cyberpunk"] .wordmark { text-shadow: 2px 2px var(--glow), -2px -2px #5237ba; }
:root[data-theme="cyberpunk"] .lead-photo img { filter: saturate(1.1) hue-rotate(24deg); }
:root[data-theme="red-scare"] .masthead {
  background: repeating-linear-gradient(0deg, transparent 0 5px, #ffc4740d 5px 6px);
  border-bottom: 3px double var(--blue);
}
:root[data-theme="red-scare"] .wordmark { font-family: Arial, Helvetica, sans-serif; text-transform: uppercase; }
:root[data-theme="red-scare"] .home-header .wordmark { font-size: min(14.5vw, 220px); }
:root[data-theme="red-scare"] .lead-photo img { filter: grayscale(1) sepia(.62) contrast(.92); }
:root[data-theme="cryptids"] :is(.wordmark, h1, h2, h3) { font-family: Georgia, 'Times New Roman', serif; }
:root[data-theme="cryptids"] .masthead {
  background: radial-gradient(ellipse at 82% 10%, #99ad6530, transparent 48%);
  border-bottom-color: var(--glow);
}
:root[data-theme="cryptids"] .lead-photo img { filter: saturate(.58) brightness(.83); }

.theme-effects[hidden] { display: none; }
:root[data-theme]:not([data-theme="news"]) body { isolation: isolate; }
.theme-effects {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.theme-effects span, .theme-effects::before {
  position: absolute;
  display: block;
  content: "";
}

[data-theme="cyberpunk"] .theme-effects {
  background: radial-gradient(ellipse at 100% 0, #693e9b55, transparent 60%),
    repeating-linear-gradient(90deg, #7bffe310 0 1px, transparent 1px 48px),
    repeating-linear-gradient(0deg, #7bffe310 0 1px, transparent 1px 48px);
}
[data-theme="cyberpunk"] .theme-effects span {
  inset: 0 auto 0 66%;
  width: 12vw;
  background: linear-gradient(90deg, transparent, #ff56bd35 85%, #7bffe375);
  transform: skewX(-24deg);
  opacity: .26;
  animation: neon-trace 1.4s ease-out both;
}
@keyframes neon-trace {
  from { transform: translateX(-55vw) skewX(-24deg); opacity: 0; }
  to { transform: translateX(0) skewX(-24deg); opacity: .26; }
}

.matrix-trail { display: none; }
.reading-progress {
  position: fixed;
  z-index: 9;
  inset: 0 0 auto;
  block-size: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}
[data-theme="cyberpunk"] .reading-progress { background: linear-gradient(90deg, #59ff94, #74ffec); }
[data-theme="red-scare"] .reading-progress { background: #e99861; }
[data-theme="cryptids"] .reading-progress { background: #b8ce83; }
.poet-cursor { display: none; }
#main :is(section, article, h2, h3)[id]:target {
  scroll-margin-block-start: 1.4rem;
  box-shadow: -.3rem 0 0 -.13rem var(--blue);
}
@media screen and (prefers-reduced-motion: no-preference) {
  [data-theme="cyberpunk"] .theme-word {
    position: relative;
    isolation: isolate;
    animation: matrix-word-rise 290ms cubic-bezier(.18,.75,.24,1) var(--word-delay) both;
  }
  [data-theme="cyberpunk"] .matrix-trail {
    display: block;
    position: absolute;
    z-index: -1;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    color: #59ff94;
    font: .62em/1.3 var(--mono);
    letter-spacing: .15em;
    white-space: nowrap;
    text-shadow: 0 0 5px #42e87d;
    animation: matrix-code-trail 320ms ease-out var(--word-delay) both;
  }
  .matrix-trail::before {
    content: attr(data-glyphs);
  }
  [data-theme="poet"] ::highlight(poet-pending) { color: color-mix(in srgb, var(--ink) 68%, var(--paper)); }
  [data-theme="poet"] .poet-cursor {
    display: block;
    position: fixed;
    z-index: 6;
    inset: 0 auto auto 0;
    inline-size: 1px;
    background: var(--glow);
    pointer-events: none;
  }
  .theme-reveal {
    position: relative;
    isolation: isolate;
  }
  [data-theme="red-scare"] .theme-reveal::after,
  [data-theme="cryptids"] .theme-reveal::before {
    position: absolute;
    z-index: -1;
    content: "";
    pointer-events: none;
  }
  [data-theme="red-scare"] .theme-reveal::after {
    inset: auto auto 0 0;
    inline-size: min(100%, 15rem);
    block-size: 1px;
    background: linear-gradient(90deg, #e99861, transparent);
    transform-origin: left;
    animation: headline-scan 520ms ease-out both;
  }
  [data-theme="cryptids"] .theme-reveal::before {
    inset: 0 4% 0 0;
    max-inline-size: 22rem;
    background: radial-gradient(ellipse at 45% 55%, #a4be8b45, transparent 70%);
    animation: headline-fog 710ms ease-out both;
  }
  [data-theme="cyberpunk"] :focus-visible .theme-word { animation: none; }
  :focus-visible .matrix-trail { display: none; }
}
@keyframes matrix-word-rise {
  from { inset-block-start: clamp(8px, 2vw, 16px); opacity: .72; }
  60% { opacity: 1; }
  to { inset-block-start: 0; opacity: 1; }
}
@keyframes matrix-code-trail {
  from { translate: 0 -4px; opacity: 0; }
  20% { opacity: .4; }
  to { translate: 0 5px; opacity: 0; }
}
@keyframes headline-scan {
  from { transform: scaleX(0); opacity: .7; }
  65% { transform: scaleX(1); opacity: .8; }
  to { transform: scaleX(1); opacity: 0; }
}
@keyframes headline-fog {
  from { translate: -8px 0; opacity: 0; }
  38% { opacity: .7; }
  to { translate: 12px 0; opacity: 0; }
}

[data-theme="red-scare"] .theme-effects {
  border: 5px double #b7785782;
  background: repeating-linear-gradient(0deg, #fb985010 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 50% 38%, #a24f263d, transparent 68%);
}
[data-theme="red-scare"] .theme-effects span {
  inset: 34% 0 auto;
  height: 52px;
  background: linear-gradient(transparent, #f38c3d29, #ffbd8155);
  opacity: 0;
  animation: terminal-sweep 2.4s ease-out both;
}
@keyframes terminal-sweep {
  0% { transform: translateY(-44vh); opacity: 0; }
  24% { opacity: .7; }
  75% { opacity: .7; }
  100% { transform: translateY(70vh); opacity: 0; }
}

[data-theme="cryptids"] .theme-effects {
  background: radial-gradient(ellipse at 82% 1%, #8d9e5270, transparent 46%),
    linear-gradient(180deg, transparent 60%, #05130ed0);
}
[data-theme="cryptids"] .theme-effects::before {
  inset: auto 0 0;
  height: min(25vh, 200px);
  background: #08160f;
  clip-path: polygon(0 26%, 3% 40%, 6% 19%, 10% 76%, 13% 57%, 16% 86%, 34% 100%, 70% 93%,
    77% 76%, 81% 46%, 84% 76%, 88% 24%, 91% 65%, 97% 11%, 100% 45%, 100% 100%, 0 100%);
}
[data-theme="cryptids"] .theme-effects span {
  inset: auto -12vw -4vh;
  height: 43vh;
  background: radial-gradient(ellipse at 20% 56%, #b1cdb84a, transparent 42%),
    radial-gradient(ellipse at 79% 80%, #91baa656, transparent 44%);
  animation: ridge-fog 4.2s ease-out both;
}
@keyframes ridge-fog {
  from { transform: translateX(-8vw); opacity: .25; }
  to { transform: translateX(0); opacity: .9; }
}

[data-theme="poet"] :is(.wordmark, h1, h2, h3) { font-family: Georgia, 'Times New Roman', serif; }
[data-theme="poet"] .masthead { border-bottom: 3px double var(--blue); }
[data-theme="poet"] .lead-photo img { filter: saturate(.78); }
[data-theme="poet"] .theme-effects {
  background: radial-gradient(ellipse at 0 0, #be77533d, transparent 44%),
    radial-gradient(ellipse at 100% 92%, #aa729a40, transparent 52%),
    repeating-linear-gradient(0deg, #663c6121 0 1px, transparent 1px 26px);
}
[data-theme="poet"] .theme-effects::before {
  inset: 0 auto 0 clamp(8px, 5vw, 72px);
  width: 5px;
  border-inline: 1px solid #934a6380;
}
[data-theme="poet"] .theme-effects span {
  inset: auto clamp(8px, 7vw, 100px) 5vh auto;
  font: clamp(76px, 23vw, 270px)/1 Georgia, serif;
  color: #743a6229;
  animation: ink-settle 2.3s ease-out both;
}
[data-theme="poet"] .theme-effects span::before { content: "❧"; }
@keyframes ink-settle {
  from { transform: translateY(15px) rotate(-7deg); opacity: 0; }
  to { transform: translateY(0) rotate(-7deg); opacity: 1; }
}

@media (max-width: 760px) {
  .nav { gap: 0; padding: 4px 0; }
  .nav-primary, .nav-secondary { width: 100%; column-gap: 18px; }
  .nav-primary a, .nav-secondary a { padding-block: 7px; }
  .nav-secondary { border-top: 1px solid var(--line); }
  .desk-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .utility { gap: 8px; }
  .utility-right { gap: 10px; }
  .theme-switch { min-height: 44px; }
  :root[data-theme="red-scare"] .home-header .wordmark { font-size: 15vw; }
  :root[data-theme="cryptids"] .home-header .wordmark { font-size: 17vw; }
  :root[data-theme="poet"] .home-header .wordmark { font-size: 17vw; }
}
@media (max-width: 365px) {
  .reservoir-link { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .theme-effects span { animation: none !important; }
}
@media print {
  :root[data-theme] { color-scheme: light; --paper: white; --ink: black; --muted: #333; --blue: #000; --pale: white; }
  .theme-switch, .theme-effects, .reading-progress { display: none; }
}

.archive-note { color: var(--muted); margin: 12px 0 24px; max-width: 72ch; }
.archive-collections { margin-top: 26px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.resource-directory { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.issue-list { padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 18px; margin: 0 0 52px; }
.issue-list a { display: inline-flex; align-items: center; min-height: 44px; }
.holdings-table { overflow-x: auto; }
.holdings-table table { width: 100%; border-collapse: collapse; text-align: left; }
.holdings-table th, .holdings-table td { border-bottom: 1px solid var(--line); padding: 10px 10px 10px 0; }
.holdings-table th small { display: block; color: var(--muted); font-weight: normal; }
.advanced-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.advanced-form label { display: block; margin-bottom: 5px; }
.advanced-form :is(input:not([type=checkbox]),select) { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 0; padding: 8px 10px; color: var(--ink); background: var(--paper); font: inherit; }
.advanced-form .search-checkbox, .search-actions { display: flex; gap: 12px; min-height: 44px; align-items: center; }
.search-actions button, .result-pagination button { padding: 10px 14px; min-height: 44px; background: var(--ink); color: var(--paper); }
.result-pagination button:disabled { opacity: .5; }
.advanced-result { border-top: 1px solid var(--line); padding: 14px 0 18px; }
.advanced-result h2 { font-size: clamp(21px, 3.1vw, 33px); margin: 7px 0; }
.advanced-result h2 a { text-decoration: none; }
.advanced-result > p:last-child { color: var(--muted); }
.result-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 20px 0 42px; }
.result-pagination[hidden] { display: none; }
@media (max-width: 650px) {
  .advanced-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .holdings-table th, .holdings-table td { font-size: 14px; overflow-wrap: anywhere; }
}
@media (max-width: 370px) {
  .advanced-form { grid-template-columns: 1fr; }
}

.ad-slot[hidden] { display: none; }
.ad-slot { margin: 20px 0 32px; padding: 16px; border: 1px solid var(--line); background: var(--pale); }
.ad-slot .eyebrow { margin-bottom: 8px; color: var(--muted); }
.ad-slot a { display: inline-grid; gap: 10px; min-height: 26px; }
.ad-slot img { max-width: 100%; height: auto; }
