/* ==========================================================================
   Physique Première Spécialité (BAC Français) — Light Theme Stylesheet
   Mobile-First & Container-Responsive Architecture
   ========================================================================== */

:root {
  color-scheme: light;

  /* Light Theme Palette (High Contrast & Academic Clarity) */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-tint: #eff6ff;
  --bg-tint-strong: #dbeafe;
  --bg-canvas: #ffffff;
  --bg-canvas-grid: #e2e8f0;

  /* Typography Colors (>= 4.5:1 contrast on light surfaces) */
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  /* Brand & Semantic Accents */
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #3b82f6;
  --indigo: #4338ca;
  --accent-red: #dc2626;
  --accent-red-bg: #fef2f2;
  --accent-green: #059669;
  --accent-green-bg: #ecfdf5;
  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;

  /* Borders & UI Component Boundaries (>= 3:1 contrast where interactive) */
  --border-subtle: #e2e8f0;
  --border-strong: #94a3b8;
  --border-focus: #1d4ed8;

  /* Elevation & Layout */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 285px;
  --topbar-height: 60px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  max-inline-size: 100dvw;
  overflow-x: clip;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  text-align: start;
  overflow-wrap: break-word;
  max-inline-size: 100dvw;
  overflow-x: clip;
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

body.drawer-open {
  overflow: hidden;
}

h1,
h2,
h3,
th {
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
  max-inline-size: 80ch;
}

/* ==========================================================================
   Top Navigation Bar
   ========================================================================== */
.site-topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 200;
  inline-size: 100%;
  max-inline-size: 100dvw;
  overflow-x: clip;
  min-block-size: var(--topbar-height);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-inline: clamp(0.75rem, 3vw, 2rem);
  padding-block: 0.45rem;
  gap: 0.75rem;
}

.topbar-brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-inline-size: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: clamp(0.98rem, 0.9rem + 0.35vw, 1.18rem);
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  flex-shrink: 0;
}

.brand-title {
  display: block;
  white-space: nowrap;
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.brand-title .brand-accent {
  color: #2563eb;
}

.brand-title .brand-tld {
  color: #dc2626;
  font-size: 0.78em;
  font-weight: 800;
}

.brand-icon {
  inline-size: 38px;
  block-size: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f172a, #1e3a8a, #2563eb);
  border: 1px solid #1e3a8a;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.24);
  flex-shrink: 0;
  overflow: hidden;
}

.brand-icon svg {
  inline-size: 100%;
  block-size: 100%;
  display: block;
}

.brand-subtitle {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.15;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar-nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 40px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.topbar-link:hover,
.topbar-link.active {
  color: var(--primary);
  background: var(--bg-tint);
  border-color: #bfdbfe;
}

.menu-toggle-btn,
.mobile-only-link {
  display: none;
}

.menu-toggle-btn {
  min-block-size: 42px;
  background: var(--bg-tint);
  border: 1px solid #93c5fd;
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==========================================================================
   Main App Layout (Sidebar + Backdrop + Content Area)
   ========================================================================== */
.app-shell {
  display: flex;
  flex: 1;
  max-inline-size: 1440px;
  inline-size: 100%;
  margin-inline: auto;
  position: relative;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 240;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}

.chapter-sidebar {
  inline-size: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-subtle);
  padding: 1.15rem 0.9rem;
  position: sticky;
  inset-block-start: var(--topbar-height);
  block-size: calc(100dvh - var(--topbar-height));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-block-end: 0.85rem;
  margin-block-end: 0.85rem;
  border-block-end: 1px solid var(--border-subtle);
}

.sidebar-close-btn {
  min-block-size: 38px;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.sidebar-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-block: 1rem 0.45rem;
  padding-inline: 0.4rem;
}

.sidebar-section-title:first-child {
  margin-block-start: 0;
}

.sidebar-unit-group {
  margin-bottom: 0.75rem;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
}

.sidebar-unit-group.is-exam-unit {
  border-color: #fde68a;
  background: #fffbeb;
}

.sidebar-unit-header {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-bottom: 1px solid #dbeafe;
  user-select: none;
  display: block;
}

.sidebar-unit-group.is-exam-unit .sidebar-unit-header {
  background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
  border-bottom-color: #fde68a;
}

.sidebar-unit-header::-webkit-details-marker {
  display: none;
}

.sidebar-unit-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.22rem;
}

.sidebar-unit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
}

