/* ==========================================================================
   BIA Learn — TMM (Técnicas de Modelação Molecular) Course UX & WCAG AA CSS
   Zero-overflow responsive navigation, module strip, WCAG AA Light & Dark
   contrast tokens across all 13 TMM pages, pedagogy panels, simulators &
   Focus-Nav / Command Palette shell.
   ========================================================================== */

:root {
  --tmm-accent: #0369a1;
  --tmm-purple: #6d28d9;
  --tmm-amber: #b45309;
  --tmm-emerald: #047857;
  --tmm-surface: #ffffff;
  --tmm-surface-2: #f8fafc;
  --tmm-border: rgba(148, 163, 184, 0.35);
}

[data-theme="dark"] {
  --tmm-accent: #38bdf8;
  --tmm-purple: #c4b5fd;
  --tmm-amber: #fbbf24;
  --tmm-emerald: #34d399;
  --tmm-surface: #0f172a;
  --tmm-surface-2: #111c33;
  --tmm-border: rgba(148, 163, 184, 0.24);
}

/* Global horizontal overflow guard */
html, body {
  overflow-x: clip;
  max-width: 100%;
}

/* Unified wrapping Module Strip */
.tmm-module-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  max-width: 1280px;
  margin: 0.65rem auto 0.25rem;
  padding: 0.5rem 1rem;
}

.tmm-strip-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, 0.45);
  transition: all 0.16s ease;
  white-space: nowrap;
}

.tmm-strip-pill:hover {
  background: #e0f2fe;
  border-color: #0369a1;
  color: #0369a1;
}

.tmm-strip-pill.active {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
  font-weight: 700;
}

[data-theme="dark"] .tmm-strip-pill {
  color: #e2e8f0;
  background: #17233b;
  border-color: rgba(148, 163, 184, 0.28);
}

[data-theme="dark"] .tmm-strip-pill:hover {
  background: #1e3a5f;
  border-color: #38bdf8;
  color: #f0f9ff;
}

[data-theme="dark"] .tmm-strip-pill.active {
  background: #0369a1;
  border-color: #38bdf8;
  color: #ffffff;
}

/* Accessible Pedagogy & History Panels (Light & Dark WCAG AA >= 4.5:1) */
.tmm-ped-panel {
  background: var(--tmm-surface-2);
  border: 1px solid var(--tmm-border);
  border-left: 5px solid var(--tmm-purple);
  border-radius: 14px;
  padding: 1.3rem 1.5rem;
  margin: 1.35rem 0;
}

.tmm-ped-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.tmm-ped-pill {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.24rem 0.7rem;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.1);
  color: #5b21b6;
}

[data-theme="dark"] .tmm-ped-pill {
  background: rgba(139, 92, 246, 0.2);
  color: #ddd6fe;
}

.tmm-ped-m0-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: #5b21b6;
  text-decoration: none;
  border: 1px solid #6d28d9;
  padding: 0.3rem 0.72rem;
  border-radius: 8px;
}

[data-theme="dark"] .tmm-ped-m0-link {
  color: #ddd6fe;
  border-color: #a78bfa;
}

.tmm-ped-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.tmm-ped-box {
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
}

.tmm-ped-concept {
  background: rgba(3, 105, 161, 0.06);
  border: 1px solid rgba(3, 105, 161, 0.24);
}

.tmm-ped-concept h3 {
  margin: 0 0 0.42rem;
  font-size: 0.98rem;
  color: #0369a1;
}

[data-theme="dark"] .tmm-ped-concept {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.26);
}

[data-theme="dark"] .tmm-ped-concept h3 {
  color: #7dd3fc;
}

.tmm-ped-curio {
  background: rgba(180, 83, 9, 0.07);
  border: 1px solid rgba(180, 83, 9, 0.25);
}

.tmm-ped-curio h3 {
  margin: 0 0 0.42rem;
  font-size: 0.98rem;
  color: #92400e;
}

[data-theme="dark"] .tmm-ped-curio {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.28);
}

[data-theme="dark"] .tmm-ped-curio h3 {
  color: #fcd34d;
}

.tmm-ped-text {
  font-size: 0.87rem;
  line-height: 1.6;
  margin: 0 0 0.5rem;
}

.tmm-ped-intuit {
  font-size: 0.83rem;
  line-height: 1.54;
  margin: 0;
  color: var(--text-secondary);
}

.tmm-ped-summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  color: #5b21b6;
}

[data-theme="dark"] .tmm-ped-summary {
  color: #ddd6fe;
}

.tmm-hist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.tmm-hist-card {
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-border);
  border-top: 3px solid var(--tmm-purple);
  border-radius: 12px;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tmm-hist-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
  object-fit: cover;
  object-position: center 15%;
  border-radius: 9px;
  border: 1px solid var(--tmm-border);
  margin-bottom: 0.65rem;
  display: block;
}

.tmm-hist-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.1);
  color: #5b21b6;
  margin-bottom: 0.35rem;
}

[data-theme="dark"] .tmm-hist-badge {
  background: rgba(139, 92, 246, 0.22);
  color: #ddd6fe;
}

.tmm-hist-title {
  margin: 0.15rem 0 0.4rem;
  font-size: 0.97rem;
  color: var(--text-primary);
}

.tmm-hist-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--tmm-purple);
}

.tmm-hist-desc {
  font-size: 0.83rem;
  line-height: 1.54;
  color: var(--text-secondary);
  margin: 0 0 0.7rem;
}

