@font-face {
  font-family: "IBM Plex Sans";
  src: url("/ali/assets/fonts/IBMPlexSans-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/ali/assets/fonts/IBMPlexSans-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("/ali/assets/fonts/SpaceGrotesk-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #07110f;
  --surface: #0d1a17;
  --surface-2: #13231f;
  --line: #315348;
  --text: #edf8f2;
  --muted: #9fb7ae;
  --green: #9cff4a;
  --cyan: #55d8f0;
  --yellow: #ffd166;
  --coral: #ff7b66;
  --ink: #050b09;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(85, 216, 240, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 216, 240, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--text);
  font-family: "IBM Plex Sans", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

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

a {
  color: inherit;
}

button {
  color: inherit;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 15, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  text-decoration: none;
}

.brand-logo-shell {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  overflow: hidden;
  flex: 0 0 auto;
  border-radius: 50%;
}

.brand-logo-video,
.brand-logo-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo-video {
  z-index: 1;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.top-nav a,
.top-nav .nav-status,
.lang-toggle {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.top-nav .nav-status {
  color: rgba(238, 247, 239, 0.58);
  cursor: pointer;
}

.top-nav a:hover,
.top-nav a:focus-visible,
.lang-toggle:hover,
.lang-toggle:focus-visible {
  color: var(--green);
}

.lang-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
}

.workbench,
.project-context,
.cube-hypothesis,
.cube-calculations,
.method-band,
.credits {
  padding-inline: clamp(18px, 4vw, 56px);
}

.workbench {
  padding-top: clamp(34px, 6vw, 82px);
  padding-bottom: 64px;
}

.workbench-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  align-items: end;
  gap: 42px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(3.2rem, 8vw, 7.4rem);
  font-weight: 560;
  line-height: 0.88;
}

.intro {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  line-height: 1.55;
}

.project-article-note {
  max-width: 940px;
  margin: 0 0 28px;
  padding: 14px 18px;
  border-left: 3px solid var(--green);
  background: rgba(146, 255, 65, 0.06);
  color: var(--muted);
  line-height: 1.55;
}

.project-article-note a {
  display: inline-block;
  margin-left: 6px;
  border-bottom: 1px solid var(--green);
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}

.project-article-note a:hover,
.project-article-note a:focus-visible {
  color: var(--text);
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.preset-bar > span {
  margin-right: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.preset-bar button,
.result-actions button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.preset-bar button:hover,
.preset-bar button:focus-visible,
.result-actions button:hover,
.result-actions button:focus-visible {
  border-color: var(--green);
  color: var(--green);
}

.reader-controls {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 44px minmax(250px, 1fr) minmax(230px, 0.7fr);
  align-items: stretch;
  border: 1px solid var(--line);
  background: rgba(13, 26, 23, 0.92);
}

.book-source,
.analysis-settings {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border: 0;
}

.book-source {
  border-right: 1px solid var(--line);
}

.book-source legend {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
}

.book-source legend span:first-child {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-size: 0.76rem;
}

.book-source label:not(.file-picker) {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--text);
}

.or {
  margin: 13px 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  text-transform: uppercase;
}

.file-picker {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--cyan);
  cursor: pointer;
  text-align: center;
}

.file-picker:hover,
.file-picker:focus-within {
  border-color: var(--cyan);
  background: rgba(85, 216, 240, 0.06);
}

.file-picker small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.file-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--yellow);
  font-size: 0.76rem;
}

.swap-button {
  align-self: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.15rem;
}

.swap-button:hover,
.swap-button:focus-visible {
  border-color: var(--green);
  color: var(--green);
}

.analysis-settings {
  background: var(--ink);
}

.analysis-settings h2 {
  margin-bottom: 18px;
  font-size: 1.12rem;
}

.reading-mode-control {
  margin-bottom: 18px;
}

.reading-mode-control > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

.segmented-control button.is-active {
  background: var(--green);
  color: var(--ink);
  font-weight: 600;
}

.reading-mode-control small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
}

.check-row input {
  accent-color: var(--green);
}

.analyze-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 0 16px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

.analyze-button:hover,
.analyze-button:focus-visible {
  background: transparent;
  color: var(--green);
}

