@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=DM+Sans:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #0a0a0f;
  --bg-space: #020617;
  --accent-cyan: #06b6d4;
  --accent-emerald: #059669;
  --accent-amber: #f59e0b;
  --accent-rose: #ec4899;
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
  --glass-bg: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(6, 182, 212, 0.2);
  --glass-blur: 12px;
  --font-heading: 'Orbitron', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text-primary);
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.4), rgba(10, 10, 15, 0.92)),
    var(--bg-deep);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  z-index: -2;
  inset: -50%;
  content: '';
  pointer-events: none;
  opacity: 0.82;
  background-image:
    radial-gradient(circle at 4% 12%, rgba(6, 182, 212, 0.95) 0 1px, transparent 1.7px),
    radial-gradient(circle at 12% 78%, rgba(226, 232, 240, 0.8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 19% 36%, rgba(5, 150, 105, 0.9) 0 1px, transparent 1.8px),
    radial-gradient(circle at 27% 91%, rgba(236, 72, 153, 0.8) 0 1px, transparent 1.7px),
    radial-gradient(circle at 34% 19%, rgba(245, 158, 11, 0.9) 0 1px, transparent 1.8px),
    radial-gradient(circle at 43% 63%, rgba(226, 232, 240, 0.75) 0 1px, transparent 1.6px),
    radial-gradient(circle at 51% 8%, rgba(6, 182, 212, 0.9) 0 1.2px, transparent 1.9px),
    radial-gradient(circle at 58% 84%, rgba(5, 150, 105, 0.85) 0 1px, transparent 1.7px),
    radial-gradient(circle at 66% 42%, rgba(226, 232, 240, 0.8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 73% 16%, rgba(236, 72, 153, 0.82) 0 1px, transparent 1.8px),
    radial-gradient(circle at 81% 71%, rgba(245, 158, 11, 0.9) 0 1px, transparent 1.7px),
    radial-gradient(circle at 89% 31%, rgba(6, 182, 212, 0.9) 0 1px, transparent 1.8px),
    radial-gradient(circle at 96% 94%, rgba(226, 232, 240, 0.75) 0 1px, transparent 1.6px);
  background-size: 200% 200%;
  animation: starfield-drift 120s linear infinite;
}

body::after {
  position: fixed;
  z-index: -3;
  inset: 0;
  content: '';
  pointer-events: none;
  background:
    radial-gradient(circle at 50% -10%, rgba(6, 182, 212, 0.12), transparent 42%),
    radial-gradient(circle at 8% 74%, rgba(5, 150, 105, 0.08), transparent 30%),
    radial-gradient(circle at 94% 82%, rgba(236, 72, 153, 0.07), transparent 28%),
    var(--bg-space);
}

@keyframes starfield-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(12%, 18%, 0); }
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@keyframes error-flash {
  0%, 100% { border-color: rgba(244, 63, 94, 0.45); }
  50% { border-color: #fb7185; box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.16); }
}

@keyframes speaking-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.32); }
  50% { box-shadow: 0 0 0 7px rgba(5, 150, 105, 0); }
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button,
summary,
label {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  color: var(--bg-space);
  background: var(--accent-cyan);
}

:focus-visible {
  outline: 3px solid var(--accent-amber);
  outline-offset: 3px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  color: var(--accent-cyan);
  font-family: var(--font-heading);
  letter-spacing: 0;
}

code,
pre,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
}

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

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.librarian-bar,
.mesh-nav-inner,
.content-shell {
  width: min(100% - 32px, 1120px);
  margin-inline: auto;
}

.librarian-bar {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
}

.librarian-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--accent-emerald);
  border-radius: 50%;
  color: var(--accent-emerald);
  background: rgba(5, 150, 105, 0.08);
  box-shadow: 0 0 18px rgba(5, 150, 105, 0.2);
}

.librarian-avatar svg {
  width: 24px;
  height: 24px;
}

