/* ============================================================================
   BIA Learn — Quantum Mechanics Course UX, Focus Mode, Mobile Zero-Overflow,
   Personalized Tracks, Biochemical Spotlights & Unified Studio Footer (v2.0)
   ============================================================================ */

/* 1. GLOBAL ZERO-OVERFLOW & MOBILE SAFETY (390px+ GUARANTEED, VERTICAL SCROLL + STICKY PRESERVED) */
html {
  max-width: 100%;
  overflow-y: auto;
}

body {
  max-width: 100%;
  overflow-x: clip;
}

section[id^="ch"],
section[id^="sec-"],
.study-body,
.chapter-section,
.book-chapter,
.qm-lab-card,
.qm-widget,
.textbook-pedagogy-panel,
.hero {
  max-width: 100%;
  box-sizing: border-box;
}

.book-layout,
.container,
main.container {
  width: 100%;
  max-width: var(--read-width, 1320px);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.hero-content {
  width: 100%;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

section[id^="ch"],
section[id^="sec-"],
.hero,
.qm-hub-dashboard,
.qm-luso-bridge,
.studio-footer {
  overflow-x: clip;
}

.katex-mathml {
  width: 1px !important;
  max-width: 1px !important;
  overflow: hidden !important;
}

select,
input[type="text"],
input[type="search"],
textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.book-layout img,
.book-chapter img,
.study-body img,
.qm-figure-card img,
figure img {
  max-width: 100%;
  height: auto !important;
  max-height: none !important;
  object-fit: contain !important;
}


/* Preserve crisp aspect ratios on pioneer portraits (never stretch circles into ovals) */
.textbook-pedagogy-panel img {
  width: 54px !important;
  height: 54px !important;
  object-fit: cover !important;
  object-position: center 20% !important;
}
.qm-giant-mini-img,
.bio-portrait-img,
.pioneer-photo,
.m0-pioneer-img {
  height: 100% !important;
  object-fit: cover !important;
  object-position: center 18% !important;
}

.book-layout figure img,
.qm-figure-card img {
  cursor: zoom-in;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.book-layout figure img:hover,
.qm-figure-card img:hover {
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

.book-layout svg,
.book-chapter svg,
.qm-widget svg,
.qm-lab-card svg,
.book-layout canvas,
.qm-widget canvas {
  max-width: 100%;
  height: auto;
}

.book-layout pre,
.book-chapter pre,
.study-body pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* KaTeX Display Math Scroll Safety on Narrow Screens */
.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0.1rem 0.45rem;
  -webkit-overflow-scrolling: touch;
}

.katex-display > .katex {
  white-space: nowrap;
}

/* Responsive Scroll Wrapper for All Tables */
.qm-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: 10px;
}

.qm-table-scroll > table {
  margin: 0 !important;
  min-width: 100%;
}

/* Fallback if a table is not yet wrapped */
.book-layout table,
.study-body table,
.container table {
  max-width: 100%;
}

/* 2. UNIFIED SLEEK TOP NAVBAR REFINEMENTS */
header.navbar {
  position: sticky;
  top: 0;
  z-index: 950;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

header.navbar .nav-container {
  max-width: 1320px;
  gap: 0.55rem;
}

header.navbar .nav-links {
  gap: 0.16rem;
  flex-wrap: nowrap;
}

header.navbar .nav-links a {
  white-space: nowrap;
  font-size: 0.81rem;
  padding: 0.32rem 0.52rem;
  border-radius: 8px;
}

/* 3. STICKY CHAPTER / SECTION FOCUS SWITCHER BAR */
body[data-qm-focus-active="1"] nav.Quick-nav,
body[data-qm-focus-active="1"] .Quick-nav,
body[data-qm-focus-active="1"] .chapter-pager {
  display: none !important;
}

.qm-focus-bar {
  position: sticky;
  top: 66px;
  z-index: 820;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 16px;
  padding: 0.8rem 1rem;
  margin: 0 auto 1.4rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

html[data-theme="dark"] .qm-focus-bar {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(71, 85, 105, 0.55);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
}

.qm-focus-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.qm-focus-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.qm-ch-pill {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(248, 250, 252, 0.95);
  color: #1e293b;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.2;
}

html[data-theme="dark"] .qm-ch-pill {
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.45);
}

.qm-ch-pill:hover {
  border-color: #2563eb;
  color: #2563eb;
  transform: translateY(-1px);
}

html[data-theme="dark"] .qm-ch-pill:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.qm-ch-pill.is-active {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  color: #ffffff !important;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
}

.qm-ch-pill.is-done::after {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #10b981;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
}

.qm-ch-pill.is-active.is-done::after {
  background: rgba(255, 255, 255, 0.25);
}

.qm-focus-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.qm-mode-toggle {
  appearance: none;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
  color: #4f46e5;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

html[data-theme="dark"] .qm-mode-toggle {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(129, 140, 248, 0.4);
}

.qm-mode-toggle:hover {
  background: rgba(99, 102, 241, 0.18);
}

.qm-progress-mini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #475569;
}

html[data-theme="dark"] .qm-progress-mini {
  color: #94a3b8;
}

.qm-progress-track {
  flex: 1;
  min-width: 90px;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  overflow: hidden;
}

.qm-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #10b981);
  transition: width 0.35s ease;
}

/* Hidden non-active chapters in Focus Mode */
.qm-focus-hidden {
  display: none !important;
}

/* 4. BOTTOM-OF-CHAPTER MASTERY & PREV/NEXT PAGER */
.qm-ch-pager {
  margin: 2.25rem 0 1.25rem;
  padding: 1.25rem 1.35rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.07), rgba(16, 185, 129, 0.06));
  border: 1px solid rgba(14, 165, 233, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

html[data-theme="dark"] .qm-ch-pager {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.09));
  border-color: rgba(56, 189, 248, 0.28);
}

