:root {
  --bg: #fbfaf8;
  --surface-1: #f1efe9;
  --surface-2: #e8e5dd;
  --text-primary: #1f1e1c;
  --text-secondary: #55524a;
  --text-muted: #898781;
  --border-strong: #d8d4c9;
  --border-accent: #2a78d6;
  --bg-accent: rgba(42,120,214,0.10);
  --text-accent: #2a78d6;
  --radius: 6px;
  --accent: #2a78d6;
  --accent-2: #c0553f;
  --accent-3: #3f9142;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface-1: #201f1c;
    --surface-2: #29281f;
    --text-primary: #ece9e2;
    --text-secondary: #b7b3a8;
    --text-muted: #898781;
    --border-strong: #38362e;
    --border-accent: #4c93e8;
    --bg-accent: rgba(76,147,232,0.14);
    --text-accent: #4c93e8;
    --accent: #4c93e8;
    --accent-2: #e0765c;
    --accent-3: #5cb860;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---- app shell ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--surface-1); border-right: 1px solid var(--border-strong);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-size: 15px; font-weight: 600; padding: 4px 8px 16px; letter-spacing: -0.01em; }
.brand span { color: var(--text-accent); }
.nav-group-title {
  font-size: 10.5px; font-weight: 600; color: var(--text-muted); letter-spacing: .08em;
  text-transform: uppercase; margin: 16px 8px 6px;
}
.nav-item {
  display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius); font-size: 13px; color: var(--text-secondary);
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--bg-accent); color: var(--text-accent); font-weight: 500; }
.nav-item .tier-tag {
  float: right; font-size: 9.5px; color: var(--text-muted); font-weight: 400;
}

.main { flex: 1; min-width: 0; }
.topbar {
  display: none; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-strong);
  background: var(--surface-1); position: sticky; top: 0; z-index: 5;
}
.topbar button { background: none; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 10px; color: var(--text-primary); }
.content { max-width: 920px; margin: 0 auto; padding: 28px 32px 80px; }

.page { display: none; }
.page.active { display: block; }

.page-title { font-size: 21px; font-weight: 600; margin: 0 0 2px; }
.page-sub { font-size: 13.5px; color: var(--text-secondary); margin: 0 0 20px; max-width: 640px; }
.tier-badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
  margin-bottom: 10px; text-transform: uppercase;
}

.note {
  font-size: 12.5px; color: var(--text-secondary); background: var(--surface-1);
  border-left: 2px solid var(--border-accent); padding: 8px 12px; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 14px 0;
}
.note.warn { border-left-color: var(--accent-2); }

/* ---- shared component classes (from the original repo) ---- */
.ctrl-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ctrl-label { font-size: 13px; color: var(--text-secondary); min-width: 130px; }
.ctrl-val { font-size: 13px; font-weight: 500; color: var(--text-primary); min-width: 52px; text-align: right; }
.ctrl-row input[type=range] { flex: 1; }
.section-title { font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; margin: 16px 0 8px; }
.panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.panel.single { grid-template-columns: 1fr; }
.stats-row { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.stat { background: var(--surface-1); border-radius: var(--radius); padding: 8px 14px; min-width: 92px; }
.stat-label { font-size: 11px; color: var(--text-muted); }
.stat-val { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.chart-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.toggle-btn { font-size: 12px; padding: 4px 10px; border-radius: var(--radius); border: 0.5px solid var(--border-strong); background: transparent; color: var(--text-secondary); cursor: pointer; transition: background .15s; }
.toggle-btn.active { background: var(--bg-accent); color: var(--text-accent); border-color: var(--border-accent); }
.chart-wrap { position: relative; height: 300px; margin-bottom: 4px; }
.chart-wrap.tall { height: 360px; }
.formula-box {
  font-size: 13.5px; background: var(--surface-1); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0;
  overflow-x: auto;
}
select.mini-select {
  font-size: 13px; padding: 4px 8px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text-primary);
}

/* ---- role table + brainteaser accordions (Pillar 6) ---- */
.role-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0 18px; }
.role-table th, .role-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); vertical-align: top; }
.role-table th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.role-table td { color: var(--text-secondary); }
.role-table td:first-child { color: var(--text-primary); font-weight: 500; white-space: nowrap; }

details.brainteaser {
  background: var(--surface-1); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px;
  border: 1px solid var(--border-strong);
}
details.brainteaser summary {
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-primary); list-style: none;
}
details.brainteaser summary::-webkit-details-marker { display: none; }
details.brainteaser summary::before { content: '▸ '; color: var(--text-accent); }
details.brainteaser[open] summary::before { content: '▾ '; }
details.brainteaser .answer { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: 13px; color: var(--text-secondary); }
.reading-list { margin: 6px 0 18px; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.reading-list li { margin-bottom: 4px; }
.reading-list b { color: var(--text-primary); }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; top: 0; z-index: 20; transition: left .18s; box-shadow: 2px 0 12px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .topbar { display: flex; }
  .panel { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 60px; }
  .role-table { font-size: 12px; }
}