.tmm-hist-wiki {
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #6d28d9;
  color: #5b21b6;
  text-decoration: none;
  display: block;
}

[data-theme="dark"] .tmm-hist-wiki {
  border-color: #a78bfa;
  color: #ddd6fe;
}

/* ==========================================================================
   SYSTEMATIC WCAG AA CONTRAST OVERRIDES (LIGHT & DARK MODE >= 4.5:1)
   ========================================================================== */

/* 1. Fix purple #7c3aed inline badges/links in BOTH Light & Dark Mode across tmm.html & tmm-block0.html */
.hist-card span[style*="#7c3aed"],
.hist-card a[style*="#7c3aed"],
.textbook-pedagogy-panel span[style*="#7c3aed"],
.textbook-pedagogy-panel a[style*="#7c3aed"],
.textbook-pedagogy-panel summary[style*="#7c3aed"],
section span[style*="color:#7c3aed"],
a[style*="color:#7c3aed"] {
  color: #5b21b6 !important;
}

[data-theme="dark"] .hist-card span[style*="#7c3aed"],
[data-theme="dark"] .hist-card a[style*="#7c3aed"],
[data-theme="dark"] .textbook-pedagogy-panel span[style*="#7c3aed"],
[data-theme="dark"] .textbook-pedagogy-panel a[style*="#7c3aed"],
[data-theme="dark"] .textbook-pedagogy-panel summary[style*="#7c3aed"],
[data-theme="dark"] section span[style*="color:#7c3aed"],
[data-theme="dark"] a[style*="color:#7c3aed"] {
  color: #ddd6fe !important;
  border-color: #a78bfa !important;
}

[data-theme="dark"] .hero-actions a[style*="color:#ddd6fe"] {
  color: #ede9fe !important;
  border-color: #a78bfa !important;
}

html:not([data-theme="dark"]) .hero-actions a[style*="color:#ddd6fe"] {
  color: #5b21b6 !important;
  border-color: #7c3aed !important;
  background: rgba(124, 58, 237, 0.07) !important;
}

/* 2. Fix Quiz Scoreboard Badge & Active Filter Chips (WCAG AA >= 5.9:1) */
.quiz-score-badge {
  color: #0369a1 !important;
  background: #e0f2fe !important;
  border-color: #0369a1 !important;
}

[data-theme="dark"] .quiz-score-badge {
  color: #e0f2fe !important;
  background: #0c4a6e !important;
  border-color: #38bdf8 !important;
}

button.chip.active,
.filter-bar button.chip.active {
  background: #0369a1 !important;
  border-color: #0369a1 !important;
  color: #ffffff !important;
}

[data-theme="dark"] button.chip.active,
[data-theme="dark"] .filter-bar button.chip.active {
  background: #0369a1 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}

/* 3. Fix Catastrophic tmm-trainer.html Dark Mode (1.21:1) & Light Mode (1.23:1) Contrast! */
.mission-chip {
  color: #0f172a !important;
  background: #f8fafc !important;
  border-color: rgba(100, 116, 139, 0.35) !important;
}

.mission-chip span {
  color: inherit !important;
}

.mission-chip.active {
  background: #e0f2fe !important;
  border-color: #0369a1 !important;
  color: #0c4a6e !important;
}

.mission-chip.done {
  background: #ecfdf5 !important;
  border-color: #059669 !important;
  color: #065f46 !important;
}

[data-theme="dark"] .mission-chip {
  color: #e2e8f0 !important;
  background: #132038 !important;
  border-color: rgba(148, 163, 184, 0.28) !important;
}

[data-theme="dark"] .mission-chip.active {
  background: #0c3559 !important;
  border-color: #38bdf8 !important;
  color: #f0f9ff !important;
}

[data-theme="dark"] .mission-chip.done {
  background: #064e3b !important;
  border-color: #34d399 !important;
  color: #ecfdf5 !important;
}

/* Fix trainer Light Mode table cells & colored inline text on light background */
html:not([data-theme="dark"]) .trainer-cheatsheet table td,
html:not([data-theme="dark"]) table.cheat-table td,
html:not([data-theme="dark"]) .sandbox-panel table td {
  color: #0f172a !important;
}

html:not([data-theme="dark"]) .study-card td[style*="color:#e2e8f0"],
html:not([data-theme="dark"]) td[style*="color:#e2e8f0"],
html:not([data-theme="dark"]) td[style*="color: #e2e8f0"] {
  color: #1e293b !important;
}

html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) td[style*="color:#4ade80"],
html:not([data-theme="dark"]) span[style*="color:#4ade80"]:not(.terminal-window *):not(.terminal-body *):not(.gui-window *):not(.gui-body *):not(.bp-terminal *):not(.terminal-prompt) {
  color: #047857 !important;
}

html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) td[style*="color:#38bdf8"],
html:not([data-theme="dark"]) span[style*="color:#38bdf8"]:not(.terminal-window *):not(.terminal-body *):not(.gui-window *):not(.gui-body *):not(.bp-terminal *):not(.terminal-prompt):not([style*="rgba(15,23,42"] *) {
  color: #0369a1 !important;
}

/* Keep dark gradient launchpad banner heading crisp bright sky-blue (> 9.5:1) in Light Mode! */
[style*="rgba(15,23,42"] span[style*="color:#38bdf8"] {
  color: #7dd3fc !important;
}