.librarian-input,
.passcode-input {
  min-width: 0;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.librarian-input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
}

.librarian-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.librarian-input:focus,
.passcode-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.ask-button,
.gate-button {
  border: 0;
  border-radius: 6px;
  color: #ecfdf5;
  background: linear-gradient(135deg, var(--accent-emerald), #10b981);
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.ask-button {
  min-width: 68px;
  height: 40px;
  padding: 0 16px;
  font-size: 0.72rem;
}

.ask-button:disabled {
  cursor: default;
  opacity: 0.86;
}

.mesh-nav {
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  background: rgba(10, 10, 15, 0.66);
}

.mesh-nav-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding-block: 9px;
}

.mesh-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--glass-bg);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.mesh-link:hover,
.mesh-link[aria-current='page'] {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.7);
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.17);
  transform: translateY(-1px);
}

.access-gate {
  display: grid;
  min-height: calc(100vh - 121px);
  padding: 48px 16px;
  place-items: center;
}

.gate-panel,
.upload-desk,
.ep-body {
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.gate-panel {
  width: min(100%, 540px);
  padding: 42px;
  text-align: center;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.36), 0 0 60px rgba(6, 182, 212, 0.06);
}

.gate-panel.is-invalid {
  animation: gate-shake 420ms ease, error-flash 720ms ease;
}

.gate-mark {
  display: inline-grid;
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  place-items: center;
  border: 1px solid rgba(6, 182, 212, 0.45);
  border-radius: 50%;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  box-shadow: inset 0 0 18px rgba(6, 182, 212, 0.1), 0 0 20px rgba(6, 182, 212, 0.1);
}

.gate-panel h1 {
  margin-bottom: 12px;
  font-size: 1.65rem;
  line-height: 1.3;
}

.gate-copy {
  margin: 0 0 26px;
  color: var(--text-muted);
}

.gate-form {
  display: grid;
  gap: 14px;
}

.passcode-input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 4px;
  text-align: center;
}

.gate-button {
  min-height: 50px;
  color: var(--bg-space);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
}

.gate-button:hover {
  box-shadow: 0 10px 26px rgba(6, 182, 212, 0.24);
  transform: translateY(-2px);
}

.gate-error {
  min-height: 24px;
  margin: 14px 0 0;
  color: #fb7185;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity 180ms ease;
}

.gate-panel.is-invalid .gate-error {
  opacity: 1;
}

.content-shell {
  padding-block: 72px 90px;
}

.library-masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  margin-bottom: 48px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--glass-border);
}

