:root {
  --bg: #06131f;
  --bg-deep: #020814;
  --panel: rgba(4, 14, 27, 0.82);
  --panel-soft: rgba(9, 27, 44, 0.7);
  --line: rgba(112, 186, 211, 0.18);
  --line-strong: rgba(104, 226, 215, 0.34);
  --text: #f1f7ff;
  --muted: #91a8bf;
  --teal: #48e6cf;
  --teal-deep: #115f68;
  --danger: #ff405c;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  --stage-bg: #020916;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 25% 14%, rgba(43, 196, 174, 0.22), transparent 30rem),
    radial-gradient(circle at 82% 18%, rgba(30, 111, 168, 0.32), transparent 34rem),
    linear-gradient(100deg, #0c342f 0%, var(--bg-deep) 42%, #0a2b49 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(117, 232, 221, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(117, 232, 221, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
}

button,
input {
  font: inherit;
}

button,
.nav-pill {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover,
.nav-pill:hover {
  transform: translateY(-1px);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--teal);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: linear-gradient(140deg, rgba(50, 228, 211, 0.18), rgba(8, 25, 43, 0.8));
  box-shadow: 0 0 28px rgba(67, 230, 207, 0.14);
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-deep);
  box-shadow: 0 0 28px rgba(67, 230, 207, 0.14);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.nav-pill,
.fire-button,
.ghost-action,
.primary-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: rgba(7, 21, 37, 0.72);
}

.nav-pill {
  padding: 13px 24px;
  color: #c9d9ec;
  font-weight: 700;
  font-size: 0.92rem;
}

.nav-pill.active {
  border-color: rgba(73, 230, 207, 0.42);
  background: linear-gradient(135deg, rgba(50, 210, 195, 0.26), rgba(20, 70, 94, 0.6));
  box-shadow: inset 0 0 24px rgba(72, 230, 207, 0.08);
}

.fire-button {
  justify-self: end;
  padding: 13px 22px;
  border-color: rgba(255, 64, 92, 0.5);
  background: linear-gradient(135deg, rgba(175, 31, 53, 0.94), rgba(105, 20, 56, 0.9));
  box-shadow: 0 16px 50px rgba(255, 64, 92, 0.18);
  cursor: pointer;
  font-weight: 800;
}

.mission-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.hero-panel,
.control-panel,
.library-panel,
.briefing-panel article {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(4, 13, 26, 0.92), rgba(5, 20, 34, 0.78));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  position: relative;
  min-height: 570px;
  padding: 32px;
  border-radius: 24px;
  overflow: hidden;
}

.hero-panel::after {
  position: absolute;
  right: 54px;
  bottom: 42px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  content: "";
  background: radial-gradient(circle, rgba(77, 232, 212, 0.28), transparent 64%);
  filter: blur(5px);
  pointer-events: none;
}

.hero-copy {
  max-width: 640px;
  margin-bottom: 28px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--teal);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 730px;
  margin-bottom: 16px;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.lede,
.briefing-panel p,
.mission-card span {
  color: var(--muted);
  line-height: 1.65;
}

.reader-stage {
  position: relative;
  display: grid;
  min-height: 255px;
  align-items: center;
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 40%, rgba(72, 230, 207, 0.09), transparent 26rem),
    var(--stage-bg);
  overflow: hidden;
}

.stage-status {
  position: absolute;
  top: 16px;
  right: 18px;
  left: 18px;
  display: flex;
  justify-content: space-between;
  color: #82a1bd;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.guide-rail {
  position: absolute;
  top: 28%;
  bottom: 24%;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--danger), transparent);
  box-shadow: 0 0 18px rgba(255, 64, 92, 0.6);
}