.sidebar-unit-group.is-exam-unit .sidebar-unit-badge {
  color: #b45309;
  background: #fde68a;
}

.sidebar-unit-count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sidebar-unit-chevron {
  display: inline-block;
  transition: transform 0.18s ease;
  font-size: 0.72rem;
}

.sidebar-unit-group:not([open]) .sidebar-unit-chevron {
  transform: rotate(-90deg);
}

.sidebar-unit-group:not([open]) .sidebar-unit-header {
  border-bottom-color: transparent;
}

.sidebar-unit-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
  color: #0f172a;
}

.sidebar-unit-subtitle {
  display: block;
  font-size: 0.71rem;
  font-weight: 500;
  line-height: 1.28;
  color: #475569;
  margin-top: 0.15rem;
}

.sidebar-unit-chapters {
  padding: 0.4rem 0.45rem 0.45rem 0.55rem;
  margin: 0.35rem 0 0.35rem 0.55rem;
  border-left: 2px solid #93c5fd;
}

.sidebar-unit-group.is-exam-unit .sidebar-unit-chapters {
  border-left-color: #f59e0b;
}

.sidebar-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-chapter-link {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.7rem;
  min-block-size: 44px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.sidebar-chapter-link:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.sidebar-chapter-link.active {
  background: var(--bg-tint);
  color: var(--primary);
  font-weight: 700;
  border-color: #93c5fd;
}

.chap-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 24px;
  block-size: 24px;
  padding-inline: 6px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.sidebar-chapter-link.active .chap-num-badge {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.main-workspace {
  flex: 1;
  min-inline-size: 0;
  inline-size: 100%;
  padding: clamp(0.85rem, 2.8vw, 2.25rem);
  container-type: inline-size;
}

/* ==========================================================================
   Light Hero Header (Course & Portal Headers)
   ========================================================================== */
.hero-banner {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 60%, #e0f2fe 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: clamp(1.1rem, 3vw, 2.25rem);
  margin-block-end: 1.25rem;
  box-shadow: var(--shadow-sm);
  container-type: inline-size;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 1px solid #93c5fd;
  color: var(--primary);
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: clamp(0.7rem, 0.65rem + 0.25vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-block-end: 0.65rem;
  max-inline-size: 100%;
}

.hero-banner h1 {
  font-size: clamp(1.25rem, 1rem + 1.8vw, 2.15rem);
  color: var(--text-main);
  line-height: 1.25;
  margin-block-end: 0.55rem;
  letter-spacing: -0.02em;
}

@supports (font-size: 1cqi) {
  .hero-banner h1 {
    font-size: clamp(1.25rem, 4.2cqi, 2.15rem);
  }
}

.hero-banner p {
  font-size: clamp(0.9rem, 0.86rem + 0.25vw, 1.05rem);
  color: var(--text-secondary);
}

.hero-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 1rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: clamp(0.76rem, 0.72rem + 0.2vw, 0.84rem);
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   Chapter In-Page Tabs Navigation (Desktop Row -> Mobile 2x2 Grid)
   ========================================================================== */
.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  gap: 0.35rem;
  position: sticky;
  inset-block-start: calc(var(--topbar-height) + 6px);
  z-index: 90;
  box-shadow: var(--shadow-sm);
  margin-block-end: 1.25rem;
}

.nav-tab {
  min-block-size: 44px;
  text-align: center;
  padding: 0.55rem 0.5rem;
  font-size: clamp(0.8rem, 0.75rem + 0.25vw, 0.9rem);
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}

.nav-tab:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.nav-tab.active {
  color: var(--primary);
  background: var(--bg-tint);
  border-color: #93c5fd;
  font-weight: 700;
}

/* ==========================================================================
   Sections, Cards & Responsive Container Queries
   ========================================================================== */
.section {
  display: none;
  animation: fadeIn 0.22s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.8rem);
  margin-block-end: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  container-type: inline-size;
}

@supports (padding: 1cqi) {
  .card {
    padding: clamp(0.95rem, 3.2cqi, 1.8rem);
  }
}

.card h2 {
  font-size: clamp(1.08rem, 0.96rem + 0.65vw, 1.38rem);
  color: var(--primary);
  margin-block-end: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border-block-end: 2px solid var(--bg-subtle);
  padding-block-end: 0.65rem;
  line-height: 1.3;
}

.card h3 {
  font-size: clamp(0.98rem, 0.92rem + 0.3vw, 1.08rem);
  color: var(--text-main);
  margin-block: 0.85rem 0.45rem;
}

.card p + p {
  margin-block-start: 0.6rem;
}

/* Container-aware 2-column & 3-column grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

@container (width < 640px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Pedagogical Callout & Formula Boxes (Mobile Math Overflow Safe) */
.formula-box {
  background: var(--bg-tint);
  border: 1px solid #bfdbfe;
  border-inline-start: 5px solid var(--primary);
  padding: clamp(0.75rem, 2vw, 1rem) clamp(0.65rem, 2vw, 1.25rem);
  border-radius: var(--radius-sm);
  margin-block: 0.85rem;
  font-size: clamp(0.92rem, 0.85rem + 0.35vw, 1.1rem);
  text-align: center;
  color: var(--text-main);
  overflow-x: auto;
  max-inline-size: 100%;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  max-inline-size: 100%;
  padding-block: 0.25rem;
  margin-block: 0.35rem !important;
}

.callout-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-inline-start: 4px solid var(--indigo);
  border-radius: var(--radius-sm);
  padding: clamp(0.85rem, 2vw, 1.15rem);
  margin-block: 0.9rem;
  font-size: 0.92rem;
  overflow-x: auto;
}

