:root {
  --bg: #090d14;
  --bg-surface: #101726;
  --bg-card: #151f33;
  --bg-card-hover: #1b2740;
  --border: #1e2c47;
  --border-focus: #38bdf8;
  
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.15);
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.15);
  --emerald: #10b981;
  --rose: #f43f5e;
  
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-sans);
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
}

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

html {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.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: static;
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  white-space: normal;
  padding: 0.5rem 1rem;
  background: var(--cyan);
  color: var(--bg);
  font-weight: bold;
}

/* Header & Nav */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

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

.langsw {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.langsw a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.langsw a:hover {
  color: var(--cyan);
}

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

/* Containers */
.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.shell-wide {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* Hero Section */
.hero {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.08) 0%, rgba(9, 13, 20, 0) 70%);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cyan);
  margin-bottom: 1rem;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: #ffffff;
  margin-bottom: 1.5rem;
}

.standfirst {
  font-size: 1.25rem;
  line-height: 1.6;
  color: #cbd5e1;
  max-width: 800px;
  margin-bottom: 2.5rem;
}

/* Ledger Line Stats Grid */
.ledgerline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.ledgerline > div {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}

.ledgerline > div:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.ledgerline .n {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.ledgerline .n.highlight-amber {
  color: var(--amber);
}

.ledgerline .n.highlight-cyan {
  color: var(--cyan);
}

.ledgerline .l {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Prose & Content Blocks */
.block {
  padding: 4rem 0;
  border-bottom: 1px solid var(--border);
}

.prose h2 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 1.25rem;
}

.prose h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 2rem 0 0.75rem;
}

.prose p {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #cbd5e1;
  margin-bottom: 1.5rem;
}

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

/* Console & Instrument Card */
.console-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  margin: 2.5rem 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.console-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Oscilloscope & Frequency Gauge */
.instrument-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.gauge-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  position: relative;
}

.gauge-display-val {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  margin: 0.75rem 0 0.25rem;
}

.gauge-display-unit {
  font-size: 1.1rem;
  color: var(--cyan);
  font-weight: 500;
}

.gauge-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 0.75rem;
}

.osc-canvas-wrapper {
  background: #06090e;
  border: 1px solid #172235;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  height: 170px;
}

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

/* Twin Clocks (Atomic UTC vs Grid Synchronous) */
.twin-clocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 2rem 0 1rem;
}

@media (max-width: 640px) {
  .twin-clocks {
    grid-template-columns: 1fr;
  }
}

.clock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.clock-card.clock-grid {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04) 0%, var(--bg-card) 100%);
}

.clock-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.clock-dial-wrapper {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: relative;
  margin-bottom: 1rem;
  background: #080c14;
}

.clock-digital-readout {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.clock-delta-readout {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--amber);
}

.clock-delta-readout.nominal {
  color: var(--emerald);
}

/* Interactive Controls */
.control-rack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #1e2c47;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-chip:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
  border-color: var(--cyan);
}

.btn-chip.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
  border-color: var(--cyan);
  font-weight: 600;
}

/* Timeline 2018 Chart & Interactive Scrubber */
.chart-container {
  position: relative;
  background: #080c14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
}

.timeline-info-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.timeline-stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.timeline-stat-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.2rem;
}

/* In-depth Method / Explainer Table */
.data-table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

th, td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

td {
  background: var(--bg);
  color: #cbd5e1;
}

tr:last-child td {
  border-bottom: none;
}

.mono-cell {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Footer & Author Signature */
footer {
  margin-top: auto;
  padding: 3.5rem 0 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.9rem;
}

footer a {
  color: var(--cyan);
  text-decoration: none;
  transition: underline 0.2s ease;
}

footer a:hover {
  text-decoration: underline;
}

.footer-credits {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  color: var(--text-dim);
}

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