:root {
  --bg-main: #0c0f14;
  --bg-surface: #141922;
  --bg-surface-raised: #1c2330;
  --bg-surface-border: #283344;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 159, 28, 0.4);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --amber-primary: #ff9f1c;
  --amber-glow: rgba(255, 159, 28, 0.25);
  --cyan-accent: #38bdf8;
  --rose-accent: #f43f5e;
  --emerald-accent: #10b981;
  
  --key-bg: #1e2634;
  --key-border: #334155;
  --key-text: #e2e8f0;
  --key-active-bg: #ff9f1c;
  --key-active-text: #0c0f14;
  
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Monaco, Consolas, monospace;

  --container-max: 1100px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(255, 159, 28, 0.07) 0%, transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
}

.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(12, 15, 20, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s ease;
}

.brand-link:hover {
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--amber-primary);
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.2rem;
  border-radius: var(--radius-sm);
}

.lang-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.main-content {
  flex: 1;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}

/* HERO */
.hero {
  margin-bottom: 3.5rem;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--amber-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-meta-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber-primary);
  box-shadow: 0 0 8px var(--amber-primary);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5.5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 1.25rem;
  max-width: 900px;
  overflow-wrap: break-word;
}

.hero-standfirst {
  font-size: clamp(1.125rem, 2vw, 1.25rem);
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 820px;
  margin-bottom: 2.5rem;
}

/* STAT CARDS */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--amber-primary), transparent);
  opacity: 0.7;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.stat-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--amber-primary);
}

.stat-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* INTERACTIVE LAB / CONSOLE */
.console-section {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 4rem;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5);
  position: relative;
}

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

.console-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.console-status-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-accent);
  box-shadow: 0 0 10px var(--emerald-accent);
  animation: pulse-led 2s infinite ease-in-out;
}

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

.console-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #ffffff;
  text-transform: uppercase;
}

.console-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.layout-select {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.layout-select:focus {
  border-color: var(--amber-primary);
}

/* LIVE TELEMETRY DISPLAY */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.telemetry-box {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--amber-primary);
  line-height: 1.2;
}

.telemetry-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* HAND BALANCE BAR */
.balance-container {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.balance-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.balance-left-label {
  color: var(--rose-accent);
}

.balance-right-label {
  color: var(--cyan-accent);
}

.balance-bar-track {
  height: 12px;
  background: var(--cyan-accent);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.balance-bar-left {
  height: 100%;
  background: var(--rose-accent);
  width: 57.4%;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* KEYBOARD MATRIX WRAPPER */
.keyboard-wrapper {
  position: relative;
  background: #090c10;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.keyboard-scale-bar {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
}

.keyboard-matrix {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 700px;
  position: relative;
}

.keyboard-vector-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.keyboard-row {
  display: flex;
  gap: 6px;
}

.key-cap {
  height: 48px;
  min-width: 44px;
  flex: 1;
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-bottom: 3px solid #171f2b;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--key-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.key-cap:hover {
  background: #252f40;
  border-color: #475569;
}

.key-cap.active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  background: var(--amber-primary) !important;
  color: #0c0f14 !important;
  box-shadow: 0 0 16px var(--amber-glow);
}

.key-cap.hand-l {
  border-left: 2px solid rgba(244, 63, 94, 0.4);
}

.key-cap.hand-r {
  border-right: 2px solid rgba(56, 189, 248, 0.4);
}

.key-cap-wide-15 { flex: 1.5; }
.key-cap-wide-175 { flex: 1.75; }
.key-cap-wide-2 { flex: 2; }
.key-cap-wide-225 { flex: 2.25; }
.key-cap-space { flex: 6.25; }

.key-sub {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.key-hits-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.5625rem;
  color: var(--amber-primary);
  opacity: 0.8;
}

/* INPUT & PRESETS */
.sandbox-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.preset-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.preset-chip {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.preset-chip:hover {
  background: #252f40;
  color: var(--text-primary);
  border-color: var(--amber-primary);
}

.preset-chip.active {
  background: var(--amber-primary);
  color: #0c0f14;
  font-weight: 600;
  border-color: var(--amber-primary);
}

.input-area-wrapper {
  position: relative;
}

.typing-input {
  width: 100%;
  height: 120px;
  background: #090c10;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}

.typing-input:focus {
  border-color: var(--amber-primary);
  box-shadow: 0 0 0 2px var(--amber-glow);
}

/* DETAILED FINGER LOAD MATRIX */
.finger-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.finger-cell {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.finger-name {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.finger-val {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
}

.finger-dist {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--amber-primary);
}

/* EDITORIAL ESSAY SECTIONS */
.narrative-section {
  margin-bottom: 4rem;
}

.narrative-section h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.narrative-section p {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  line-height: 1.75;
  margin-bottom: 1.25rem;
  max-width: 800px;
}

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

.comparison-table-wrapper {
  overflow-x: auto;
  margin: 1.75rem 0 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

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

.comparison-table th {
  background: var(--bg-surface-raised);
  padding: 0.875rem 1.25rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.comparison-table td {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

.comparison-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.comparison-table .num-cell {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 600;
}

.comparison-table .highlight-cell {
  color: var(--amber-primary);
}

/* SOURCES & FOOTER */
.sources-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  margin-bottom: 3.5rem;
}

.sources-title {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.sources-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sources-list li {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sources-list a {
  color: var(--amber-primary);
  text-decoration: none;
}

.sources-list a:hover {
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 1.5rem;
  background: rgba(12, 15, 20, 0.95);
}

.footer-container {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

@media (max-width: 768px) {
  .main-content {
    padding: 1.5rem 1rem 3rem;
  }
  .hero-title {
    font-size: 1.875rem;
    line-height: 1.2;
  }
  .hero-standfirst {
    font-size: 1.0625rem;
  }
  .stat-strip {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .console-section {
    padding: 1rem 0.75rem;
    border-radius: var(--radius-md);
  }
  .telemetry-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .finger-matrix {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .telemetry-grid {
    grid-template-columns: 1fr;
  }
  .finger-matrix {
    grid-template-columns: repeat(2, 1fr);
  }
  .preset-strip {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
  }
  .preset-chip {
    white-space: nowrap;
  }
}

@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;
  }
}