.qm-ch-pager-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.qm-complete-btn {
  appearance: none;
  border: 1.5px solid #10b981;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 0.56rem 1.05rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

html[data-theme="dark"] .qm-complete-btn {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.15);
}

.qm-complete-btn.is-done {
  background: #10b981;
  color: #ffffff !important;
  border-color: #10b981;
}

.qm-ch-pager-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.qm-pager-card {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.9rem 1.05rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.34);
  text-decoration: none;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  font-family: inherit;
}

html[data-theme="dark"] .qm-pager-card {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(71, 85, 105, 0.55);
  color: #f1f5f9;
}

.qm-pager-card:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.14);
}

.qm-pager-card.is-next {
  text-align: right;
  border-color: rgba(37, 99, 235, 0.35);
}

.qm-pager-dir {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0284c7;
}

html[data-theme="dark"] .qm-pager-dir {
  color: #38bdf8;
}

.qm-pager-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
}

/* 5. COLLAPSIBLE BLOCK PEDAGOGY ACCORDION */
.qm-pedagogy-accordion {
  margin: 0 0 1.4rem;
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.28);
  background: rgba(248, 250, 252, 0.88);
  overflow: hidden;
}

html[data-theme="dark"] .qm-pedagogy-accordion {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(129, 140, 248, 0.32);
}

.qm-pedagogy-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.95rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 0.94rem;
  color: #312e81;
  user-select: none;
}

html[data-theme="dark"] .qm-pedagogy-accordion > summary {
  color: #c7d2fe;
}

.qm-pedagogy-accordion > summary::-webkit-details-marker {
  display: none;
}

.qm-pedagogy-accordion > summary::after {
  content: "▾";
  font-size: 1rem;
  transition: transform 0.2s ease;
  opacity: 0.75;
}

.qm-pedagogy-accordion[open] > summary::after {
  transform: rotate(180deg);
}

.qm-pedagogy-accordion .textbook-pedagogy-panel {
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  border-top: 1px solid rgba(148, 163, 184, 0.25) !important;
}

/* 6. BIOCHEMICAL & DRUG DISCOVERY SPOTLIGHT BOXES */
.qm-bio-spotlight {
  margin: 1.6rem 0;
  padding: 1.25rem 1.45rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(6, 182, 212, 0.06));
  border: 1px solid rgba(16, 185, 129, 0.32);
  border-left: 5px solid #059669;
}