.callout-box.warning {
  background: var(--accent-amber-bg);
  border-color: #fde68a;
  border-inline-start-color: var(--accent-amber);
}

.callout-box.success {
  background: var(--accent-green-bg);
  border-color: #a7f3d0;
  border-inline-start-color: var(--accent-green);
}

.feature-panel {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: clamp(0.9rem, 2vw, 1.15rem);
  min-inline-size: 0;
}

/* ==========================================================================
   Accessible Responsive Table (Sticky Headers + Container Stacked Fallback)
   ========================================================================== */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(540px, 80dvh);
  container-type: inline-size;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-block-start: 0.75rem;
}

.table-wrapper:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

caption {
  text-align: start;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-block-end: 1px solid var(--border-subtle);
}

th,
td {
  padding: 0.75rem 0.9rem;
  border-block-end: 1px solid var(--border-subtle);
  border-inline-end: 1px solid var(--border-subtle);
  text-align: start;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-inline-end: none;
}

thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}

thead th {
  background: var(--bg-tint);
  color: var(--primary);
  font-weight: 700;
  border-block-end: 2px solid #93c5fd;
}

tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 700;
}

tbody tr:nth-child(even) td,
tbody tr:nth-child(even) th {
  background: var(--bg-page);
}

@container (width < 600px) {
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-block-end: 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }

  tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--bg-tint) !important;
    color: var(--primary);
    border-block-end: 1px solid #93c5fd;
  }

  td {
    border-inline-end: none;
  }

  td:nth-child(2)::before {
    content: var(--label-2) " : ";
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-block-end: 0.2rem;
  }

  td:nth-child(3)::before {
    content: var(--label-3) " : ";
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-block-end: 0.2rem;
  }
}

/* ==========================================================================
   Light-Theme HTML5 Simulators & Touch-Friendly Controls
   ========================================================================== */
.sim-canvas-wrap {
  position: relative;
  background: var(--bg-canvas);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-block: 0.9rem;
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.04);
  /* Allow vertical page scrolling on mobile unless overridden on draggable canvas */
  touch-action: pan-y;
}