.analyze-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.privacy-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.loading-panel {
  margin-top: 22px;
  padding: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.scanner {
  position: relative;
  width: min(520px, 100%);
  height: 3px;
  margin: 0 auto 18px;
  overflow: hidden;
  background: var(--line);
}

.scanner [data-loading-bar] {
  position: absolute;
  inset: 0 auto 0 0;
  width: 28%;
  background: var(--green);
  animation: scan 1.1s ease-in-out infinite;
}

.scanner.is-determinate [data-loading-bar] {
  width: var(--analysis-progress, 0%);
  animation: none;
  transition: width 180ms ease;
}

.loading-panel p {
  margin: 0;
}

.loading-detail {
  min-height: 1.4em;
  margin-top: 7px !important;
  color: var(--muted);
  font-size: 0.76rem;
}

.cancel-analysis {
  margin-top: 17px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
}

.cancel-analysis:hover,
.cancel-analysis:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
}

@keyframes scan {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(370%);
  }
}

.results {
  margin-top: 36px;
}

.result-header,
.map-panel > header,
.milestones > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.result-header {
  margin-bottom: 18px;
}

.result-header h2 {
  max-width: 900px;
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3.5vw, 3.4rem);
  line-height: 1.05;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metric {
  min-height: 118px;
  padding: 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 26, 23, 0.9);
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.3rem, 2.4vw, 2.2rem);
  font-weight: 540;
}

.metric span {
  color: var(--muted);
  font-size: 0.77rem;
  text-transform: uppercase;
}

.metric.is-success strong {
  color: var(--green);
}

.metric.is-failure strong {
  color: var(--coral);
}

.map-panel,
.host-reader,
.trajectory-panel,
.break-panel,
.milestones {
  margin-top: 28px;
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid var(--line);
  background: rgba(13, 26, 23, 0.92);
}

.map-panel h3,
.host-reader h3,
.trajectory-panel h3,
.break-panel h3,
.milestones h3 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.map-legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 0.76rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.map-legend i {
  display: block;
  width: 18px;
  height: 5px;
}

.legend-match {
  background: var(--green);
}

.legend-gap {
  background: var(--cyan);
  opacity: 0.28;
}

.canvas-shell {
  position: relative;
  width: 100%;
  height: 230px;
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink);
}

[data-density-canvas],
[data-path-canvas] {
  display: block;
  width: 100%;
  height: 100%;
}

.playhead {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--yellow);
  box-shadow: 0 0 18px var(--yellow);
  opacity: 0;
  pointer-events: none;
}

.playhead.is-playing {
  opacity: 1;
}

.book-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.host-reader {
  overflow: hidden;
}

.host-reader-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.host-reader-header h3 {
  margin-bottom: 0;
}

.reader-pagination {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.reader-pagination button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid rgba(85, 216, 240, 0.34);
  border-radius: 6px;
  background: var(--ink);
  color: var(--cyan);
  cursor: pointer;
  font-size: 1.1rem;
}

.reader-pagination button:hover,
.reader-pagination button:focus-visible {
  border-color: var(--green);
  color: var(--green);
}

.reader-pagination button:disabled {
  border-color: var(--line);
  color: #4d625a;
  cursor: default;
}

.page-number-control {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.page-number-control input {
  width: 62px;
  border: 0;
  border-bottom: 1px solid rgba(156, 255, 74, 0.45);
  border-radius: 0;
  padding: 4px;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.host-reader-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 24px auto 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.host-reader-meta strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-book-page {
  min-height: 620px;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(30px, 5vw, 64px);
  border: 1px solid #d7d1c3;
  background:
    linear-gradient(rgba(73, 57, 35, 0.025), rgba(73, 57, 35, 0.025)),
    #f5f1e7;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  color: #211f1b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.25vw, 1.12rem);
  line-height: 1.85;
  white-space: pre-wrap;
}

.ghost-letter {
  position: relative;
  display: inline-flex;
  min-width: 0.78em;
  margin: 0 0.04em;
  align-items: baseline;
  justify-content: center;
  border: 0;
  border-bottom: 2px solid #4ca914;
  border-radius: 0;
  background: rgba(156, 255, 74, 0.2);
  box-shadow: none;
  color: #0d3607;
  font-family: inherit;
  font-weight: 700;
  line-height: inherit;
  vertical-align: baseline;
}

.cycle-badges {
  display: inline-flex;
  align-self: flex-start;
  gap: 1px;
  margin: -0.45em -0.08em 0 0.03em;
  color: #1b6c0d;
  font-family: "IBM Plex Sans", sans-serif;
  line-height: 1;
}

.cycle-badges sup {
  min-width: 1em;
  font-size: 0.54em;
  font-weight: 700;
  text-align: center;
}

.host-reader-legend {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.host-reader-legend > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.host-reader-legend i {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border-bottom: 2px solid var(--green);
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
}

.host-reader-legend i sup {
  margin-left: 1px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.55em;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
}

.trajectory-panel,
.break-panel {
  min-width: 0;
}

.trajectory-panel canvas {
  height: 260px;
  margin: 20px 0;
  border: 1px solid var(--line);
  background: var(--ink);
}

.trajectory-panel > p:last-child,
.break-panel > p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.sequence-view {
  min-height: 138px;
  margin: 20px 0;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.85;
}

.sequence-view .matched {
  color: var(--green);
}

.sequence-view .next {
  display: inline-block;
  padding: 0 3px;
  background: var(--coral);
  color: var(--ink);
}

.sequence-view .remaining {
  color: #597168;
}

.milestone-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.milestone {
  min-width: 0;
  min-height: 154px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--ink);
}

.milestone strong {
  display: block;
  color: var(--cyan);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.8rem;
}

.milestone p {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.6;
}

.milestone mark {
  padding: 1px 2px;
  background: var(--green);
  color: var(--ink);
}

.project-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.85fr);
  align-items: center;
  gap: clamp(34px, 7vw, 90px);
  padding-top: 74px;
  padding-bottom: 74px;
  border-top: 1px solid var(--line);
}

