:root {
  --bg: #090a0f;
  --bg-card: #12151f;
  --bg-card-subtle: #171b26;
  --border: #222736;
  --border-light: #2d3448;
  --ink: #f1f3f7;
  --ink-soft: #a3aabf;
  --ink-muted: #677087;
  --amber: #f59e0b;
  --amber-soft: #fbbf24;
  --amber-dim: rgba(245, 158, 11, 0.12);
  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.12);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.12);
  --emerald: #10b981;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Spline Sans Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.68;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.04) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(245, 158, 11, 0.03) 0%, transparent 40%);
}

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

.visually-hidden:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  background: var(--amber);
  color: #000;
  font-family: var(--sans);
  font-weight: 600;
  clip: auto;
  text-decoration: none;
  border-radius: 4px;
}

.shell {
  width: 100%;
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.shell-wide {
  width: 100%;
  max-width: 62rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  max-width: 62rem;
  margin: 0 auto;
  width: 100%;
}

.brand {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s ease;
}

.brand:hover {
  color: var(--ink);
}

.langsw {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.langsw a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.langsw a[aria-current="page"] {
  color: var(--amber);
  font-weight: 600;
  background: var(--amber-dim);
}

.langsw a:hover:not([aria-current="page"]) {
  color: var(--ink);
}

/* Hero Section */
.hero {
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
  border-bottom: 1px solid var(--border);
}

.kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--amber);
  margin-bottom: 0.8rem;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 1.4rem;
}

.standfirst {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 2.5rem;
}

/* Ledger Metrics Line */
.ledgerline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}

@media (max-width: 768px) {
  .ledgerline {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.2rem 1rem;
  }
}

@media (max-width: 480px) {
  .ledgerline {
    grid-template-columns: 1fr;
  }
}

.ledgerline > div {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
}

.ledgerline .n {
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--amber);
  margin-bottom: 0.4rem;
}

.ledgerline .l {
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* Prose Sections */
.block {
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
}

.prose h2 {
  font-size: 1.65rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #ffffff;
  margin-bottom: 1.2rem;
  line-height: 1.25;
}

.prose p {
  margin-bottom: 1.3rem;
  color: var(--ink);
}

.prose strong {
  color: #ffffff;
  font-weight: 600;
}

.divider {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* Figures & Charts */
.fig {
  margin: 2.2rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.4rem;
  overflow: hidden;
  max-width: 100%;
}

figcaption {
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.75rem;
}

/* Interactive Instruments */
.instrument {
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
  background: linear-gradient(180deg, rgba(18, 21, 31, 0.7) 0%, rgba(9, 10, 15, 0.9) 100%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1.5rem 0 2rem 0;
  align-items: center;
  max-width: 100%;
}

.ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 100%;
}

.ctrl label {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 100%;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 14rem;
  max-width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.range-val {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--amber);
  min-width: 3.5rem;
}

.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented button[aria-pressed="true"] {
  background: var(--amber-dim);
  color: var(--amber);
  font-weight: 600;
}

.segmented button:hover:not([aria-pressed="true"]) {
  color: var(--ink);
}

/* Acuity & Vision Test Box */
.acuity-box {
  position: relative;
  background: #030407;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.5rem 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
  overflow: hidden;
  user-select: none;
  max-width: 100%;
}

.fixation-cross {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-family: var(--mono);
  font-size: 1.8rem;
  color: var(--amber);
  line-height: 1;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  animation: pulseCross 3s infinite alternate ease-in-out;
}

@keyframes pulseCross {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.15); opacity: 1; }
}

.acuity-radial-grid {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.acuity-word {
  position: absolute;
  font-family: var(--sans);
  font-weight: 500;
  color: var(--ink);
  transition: all 0.2s ease;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .acuity-radial-grid {
    min-height: 240px;
  }
  .acuity-word[data-deg="2"] { left: calc(50% + 20px) !important; font-size: 0.8rem; }
  .acuity-word[data-deg="6"] { left: calc(50% + 48px) !important; font-size: 0.82rem; }
  .acuity-word[data-deg="12"] { left: calc(50% + 82px) !important; font-size: 0.88rem; }
  .acuity-word[data-deg="22"] { left: calc(50% + 118px) !important; font-size: 0.94rem; }
}

/* Readout Cards Grid */
.colgrid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 860px) {
  .colgrid {
    grid-template-columns: 1fr;
  }
}

.readouts {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.readout {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem;
}

.r-num {
  display: block;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.r-num.fovea { color: var(--amber); }
.r-num.cyan { color: var(--cyan); }
.r-num.rose { color: var(--rose); }

.r-txt {
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* Foveator Lens Simulator */
.foveator-stage {
  position: relative;
  width: 100%;
  height: 380px;
  background: #06070a;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

.foveator-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.foveator-hud {
  position: absolute;
  bottom: 0.8rem;
  left: 0.8rem;
  background: rgba(9, 10, 15, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  pointer-events: none;
}

/* Blind Spot Cartographer */
.blindspot-stage {
  background: #020305;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem 1.5rem;
  margin: 1.5rem 0;
  position: relative;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.blindspot-track {
  width: 100%;
  max-width: 680px;
  height: 90px;
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 1rem;
}

.blindspot-cross {
  position: absolute;
  left: 15%;
  font-family: var(--mono);
  font-size: 2rem;
  color: var(--amber);
  user-select: none;
}

.blindspot-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--rose);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.7);
  transition: left 0.05s linear;
}

.blindspot-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

.btn-action {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1.1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: var(--border);
  border-color: var(--amber);
  color: #fff;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-top: 0.9rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.sw-cones { background: var(--amber); }
.sw-rods { background: var(--cyan); }
.sw-blind { background: var(--rose); }
.sw-v1 { background: var(--emerald); }

/* Sources & Ledger Section */
.ledger {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 3rem 0;
}

.srcrow {
  margin-top: 1.5rem;
}

.srcrow:first-of-type {
  margin-top: 1.2rem;
}

.srcrow .tag {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.3rem;
}

.srcrow p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.srcrow p a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.srcrow p a:hover {
  color: var(--amber);
}

.srcrow .meta {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-top: 0.4rem;
}

/* Site Footer */
footer.site {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem 0;
  margin-top: auto;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-muted);
}

footer.site .shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

footer.site a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s ease;
}

footer.site a:hover {
  color: var(--amber);
}

/* Floating Back-to-Top Button */
.totop {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.6rem;
  height: 2.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--ink-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
  z-index: 90;
  opacity: 0.7;
}

.totop:hover {
  opacity: 1;
  border-color: var(--amber);
  color: var(--amber);
  transform: translateY(-2px);
}