html[data-theme="dark"] .qm-bio-spotlight {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), rgba(6, 182, 212, 0.09));
  border-color: rgba(52, 211, 153, 0.35);
  border-left-color: #10b981;
}

.qm-bio-spotlight-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #047857;
}

html[data-theme="dark"] .qm-bio-spotlight-head {
  color: #34d399;
}

.qm-bio-spotlight h4 {
  margin: 0 0 0.55rem;
  font-size: 1.04rem;
  font-weight: 800;
  color: #0f172a;
}

html[data-theme="dark"] .qm-bio-spotlight h4 {
  color: #f8fafc;
}

.qm-bio-spotlight p {
  margin: 0 0 0.55rem;
  font-size: 0.94rem;
  line-height: 1.68;
  text-align: justify;
}

.qm-bio-spotlight p:last-child {
  margin-bottom: 0;
}

/* 7. GUIDED INDIVIDUAL EXPERIMENTATION CHALLENGE BOX */
.qm-challenge-box {
  margin: 1rem 0 1.25rem;
  padding: 0.95rem 1.15rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.09), rgba(139, 92, 246, 0.07));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid #d97706;
}

html[data-theme="dark"] .qm-challenge-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.13), rgba(139, 92, 246, 0.11));
  border-color: rgba(251, 191, 36, 0.35);
}

.qm-challenge-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b45309;
  margin-bottom: 0.38rem;
}

html[data-theme="dark"] .qm-challenge-title {
  color: #fbbf24;
}

.qm-challenge-box p {
  margin: 0;
  font-size: 0.89rem;
  line-height: 1.58;
}

/* 8. COURSE HUB: PERSONALIZED TRACKS, LIVE PROGRESS & LUSOPHONE BRIDGE */
.qm-hub-dashboard {
  max-width: 1180px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.qm-hub-progress-card {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(14, 165, 233, 0.28);
  border-radius: 18px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.1rem;
}

html[data-theme="dark"] .qm-hub-progress-card {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.13), rgba(16, 185, 129, 0.1));
  border-color: rgba(56, 189, 248, 0.3);
}

.qm-hub-progress-left {
  flex: 1 1 320px;
}