canvas.sim-canvas {
  display: block;
  inline-size: 100%;
  block-size: clamp(235px, 52dvw, 350px);
}

canvas#fieldCanvas {
  touch-action: none;
  cursor: grab;
}

canvas#fieldCanvas:active {
  cursor: grabbing;
}

.controls {
  background: var(--bg-page);
  padding: clamp(0.9rem, 2.5vw, 1.2rem);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.control-group {
  margin-block-end: 1rem;
}

.control-group:last-child {
  margin-block-end: 0;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-block-end: 0.4rem;
}

input[type="range"] {
  inline-size: 100%;
  accent-color: var(--primary);
  block-size: 28px;
  cursor: pointer;
}

.readout-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.65rem;
  margin-block-start: 1rem;
}

.readout-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 0.65rem 0.6rem;
  border-radius: var(--radius-sm);
  text-align: center;
  min-inline-size: 0;
}

.readout-item .label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.readout-item .val {
  font-size: clamp(0.95rem, 0.88rem + 0.3vw, 1.1rem);
  font-weight: 800;
  color: var(--primary);
  margin-block-start: 0.2rem;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Buttons & Interactive Toolbar (Thumb-friendly 44px touch targets)
   ========================================================================== */
.toolbar-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-block-end: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-block-size: 44px;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--primary);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover,
.btn-outline.active {
  background: var(--bg-tint);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-success {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #ffffff;
}

.btn-success:hover {
  background: #047857;
}

/* ==========================================================================
   Quiz & Self-Evaluation
   ========================================================================== */
.quiz-question-block {
  padding: clamp(0.85rem, 2vw, 1.15rem);
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-block-end: 1rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  inline-size: 100%;
  min-block-size: 46px;
  text-align: start;
  padding: 0.75rem 0.9rem;
  margin-block: 0.45rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.quiz-option:hover {
  border-color: var(--primary);
  background: var(--bg-tint);
}

.quiz-option.correct {
  background: var(--accent-green-bg);
  border-color: var(--accent-green);
  color: #065f46;
  font-weight: 700;
}

.quiz-option.wrong {
  background: var(--accent-red-bg);
  border-color: var(--accent-red);
  color: #991b1b;
}

.feedback {
  font-size: 0.9rem;
  margin-block-start: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: none;
}

/* ==========================================================================
   W Academy — Multi-Level & Multi-Subject Selector Hub
   ========================================================================== */
.academy-selector-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  margin-block-end: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.level-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 1.1rem;
  padding-block-end: 1rem;
  border-block-end: 1px solid var(--border-subtle);
}

.level-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-block-size: 42px;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.level-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-tint);
}

.level-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.22);
}

.subject-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 195px), 1fr));
  gap: 0.75rem;
}

.subject-tab-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  background: var(--bg-page);
  color: var(--text-main);
  text-align: start;
  cursor: pointer;
  transition: all 0.18s ease;
  min-block-size: 86px;
}

