:root {
  --bg-deep: #080d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-subtle: #141e33;
  --border-subtle: #1e293b;
  --border-bright: #334155;
  --border-accent: rgba(56, 189, 248, 0.3);
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --cyan-bright: #38bdf8;
  --cyan-dark: #0284c7;
  --cyan-glow: rgba(56, 189, 248, 0.15);
  
  --amber-bright: #fbbf24;
  --amber-dark: #d97706;
  --amber-glow: rgba(245, 158, 11, 0.18);
  
  --emerald-bright: #34d399;
  
  --font-mono: ui-monospace, SFMono-Regular, "Roboto Mono", Menlo, Monaco, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", Times, Source Serif Pro, serif;

  --max-w: 920px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg-deep);
  color: var(--text-main);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  line-height: 1.65;
  background: radial-gradient(circle at 50% 0%, #111c30 0%, var(--bg-deep) 70%);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* FM-001 Accessibility Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.site-container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Language Navigation */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: rgba(8, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.brand-link {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s ease;
}

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

.brand-badge {
  font-size: 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-bright);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--cyan-bright);
}

.lang-nav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

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

.lang-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.lang-btn.active {
  background: var(--cyan-dark);
  color: #ffffff;
}

/* Hero Section */
.hero {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
  position: relative;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--amber-bright);
  background: var(--amber-glow);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.15;
  color: #ffffff;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 2rem;
  }
}

.hero-subtitle {
  font-size: 1.1875rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 2rem;
  font-weight: 400;
}

/* Key Metrics Grid */
.metrics-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 2.5rem 0;
}

@media (max-width: 768px) {
  .metrics-banner {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top: 3px solid var(--cyan-dark);
  padding: 1.25rem 1rem;
  border-radius: var(--radius-md);
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--cyan-bright);
}

.metric-card.accent {
  border-top-color: var(--amber-bright);
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.35rem;
  line-height: 1.1;
}

.metric-card.accent .metric-val {
  color: var(--amber-bright);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.metric-desc {
  font-size: 0.775rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

/* Interactive Component: Canvas & Nanomechanical Stepper */
.interactive-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin: 3rem 0;
  box-shadow: var(--shadow-md);
}

@media (max-width: 640px) {
  .interactive-section {
    padding: 1.25rem 1rem;
  }
}

.section-header {
  margin-bottom: 1.5rem;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan-bright);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  display: block;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  color: #ffffff;
  line-height: 1.25;
}

/* Canvas Container */
.canvas-wrapper {
  position: relative;
  width: 100%;
  background: #060a11;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

canvas#kinesinCanvas {
  display: block;
  width: 100%;
  height: 240px;
}

.canvas-overlay-stats {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.canvas-overlay-stats span {
  color: var(--cyan-bright);
  font-weight: 600;
}

/* Control Panel */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.control-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.control-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--cyan-bright);
  font-weight: 700;
}

.control-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-bright);
  border-radius: 3px;
  outline: none;
  margin-bottom: 0.65rem;
  cursor: pointer;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan-bright);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  border: 2px solid #0f172a;
}

.control-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan-bright);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  border: 2px solid #0f172a;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.btn-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border-bright);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover {
  background: #273549;
  border-color: var(--cyan-bright);
}

.btn.active, .btn-primary {
  background: var(--cyan-dark);
  border-color: var(--cyan-bright);
  color: #ffffff;
}

.btn-amber {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--amber-bright);
}

.btn-amber:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: var(--amber-bright);
}

/* Simulation Live Readout */
.readout-panel {
  background: #0a111e;
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
}

@media (max-width: 640px) {
  .readout-panel {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.readout-item-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--cyan-bright);
  margin-bottom: 0.25rem;
}

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

/* Calculator Section */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

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

.calc-inputs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calc-results {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.65rem;
}

.result-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.result-title {
  font-size: 0.875rem;
  color: var(--text-muted);
}

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

.result-val.highlight {
  color: var(--amber-bright);
}

.result-val.cyan {
  color: var(--cyan-bright);
}

/* Prose & Essay Sections */
.essay-content {
  margin: 3.5rem 0;
}

.prose {
  font-family: var(--font-sans);
  color: #cbd5e1;
  font-size: 1.0625rem;
  line-height: 1.75;
}

.prose h2 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
  margin: 2.75rem 0 1.25rem;
  letter-spacing: -0.01em;
}

.prose h3 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--cyan-bright);
  margin: 2rem 0 0.85rem;
}

.prose p {
  margin-bottom: 1.35rem;
}

.prose strong {
  color: #ffffff;
}

.prose em {
  color: #e2e8f0;
}

.callout {
  background: var(--bg-surface);
  border-left: 4px solid var(--cyan-bright);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 2rem 0;
}

.callout-amber {
  border-left-color: var(--amber-bright);
  background: rgba(245, 158, 11, 0.08);
}

.callout-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cyan-bright);
  margin-bottom: 0.5rem;
}

.callout-amber .callout-title {
  color: var(--amber-bright);
}

/* Table of comparison */
.data-table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

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

.data-table th {
  background: var(--bg-surface-elevated);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-bright);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  background: var(--bg-surface);
}

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

.data-table td.mono {
  font-family: var(--font-mono);
}

.data-table tr.highlight td {
  background: rgba(56, 189, 248, 0.08);
  font-weight: 600;
}

/* Method Note & References */
.method-section {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2rem;
  margin: 3.5rem 0;
  font-size: 0.925rem;
  color: var(--text-muted);
}

.method-section h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: #ffffff;
  margin-bottom: 1rem;
}

.references-list {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.references-list li {
  padding-left: 1.25rem;
  position: relative;
}

.references-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--cyan-bright);
}

/* Back to Top button */
.back-to-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 40;
  box-shadow: var(--shadow-md);
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top-btn:hover {
  color: var(--cyan-bright);
  border-color: var(--cyan-bright);
  transform: translateY(-2px);
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 0;
  background: #060a11;
  font-size: 0.85rem;
  color: var(--text-dim);
}

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

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

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

.footer-links a:hover {
  color: var(--cyan-bright);
}

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