.qm-hub-progress-title {
  font-size: 0.96rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.qm-tracks-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.qm-track-card {
  border-radius: 16px;
  padding: 1.2rem 1.25rem;
  background: var(--bg-secondary, #ffffff);
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

html[data-theme="dark"] .qm-track-card {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(71, 85, 105, 0.5);
}

.qm-track-card:hover,
.qm-track-card.is-selected {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.14);
}

.qm-track-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.24rem 0.66rem;
  border-radius: 999px;
}

.qm-track-badge.is-t1 { background: rgba(14, 165, 233, 0.14); color: #0369a1; }
.qm-track-badge.is-t2 { background: rgba(16, 185, 129, 0.15); color: #047857; }
.qm-track-badge.is-t3 { background: rgba(124, 58, 237, 0.14); color: #6d28d9; }

html[data-theme="dark"] .qm-track-badge.is-t1 { background: rgba(56, 189, 248, 0.18); color: #7dd3fc !important; }
html[data-theme="dark"] .qm-track-badge.is-t2 { background: rgba(52, 211, 153, 0.18); color: #6ee7b7 !important; }
html[data-theme="dark"] .qm-track-badge.is-t3 { background: rgba(167, 139, 250, 0.2); color: #ddd6fe !important; }

.qm-track-link {
  font-weight: 800;
  text-decoration: none;
}
.qm-track-link.is-t1 { color: #0284c7; }
.qm-track-link.is-t2 { color: #047857; }
.qm-track-link.is-t3 { color: #6d28d9; }

html[data-theme="dark"] .qm-track-link.is-t1 { color: #38bdf8 !important; }
html[data-theme="dark"] .qm-track-link.is-t2 { color: #34d399 !important; }
html[data-theme="dark"] .qm-track-link.is-t3 { color: #c4b5fd !important; }

.qm-track-feedback {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.32);
  font-size: 0.86rem;
  font-weight: 700;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
}

html[data-theme="dark"] .qm-track-feedback {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #e0f2fe;
}

.qm-track-feedback.is-visible {
  display: flex;
}

.qm-track-card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.3;
}

.qm-track-card p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-secondary, #475569);
  flex: 1;
}

.qm-track-meta {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.35);
}

.qm-track-highlight {
  outline: 2.5px solid #2563eb !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12) !important;
}

.qm-luso-bridge {
  max-width: 1180px;
  margin: 2rem auto;
  padding: 1.4rem 1.55rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(16, 185, 129, 0.07));
  border: 1px solid rgba(37, 99, 235, 0.24);
}

html[data-theme="dark"] .qm-luso-bridge {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(16, 185, 129, 0.1));
  border-color: rgba(56, 189, 248, 0.28);
}

.qm-luso-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  margin-top: 0.85rem;
}

.qm-luso-table th,
.qm-luso-table td {
  padding: 0.58rem 0.78rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
}

.qm-luso-table th {
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(148, 163, 184, 0.12);
}

/* 9. UNIFIED 3-COLUMN STUDIO FOOTER (MATCHING INDEX.HTML) */
.studio-footer {
  margin-top: 4rem;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 3rem 1.5rem 2rem;
  color: #475569;
}

html[data-theme="dark"] .studio-footer {
  background: #0b1120;
  border-top-color: #1e293b;
  color: #94a3b8;
}

.studio-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.studio-footer-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1.15fr;
  gap: 2.5rem;
  align-items: start;
}

.studio-footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.studio-footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: #0f172a;
  font-size: 1.16rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

html[data-theme="dark"] .studio-footer-logo {
  color: #f8fafc;
}

.studio-footer-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.09);
  border: 1px solid rgba(37, 99, 235, 0.22);
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  width: fit-content;
}

html[data-theme="dark"] .studio-footer-tag {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.3);
}

.studio-footer-desc {
  margin: 0;
  font-size: 0.87rem;
  line-height: 1.65;
  color: #64748b;
  max-width: 370px;
}

html[data-theme="dark"] .studio-footer-desc {
  color: #94a3b8;
}

.studio-footer-col h4 {
  margin: 0 0 0.82rem;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f172a;
}

html[data-theme="dark"] .studio-footer-col h4 {
  color: #e2e8f0;
}

.studio-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
}

.studio-footer-links a {
  color: #475569;
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 500;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

html[data-theme="dark"] .studio-footer-links a {
  color: #94a3b8;
}

.studio-footer-links a:hover {
  color: #2563eb;
}

html[data-theme="dark"] .studio-footer-links a:hover {
  color: #38bdf8;
}

.studio-footer-bottom {
  margin-top: 2.2rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: #64748b;
}

html[data-theme="dark"] .studio-footer-bottom {
  border-top-color: #1e293b;
  color: #94a3b8;
}

.studio-footer-bottom a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

/* 10. IMAGE LIGHTBOX OVERLAY */
.qm-lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  cursor: zoom-out;
}

.qm-lightbox-backdrop.is-open {
  display: flex;
}

.qm-lightbox-inner {
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  cursor: default;
}

.qm-lightbox-inner img {
  max-width: 94vw;
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  background: #0b1120;
}

.qm-lightbox-caption {
  color: #e2e8f0;
  font-size: 0.9rem;
  text-align: center;
  max-width: 900px;
  line-height: 1.45;
}

.qm-lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 11. MOBILE RESPONSIVE BREAKPOINTS (390px STRICT ZERO-OVERFLOW) */
@media (max-width: 900px) {
  .qm-tracks-grid {
    grid-template-columns: 1fr;
  }
  .studio-footer-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }
}