.subject-tab-card:hover {
  border-color: #93c5fd;
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.subject-tab-card.active {
  border-color: var(--primary);
  background: var(--bg-tint);
  box-shadow: var(--shadow-sm);
}

.subject-tab-card .subj-title {
  font-weight: 800;
  font-size: 0.96rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.subject-tab-card.active .subj-title {
  color: var(--primary);
}

.subject-tab-card .subj-meta {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

@media (max-width: 680px) {
  .level-pills-row .level-pill-btn {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
  }
  .subject-cards-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 400px) {
  .subject-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Portal Chapter Cards & Search
   ========================================================================== */
.theme-block {
  margin-block-end: 2rem;
}

.theme-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-end: 1rem;
  padding-block-end: 0.6rem;
  border-block-end: 2px solid var(--border-subtle);
}

.theme-header h2 {
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.42rem);
  color: var(--text-main);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: normal;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1.25rem;
}

.chapter-card {
  min-width: 0;
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2.5vw, 1.35rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  overflow: hidden;
}

.chapter-card h3 {
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.chapter-card p {
  font-size: 0.88rem;
  line-height: 1.48;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
  overflow-wrap: anywhere;
  word-break: normal;
}

.chapter-card.available:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #93c5fd;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.status-badge.ready {
  background: var(--accent-green-bg);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.status-badge.planned {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.chapter-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block-start: 1.75rem;
  padding-block-start: 1.25rem;
  border-block-start: 1px solid var(--border-subtle);
}

.site-footer {
  background: var(--bg-surface);
  border-block-start: 1px solid var(--border-subtle);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-block-start: auto;
}

/* ==========================================================================
   Mobile & Tablet Breakpoints
   ========================================================================== */
@media (max-width: 960px) {
  .menu-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
  }

  .chapter-sidebar {
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0;
    block-size: 100dvh;
    inline-size: min(86dvw, 310px);
    z-index: 250;
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-lg);
  }

  .chapter-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-mobile-header {
    display: flex;
  }
}

@media (max-width: 768px) {
  /* Split mobile header into 2 distinct rows so brand and buttons never overlap */
  .site-topbar {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding-inline: 0.75rem;
    padding-block: 0.5rem;
    gap: 0.45rem;
  }

  .topbar-brand-row {
    inline-size: 100%;
    justify-content: space-between;
  }

  .brand-link {
    gap: 0.5rem;
    font-size: 1.02rem;
  }

  .brand-icon {
    inline-size: 34px;
    block-size: 34px;
    font-size: 1.02rem;
    border-radius: 9px;
  }

  .brand-subtitle {
    display: block;
    font-size: 0.64rem;
  }

  .topbar-actions {
    inline-size: 100%;
    max-inline-size: 100%;
    min-inline-size: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.38rem;
    padding-block-start: 0.4rem;
    border-block-start: 1px solid var(--border-subtle);
  }

  /* Hide desktop-only nav links & print button on mobile screens */
  .topbar-nav-links,
  .print-course-btn,
  .site-topbar button[onclick*="print"] {
    display: none !important;
  }

  .menu-toggle-btn,
  .topbar-actions .topbar-link {
    flex: 1 1 0;
    min-inline-size: 0;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.38rem 0.5rem !important;
    font-size: clamp(0.74rem, 0.68rem + 0.35dvw, 0.82rem) !important;
    min-block-size: 38px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
  }

  .topbar-actions .topbar-icon-btn {
    flex: 0 0 38px !important;
    inline-size: 38px !important;
    block-size: 38px !important;
    min-block-size: 38px !important;
    padding: 0 !important;
  }

  .topbar-actions .topbar-link {
    background: var(--bg-page);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    border-radius: var(--radius-sm);
  }

  .badge-pill {
    border-radius: 10px;
    line-height: 1.35;
    padding: 0.3rem 0.65rem;
  }

  /* 2x2 grid for chapter tabs on smartphones: all 4 tabs visible without horizontal scrolling */
  .nav-tabs {
    grid-template-columns: 1fr 1fr;
    position: static;
    gap: 0.35rem;
  }

  .nav-tab {
    font-size: 0.82rem;
    padding: 0.5rem 0.4rem;
  }

  canvas.sim-canvas {
    block-size: clamp(230px, 64dvw, 310px) !important;
  }

  /* Full-width stacked buttons in toolbars and footer nav on smartphones */
  .toolbar-row .btn {
    flex: 1 1 100%;
  }

  .chapter-footer-nav {
    flex-direction: column;
  }

  .chapter-footer-nav > div,
  .chapter-footer-nav .btn {
    inline-size: 100%;
  }

  .readout-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 380px) {
  .readout-bar {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Einstein Avatar & Live Whiteboard Video Player (W Academy)
   ========================================================================== */
.einstein-video-card {
  background: var(--bg-surface);
  border: 2px solid #93c5fd;
  border-radius: var(--radius-lg);
  padding: clamp(0.9rem, 2.5vw, 1.5rem);
  margin-block-end: 1.35rem;
  box-shadow: var(--shadow-md);
}

.einstein-video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-block-end: 0.85rem;
}

.einstein-video-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.einstein-avatar-badge {
  inline-size: 42px;
  block-size: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  border: 2px solid var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.einstein-persona-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  margin-block-end: 0.7rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.persona-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.persona-group-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-inline-end: 0.2rem;
}

.persona-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  min-block-size: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.persona-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-tint);
}