.context-image img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.context-copy h2 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.context-copy p {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.text-link {
  display: inline-block;
  margin-top: 10px;
  border-bottom: 1px solid var(--green);
  color: var(--green);
  text-decoration: none;
}

.text-link-muted {
  border-color: rgba(238, 247, 239, 0.18);
  color: rgba(238, 247, 239, 0.58);
  cursor: default;
}

.cube-hypothesis {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1.18fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
  padding-top: clamp(48px, 6vw, 84px);
  padding-bottom: clamp(48px, 6vw, 84px);
  background: #d4eef0;
  color: #07110e;
  border-top: 1px solid rgba(7, 17, 14, 0.12);
  border-bottom: 1px solid rgba(7, 17, 14, 0.12);
}

.cube-copy {
  max-width: 610px;
}

.cube-copy .eyebrow {
  color: #176b45;
}

.cube-copy h2 {
  margin: 10px 0 20px;
  font-size: clamp(36px, 4.2vw, 60px);
  line-height: 1;
}

.cube-copy p:not(.eyebrow) {
  max-width: 58ch;
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.6;
}

.cube-copy .text-link {
  border-color: #176b45;
  color: #0c5a38;
  font-weight: 600;
}

.cube-copy .text-link:hover,
.cube-copy .text-link:focus-visible {
  color: #07110e;
}

.cube-hypothesis figure {
  margin: 0;
}

.cube-hypothesis img {
  display: block;
  width: 100%;
  max-height: 640px;
  object-fit: contain;
}

.cube-hypothesis figcaption {
  margin-top: 12px;
  color: rgba(7, 17, 14, 0.68);
  font-size: 13px;
}

.cube-calculations {
  padding-top: clamp(54px, 7vw, 94px);
  padding-bottom: clamp(54px, 7vw, 94px);
  scroll-margin-top: 86px;
}

.cube-calculations > header {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  gap: 18px clamp(32px, 7vw, 100px);
  align-items: end;
  margin-bottom: 42px;
}

.cube-calculations > header .eyebrow {
  grid-column: 1 / -1;
}

.cube-calculations > header h2 {
  margin: 0;
  font-size: clamp(34px, 4.6vw, 68px);
  line-height: 0.98;
}

.cube-calculations > header > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 1.35vw, 20px);
  line-height: 1.6;
}

.calculation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.calculation-grid article {
  min-width: 0;
  padding: clamp(22px, 3vw, 38px);
  border-right: 1px solid var(--line);
}

.calculation-grid article:last-child {
  border-right: 0;
}

.calculation-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--green);
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(21px, 2.25vw, 34px);
  line-height: 1.1;
}

.calculation-grid span {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.installation-protocol {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.3fr);
  gap: 36px;
  margin-top: 44px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.installation-protocol h3 {
  margin: 0;
  font-size: clamp(25px, 3vw, 42px);
}

.installation-protocol ol {
  display: grid;
  gap: 16px;
  margin: 0;
  padding-left: 26px;
  color: var(--muted);
  line-height: 1.55;
}

#ghostbook-cube {
  scroll-margin-top: 86px;
}

.method-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 54px;
  padding-bottom: 54px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.method-band article {
  padding: 0 24px;
  border-right: 1px solid var(--line);
}

.method-band article:first-child {
  padding-left: 0;
}

.method-band article:last-child {
  padding-right: 0;
  border-right: 0;
}