.word-display {
  position: absolute;
  top: var(--word-y, 50%);
  left: 0;
  width: 100%;
  padding: 0 18px;
  color: var(--reader-text, #f1f7ff);
  font-size: var(--word-size, 72px);
  font-weight: 800;
  height: 1em;
  line-height: 1;
  text-align: center;
  transform: translateY(-50%);
  white-space: nowrap;
}

.word-display .before {
  position: absolute;
  top: 0;
  right: 50%;
  display: block;
  text-align: right;
}

.word-display .pivot {
  position: absolute;
  top: 0;
  left: 50%;
  color: var(--reader-focus, #ff405c);
}

.word-display .after {
  position: absolute;
  top: 0;
  left: calc(50% + var(--pivot-width, 0px));
  display: block;
  text-align: left;
}

.placeholder-word {
  color: #dcecff;
}

.progress-track {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  height: 8px;
  border: 1px solid rgba(93, 139, 160, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--danger));
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.primary-action,
.ghost-action {
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  min-width: 112px;
  border-color: rgba(72, 230, 207, 0.44);
  background: linear-gradient(135deg, rgba(67, 206, 191, 0.94), rgba(17, 95, 104, 0.92));
  color: #031018;
}

.ghost-action {
  min-width: 112px;
}

.info-action {
  min-width: 136px;
}

.rsvp-explainer {
  max-width: 640px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.rsvp-explainer[hidden] {
  display: none;
}

.rsvp-explainer h2 {
  margin-bottom: 8px;
}

.rsvp-explainer p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.control-panel,
.library-panel {
  padding: 24px;
  border-radius: 20px;
}

.control-panel {
  grid-row: span 2;
}

.panel-heading {
  margin-bottom: 22px;
}

.control {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
  color: #d9e9f8;
  font-weight: 700;
}

.control span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

output {
  color: var(--teal);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.color-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 24px;
  color: #d5e4f3;
  line-height: 1.4;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.hotkeys {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.hotkeys .kicker {
  margin-bottom: 2px;
}

.library-panel {
  min-height: 360px;
}

.library-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.76rem;
}

.file-list {
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
  padding-right: 4px;
}

.file-item {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(112, 186, 211, 0.12);
  border-radius: 12px;
  color: #d7e8f8;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.file-item.active {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(72, 230, 207, 0.12);
}

.mission-card {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.mission-card .kicker {
  margin-bottom: 0;
}

.briefing-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column: 1 / -1;
  gap: 18px;
}

.briefing-panel article {
  min-height: 170px;
  padding: 24px;
  border-radius: 18px;
}

body.fullscreen-reader {
  overflow: hidden;
}

body.fullscreen-reader .topbar,
body.fullscreen-reader .control-panel,
body.fullscreen-reader .library-panel,
body.fullscreen-reader .briefing-panel,
body.fullscreen-reader .hero-copy,
body.fullscreen-reader .hero-actions {
  display: none;
}

body.fullscreen-reader .shell {
  width: 100%;
  padding: 0;
}

body.fullscreen-reader .mission-grid,
body.fullscreen-reader .hero-panel {
  display: block;
  width: 100vw;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

body.fullscreen-reader .reader-stage {
  min-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.fullscreen-controls {
  position: absolute;
  right: 18px;
  bottom: 38px;
  z-index: 5;
  display: none;
  gap: 10px;
}

.fullscreen-controls button {
  min-width: 72px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  background: rgba(3, 14, 25, 0.78);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.fullscreen-controls button:first-child {
  color: #031018;
  background: linear-gradient(135deg, rgba(72, 230, 207, 0.96), rgba(40, 161, 163, 0.94));
}

.fullscreen-controls button:last-child {
  border-color: rgba(255, 64, 92, 0.5);
}

body.fullscreen-reader .fullscreen-controls {
  display: flex;
}

.reader-stage:fullscreen .fullscreen-controls,
.reader-stage:-webkit-full-screen .fullscreen-controls {
  display: flex;
}

.fullscreen-tuning {
  position: absolute;
  bottom: 34px;
  left: 18px;
  z-index: 5;
  display: none;
  width: min(320px, calc(100% - 36px));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(3, 14, 25, 0.8);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.fullscreen-tuning label {
  display: grid;
  gap: 5px;
}

.fullscreen-tuning span {
  display: flex;
  justify-content: space-between;
  color: #d7e8f8;
  font-size: 0.76rem;
  font-weight: 800;
}

.fullscreen-tuning output {
  color: var(--teal);
}

.fullscreen-tuning input {
  width: 100%;
}

body.fullscreen-reader .fullscreen-tuning,
.reader-stage.is-fullscreen .fullscreen-tuning,
.reader-stage:fullscreen .fullscreen-tuning,
.reader-stage:-webkit-full-screen .fullscreen-tuning {
  display: grid !important;
  visibility: visible;
  opacity: 1;
}

.reader-stage.is-fullscreen,
.reader-stage:fullscreen {
  min-height: 100vh;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.reader-stage.is-fullscreen .progress-track,
.reader-stage:fullscreen .progress-track {
  left: 360px;
}

@media (max-width: 720px) {
  .reader-stage.is-fullscreen .progress-track,
  .reader-stage:fullscreen .progress-track {
    left: 18px;
    bottom: 184px;
  }

  .fullscreen-tuning {
    right: 18px;
    width: auto;
  }
}

@media (max-width: 980px) {
  .topbar,
  .mission-grid,
  .briefing-panel {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .fire-button {
    justify-self: start;
  }

  .control-panel {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .hero-panel,
  .control-panel,
  .library-panel,
  .briefing-panel article {
    border-radius: 16px;
    padding: 18px;
  }

  h1 {
    font-size: 3rem;
  }

  .reader-stage {
    min-height: 230px;
  }

  .word-display {
    font-size: min(var(--word-size, 72px), 16vw);
  }

  .nav-pill {
    padding: 11px 17px;
  }

  .color-grid {
    grid-template-columns: 1fr;
  }
}
