.legal-shell {
  min-height: 100vh;
  margin: 0;
  color: #212529;
  background: #f1f3f5;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

.legal-page {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 0;
}

/* Header — shared control-room top bar (sticky), self-contained so the legal page does
   not pull in home-v2/exam-v2. Its rail tokens are scoped to the bar; the bar is dark in
   both themes, matching the home, roadmaps and editor. */
.cr-topbar {
  --rail-bg: #1d232f;
  --rail-text: #aab2c0;
  --rail-text-strong: #e8ebf0;
  --rail-line: #313947;
  --accent-bright: #2dd4bf;
  --h-radius: 10px;

  position: sticky;
  top: 0;
  z-index: 50;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: -20px;          /* cancel .legal-page's 20px top padding so the bar meets the top */
  margin-bottom: 18px;
  background: var(--rail-bg);
  color: var(--rail-text);
  border-bottom: 1px solid var(--rail-line);
}
.cr-topnav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.cr-topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
}
.cr-topnav-brand .logo-img { width: 26px; height: auto; }
.cr-topnav-brand .cr-wordmark {
  color: var(--rail-text-strong);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.cr-topnav-brand .logo-accent { color: var(--accent-bright); }
.cr-topnav-brand:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; border-radius: 6px; }
.cr-topnav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.1rem;
}
.cr-topnav-links > a {
  color: var(--rail-text);
  text-decoration: none;
  font-size: 0.8438rem;
  font-weight: 600;
  transition: color 0.15s;
}
.cr-topnav-links > a:hover { color: var(--rail-text-strong); }
.cr-topnav-links > a:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.cr-topnav .theme-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.cr-topnav .theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: var(--h-radius);
  background: transparent;
  border: 1px solid var(--rail-line);
  color: var(--rail-text);
  transition: color 0.15s, border-color 0.15s;
}
.cr-topnav .theme-toggle:hover { color: var(--accent-bright); border-color: var(--accent-bright); }
.cr-topnav .theme-toggle:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.legal-hero {
  padding: 24px;
  color: #212529;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e3e6ea;
  border-left: 4px solid #0f766e;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(31, 39, 51, 0.05);
}

.legal-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px 10px;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.legal-hero h1 {
  max-width: 720px;
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.legal-hero p {
  max-width: 720px;
  margin: 16px 0 0;
  color: #6c757d;
  font-size: 1rem;
  line-height: 1.65;
}

.legal-content {
  margin-top: 18px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(31, 39, 51, 0.05);
}

.legal-content h2 {
  margin: 26px 0 10px;
  color: #212529;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content p,
.legal-content li {
  color: #6c757d;
  font-size: 0.96rem;
  line-height: 1.72;
}

.legal-content p {
  margin: 0 0 14px;
}

.legal-content ul {
  margin: 0 0 18px;
  padding-left: 20px;
}

.legal-content strong {
  color: #212529;
}

.legal-callout {
  margin: 0 0 22px;
  padding: 16px;
  background: rgba(31, 122, 77, 0.08);
  border: 1px solid rgba(31, 122, 77, 0.18);
  border-left: 4px solid #1f7a4d;
  border-radius: 8px;
}

.legal-callout p:last-child {
  margin-bottom: 0;
}

.legal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 22px;
}

.legal-mini-card {
  padding: 15px;
  background: #f7f8fa;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
}

.legal-mini-card i {
  color: #0f766e;
  margin-bottom: 10px;
}

.legal-mini-card h2 {
  margin: 0 0 8px;
}

.legal-pre {
  overflow-x: auto;
  margin: 0;
  padding: 20px;
  color: #212529;
  background: #f7f8fa;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  font-family: 'Cascadia Mono', Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.legal-shell.dark-mode {
  color: #e2e8f0;
  background: #10141b;
}

/* The control-room top bar is dark in both themes; only its graphite deepens. */
.legal-shell.dark-mode .cr-topbar {
  --rail-bg: #161b24;
  --rail-line: #2b3340;
}

.legal-shell.dark-mode .legal-hero {
  color: #f8fafc;
  background: #1a212c;
  border-color: rgba(255, 255, 255, 0.08);
  border-left-color: #2dd4bf;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.legal-shell.dark-mode .legal-kicker {
  color: #7fd7c9;
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.24);
}

.legal-shell.dark-mode .legal-hero p {
  color: #cbd5e1;
}

.legal-shell.dark-mode .legal-content {
  background: #1a212c;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.legal-shell.dark-mode .legal-content h2,
.legal-shell.dark-mode .legal-content strong {
  color: #f8fafc;
}

.legal-shell.dark-mode .legal-content p,
.legal-shell.dark-mode .legal-content li {
  color: #cbd5e1;
}

.legal-shell.dark-mode .legal-callout {
  background: rgba(20, 83, 45, 0.28);
  border-color: rgba(74, 222, 128, 0.2);
  border-left-color: #1f7a4d;
}

.legal-shell.dark-mode .legal-mini-card,
.legal-shell.dark-mode .legal-pre {
  color: #e2e8f0;
  background: #1f2733;
  border-color: rgba(148, 163, 184, 0.18);
}

.legal-shell.dark-mode .legal-mini-card i {
  color: #7fd7c9;
}

@media (max-width: 720px) {
  .legal-page {
    width: min(1120px, calc(100% - 8px));
    padding-top: 18px;
  }

  .cr-topnav {
    padding: 0.55rem 1rem;
  }

  .legal-hero,
  .legal-content {
    padding: 20px;
  }

  .legal-hero h1 {
    font-size: 1.7rem;
  }

  .legal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .legal-hero,
  .legal-content {
    padding: 0.85rem;
  }
}