.method-band span {
  color: var(--green);
  font-family: "Space Grotesk", sans-serif;
}

.method-band h2 {
  margin: 18px 0 10px;
  font-size: 1.18rem;
}

.method-band p,
.credits p {
  color: var(--muted);
  line-height: 1.6;
}

.credits {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr 0.65fr;
  gap: 42px;
  padding-top: 54px;
  padding-bottom: 70px;
}

.credits h2 {
  margin: 0;
  font-size: 1.45rem;
}

.credits p {
  margin: 0;
}

.credits a {
  color: var(--green);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .reader-controls {
    grid-template-columns: 1fr 44px 1fr;
  }

  .analysis-settings {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .analysis-settings {
    display: grid;
    grid-template-columns: repeat(3, auto) minmax(230px, 1fr);
    align-items: center;
    gap: 12px 20px;
  }

  .analysis-settings h2,
  .privacy-note {
    grid-column: 1 / -1;
    margin: 0;
  }

  .analyze-button {
    margin: 0;
  }

  .metrics,
  .milestone-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .site-header {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    overflow-x: auto;
  }

  .brand > span:last-child {
    font-size: 0.95rem;
  }

  .workbench-heading,
  .project-context,
  .cube-hypothesis,
  .cube-calculations > header,
  .installation-protocol,
  .credits {
    grid-template-columns: 1fr;
  }

  .cube-hypothesis {
    gap: 30px;
    padding-top: 42px;
    padding-bottom: 42px;
  }

  .cube-copy {
    max-width: 36rem;
  }

  .cube-copy h2 {
    margin-bottom: 18px;
    font-size: clamp(2.25rem, 6.5vw, 3rem);
    line-height: 1.02;
  }

  .cube-copy p:not(.eyebrow) {
    font-size: 1rem;
    line-height: 1.55;
  }

  .cube-hypothesis figure {
    max-width: 620px;
  }

  .reader-controls {
    grid-template-columns: 1fr;
  }

  .book-source {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .swap-button {
    z-index: 2;
    margin: -18px auto;
    transform: rotate(90deg);
  }

  .analysis-settings {
    display: block;
  }

  .analysis-settings h2 {
    margin-bottom: 18px;
  }

  .analyze-button {
    margin-top: 22px;
  }

  .result-header,
  .map-panel > header,
  .host-reader-header,
  .milestones > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .reader-pagination {
    width: 100%;
  }

  .host-reader-meta,
  .host-reader-legend {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .milestone-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .method-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 0;
  }

  .method-band article:nth-child(2) {
    border-right: 0;
  }

  .credits {
    gap: 20px;
  }

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

  .calculation-grid article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .calculation-grid article:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 520px) {
  .site-header,
  .workbench,
  .project-context,
  .cube-hypothesis,
  .cube-calculations,
  .method-band,
  .credits {
    padding-inline: 16px;
  }

  h1 {
    font-size: 3.15rem;
  }

  .brand-logo-shell {
    width: 48px;
    height: 48px;
  }

  .top-nav a:nth-child(2) {
    display: none;
  }

  .preset-bar {
    margin-inline: -16px;
    padding-inline: 16px;
  }

  .book-source,
  .analysis-settings,
  .map-panel,
  .host-reader,
  .trajectory-panel,
  .break-panel,
  .milestones {
    padding: 18px;
  }

  .metrics,
  .milestone-list,
  .method-band {
    grid-template-columns: 1fr;
  }

  .method-band article {
    padding: 0 0 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .method-band article:last-child {
    border-bottom: 0;
  }

  .canvas-shell {
    height: 190px;
  }

  .result-actions {
    width: 100%;
    overflow-x: auto;
  }

  .map-legend {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .reader-pagination {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }

  .reader-pagination button {
    width: 100%;
  }

  .page-number-control {
    grid-row: 1;
    grid-column: 1 / -1;
    justify-content: center;
  }

  .reader-pagination [data-reader-action="previous-marked"] {
    grid-row: 2;
    grid-column: 1;
  }

  .reader-pagination [data-reader-action="previous"] {
    grid-row: 2;
    grid-column: 2;
  }

  .reader-pagination [data-reader-action="next"] {
    grid-row: 2;
    grid-column: 3;
  }

  .reader-pagination [data-reader-action="next-marked"] {
    grid-row: 2;
    grid-column: 4;
  }

  .host-book-page {
    min-height: 520px;
    padding: 26px 22px;
    font-size: 0.98rem;
    line-height: 1.78;
  }
}

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

  .scanner::after {
    animation: none;
  }
}
