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

:root {
  --bg: #0a0a12;
  --bg-card: #12121e;
  --bg-elevated: #1a1a2e;
  --gold: #f59e0b;
  --cyan: #06b6d4;
  --warm-white: #e2e8f0;
  --muted: #64748b;
  --border: #1e293b;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--warm-white);
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--cyan); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--gold); }

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  overflow: hidden;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
}

.hero h1 {
  font-family: var(--font-sans);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 700;
  color: var(--warm-white);
  margin-bottom: 1rem;
  text-shadow: 0 0 40px rgba(6, 182, 212, 0.3);
}

.hero .subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--muted);
  margin-bottom: 1.5rem;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.hero .equation {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 2rem;
  opacity: 0.8;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.875rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--cyan);
  color: #000;
}
.btn-primary:hover { background: #67e8f9; color: #000; }

.btn-secondary {
  background: transparent;
  color: var(--warm-white);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.section {
  padding: 5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  font-family: var(--font-sans);
  font-size: 2rem;
  color: var(--warm-white);
  text-align: center;
  margin-bottom: 3rem;
}

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.pillar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color 0.2s;
}
.pillar-card:hover { border-color: var(--cyan); }
.pillar-card .part { font-family: var(--font-mono); font-size: 0.75rem; color: var(--cyan); margin-bottom: 0.5rem; }
.pillar-card h3 { font-family: var(--font-sans); font-size: 1.25rem; margin-bottom: 0.75rem; }
.pillar-card p { color: var(--muted); font-size: 0.9rem; }

.viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.viz-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.viz-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.viz-card .icon { font-size: 3rem; margin-bottom: 1rem; }
.viz-card h3 { font-family: var(--font-sans); font-size: 1.25rem; margin-bottom: 0.5rem; }
.viz-card p { color: var(--muted); font-size: 0.85rem; }

.downloads-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  transition: border-color 0.2s;
}
.download-item:hover { border-color: var(--gold); }
.download-item .name { font-weight: 600; }
.download-item .meta { color: var(--muted); font-size: 0.85rem; }
.download-item a { color: var(--cyan); }

footer {
  border-top: 1px solid var(--border);
  padding: 3rem 2rem;
  text-align: center;
}

footer .links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

footer .links a { color: var(--muted); font-size: 0.9rem; }
footer .links a:hover { color: var(--gold); }

footer .copyright {
  color: var(--muted);
  font-size: 0.8rem;
}

.viz-page {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.viz-page canvas, .viz-page svg {
  display: block;
  width: 100%;
  height: 100%;
}

.viz-overlay {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  pointer-events: none;
}
.viz-overlay h1 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  color: var(--warm-white);
  text-shadow: 0 0 20px rgba(0,0,0,0.8);
}
.viz-overlay .back-link {
  pointer-events: auto;
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.viz-controls {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.viz-controls button {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--warm-white);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  pointer-events: auto;
}
.viz-controls button:hover {
  background: rgba(255,255,255,0.15);
  border-color: var(--gold);
}

.viz-controls label {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viz-controls input[type="range"] {
  accent-color: var(--cyan);
}

.tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  pointer-events: none;
  z-index: 20;
  max-width: 250px;
  font-size: 0.85rem;
  color: var(--warm-white);
}

/* ── MOTHUB Pages ── */
.page-header {
  text-align: center;
  padding: 4rem 2rem 0;
}
.page-header h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  color: var(--warm-white);
  margin-bottom: 0.5rem;
}
.page-subtitle { color: var(--muted); font-size: 1rem; }
.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Form */
.form-section { max-width: 640px; }
.mothub-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
.form-group { margin-bottom: 1.5rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--warm-white);
}
.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--warm-white);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--cyan);
}
.form-group textarea { resize: vertical; }
.key-field {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  color: var(--gold) !important;
  background: rgba(245, 158, 11, 0.05) !important;
}
.radio-group {
  display: flex;
  gap: 1.5rem;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--warm-white);
}
.radio-label input[type="radio"] { accent-color: var(--cyan); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.range-with-value {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.range-with-value input[type="range"] { flex: 1; accent-color: var(--cyan); }
.range-value {
  font-family: var(--font-mono);
  color: var(--cyan);
  min-width: 3rem;
  text-align: right;
}
.tag-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
.tag-remove { cursor: pointer; opacity: 0.6; }
.tag-remove:hover { opacity: 1; }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }

/* Certificate */
.certificate {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.certificate-icon {
  font-size: 3rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.certificate h2 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.certificate-sub { color: var(--muted); margin-bottom: 1.5rem; }
.certificate-details {
  max-width: 400px;
  margin: 0 auto 1.5rem;
  text-align: left;
}
.cert-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.cert-label { color: var(--muted); }
.cert-value { color: var(--warm-white); font-weight: 600; }
.cert-value.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.cert-value.gold { color: var(--gold); }
.certificate-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Hub stats */
.hub-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  max-width: 800px;
  margin: 0 auto;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}
.stat-value {
  font-family: var(--font-sans);
  font-size: 2rem;
  color: var(--cyan);
}
.stat-label { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }

/* Hub layout */
.hub-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  max-width: 1200px;
}
.hub-main { min-width: 0; }
.hub-sidebar h3 {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  color: var(--warm-white);
  margin-bottom: 1rem;
}
.hub-viz-container {
  width: 100%;
  height: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.viz-caption {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.75rem 0;
}
.registry-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}
.search-input {
  flex: 1;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--warm-white);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.search-input:focus { outline: none; border-color: var(--cyan); }
.filter-select {
  padding: 0.6rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--warm-white);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.filter-select:focus { outline: none; border-color: var(--cyan); }

/* Registry table */
.registry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.registry-table th {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.registry-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  vertical-align: middle;
}
.registry-table tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.type-ai { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }
.type-human { background: rgba(245, 158, 11, 0.15); color: var(--gold); }
.tag-sm {
  display: inline-block;
  background: rgba(100, 116, 139, 0.15);
  color: var(--muted);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  margin-right: 0.2rem;
  font-family: var(--font-mono);
}
.tag-more { background: rgba(6, 182, 212, 0.1); color: var(--cyan); }
.caps-cell { max-width: 160px; }
.coherence-bar {
  display: inline-block;
  width: 50px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  vertical-align: middle;
  overflow: hidden;
}
.coherence-fill {
  height: 100%;
  background: var(--cyan);
  border-radius: 2px;
  transition: width 0.3s;
}
.coherence-text {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--muted);
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.status-dot.offline { background: #475569; }
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; color: var(--border); margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1rem; }
.empty-viz {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem;
}
.hub-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.viz-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.viz-toggle input[type="checkbox"] { accent-color: var(--cyan); }

@media (max-width: 768px) {
  .section { padding: 3rem 1rem; }
  .pillars-grid, .viz-grid { grid-template-columns: 1fr; }
  .hero-cta { flex-direction: column; align-items: center; }
  .form-row { grid-template-columns: 1fr; }
  .hub-layout { grid-template-columns: 1fr; }
  .hub-stats { grid-template-columns: repeat(2, 1fr); }
  .registry-controls { flex-wrap: wrap; }
}