/* 4. Fix tmm-qmmm.html Light Mode pre > code (#e2e8f0 on #f8fafc = 1.18:1!) */
.code-block pre,
pre.code-block,
.code-block > pre {
  background: #0b1120 !important;
  color: #e2e8f0 !important;
  border-radius: 0 0 10px 10px;
}

.code-block pre code,
pre.code-block code {
  background: transparent !important;
  color: #e2e8f0 !important;
}

/* 5. Fix tmm-viz.html 3Dmol VMD/PyMOL dark bar code contrast (#2563eb on #0d1526!) */
#mol3d-cmd,
.mol3d-cmd,
#mol3d-caption code,
.mol3d-caption {
  color: #93c5fd !important;
}

/* 6. Fix tmm-best-practices.html comments & badges in Light & Dark Mode */
.bp-terminal .c-comment,
pre .c-comment,
.tok-comment {
  color: #94a3b8 !important;
}

[data-theme="dark"] .soft-badge {
  background: #1e3a5f !important;
  color: #e0f2fe !important;
  border-color: #38bdf8 !important;
}

html:not([data-theme="dark"]) .soft-badge {
  background: #e0f2fe !important;
  color: #0c4a6e !important;
}

/* 7. Ensure dark-mode inline code contrast inside buttons & callouts */
[data-theme="dark"] code {
  color: #bae6fd;
}

.btn code,
.btn-primary code,
.btn-secondary code {
  background: rgba(255, 255, 255, 0.2) !important;
  color: inherit !important;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.06rem 0.32rem;
}

/* 8. Pedagogical Widgets (TL;DR, Microcheck, Worked Example, Pitfall, Q&A, Eq Anatomy, Simulators) */
.tmm-tldr-box {
  background: linear-gradient(135deg, rgba(3, 105, 161, 0.08), rgba(109, 40, 217, 0.07));
  border: 1px solid rgba(3, 105, 161, 0.3);
  border-left: 5px solid #0369a1;
  border-radius: 14px;
  padding: 1.1rem 1.35rem;
  margin: 1.2rem 0;
}

[data-theme="dark"] .tmm-tldr-box {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(139, 92, 246, 0.1));
  border-color: rgba(56, 189, 248, 0.3);
  border-left-color: #38bdf8;
}

.tmm-tldr-box h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #0369a1;
}

[data-theme="dark"] .tmm-tldr-box h3 {
  color: #7dd3fc;
}

.tmm-sim-card {
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-border);
  border-top: 4px solid #0369a1;
  border-radius: 14px;
  padding: 1.25rem 1.4rem;
  margin: 1.45rem 0;
  box-shadow: 0 6px 20px -10px rgba(15, 23, 42, 0.16);
}

.tmm-sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin: 0.85rem 0;
}

.tmm-sim-control label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.tmm-sim-control input[type="range"] {
  width: 100%;
  accent-color: #0369a1;
}

[data-theme="dark"] .tmm-sim-control input[type="range"] {
  accent-color: #38bdf8;
}

.tmm-sim-readout {
  background: #0b1120;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  font-size: 0.86rem;
  line-height: 1.6;
  margin-top: 0.75rem;
}

.tmm-microcheck {
  background: var(--tmm-surface-2);
  border: 1px solid rgba(4, 120, 87, 0.32);
  border-left: 4px solid #047857;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
}

[data-theme="dark"] .tmm-microcheck {
  border-color: rgba(52, 211, 153, 0.35);
  border-left-color: #34d399;
}

.tmm-mc-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.tmm-mc-btn {
  padding: 0.42rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--tmm-border);
  background: var(--tmm-surface);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tmm-mc-btn:hover {
  border-color: var(--tmm-accent);
}

.tmm-mc-btn.is-correct {
  background: #065f46;
  border-color: #059669;
  color: #ffffff;
}

.tmm-mc-btn.is-wrong {
  background: #991b1b;
  border-color: #dc2626;
  color: #ffffff;
}

.tmm-mc-fb {
  margin-top: 0.55rem;
  font-size: 0.84rem;
  line-height: 1.55;
  display: none;
}

.tmm-worked-box {
  background: var(--tmm-surface-2);
  border: 1px solid rgba(109, 40, 217, 0.28);
  border-left: 4px solid #6d28d9;
  border-radius: 12px;
  padding: 1.05rem 1.25rem;
  margin: 1.2rem 0;
}

[data-theme="dark"] .tmm-worked-box {
  border-color: rgba(167, 139, 250, 0.32);
  border-left-color: #a78bfa;
}

.tmm-pitfall-box {
  background: rgba(185, 28, 28, 0.06);
  border: 1px solid rgba(185, 28, 28, 0.3);
  border-left: 4px solid #b91c1c;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.2rem 0;
}

[data-theme="dark"] .tmm-pitfall-box {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(248, 113, 113, 0.32);
  border-left-color: #f87171;
}

.tmm-qa-box details {
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-border);
  border-radius: 10px;
  padding: 0.72rem 1rem;
  margin-bottom: 0.55rem;
}

.tmm-qa-box summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
}

.tmm-bridge-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.85rem 1.1rem;
  margin: 1.35rem 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(3, 105, 161, 0.08));
  border: 1px solid rgba(3, 105, 161, 0.25);
  font-size: 0.84rem;
}

.tmm-bridge-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.68rem;
  border-radius: 999px;
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-accent);
  color: var(--tmm-accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.8rem;
}

