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

:root {
  --bg: #0a0e17;
  --bg-raised: #111827;
  --fg: #c8d0e0;
  --fg-bright: #e2e8f0;
  --fg-muted: #94a3b8;
  --fg-dim: #64748b;
  --accent: #3b82f6;
  --accent-glow: #3b82f644;
  --surface: #0f172a;
  --border: #1e293b;
  --border-mid: #334155;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --nav-height: 40px;
  --content-max: 1200px;
  --gutter: 24px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--fg-bright);
  line-height: 1.3;
}

h1 { font-size: 2rem; margin-bottom: 16px; }
h2 { font-size: 1.4rem; margin-bottom: 12px; }
h3 { font-size: 1.1rem; margin-bottom: 8px; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--fg-bright);
}

pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code { background: none; padding: 0; }

/* --- Nav bar --- */
.garden-nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-height); z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; white-space: nowrap;
  padding: 0 8px;
}

.garden-nav::-webkit-scrollbar { height: 0; }

.garden-nav a {
  display: inline-flex; align-items: center; height: var(--nav-height);
  padding: 0 14px; font-size: 12px; font-weight: 500;
  color: var(--fg-dim); text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.garden-nav a:hover { color: var(--fg-muted); text-decoration: none; }
.garden-nav a.active { color: var(--fg-bright); border-bottom-color: var(--accent); }

.garden-nav .nav-home {
  font-weight: 600; color: var(--fg-bright);
  letter-spacing: -0.3px; padding: 0 16px;
}
.garden-nav .nav-home:hover { color: #f1f5f9; }

.garden-nav .nav-sep {
  color: var(--border-mid); padding: 0 4px;
  font-size: 10px; pointer-events: none;
  user-select: none;
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--fg-dim);
  padding: 12px var(--gutter);
  margin-top: var(--nav-height);
}

.breadcrumb a { color: var(--fg-dim); }
.breadcrumb a:hover { color: var(--fg-muted); }
.breadcrumb .sep { color: var(--border-mid); }
.breadcrumb .current { color: var(--fg-muted); }

/* --- Page layout --- */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter) 80px;
}

.page-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.page-header h1 { margin-bottom: 8px; }
.page-header .subtitle {
  font-size: 1rem; color: var(--fg-muted);
  max-width: 700px;
}

/* --- Full-bleed sections (for charts) --- */
.exhibit { position: relative; width: 100%; }
.exhibit-chart { width: 100%; height: 500px; }

/* --- Domain entry cards --- */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.domain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  transition: border-color 0.2s, transform 0.15s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.domain-card:hover {
  border-color: var(--border-mid);
  transform: translateY(-2px);
  text-decoration: none;
}

.domain-card .card-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
  display: block;
}

.domain-card h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.domain-card .card-count {
  font-size: 12px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

.domain-card .card-desc {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 8px;
  line-height: 1.5;
  white-space: normal;
}

.domain-card .card-roles {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.domain-card .role-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--border);
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

/* --- Handbook footer (trail links) --- */
.trail-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.trail-footer h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-dim);
  margin-bottom: 16px;
}

.trail-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.trail-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s;
}

.trail-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.trail-card .trail-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-bright);
}

.trail-card .trail-desc {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* --- Role list table --- */
.role-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.role-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-mid);
}

.role-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.role-table tr:hover td { background: var(--bg-raised); }

.role-table .role-name {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
}

.role-table .role-db {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
}

/* --- Section blocks --- */
.section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* --- Stat row --- */
.stat-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg-bright);
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* --- Nutshell overrides --- */
.nutshell-bubble {
  background: var(--bg-raised) !important;
  border: 1px solid var(--border-mid) !important;
  color: var(--fg) !important;
  border-radius: 6px !important;
}

a[data-nutshell] {
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  cursor: pointer;
}

/* --- Quote block --- */
.quote-block {
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin: 24px 0;
  background: var(--surface);
  border-radius: 0 6px 6px 0;
}

.quote-block .quote-text {
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.7;
}

.quote-block .quote-attr {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 8px;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: var(--border);
  color: var(--fg-muted);
}

/* --- Layer diagram (memory page) --- */
.layer-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 24px 0;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.layer-item .layer-num {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--fg-dim);
  min-width: 40px;
}

.layer-item .layer-name {
  font-weight: 600;
  color: var(--fg-bright);
}

.layer-item .layer-desc {
  font-size: 13px;
  color: var(--fg-muted);
}

/* --- Timeline (session page) --- */
.timeline {
  position: relative;
  padding-left: 32px;
  margin: 24px 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -27px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-item .time-label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--fg-dim);
  margin-bottom: 4px;
}

.timeline-item h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.timeline-item p {
  font-size: 13px;
  color: var(--fg-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root { --gutter: 16px; }
  h1 { font-size: 1.5rem; }
  .domain-grid { grid-template-columns: 1fr; }
  .trail-cards { grid-template-columns: 1fr; }
  .stat-row { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