@media (max-width: 768px) {
  header.navbar .nav-container {
    padding: 0.55rem 0.75rem !important;
    flex-wrap: wrap;
    row-gap: 0.45rem;
  }
  header.navbar .bialab-pill {
    display: none !important;
  }
  header.navbar .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  header.navbar .nav-links a {
    font-size: 0.78rem;
    padding: 0.3rem 0.58rem;
    flex: 0 0 auto;
  }
  .hero {
    padding: 1.5rem 0.9rem 1.35rem !important;
  }
  .hero h1 {
    font-size: clamp(1.5rem, 6.5vw, 2.1rem) !important;
    line-height: 1.18 !important;
  }
  .chapter-nav-pill {
    font-size: 0.74rem !important;
    padding: 0.4rem 0.65rem !important;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
    box-sizing: border-box;
  }
  .book-layout,
  .container,
  .qm-hub-dashboard {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  .qm-focus-bar {
    top: 0;
    position: relative;
    padding: 0.7rem 0.75rem;
  }
  .qm-ch-pager-nav {
    grid-template-columns: 1fr;
  }
  .qm-pager-card.is-next {
    text-align: left;
  }
  .textbook-pedagogy-panel,
  .qm-bio-spotlight,
  .qm-luso-bridge {
    padding: 1rem !important;
  }
  .textbook-pedagogy-panel > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .qm-lab-grid,
  .qm-control-grid,
  .qm-readout-grid,
  .dft-grid,
  .dft-visual-grid,
  .dft-ing-grid,
  .atlas-controls,
  .lab-grid {
    grid-template-columns: 1fr !important;
  }
  .dft-visual-grid > *,
  .dft-viz-panel,
  .interactive-box,
  .simulator-card,
  .simulator-canvas-wrapper,
  .qm-lab-widget,
  .book-toc,
  .book-layout > *,
  .container > * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .dft-viz-panel,
  .simulator-canvas-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions a,
  .hero-actions button {
    text-align: center;
    justify-content: center;
  }
}

/* ============================================================================
   12. WORLD-CLASS POLISH: COLLAPSIBLE TOC/HUB ACCORDIONS, 30-SEC TLDR CARDS,
       MID-CHAPTER MICRO-CHECKS, GLOBAL SEARCH (⌘K), QUANTUM UNIT CONVERTER
       & INSTITUTIONAL PRINT STYLESHEET (v3.0)
   ============================================================================ */

/* Collapsible TOC & Hub Accordions (eliminates vertical bloat above Ch. 1) */
.qm-toc-accordion,
.qm-hub-accordion {
  margin: 0 0 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

html[data-theme="dark"] .qm-toc-accordion,
html[data-theme="dark"] .qm-hub-accordion {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(71, 85, 105, 0.52);
}

.qm-toc-accordion > summary,
.qm-hub-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 0.92rem;
  color: #0f172a;
  user-select: none;
}

html[data-theme="dark"] .qm-toc-accordion > summary,
html[data-theme="dark"] .qm-hub-accordion > summary {
  color: #e2e8f0;
}

.qm-toc-accordion > summary::-webkit-details-marker,
.qm-hub-accordion > summary::-webkit-details-marker {
  display: none;
}

.qm-toc-accordion > summary::after,
.qm-hub-accordion > summary::after {
  content: "▾";
  font-size: 1rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.qm-toc-accordion[open] > summary::after,
.qm-hub-accordion[open] > summary::after {
  transform: rotate(180deg);
}

.qm-toc-accordion .book-toc {
  margin: 0 !important;
  border: none !important;
  border-top: 1px solid rgba(148, 163, 184, 0.24) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.qm-hub-accordion-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
}

/* Compact Hero on Block Pages so Chapter 1 starts much higher */
body[data-qm-focus-active="1"] header.hero {
  padding: 1.75rem 1.5rem 1.55rem !important;
}

body[data-qm-focus-active="1"] header.hero .hero-actions {
  display: none !important;
}

/* 30-Second Intuition Card + Classic Pitfall Warning at Top of Every Chapter */
.qm-tldr-card {
  margin: 1.15rem 0 1.5rem;
  padding: 1.15rem 1.35rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.065), rgba(99, 102, 241, 0.055));
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-left: 5px solid #2563eb;
}

html[data-theme="dark"] .qm-tldr-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(99, 102, 241, 0.11));
  border-color: rgba(96, 165, 250, 0.34);
  border-left-color: #38bdf8;
}