.tmm-bridge-link:hover {
  background: #0369a1;
  color: #ffffff;
}

/* Mobile 390px strict responsive guard */
@media (max-width: 768px) {
  .navbar .nav-container {
    flex-wrap: wrap !important;
    gap: 0.45rem !important;
    padding: 0.55rem 0.75rem !important;
  }
  .navbar .nav-links {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    width: 100% !important;
    overflow-x: visible !important;
  }
  .navbar .nav-links a {
    font-size: 0.78rem !important;
    padding: 0.28rem 0.52rem !important;
  }
  .tmm-module-strip {
    padding: 0.4rem 0.5rem;
    gap: 0.32rem;
  }
  .tmm-strip-pill {
    font-size: 0.72rem;
    padding: 0.24rem 0.52rem;
  }
  .table-responsive,
  pre,
  .code-block,
  .gui-window {
    max-width: 100% !important;
    overflow-x: auto !important;
  }
  .tmm-ped-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Focus Mode & Floating Tools (tmm-focus-nav.js) */
body.tmm-focus-mode .tmm-module-strip,
body.tmm-focus-mode .book-toc,
body.tmm-focus-mode .Quick-nav {
  display: none !important;
}

body.tmm-focus-mode main,
body.tmm-focus-mode .container,
body.tmm-focus-mode .book-layout {
  max-width: 920px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* ==========================================================================
   GATE-1 SURGICAL LAYOUT, MOBILE 390px & WCAG AA PERFECTION LAYER
   ========================================================================== */

/* 1. Eliminate ALL Grid min-width:auto blowout & Mobile 390px overflow (trainer, amber, qmmm, alphafold) */
.step-item,
.step-item > *,
.step-content,
.grid-2,
.grid-2 > *,
.equation-table-wrap,
.gui-window,
.terminal-window,
.code-block-wrap,
.code-block {
  min-width: 0 !important;
  max-width: 100% !important;
}

.equation-table-wrap {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.25rem;
}

/* 2. Fix tmm-qmmm.html .step-item (badge + content) & <pre> overflow */
.step-item:has(> .step-badge) {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) !important;
  gap: 1rem !important;
  align-items: start !important;
}

.step-content pre,
.code-block pre {
  overflow-x: auto !important;
  max-width: 100% !important;
  white-space: pre !important;
  box-sizing: border-box !important;
}

@media (max-width: 820px) {
  .step-item,
  .step-item:has(> .step-badge),
  .grid-2 {
    grid-template-columns: 1fr !important;
  }
}

/* 3. Justified centered hero subtitle/lead across all TMM pages */
.hero .hero-lead,
.hero .subtitle,
section.hero p.hero-lead,
section.hero p.subtitle {
  max-width: 820px;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: center !important;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* 4. Frame wide dual portrait Ken Thompson & Dennis Ritchie without slicing faces */
img[src*="tmm_thompson_ritchie"] {
  object-fit: contain !important;
  object-position: center center !important;
  background: #0b1120 !important;
}

/* 5. Fix tmm.html M0 primary CTA button (#5b21b6 on #7c3aed -> #ffffff on #5b21b6 = 8.9:1!) */
#tmm-history-m0 a.btn.btn-primary,
#tmm-history-m0 a.btn-primary,
a.btn-primary[style*="#7c3aed"] {
  background: #5b21b6 !important;
  color: #ffffff !important;
  border-color: #5b21b6 !important;
}

[data-theme="dark"] #tmm-history-m0 a.btn.btn-primary,
[data-theme="dark"] #tmm-history-m0 a.btn-primary {
  background: #6d28d9 !important;
  color: #ffffff !important;
  border-color: #a78bfa !important;
}

/* 6. Fix tmm-block0.html & tmm.html Dark Mode gallery h3 (#7c3aed -> #c4b5fd) & callout headers */
[data-theme="dark"] #tmm-history-m0 h3,
[data-theme="dark"] [id^="era-"] h3,
[data-theme="dark"] .hist-section h3,
[data-theme="dark"] h3[style*="#7c3aed"] {
  color: #c4b5fd !important;
}

[data-theme="dark"] [style*="color:#b45309"],
[data-theme="dark"] [style*="color: #b45309"] {
  color: #fcd34d !important;
}

[data-theme="dark"] [style*="color:#0284c7"],
[data-theme="dark"] [style*="color: #0284c7"] {
  color: #7dd3fc !important;
}

/* 7. Fix tmm-trainer.html LIGHT MODE contrast collapse (never override dark launchpad .btn-quiz-action!) */
html:not([data-theme="dark"]) a[style*="color:#facc15"]:not(.btn-quiz-action),
html:not([data-theme="dark"]) a[style*="color: #facc15"]:not(.btn-quiz-action),
html:not([data-theme="dark"]) span[style*="color:#facc15"]:not(.gui-body *):not(.terminal-body *):not(.bp-terminal *):not(pre *):not(svg *) {
  color: #92400e !important;
}

/* Ensure Light Mode --accent-sky links in tmm-trainer.html satisfy WCAG AA (>= 5.9:1) */
html:not([data-theme="dark"]) {
  --accent-sky: #0369a1;
}
html:not([data-theme="dark"]) a[style*="--accent-sky"] {
  color: #0369a1 !important;
}

/* Keep dark sandbox buttons/tables inside dark panels strictly dark-surface with bright text! */
.gui-window .btn-quiz-action,
.terminal-window .btn-quiz-action,
[style*="background:#0b1120"] .btn-quiz-action,
[style*="background:#090d16"] .btn-quiz-action,
[style*="background: #0b1120"] .btn-quiz-action,
[style*="background: #090d16"] .btn-quiz-action,
[style*="background:#0f172a"] .btn-quiz-action {
  background: #1e293b !important;
  color: #f8fafc !important;
  border-color: #38bdf8 !important;
}

.gui-window table,
.gui-window table td,
.gui-window table th,
.terminal-window table,
.terminal-window table td,
.terminal-window table th {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}

.gui-window table tr:hover td,
.gui-window table tr[style*="rgba(16,185,129"] td,
.gui-window table tr[style*="rgba(56,189,248"] td {
  background-color: #132a24 !important;
  color: #ecfdf5 !important;
}

/* Dark sandbox launcher banner heading */
[style*="linear-gradient(135deg, #0f172a"] [style*="color:#0369a1"],
[style*="linear-gradient(135deg, #0f172a"] [style*="color:#38bdf8"],
[style*="background:#0f172a"] [style*="color:#0369a1"] {
  color: #7dd3fc !important;
}

/* Trainer sandbox quick-pill links on light bg (never override dark launchpad .btn-quiz-action!) */
html:not([data-theme="dark"]) .sandbox-nav-pill,
html:not([data-theme="dark"]) a[style*="border-color:#facc15"]:not(.btn-quiz-action),
html:not([data-theme="dark"]) a[style*="border:1px solid #facc15"]:not(.btn-quiz-action) {
  color: #92400e !important;
  background: #fef3c7 !important;
  border-color: #d97706 !important;
}

/* Fix Light Mode table cells with dark-palette inline colors (amber thermostats, trainer tables) */
html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) span[style*="color:#fbbf24"],
html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) td[style*="color:#fbbf24"] {
  color: #92400e !important;
}