.persona-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(29, 78, 216, 0.2);
}

.einstein-scene-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-end: 0.75rem;
}

.einstein-scene-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.einstein-scene-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-tint);
}

.einstein-scene-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(29, 78, 216, 0.22);
}

.einstein-stage-wrap {
  position: relative;
  inline-size: 100%;
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.06);
}

canvas#einsteinWhiteboardCanvas {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 16 / 9;
  max-block-size: 480px;
  cursor: pointer;
}

.einstein-big-play-overlay,
.einstein-stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.einstein-big-play-overlay.hidden,
.einstein-stage-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.einstein-subtitle-bar {
  margin: 0;
  padding: 0.65rem 0.95rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  border-inline-start: 4px solid var(--primary);
  font-size: clamp(0.86rem, 0.82rem + 0.2vw, 0.95rem);
  color: var(--text-main);
  min-block-size: 2.9rem;
  display: flex;
  align-items: center;
}

.einstein-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.42rem 0.8rem;
  min-block-size: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.einstein-ctrl-btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.einstein-progress-track {
  flex: 1 1 180px;
  height: 10px;
  background: #cbd5e1;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.einstein-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8, #0284c7);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.einstein-speed-select {
  padding: 0.35rem 0.55rem;
  min-block-size: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.einstein-fs-corner-btn {
  position: absolute;
  inset-block-end: 10px;
  inset-inline-end: 12px;
  z-index: 30;
  inline-size: 38px;
  block-size: 38px;
  border-radius: 9px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  background: rgba(15, 23, 42, 0.74);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.32);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.einstein-fs-corner-btn:hover {
  background: var(--primary);
  border-color: #ffffff;
  transform: scale(1.07);
}

.einstein-fs-corner-btn svg {
  inline-size: 20px;
  block-size: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.einstein-video-card:fullscreen,
.einstein-video-card:-webkit-full-screen,
.einstein-video-card.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  inline-size: 100vw;
  block-size: 100vh;
  max-inline-size: 100vw;
  max-block-size: 100vh;
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-radius: 0;
  border: none;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  overflow-y: auto;
}

.einstein-video-card:fullscreen .einstein-video-header h2,
.einstein-video-card:-webkit-full-screen .einstein-video-header h2,
.einstein-video-card.is-pseudo-fullscreen .einstein-video-header h2 {
  color: #60a5fa !important;
}

.einstein-video-card:fullscreen .einstein-video-header p,
.einstein-video-card:-webkit-full-screen .einstein-video-header p,
.einstein-video-card.is-pseudo-fullscreen .einstein-video-header p {
  color: #cbd5e1 !important;
}

.einstein-video-card:fullscreen .einstein-stage-wrap,
.einstein-video-card:-webkit-full-screen .einstein-stage-wrap,
.einstein-video-card.is-pseudo-fullscreen .einstein-stage-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #090d16;
  border-color: #334155;
  max-block-size: calc(100vh - 205px);
}

.einstein-video-card:fullscreen canvas#einsteinWhiteboardCanvas,
.einstein-video-card:-webkit-full-screen canvas#einsteinWhiteboardCanvas,
.einstein-video-card.is-pseudo-fullscreen canvas#einsteinWhiteboardCanvas {
  max-block-size: calc(100vh - 210px);
  inline-size: auto;
  max-inline-size: 100%;
  block-size: auto;
  margin-inline: auto;
}

.sim-panel {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.85rem;
}

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

.control-group {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
}

.control-group label {
  display: block;
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.canvas-wrapper {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #0f172a;
  margin-bottom: 0.9rem;
}

.canvas-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.metrics-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}