.qm-tldr-head {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1d4ed8;
  margin-bottom: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

html[data-theme="dark"] .qm-tldr-head {
  color: #60a5fa;
}

.qm-tldr-list {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  font-size: 0.92rem;
  line-height: 1.56;
}

.qm-tldr-pitfall {
  padding: 0.62rem 0.9rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.11);
  border: 1px solid rgba(245, 158, 11, 0.32);
  font-size: 0.86rem;
  line-height: 1.5;
  color: #92400e;
}

html[data-theme="dark"] .qm-tldr-pitfall {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(251, 191, 36, 0.34);
  color: #fde68a;
}

/* Mid-Chapter Interactive Micro-Check ("Paragem Rápida de Intuição") */
.qm-microcheck {
  margin: 1.65rem 0;
  padding: 1.15rem 1.35rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(14, 165, 233, 0.06));
  border: 1.5px solid rgba(139, 92, 246, 0.32);
}

html[data-theme="dark"] .qm-microcheck {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(14, 165, 233, 0.1));
  border-color: rgba(167, 139, 250, 0.36);
}

.qm-microcheck-badge {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6d28d9;
  margin-bottom: 0.4rem;
}

html[data-theme="dark"] .qm-microcheck-badge {
  color: #c4b5fd;
}

.qm-microcheck-q {
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.52;
  margin: 0 0 0.75rem;
}

.qm-microcheck-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.qm-mc-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.88rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
}

html[data-theme="dark"] .qm-mc-btn {
  background: rgba(15, 23, 42, 0.88);
  color: #f1f5f9;
  border-color: rgba(100, 116, 139, 0.55);
}

.qm-mc-btn:hover {
  border-color: #6366f1;
  transform: translateY(-1px);
}

.qm-mc-btn.is-correct {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}

.qm-mc-btn.is-wrong {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #dc2626 !important;
}

.qm-microcheck-fb {
  display: none;
  margin-top: 0.72rem;
  padding: 0.72rem 0.95rem;
  border-radius: 10px;
  font-size: 0.87rem;
  line-height: 1.56;
  background: rgba(16, 185, 129, 0.11);
  border: 1px solid rgba(16, 185, 129, 0.34);
}

html[data-theme="dark"] .qm-microcheck-fb {
  background: rgba(16, 185, 129, 0.16);
  color: #d1fae5;
}

.qm-microcheck-fb.is-show {
  display: block;
}

/* Navbar Global Search Trigger Pill (⌘K) */
.qm-search-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(148, 163, 184, 0.42);
  background: rgba(248, 250, 252, 0.9);
  color: #334155;
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 700;
  padding: 0.34rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

html[data-theme="dark"] .qm-search-btn {
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  border-color: rgba(100, 116, 139, 0.5);
}

.qm-search-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

html[data-theme="dark"] .qm-search-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.qm-search-kbd {
  font-size: 0.68rem;
  padding: 0.08rem 0.35rem;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.22);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Global Search Modal */
.qm-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9950;
  background: rgba(2, 6, 23, 0.66);
  backdrop-filter: blur(8px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 1rem 1rem;
}

.qm-search-backdrop.is-open {
  display: flex;
}

.qm-search-dialog {
  width: 100%;
  max-width: 660px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 76vh;
}

html[data-theme="dark"] .qm-search-dialog {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.qm-search-input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.qm-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
}

.qm-search-results {
  overflow-y: auto;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.qm-search-item {
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
  padding: 0.68rem 0.85rem;
  border-radius: 11px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: all 0.14s ease;
}

.qm-search-item:hover,
.qm-search-item:focus {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.28);
  outline: none;
}

html[data-theme="dark"] .qm-search-item:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.32);
}

.qm-search-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.qm-search-tag {
  font-size: 0.69rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  white-space: nowrap;
}

html[data-theme="dark"] .qm-search-tag {
  background: rgba(129, 140, 248, 0.2);
  color: #a5b4fc;
}

.qm-search-sub {
  font-size: 0.79rem;
  color: #64748b;
}

html[data-theme="dark"] .qm-search-sub {
  color: #94a3b8;
}

/* Floating Pocket Quantum Unit Converter (bottom-left, symmetric to bia-wayfinder) */
.qm-unit-fab {
  position: fixed;
  left: 18px;
  right: auto;
  bottom: 18px;
  z-index: 940;
  appearance: none;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.81rem;
  font-weight: 800;
  padding: 0.58rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.32);
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.qm-unit-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.38);
}