html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) span[style*="color:#f87171"],
html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) td[style*="color:#f87171"] {
  color: #b91c1c !important;
}

html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) td[style*="color:#7dd3fc"],
html:not([data-theme="dark"]) table:not(.gui-window table):not(.terminal-window table) span[style*="color:#7dd3fc"] {
  color: #0369a1 !important;
}

/* 8. Fix Green .gui-btn-mock (#10b981 -> #047857 = 5.48:1) & Sky-Blue #0284c7 -> #0369a1 (5.93:1) */
.gui-btn-mock[style*="#10b981"],
.gui-btn-mock[style*="#059669"] {
  background: #047857 !important;
  color: #ffffff !important;
}

.mol3d-btn.active,
#mda-sys-holo.active,
.step-badge,
.gui-menubar span.hl {
  background: #0369a1 !important;
  color: #ffffff !important;
}

.btn-primary {
  background: linear-gradient(135deg, #0369a1, #4f46e5) !important;
  color: #ffffff !important;
}

/* 9. Fix opaque dark figure wrapper in Light Mode (eliminates slate #636875 bleed in Fig 3.3 & Fig 7.1) */
figure.diagram-box,
.diagram-box,
figure[style*="rgba(15,23,42"],
div.diagram-card {
  background: #0b1120 !important;
}

/* 10. Global Light micro-tokens (WCAG AA >= 4.5:1) */
.bia-highlight {
  color: #c2410c !important;
}

[data-theme="dark"] .bia-highlight {
  color: #fb923c !important;
}

.breadcrumb,
.breadcrumb span,
.breadcrumbs,
.breadcrumbs span {
  color: #475569 !important;
}

[data-theme="dark"] .breadcrumb,
[data-theme="dark"] .breadcrumb span,
[data-theme="dark"] .breadcrumbs,
[data-theme="dark"] .breadcrumbs span {
  color: #cbd5e1 !important;
}

html:not([data-theme="dark"]) .portal-tag.orange {
  color: #9a3412 !important;
  background: #ffedd5 !important;
  border-color: #fdba74 !important;
}

html:not([data-theme="dark"]) .book-toc-sub[style*="#d97706"] {
  color: #92400e !important;
}

html:not([data-theme="dark"]) .bp-badge-ok,
html:not([data-theme="dark"]) span[style*="color:#10b981"]:not(.gui-body *):not(.terminal-body *):not(pre *) {
  color: #047857 !important;
}

html:not([data-theme="dark"]) span[style*="color:#ef4444"]:not(.gui-body *):not(.terminal-body *):not(pre *) {
  color: #b91c1c !important;
}

/* 11. Center tmm.html Quick-nav cleanly inside the 1320px .book-layout (no negative-margin left shift!) */
.Quick-nav,
.book-layout > .Quick-nav {
  flex-wrap: wrap !important;
  justify-content: center !important;
  overflow-x: visible !important;
  margin: 0 auto 1.4rem auto !important;
  padding: 0.65rem 0.9rem !important;
  border: 1px solid var(--tmm-border) !important;
  border-radius: 14px !important;
  width: 100% !important;
  max-width: 100% !important;
}

.Quick-nav .btn-primary {
  margin-left: 0 !important;
}

/* Keep ALL 8 top navbar links comfortably visible inside 1320px on Desktop */
@media (min-width: 769px) {
  header.navbar .nav-container {
    gap: 0.45rem !important;
  }
  header.navbar .brand-sub {
    display: none !important;
  }
  header.navbar .bialab-pill {
    padding: 0.24rem 0.52rem !important;
    font-size: 0.74rem !important;
  }
  header.navbar .nav-links {
    gap: 0.14rem !important;
  }
  header.navbar .nav-links a {
    padding: 0.32rem 0.42rem !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
  }
}

/* ==========================================================================
   CYCLE-9 SURGICAL ZERO-DEFECT LAYER (WCAG AA 100% + MOBILE 390px 0px)
   ========================================================================== */

/* A. Fix Cycle-5 Simulator Dark Readouts in Light Mode (style.css strong override -> 1.05:1 fix!) */
.tmm-sim-readout,
.tmm-sim-readout p,
.tmm-sim-readout span,
.tmm-sim-readout div {
  color: #e2e8f0;
}

.tmm-sim-readout strong,
.tmm-sim-readout b,
.tmm-sim-readout sub,
.tmm-sim-readout sup {
  color: #f8fafc !important;
}

.tmm-sim-readout code {
  background: #1e293b !important;
  color: #7dd3fc !important;
  border: 1px solid #334155 !important;
  padding: 0.06rem 0.32rem;
  border-radius: 5px;
}

/* B. Fix Opaque Dark Background on ALL .svg-diagram-card (Fig 3.3, Fig 7.1, etc.) */
.svg-diagram-card {
  background: #0b1120 !important;
  border-color: #334155 !important;
}

.svg-diagram-card .fig-title {
  color: #7dd3fc !important;
}

/* C. Fix .gui-btn-mock #0284c7 (4.10:1) -> #0369a1 (5.93:1) in BOTH Light & Dark Mode */
.gui-btn-mock:not([style*="background"]),
.gui-btn-mock[style*="#0284c7"],
.gui-btn-mock[style*="rgb(2, 132, 199)"] {
  background: #0369a1 !important;
  color: #ffffff !important;
}

/* C2. Brighten Dark Mode active navbar link (#31b2ed on #2c4053 = 4.43:1 -> #7dd3fc = 7.6:1) */
[data-theme="dark"] .navbar .nav-links a.active {
  color: #bae6fd !important;
}

/* C3. Keep Trainer dark sandbox tables/prompts bright even in Light Mode */
.gui-window td[style*="color:#4ade80"],
.terminal-window td[style*="color:#4ade80"],
.gui-body td[style*="color:#4ade80"] {
  color: #4ade80 !important;
}
.gui-window td[style*="color:#38bdf8"],
.terminal-window td[style*="color:#38bdf8"],
.gui-body td[style*="color:#38bdf8"] {
  color: #7dd3fc !important;
}
.terminal-prompt,
span.terminal-prompt[style*="color:#38bdf8"] {
  color: #7dd3fc !important;
}
span.terminal-prompt[style*="color:#4ade80"] {
  color: #4ade80 !important;
}

@media (max-width: 768px) {
  table.data-table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* D. Fix tmm.html TOC numbers & bibliography link contrast */
.toc-num {
  color: #0369a1 !important;
}

[data-theme="dark"] .toc-num {
  color: #38bdf8 !important;
}

.tmm-biblio-toc-link {
  color: #92400e !important;
  font-weight: 700 !important;
}

[data-theme="dark"] .tmm-biblio-toc-link {
  color: #fbbf24 !important;
}

/* E. Fix tmm-trainer.html Light Mode (Launchpad, Nav Pill, Workstation Buttons, Portal Tags) & Dark Mode */
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#38bdf8"] { color: #0369a1 !important; }
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#4ade80"] { color: #047857 !important; }
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#fb923c"] { color: #c2410c !important; }
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#f472b6"] { color: #be185d !important; }
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#facc15"] { color: #92400e !important; }
html:not([data-theme="dark"]) .chapter-nav-pill a[style*="#c084fc"] { color: #6d28d9 !important; }

/* Dark-themed neon action buttons in Trainer Launchpad & Workstations stay crisp dark-surface in Light Mode */
.btn-quiz-action[style*="color:#38bdf8"],
.btn-quiz-action[style*="color:#d8b4fe"],
.btn-quiz-action[style*="color:#34d399"],
.btn-quiz-action[style*="color:#fbbf24"],
.btn-quiz-action[style*="color:#22d3ee"],
.btn-quiz-action[style*="color:#4ade80"],
.btn-quiz-action[style*="color:#fb923c"],
.btn-quiz-action[style*="color:#f472b6"],
.btn-quiz-action[style*="color:#facc15"],
.btn-quiz-action[style*="color:#7dd3fc"],
.btn-quiz-action[style*="color:#e879f9"],
.btn-quiz-action[style*="color:#c084fc"],
.btn-quiz-action[style*="color:#f87171"],
[style*="rgba(15,23,42"] .btn-quiz-action {
  background: #0f172a !important;
}

.btn-quiz-action[style*="color:#"] code {
  background: #1e293b !important;
  color: #f8fafc !important;
}

/* Fix Light Mode .portal-tag pastel inline badges in Trainer */
html:not([data-theme="dark"]) .portal-tag[style*="#38bdf8"] {
  background: #e0f2fe !important;
  color: #0369a1 !important;
  border-color: #7dd3fc !important;
}

html:not([data-theme="dark"]) .portal-tag[style*="#f472b6"] {
  background: #fce7f3 !important;
  color: #9d174d !important;
  border-color: #f9a8d4 !important;
}

html:not([data-theme="dark"]) .portal-tag[style*="#facc15"] {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #fcd34d !important;
}

/* Fix Trainer terminal prompt & dark table header (#64748b on #090d16 -> #94a3b8 = 7.1:1) */
.terminal-prompt {
  color: #38bdf8 !important;
}

.gui-body div[style*="color:#64748b"],
.gui-window div[style*="color:#64748b"] {
  color: #94a3b8 !important;
}

/* F. Fix Pocket Drawer inline code styling */
#tmm-pocket-drawer code {
  background: #1e293b !important;
  color: #7dd3fc !important;
  padding: 0.08rem 0.34rem;
  border-radius: 5px;
  border: 1px solid #334155;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* G. Strict Mobile 390px 0px Overflow Guard across ALL 14 TMM pages */
.katex-mathml {
  max-width: 1px !important;
  width: 1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
}

/* Unified 1320px BIA Learn Textbook Width across ALL 14 TMM pages (exact parity with QM, MD & DVS!) */
header.navbar .nav-container,
.book-layout,
main.page-wrap,
main.container {
  max-width: var(--read-width, 1320px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* Re-assert Focus Mode narrow reading column (920px) cleanly above desktop width rule */
body.tmm-focus-mode main,
body.tmm-focus-mode main.page-wrap,
body.tmm-focus-mode main.container,
body.tmm-focus-mode .book-layout {
  max-width: 920px !important;
}

.study-card,
.study-body,
.study-section,
.card,
.book-main,
.book-layout > *,
.trainer-grid > * {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.study-card,
.card {
  overflow-x: clip;
}

p code,
li code,
td code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.atlas-table-wrap,
.table-wrap,
.table-responsive,
.equation-table-wrap {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.gui-body {
  max-width: 100% !important;
  overflow-x: auto !important;
}

/* Keep wide display equations inside 2-column dark cards completely visible without right clipping */
.grid-2 .katex-display {
  font-size: 0.9em;
  overflow-x: auto !important;
  max-width: 100% !important;
}

@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  main.page-wrap,
  main.container,
  .book-layout,
  .book-main {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  /* CSS Containment prevents Chromium Mobile shrink-to-fit from inflating viewport width on wide tables */
  .study-card,
  .study-section,
  .card {
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    contain: layout paint;
  }
  .study-body,
  .study-body > *,
  .trainer-grid > * {
    max-width: 100% !important;
    min-width: 0 !important;
  }
}

/* ==========================================================================
   CYCLE-10 FINAL WCAG AA ZERO-DEFECT LAYER (100% LIGHT & DARK COMPLIANCE)
   ========================================================================== */
html:not([data-theme="dark"]) .step-badge-inline {
  color: #1e40af !important;
}
html:not([data-theme="dark"]) .step-badge-inline[style*="#0284c7"] {
  color: #0c4a6e !important;
}
html:not([data-theme="dark"]) .toc-featured-top-label {
  color: #0369a1 !important;
}
[data-theme="dark"] .toc-featured-top-label {
  color: #7dd3fc !important;
}

/* Fix tmm-block0.html callout headings, badges & dark-mode code chips */
html:not([data-theme="dark"]) strong[style*="color:#0284c7"],
html:not([data-theme="dark"]) strong[style*="color: #0284c7"] {
  color: #0369a1 !important;
}
html:not([data-theme="dark"]) span[style*="color:#0369a1"][style*="rgba(2,132,199"] {
  color: #075985 !important;
}
html:not([data-theme="dark"]) strong[style*="color:#b45309"],
html:not([data-theme="dark"]) strong[style*="color: #b45309"] {
  color: #92400e !important;
}
[data-theme="dark"] div[style*="rgba(2,132,199"] code {
  color: #e0f2fe !important;
  background: rgba(15, 23, 42, 0.7) !important;
}

/* Ensure all primary quiz/action gradients start at AA-safe #0369a1 (>= 5.93:1 with #fff) */
.btn-quiz-action.primary,
.step-dot.current,
.sec-num {
  background: linear-gradient(135deg, #0369a1, #4f46e5) !important;
  color: #ffffff !important;
}

.btn-primary code,
a.btn-primary code {
  background: rgba(15, 23, 42, 0.38) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
}

/* Bloom Taxonomy badge on quiz cards */
.tmm-bloom-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

[data-theme="dark"] .tmm-bloom-pill {
  background: #2e1065;
  color: #ede9fe;
  border-color: #a78bfa;
}

.terminal-topbar,
.terminal-topbar > div,
.terminal-input-row,
.gui-menubar {
  flex-wrap: wrap !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.terminal-input {
  min-width: 0 !important;
  flex: 1 1 120px !important;
  max-width: 100% !important;
}

@media (max-width: 960px) {
  .trainer-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  #pymol-scene-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* H. Compact #tmm-float-dock on narrow mobile so it NEVER collides with ≡ Secções + ↑ */
@media (max-width: 640px) {
  #tmm-float-dock {
    bottom: 0.55rem !important;
    left: 0.55rem !important;
    gap: 0.3rem !important;
    flex-wrap: nowrap !important;
    max-width: calc(100vw - 155px) !important;
  }
  #tmm-float-dock button {
    padding: 0.36rem 0.58rem !important;
    font-size: 0.76rem !important;
  }
  #tmm-pocket-btn .lang-pt,
  #tmm-pocket-btn .lang-en,
  #tmm-focus-btn .lang-pt,
  #tmm-focus-btn .lang-en,
  #tmm-prog-pill {
    display: none !important;
  }
}

/* I. Hub Progress Dashboard, Learning Tracks & Interactive Glossary (tmm.html) */
.tmm-hub-progress-card {
  background: var(--tmm-surface-2);
  border: 1px solid var(--tmm-border);
  border-left: 5px solid #0369a1;
  border-radius: 14px;
  padding: 1.05rem 1.35rem;
  margin: 1.25rem 0;
}

[data-theme="dark"] .tmm-hub-progress-card {
  border-left-color: #38bdf8;
}

.tmm-prog-track {
  width: 100%;
  height: 11px;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.55rem;
}

#tmm-hub-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0369a1, #059669);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.tmm-tracks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
  gap: 1rem;
  margin: 1.1rem 0;
}

.tmm-track-card {
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-border);
  border-top: 4px solid #0369a1;
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tmm-track-card.track-dd { border-top-color: #047857; }
.tmm-track-card.track-enz { border-top-color: #6d28d9; }
.tmm-track-card.track-hpc { border-top-color: #b45309; }

.tmm-track-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.tmm-track-step {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.45);
  text-decoration: none;
}

.tmm-track-step:hover {
  background: #0369a1;
  color: #ffffff;
  border-color: #0369a1;
}

[data-theme="dark"] .tmm-track-step {
  background: #17233b;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.3);
}

[data-theme="dark"] .tmm-track-step:hover {
  background: #0369a1;
  color: #ffffff;
  border-color: #38bdf8;
}

.tmm-gloss-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0.85rem 0 1rem;
}

.tmm-gloss-search {
  flex: 1 1 240px;
  padding: 0.52rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--tmm-border);
  background: var(--tmm-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.tmm-gloss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 0.8rem;
}

.tmm-gloss-item {
  background: var(--tmm-surface);
  border: 1px solid var(--tmm-border);
  border-left: 4px solid #0369a1;
  border-radius: 11px;
  padding: 0.85rem 1rem;
}

.tmm-gloss-item h4 {
  margin: 0 0 0.32rem;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.tmm-gloss-item p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.52;
  color: var(--text-secondary);
}

.tmm-gloss-mod {
  display: inline-block;
  margin-top: 0.42rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0369a1;
  text-decoration: none;
}

[data-theme="dark"] .tmm-gloss-mod {
  color: #7dd3fc;
}

/* ==========================================================================
   TMM GLOBAL TEXTBOOK PROSE JUSTIFICATION (ALL 14 TMM PAGES — PT / BR / EN)
   ========================================================================== */
.book-layout p,
.book-layout li,
.book-chapter-section p,
.book-chapter-section li,
.book-subcard p,
.book-subcard li,
.study-section p,
.study-section li,
.study-body p,
.study-body li,
.study-card p,
.study-card li,
.step-item p,
.step-item li,
.step-walkthrough p,
.step-walkthrough li,
.portal-card p,
.hist-card p,
.tmm-hist-desc,
.m0-card p,
.m0-card li,
.callout,
.callout p,
.callout li,
.read-aloud-box,
.read-aloud-box p,
.analogy-box,
.analogy-box p,
.real-world-box,
.real-world-box p,
.key-message-box p,
.key-message-box li,
.worked-step,
.worked-step p,
.tmm-ped-box,
.tmm-ped-box p,
.tmm-ped-box li,
.tmm-ped-text,
.tmm-worked-box,
.tmm-worked-box p,
.tmm-worked-box li,
.tmm-pitfall-box,
.tmm-pitfall-box p,
.tmm-pitfall-box li,
.tmm-tldr-box p,
.tmm-tldr-box li,
.tmm-mc-fb,
.tmm-track-card p,
.tmm-gloss-item p,
.tmm-sim-card p,
.tmm-sim-card li,
.quiz-section p,
.card p,
.card li,
.bp-soft-card p,
.bp-fe-content p,
.bp-storage-pane p,
main p,
main li,
main.container p,
main.container li,
figcaption {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Centered multi-line hero introductions: justified full lines, centered final line */
.hero .subtitle,
.hero .hero-lead,
.hero .hero-subtitle,
.m0-hero p {
  text-align: justify !important;
  text-justify: inter-word !important;
  text-align-last: center !important;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.hero.tmm-bp-hero .hero-lead {
  text-align-last: left !important;
}

/* Protect code blocks, terminals, GUI mockups, tables, equations, badges, nav & footers */
pre,
pre *,
code,
.terminal-window,
.terminal-window *,
.gui-window,
.gui-window *,
.bp-terminal,
.bp-terminal *,
.tmm-sim-readout,
.tmm-sim-readout *,
.tmm-mc-btn,
.quiz-option,
table,
table th,
table td,
table p,
table li,
.nav-links,
.nav-links li,
.book-toc li,
.Quick-nav,
.Quick-nav *,
.tmm-module-strip,
.tmm-module-strip * {
  hyphens: none;
  -webkit-hyphens: none;
}

table th,
table td,
table p,
table li,
.terminal-window,
.terminal-window *,
.gui-window,
.gui-window *,
.bp-terminal,
.bp-terminal *,
.tmm-mc-btn,
.quiz-option,
.book-toc li,
.nav-links li {
  text-align: left !important;
  text-align-last: auto !important;
}

.formula-box,
.formula-box p,
.fig-title,
footer p,
.site-footer p {
  text-align: center !important;
  text-align-last: center !important;
  hyphens: none !important;
  -webkit-hyphens: none !important;
}