.metric {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.metric span {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric strong {
  font-size: 0.98rem;
  color: var(--text-main);
}

.callout-tip,
.callout-warning {
  padding: 0.85rem 1.05rem;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.55;
  margin-top: 0.75rem;
}

.callout-tip {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-inline-start: 4px solid #059669;
  color: #064e3b;
}

.callout-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-inline-start: 4px solid #d97706;
  color: #78350f;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-block: 0.75rem;
}

.chart-holder {
  position: relative;
  width: 100%;
  height: 310px;
  margin-top: 0.75rem;
}

.feedback {
  display: none;
  margin-top: 0.55rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.einstein-big-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #ffffff;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  font-weight: 800;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.32);
  cursor: pointer;
  transition: transform 0.16s ease;
}

.einstein-big-play-btn:hover {
  transform: scale(1.04);
}

.einstein-subtitle-box {
  margin-block-start: 0.65rem;
  padding: 0.65rem 0.95rem;
  background: #f8fafc;
  border-inline-start: 4px solid var(--primary);
  border-radius: 8px;
  border-block: 1px solid var(--border-subtle);
  border-inline-end: 1px solid var(--border-subtle);
  font-size: clamp(0.86rem, 0.82rem + 0.2vw, 0.96rem);
  color: var(--text-main);
  min-block-size: 3.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.einstein-controls-bar {
  margin-block-start: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.einstein-scrubber-wrap {
  flex: 1 1 180px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.einstein-time-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

@media (max-width: 680px) {
  canvas#einsteinWhiteboardCanvas {
    aspect-ratio: 4 / 3;
  }
  .einstein-scene-pill {
    flex: 1 1 calc(50% - 0.4rem);
    text-align: center;
    padding: 0.35rem 0.5rem;
    font-size: 0.74rem;
  }
  .einstein-big-play-btn {
    padding: 0.7rem 1.15rem;
    font-size: 0.86rem;
  }
}

@media (forced-colors: active) {
  .card,
  .chapter-card,
  .readout-item,
  .quiz-option,
  .btn,
  .sim-canvas-wrap {
    border: 2px solid CanvasText;
  }
  .nav-tab.active,
  .sidebar-chapter-link.active {
    outline: 2px solid Highlight;
  }
}

@media print {
  .site-topbar,
  .chapter-sidebar,
  .sidebar-backdrop,
  .nav-tabs,
  .chapter-footer-nav,
  .w-guest-banner,
  .w-auth-modal-backdrop {
    display: none !important;
  }
  .section {
    display: block !important;
    page-break-after: always;
  }
  body {
    background: #ffffff;
  }
}

/* ==========================================================================
   W Academy — Accès Invité (1 Chapitre Gratuit) & Portail d'Authentification
   ========================================================================== */
.topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  inline-size: 38px;
  block-size: 38px;
  min-block-size: 38px;
  padding: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-auth-btn {
  border: 1.5px solid #93c5fd;
  background: #eff6ff;
  color: #1e40af;
}

.topbar-auth-btn:hover {
  background: #dbeafe;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.topbar-auth-btn.is-verified {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.topbar-user-dot {
  position: absolute;
  inset-block-end: -2px;
  inset-inline-end: -2px;
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.topbar-user-dot.online {
  background: #10b981;
}

.topbar-user-dot.guest {
  background: #3b82f6;
}

.topbar-share-btn {
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-secondary);
}

.topbar-share-btn:hover {
  background: var(--bg-tint);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.topbar-share-btn.is-copied {
  background: #ecfdf5;
  border-color: #10b981;
  color: #059669;
}

.w-guest-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  margin-block-end: 1.15rem;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1.5px solid #93c5fd;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.w-guest-banner-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.45;
  flex: 1 1 280px;
}

.w-guest-banner-text strong {
  color: var(--primary);
}

body.w-auth-locked {
  overflow: hidden;
}

body.w-auth-locked main.main-content,
body.w-auth-locked main.main-workspace {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.w-auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2200;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.w-auth-modal-backdrop.open {
  display: flex;
}

.w-auth-modal-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.32);
  overflow: hidden;
  animation: wAuthSlideUp 0.22s ease-out;
}

@keyframes wAuthSlideUp {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.w-auth-modal-header {
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  color: #ffffff;
  padding: 1.25rem 1.4rem;
  position: relative;
}

.w-auth-modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.w-auth-modal-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.w-auth-badge-free {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.24);
  border: 1px solid #6ee7b7;
  color: #ecfdf5;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
}

.w-auth-modal-header h3 {
  margin: 0 0 0.3rem;
  font-size: 1.22rem;
  font-weight: 800;
  color: #ffffff;
}

.w-auth-modal-header p {
  margin: 0;
  font-size: 0.85rem;
  color: #dbeafe;
  line-height: 1.45;
}

.w-auth-modal-body {
  padding: 1.3rem 1.4rem 1.4rem;
}

.w-auth-social-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.w-oauth-btn {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.w-oauth-btn.google {
  background: #ffffff;
  color: #1e293b;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.w-oauth-btn.google:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.w-oauth-btn.apple {
  background: #0f172a;
  color: #ffffff;
  border: 1.5px solid #0f172a;
}

.w-oauth-btn.apple:hover {
  background: #1e293b;
}

.w-auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.w-auth-divider::before,
.w-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.w-auth-field {
  margin-bottom: 0.8rem;
}

.w-auth-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.w-auth-field input,
.w-auth-field select {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  font-size: 0.92rem;
  color: var(--text-main);
  background: #f8fafc;
  box-sizing: border-box;
}

.w-auth-field input:focus,
.w-auth-field select:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.w-auth-submit-btn {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.w-auth-submit-btn:hover {
  transform: translateY(-1px);
}

.w-auth-submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.w-auth-msg {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.83rem;
  line-height: 1.45;
}

.w-auth-msg.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.w-auth-msg.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.w-auth-msg.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.w-auth-footer-links {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.w-auth-footer-links a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.w-auth-footer-links a:hover {
  text-decoration: underline;
}

.w-auth-toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  left: 1.2rem;
  max-width: 520px;
  margin-inline: auto;
  z-index: 2500;
  padding: 0.9rem 1.15rem;
  border-radius: 12px;
  background: #065f46;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(6, 95, 70, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* ==========================================================================
   W Academy — Admin Dashboard (wael.inotek@gmail.com) & Academic Year Menu
   ========================================================================== */
.topbar-admin-btn {
  border: 1.5px solid #c084fc;
  background: linear-gradient(135deg, #581c87, #7e22ce);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(126, 34, 206, 0.28);
}

.topbar-admin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(126, 34, 206, 0.4);
}

.w-admin-modal-card {
  width: 100%;
  max-width: 980px;
  max-height: 90dvh;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 54px rgba(15, 23, 42, 0.38);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: wAuthSlideUp 0.22s ease-out;
}

.w-admin-header {
  background: linear-gradient(135deg, #0f172a, #1e1b4b, #312e81);
  color: #ffffff;
  padding: 1.15rem 1.4rem;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.w-admin-body {
  padding: 1.2rem 1.4rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.w-admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.w-admin-kpi-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.w-admin-kpi-card.online {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.w-admin-kpi-card.registered {
  background: #eff6ff;
  border-color: #93c5fd;
}

.w-admin-kpi-card.disabled-kpi {
  background: #fef2f2;
  border-color: #fecaca;
}

.w-admin-kpi-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.w-admin-kpi-val {
  font-size: 1.65rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.15;
}

.w-admin-kpi-sub {
  font-size: 0.76rem;
  color: #64748b;
  font-weight: 600;
}

.w-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding: 0.65rem 0.8rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.w-admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
}

.w-admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.w-admin-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 800;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1.5px solid #cbd5e1;
  white-space: nowrap;
}

.w-admin-table td {
  padding: 0.68rem 0.85rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.w-admin-table tr:hover td {
  background: #f8fafc;
}

.w-admin-table tr.is-disabled-row td {
  background: #fff1f2;
  color: #881337;
}

.w-year-step-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.w-year-step-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
}

.w-year-step-item.current {
  border-color: #2563eb;
  background: #eff6ff;
}

.w-year-step-item.locked-past {
  opacity: 0.62;
  background: #f1f5f9;
  border-style: dashed;
}