.qm-unit-popover {
  position: fixed;
  left: 18px;
  right: auto;
  bottom: 68px;
  z-index: 945;
  width: min(360px, calc(100vw - 24px));
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: 0 20px 52px rgba(15, 23, 42, 0.28);
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

html[data-theme="dark"] .qm-unit-popover {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

.qm-unit-popover.is-open {
  display: flex;
}

.qm-unit-row {
  display: grid;
  grid-template-columns: 1fr 122px;
  gap: 0.45rem;
}

.qm-unit-row input,
.qm-unit-row select {
  padding: 0.46rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
}

.qm-unit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.qm-unit-cell {
  padding: 0.42rem 0.58rem;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.11);
  font-size: 0.78rem;
}

.qm-unit-cell strong {
  display: block;
  font-size: 0.86rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: #0284c7;
}

html[data-theme="dark"] .qm-unit-cell strong {
  color: #38bdf8;
}

.qm-unit-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.qm-unit-preset {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.38);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 0.71rem;
  font-weight: 700;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  cursor: pointer;
}

.qm-unit-preset:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* Institutional Print Stylesheet (@media print — clean PDF sebenta export) */
@media print {
  header.navbar,
  .qm-focus-bar,
  .qm-ch-pager,
  .qm-unit-fab,
  .qm-unit-popover,
  .qm-search-backdrop,
  .qm-lightbox-backdrop,
  .qm-toggle-all-help-btn,
  .qm-microcheck-opts,
  .hero-actions,
  .chapter-nav-pill,
  .qm-hub-dashboard,
  .studio-footer-links {
    display: none !important;
  }

  html, body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 11pt !important;
    overflow: visible !important;
  }

  .qm-tldr-card,
  .qm-bio-spotlight,
  .qm-challenge-box,
  figure,
  .formula-box {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
  }

  body::after {
    content: "BIA Learn — Mecânica Quântica | Prof. Sérgio F. Sousa · BIA Lab · Universidade de Coimbra (www.bialearn.com)";
    display: block;
    margin-top: 2rem;
    padding-top: 0.75rem;
    border-top: 1px solid #cbd5e1;
    font-size: 9pt;
    color: #475569;
    text-align: center;
  }
}