.pillar-label,
.collection-label,
.ep-kicker,
.audio-label,
.collection-count,
.foot-note {
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.pillar-label,
.collection-label {
  margin: 0 0 12px;
  color: var(--accent-emerald);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
}

.library-masthead h1 {
  max-width: 850px;
  margin-bottom: 14px;
  font-size: 3.75rem;
  line-height: 1.04;
}

.library-summary {
  max-width: 680px;
  margin: 0;
  color: var(--text-muted);
  font-size: 1.08rem;
}

.archive-status {
  min-width: 154px;
  margin: 0;
  padding: 13px 16px;
  border-left: 3px solid var(--accent-emerald);
  color: var(--text-primary);
  background: rgba(5, 150, 105, 0.08);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: right;
  text-transform: uppercase;
}

.archive-status strong {
  display: block;
  color: #34d399;
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.upload-section {
  margin-bottom: 84px;
}

.section-heading {
  margin-bottom: 18px;
  font-size: 1.35rem;
}

.upload-desk {
  position: relative;
  display: grid;
  min-height: 188px;
  padding: 34px;
  place-items: center;
  border-style: dashed;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease, background-color 200ms ease;
}

.upload-desk:hover,
.upload-desk:focus-within {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.07);
  box-shadow: inset 0 0 42px rgba(6, 182, 212, 0.05), 0 0 28px rgba(6, 182, 212, 0.12);
  transform: translateY(-2px);
}

.upload-icon {
  display: block;
  margin-bottom: 10px;
  color: var(--accent-cyan);
  font-size: 2rem;
  line-height: 1;
}

.upload-primary {
  display: block;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 1rem;
}

.upload-secondary {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.collection-head {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.collection-head h2 {
  max-width: 760px;
  margin: 0;
  font-size: 2.3rem;
  line-height: 1.18;
}

.collection-count {
  margin: 0;
  color: var(--accent-amber);
  font-size: 0.78rem;
}

.episode {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  margin-bottom: 36px;
}

.ep-ghost {
  position: absolute;
  z-index: -1;
  top: -36px;
  right: 12px;
  color: rgba(6, 182, 212, 0.045);
  font-family: var(--font-heading);
  font-size: 7rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.ep-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding-top: 24px;
}

.ep-rail-num {
  color: var(--accent-amber);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.ep-rail-line {
  width: 1px;
  flex: 1;
  background: linear-gradient(180deg, var(--accent-amber), transparent);
  opacity: 0.45;
}

.ep-body {
  min-width: 0;
  padding: 34px;
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.ep-body:hover {
  border-color: rgba(6, 182, 212, 0.52);
  box-shadow: 0 24px 62px rgba(0, 0, 0, 0.28), 0 0 30px rgba(6, 182, 212, 0.07);
  transform: translateY(-3px);
}

.ep-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

.ep-tag {
  padding: 4px 9px;
  border-radius: 4px;
  color: var(--bg-space);
  background: var(--accent-amber);
  font-weight: 700;
}

.ep-sep {
  color: var(--accent-cyan);
}

.ep-title {
  max-width: 850px;
  margin-bottom: 12px;
  font-size: 2rem;
  line-height: 1.2;
}

.ep-theme {
  max-width: 72ch;
  margin: 0 0 26px;
  color: var(--text-muted);
}

.ep-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.audio-wrap {
  min-width: 0;
}

.audio-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
}

audio {
  display: block;
  width: 100%;
  min-width: 0;
  height: 44px;
  border-radius: 4px;
  background: rgba(2, 6, 23, 0.64);
}

.tts-btn {
  display: inline-flex;
  min-height: 44px;
  gap: 9px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid rgba(5, 150, 105, 0.52);
  border-radius: 6px;
  color: #6ee7b7;
  background: rgba(5, 150, 105, 0.09);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.tts-btn:hover {
  color: #ecfdf5;
  border-color: var(--accent-emerald);
  background: rgba(5, 150, 105, 0.2);
  transform: translateY(-2px);
}

.tts-btn.speaking {
  color: #ecfdf5;
  border-color: var(--accent-emerald);
  background: var(--accent-emerald);
  animation: speaking-pulse 1.8s ease-in-out infinite;
}

.ep-transcript {
  margin-top: 26px;
  padding-top: 5px;
  border-top: 1px solid var(--glass-border);
}

.ep-transcript summary {
  display: flex;
  min-height: 54px;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  list-style: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 180ms ease;
}

.ep-transcript summary::-webkit-details-marker {
  display: none;
}

.ep-transcript summary:hover {
  color: #67e8f9;
}

.sum-chev {
  position: relative;
  width: 16px;
  height: 16px;
  flex: none;
}

.sum-chev::before,
.sum-chev::after {
  position: absolute;
  content: '';
  background: currentColor;
  transition: opacity 180ms ease, transform 180ms ease;
}

.sum-chev::before {
  top: 7px;
  left: 0;
  width: 16px;
  height: 2px;
}

.sum-chev::after {
  top: 0;
  left: 7px;
  width: 2px;
  height: 16px;
}

.ep-transcript[open] .sum-chev::after {
  opacity: 0;
  transform: scaleY(0);
}

.transcript-body {
  max-width: 78ch;
  padding: 12px 0 6px;
}

.scene {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 34px 0 16px;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  line-height: 1.5;
  text-transform: uppercase;
}

.scene::after {
  height: 1px;
  flex: 1;
  content: '';
  background: var(--glass-border);
}

.scene:first-child {
  margin-top: 8px;
}

.line {
  margin: 0 0 19px;
  padding: 2px 0 2px 16px;
}

.speaker-name {
  display: block;
  margin-bottom: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
}

.say {
  color: #cbd5e1;
}

.say strong {
  color: var(--text-primary);
}

.voice-roger { border-left: 3px solid #f59e0b; } /* Amber — The Architect */
.voice-roger .speaker-name { color: #f59e0b; font-family: 'Orbitron'; text-transform: uppercase; }

.voice-aria { border-left: 3px solid #ec4899; } /* Rose — The Heart */
.voice-aria .speaker-name { color: #ec4899; font-family: 'Orbitron'; text-transform: uppercase; }

.voice-catalyst { border-left: 3px solid #06b6d4; } /* Cyan — The Authority */
.voice-catalyst .speaker-name { color: #06b6d4; font-family: 'Orbitron'; text-transform: uppercase; }

.voice-narration {
  border-left: 3px solid rgba(148, 163, 184, 0.38);
}

.library-footer {
  margin-top: 84px;
  padding-top: 34px;
  border-top: 1px solid var(--glass-border);
  text-align: center;
}

.library-footer p {
  margin: 0;
}

.footer-seal {
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.footer-seal strong {
  color: var(--accent-cyan);
}

.foot-note {
  margin-top: 8px !important;
  color: var(--text-muted);
  font-size: 0.7rem;
}

@media (max-width: 820px) {
  .content-shell {
    padding-block: 52px 70px;
  }

  .library-masthead {
    grid-template-columns: 1fr;
  }

  .library-masthead h1 {
    font-size: 2.8rem;
  }

  .archive-status {
    width: fit-content;
    text-align: left;
  }

  .collection-head h2 {
    font-size: 1.9rem;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 0.94rem;
  }

  .librarian-bar,
  .mesh-nav-inner,
  .content-shell {
    width: min(100% - 24px, 1120px);
  }

  .librarian-bar {
    grid-template-columns: 34px minmax(0, 1fr) 58px;
    gap: 8px;
  }

  .librarian-avatar {
    width: 32px;
    height: 32px;
  }

  .librarian-input {
    padding-inline: 10px;
    font-size: 0.88rem;
  }

  .ask-button {
    min-width: 58px;
    padding-inline: 8px;
  }

  .mesh-nav-inner {
    gap: 6px;
  }

  .mesh-link {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 0.65rem;
  }

  .access-gate {
    min-height: calc(100vh - 164px);
    padding-inline: 12px;
  }

  .gate-panel {
    padding: 30px 20px;
  }

  .gate-panel h1 {
    font-size: 1.28rem;
  }

  .content-shell {
    padding-top: 44px;
  }

  .library-masthead {
    margin-bottom: 38px;
  }

  .library-masthead h1 {
    font-size: 2.15rem;
  }

  .upload-section {
    margin-bottom: 64px;
  }

  .upload-desk {
    min-height: 164px;
    padding: 28px 18px;
  }

  .collection-head h2 {
    font-size: 1.55rem;
  }

  .episode {
    grid-template-columns: 1fr;
    margin-bottom: 28px;
  }

  .ep-rail {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 0 9px 2px;
  }

  .ep-rail-num {
    writing-mode: horizontal-tb;
    transform: none;
  }

  .ep-rail-line {
    width: 54px;
    height: 1px;
    flex: none;
    background: linear-gradient(90deg, var(--accent-amber), transparent);
  }

  .ep-ghost {
    top: -20px;
    font-size: 4.8rem;
  }

  .ep-body {
    padding: 24px 18px;
  }

  .ep-title {
    font-size: 1.45rem;
  }

  .ep-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tts-btn {
    width: 100%;
  }

  .scene {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}