:root {
  --bg: #111118;
  --surface: #1a1a28;
  --surface2: #222235;
  --border: #2a2a40;
  --text: #d8d8e0;
  --dim: #7a7a90;
  --accent: #e05070;
  --accent2: #50b0e0;
  --success: #50c890;
  --warning: #e0a040;
  --hot: #e05050;
  --cold: #3060a0;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 0;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 4rem;
  color: var(--dim);
  font-size: 1.2rem;
}

/* --- Header --- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2rem 3rem;
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
header .meta {
  font-size: 0.85rem;
  color: var(--dim);
}
header .meta span {
  margin-right: 1.5rem;
}
header .hypothesis {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  color: var(--dim);
  font-style: italic;
}

/* --- Navigation --- */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 3rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav a {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Main content --- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 3rem;
}

/* --- Sections --- */
section {
  margin-bottom: 3rem;
  scroll-margin-top: 3.5rem;
}
section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
section h3 {
  font-size: 0.9rem;
  color: var(--dim);
  margin: 1rem 0 0.5rem;
}
section .narrative {
  font-size: 0.88rem;
  color: var(--dim);
  margin-bottom: 1.5rem;
  max-width: 800px;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: var(--mono);
  margin-bottom: 1rem;
}
th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  color: var(--dim);
  border-bottom: 2px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 2.8rem;
  background: var(--bg);
}
th.num { text-align: right; }
td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.model {
  font-weight: 600;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
}
tr:hover td { background: var(--surface); }

/* --- Heatmap cells --- */
td.heat {
  text-align: center;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  transition: background 0.15s;
}

/* --- Compliance bars --- */
.bar-cell {
  position: relative;
  padding: 0.3rem 0.75rem;
}
.bar-bg {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  opacity: 0.2;
}
.bar-label {
  position: relative;
  z-index: 1;
}

/* --- Domain tags --- */
.tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin: 0.1rem 0.2rem;
  font-family: var(--mono);
}
.tag-physical { background: rgba(80,176,224,0.2); color: var(--accent2); }
.tag-institutional { background: rgba(224,160,64,0.2); color: var(--warning); }
.tag-moral { background: rgba(224,80,112,0.2); color: var(--accent); }

/* --- Finding box --- */
.finding-box {
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}
.finding-box h3 {
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.finding-box p {
  font-size: 0.9rem;
}

/* --- Annotation boxes --- */
.annotation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.85rem;
}
.annotation summary {
  padding: 0.6rem 1rem;
  cursor: pointer;
  color: var(--accent2);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.annotation summary::-webkit-details-marker { display: none; }
.annotation summary::before {
  content: '\25B6';
  font-size: 0.6rem;
  transition: transform 0.2s;
}
.annotation[open] summary::before { transform: rotate(90deg); }
.annotation .anno-body {
  padding: 0 1rem 1rem;
  color: var(--dim);
  line-height: 1.7;
}
.annotation .anno-body strong { color: var(--text); }
.annotation .anno-body .anno-example {
  background: var(--surface2);
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
}

/* --- FSI bar labels --- */
.fsi-bar-label {
  font-size: 0.6rem;
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
  text-shadow: 0 0 2px rgba(0,0,0,0.5);
}

/* --- Procrustes scatter --- */
.scatter-legend {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
}
.scatter-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.proc-toggle {
  transition: opacity 0.2s;
}
.proc-toggle:hover {
  filter: brightness(1.2);
}
.scatter-shapes {
  font-size: 0.72rem;
  color: var(--dim);
  margin-bottom: 1.5rem;
}

/* --- FSI section --- */
.fsi-selector {
  margin-bottom: 1rem;
}
.fsi-selector label {
  font-size: 0.8rem;
  color: var(--dim);
}
.fsi-selector select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.fsi-domain-header {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.fsi-row {
  display: grid;
  grid-template-columns: 130px 1fr 50px;
  align-items: center;
  margin-bottom: 2px;
  gap: 0.5rem;
}
.fsi-concept {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  padding-right: 0.5rem;
  color: var(--text);
}
.fsi-bars {
  display: flex;
  gap: 1px;
  align-items: center;
  height: 20px;
}
.fsi-bar {
  height: 18px;
  border-radius: 1px;
  opacity: 0.85;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fsi-mean {
  font-size: 0.7rem;
  color: var(--dim);
  font-family: var(--mono);
  text-align: right;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  header, main, nav { padding-left: 1rem; padding-right: 1rem; }
  table { font-size: 0.72rem; }
  .fsi-row { grid-template-columns: 100px 1fr 40px; }
}