/* SURGICAL_MOBILE_ZERO_OVERFLOW_2026 */
.katex-mathml {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  max-width: 1px !important;
  max-height: 1px !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

main.container,
.book-layout {
  width: 100%;
  max-width: var(--read-width, 1320px);
  overflow-x: clip;
}

.book-chapter,
.chapter-section,
.study-body,
article.bio-card,
.interactive-box,
.simulator-card {
  max-width: 100%;
  overflow-x: clip;
}

.formula-box,
.equation-box,
.math-block,
.katex-display {
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  header.navbar {
    max-width: 100vw;
    overflow-x: clip;
  }
  header.navbar .nav-container {
    max-width: 100%;
    overflow-x: clip;
  }
  header.navbar .nav-links {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  header.navbar .nav-links::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 640px) {
  .qm-unit-fab {
    padding: 0;
    width: 42px;
    height: 42px;
    justify-content: center;
    border-radius: 50%;
    left: 12px;
    bottom: 12px;
    font-size: 1.05rem;
  }
  .qm-unit-fab .lang-pt,
  .qm-unit-fab .lang-en {
    display: none !important;
  }
}


/* PHASE2_UX_DARK_MOBILE_PRECISION_2026 */
/* 1. Fix Dark Mode active Focus/Atlas/Giants tab specificity (beats html[data-theme="dark"] .qm-ch-pill!) */
html[data-theme="dark"] .qm-ch-pill.is-active,
[data-theme="dark"] .qm-ch-pill.is-active {
  background: linear-gradient(135deg, #0369a1, #1d4ed8) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45) !important;
}

/* 2. Prevent sticky navbar (64px) + sticky focus bar (~96px) from occluding anchored targets */
section[id],
article[id],
h2[id],
h3[id],
h4[id],
div[id^="ch"],
div[id^="sec-"],
.book-chapter-section[id],
.book-subcard[id],
.interactive-box[id],
.simulator-card[id],
.bio-card[id] {
  scroll-margin-top: 176px;
}

/* 3. Improve Dark Mode sub-AA badge & bibliography publisher pill contrast */
html[data-theme="dark"] .bio-portrait-nobel,
html[data-theme="dark"] .pioneer-nobel-badge,
html[data-theme="dark"] [id*="synthesis"] [style*="b45309"] {
  color: #fbbf24 !important;
}
html[data-theme="dark"] #ponte-lusofona [style*="047857"],
html[data-theme="dark"] .qm-luso-bridge [style*="047857"] {
  color: #34d399 !important;
}
html[data-theme="dark"] #b1-phase-label {
  color: #a78bfa !important;
}
html[data-theme="dark"] .bib-card span[style*="#f0f9ff"],
html[data-theme="dark"] #bib-accordion span[style*="#f0f9ff"],
html[data-theme="dark"] details span[style*="background:#f0f9ff"] {
  background: rgba(56, 189, 248, 0.16) !important;
  color: #7dd3fc !important;
  border-color: rgba(56, 189, 248, 0.35) !important;
}

/* 4. Fix squished oval pills in qm-labs.html directory table */
#labs-dir-tbody .badge,
#labs-dir-tbody .qm-review-pill,
#labs-dir-tbody span[style*="border-radius:999px"],
#labs-dir-tbody span[style*="border-radius: 999px"] {
  white-space: nowrap;
  display: inline-block;
  border-radius: 8px !important;
}

/* 5. Give footer subtle bottom breathing room so #qm-unit-fab never obscures copyright text */
.studio-footer {
  padding-bottom: 4.5rem;
}

/* 6. Prevent 'Expandir / Recolher' summary toggle from wrapping awkwardly onto 3 lines */
.qm-toc-accordion > summary > span:last-child,
details.book-toc-details > summary > span:last-child,
details > summary span[style*="font-size"] {
  white-space: nowrap;
  flex-shrink: 0;
}

/* 7. Mobile (<= 640px): Full-width .qm-tldr-card (no 92px dead left margin!), hide desktop ⌘K chip, better touch targets */
@media (max-width: 640px) {
  .section-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.65rem !important;
  }
  .section-header > div {
    width: 100% !important;
    max-width: 100% !important;
  }
  .qm-tldr-card {
    width: 100% !important;
    margin-left: 0 !important;
    box-sizing: border-box !important;
  }
  .qm-search-kbd {
    display: none !important;
  }
  header.navbar .nav-links a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
  .qm-unit-fab {
    opacity: 0.92;
  }
}


/* === FINAL WCAG 2.1 AA CONTRAST HARDENING (DARK + LIGHT) === */
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#2563eb"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="37, 99, 235"] { color: #60a5fa !important; }
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#dc2626"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="220, 38, 38"] { color: #f87171 !important; }
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#7c3aed"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="124, 58, 237"] { color: #c4b5fd !important; }
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#059669"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="5, 150, 105"] { color: #34d399 !important; }
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#0d9488"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="13, 148, 136"] { color: #2dd4bf !important; }
html[data-theme="dark"] .qm-readout-card .ro-val[style*="#d97706"],
html[data-theme="dark"] .qm-readout-card .ro-val[style*="217, 119, 6"] { color: #fbbf24 !important; }

html:not([data-theme="dark"]) .qm-review-pill { color: #0369a1 !important; }
html:not([data-theme="dark"]) .qm-track-link.is-t1 { color: #0369a1 !important; }
html:not([data-theme="dark"]) .qm-track-badge.is-t2 { color: #065f46 !important; }
html:not([data-theme="dark"]) .qm-complete-btn:not(.is-done) { color: #065f46 !important; }
html:not([data-theme="dark"]) .qm-complete-btn.is-done { background: #047857 !important; border-color: #047857 !important; color: #ffffff !important; }
html:not([data-theme="dark"]) .bio-portrait-nobel { color: #92400e !important; }
html:not([data-theme="dark"]) .studio-footer-tag { color: #334155 !important; }
