/* ==========================================================================
   LinguaPulse AI — Cloud-Native English Learning Platform Stylesheet
   Implements Modern Web Guidance:
   - `dark-mode`: root color-scheme, light-dark() with @media fallback, scrollbar-color + scrollbar-width
   - `validate-input-after-interaction`: :user-invalid, :user-valid, :has(), WeakMap fallback classes
   - `responsive-design`: @container queries, dvh units, aspect-ratio, fluid clamp() typography
   ========================================================================== */

:root {
  /* Luma Academy Executive Palette: Royal Emerald, Warm Alabaster & Academic Gold */
  --bg-canvas-light: #f3f7f5;
  --bg-canvas-dark: #06120e;
  --bg-surface-light: #ffffff;
  --bg-surface-dark: #0c1f18;
  --bg-elevated-light: #e8f1ed;
  --bg-elevated-dark: #132e24;

  --text-primary-light: #0a2219;
  --text-primary-dark: #f0fdf4;
  --text-muted-light: #3f6254;
  --text-muted-dark: #94b8a8;

  --brand-primary-light: #047857;
  --brand-primary-dark: #10b981;
  --brand-accent-light: #059669;
  --brand-accent-dark: #34d399;
  --brand-gold: #d97706;

  --border-subtle-light: #d1e3db;
  --border-subtle-dark: #1f4537;

  --scrollbar-track-light: #e8f1ed;
  --scrollbar-track-dark: #06120e;
  --scrollbar-thumb-light: #9ec5b5;
  --scrollbar-thumb-dark: #285947;

  /* Modern Multi-layer Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(6, 46, 34, 0.05);
  --shadow-sm: 0 2px 4px 0 rgba(6, 46, 34, 0.06), 0 1px 2px -1px rgba(6, 46, 34, 0.04);
  --shadow-md: 0 6px 12px -2px rgba(6, 46, 34, 0.08), 0 3px 6px -3px rgba(6, 46, 34, 0.05);
  --shadow-lg: 0 14px 24px -4px rgba(6, 46, 34, 0.1), 0 6px 10px -4px rgba(6, 46, 34, 0.05);
  --shadow-card: 0 0 0 1px rgba(4, 120, 87, 0.08), 0 4px 12px -2px rgba(6, 46, 34, 0.06);
  --shadow-card-hover: 0 0 0 2px rgba(4, 120, 87, 0.45), 0 14px 28px -4px rgba(4, 120, 87, 0.16);

  /* Semantic Tonal Palettes */
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;

  /* Default Light Assignments */
  --bg-canvas: var(--bg-canvas-light);
  --bg-surface: var(--bg-surface-light);
  --bg-elevated: var(--bg-elevated-light);
  --text-primary: var(--text-primary-light);
  --text-muted: var(--text-muted-light);
  --brand-primary: var(--brand-primary-light);
  --brand-accent: var(--brand-accent-light);
  --border-subtle: var(--border-subtle-light);
  --scrollbar-track: var(--scrollbar-track-light);
  --scrollbar-thumb: var(--scrollbar-thumb-light);

  @media (prefers-color-scheme: dark) {
    --bg-canvas: var(--bg-canvas-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-elevated: var(--bg-elevated-dark);
    --text-primary: var(--text-primary-dark);
    --text-muted: var(--text-muted-dark);
    --brand-primary: var(--brand-primary-dark);
    --brand-accent: var(--brand-accent-dark);
    --border-subtle: var(--border-subtle-dark);
    --scrollbar-track: var(--scrollbar-track-dark);
    --scrollbar-thumb: var(--scrollbar-thumb-dark);
    --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 16px -2px rgba(0, 0, 0, 0.4);
    --shadow-card-hover: 0 0 0 1px rgba(56, 189, 248, 0.35), 0 12px 28px -4px rgba(0, 0, 0, 0.6);
  }

  @supports (color: light-dark(white, black)) {
    --bg-canvas: light-dark(var(--bg-canvas-light), var(--bg-canvas-dark));
    --bg-surface: light-dark(var(--bg-surface-light), var(--bg-surface-dark));
    --bg-elevated: light-dark(var(--bg-elevated-light), var(--bg-elevated-dark));
    --text-primary: light-dark(var(--text-primary-light), var(--text-primary-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --brand-primary: light-dark(var(--brand-primary-light), var(--brand-primary-dark));
    --brand-accent: light-dark(var(--brand-accent-light), var(--brand-accent-dark));
    --border-subtle: light-dark(var(--border-subtle-light), var(--border-subtle-dark));
    --scrollbar-track: light-dark(var(--scrollbar-track-light), var(--scrollbar-track-dark));
    --scrollbar-thumb: light-dark(var(--scrollbar-thumb-light), var(--scrollbar-thumb-dark));
  }

  color-scheme: light dark;
  accent-color: var(--brand-primary);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: var(--bg-canvas-dark);
  --bg-surface: var(--bg-surface-dark);
  --bg-elevated: var(--bg-elevated-dark);
  --text-primary: var(--text-primary-dark);
  --text-muted: var(--text-muted-dark);
  --brand-primary: var(--brand-primary-dark);
  --brand-accent: var(--brand-accent-dark);
  --border-subtle: var(--border-subtle-dark);
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 0 0 1px rgba(56, 189, 248, 0.35), 0 12px 28px -4px rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-canvas: var(--bg-canvas-light);
  --bg-surface: var(--bg-surface-light);
  --bg-elevated: var(--bg-elevated-light);
  --text-primary: var(--text-primary-light);
  --text-muted: var(--text-muted-light);
  --brand-primary: var(--brand-primary-light);
  --brand-accent: var(--brand-accent-light);
  --border-subtle: var(--border-subtle-light);
  --shadow-card: 0 0 0 1px rgba(15, 23, 42, 0.05), 0 2px 8px -1px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 0 0 1px rgba(37, 99, 235, 0.25), 0 12px 24px -4px rgba(15, 23, 42, 0.08);
}

@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
  }
  ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

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

body {
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fluid Typography using clamp() with Cairo weighting */
h1 {
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.3px;
  text-wrap: balance;
  line-height: 1.35;
}

h2 {
  font-size: clamp(1.15rem, 0.95rem + 0.9vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.2px;
  text-wrap: balance;
  line-height: 1.4;
}

h3 {
  font-size: clamp(0.98rem, 0.88rem + 0.4vw, 1.2rem);
  font-weight: 700;
  line-height: 1.45;
}

.ltr-text {
  direction: ltr;
  text-align: left;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================================================
   TOP HEADER — SOBER, SLEEK, ENTERPRISE GRADE
   ========================================================================== */
.top-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(12px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.platform-logo-img {
  max-height: 44px;
  width: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.brand-text-block {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title-row h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.system-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
  display: inline-block;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.1rem;
}

/* Header Center Stats: User Identity & XP Pill */
.header-center-stats {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.user-identity-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
}

#hdr-user-avatar {
  font-size: 1.05rem;
}

#hdr-username {
  font-weight: 700;
  color: var(--text-primary);
}

.stat-capsule {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.stat-icon {
  font-size: 0.95rem;
}

.stat-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
}

.role-switcher-wrap {
  display: inline-flex;
}

.role-select-control {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  font-family: inherit;
}

.role-select-control:hover,
.role-select-control:focus {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  outline: none;
}

/* Header Action Toolbar: Refined Executive Style Buttons */
.header-action-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-elevated);
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.btn-header-action {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.16s ease;
  cursor: pointer;
}

.btn-header-action:hover {
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

.btn-admin-action {
  color: #991b1b;
}

html[data-theme="dark"] .btn-admin-action {
  color: #f87171;
}

.btn-admin-action:hover {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.06);
}

.btn-teacher-action {
  color: #065f46;
}

html[data-theme="dark"] .btn-teacher-action {
  color: #34d399;
}

.btn-teacher-action:hover {
  border-color: rgba(5, 150, 105, 0.3);
  background: rgba(5, 150, 105, 0.06);
}

.btn-tutoring-action {
  color: #92400e;
}

html[data-theme="dark"] .btn-tutoring-action {
  color: #fbbf24;
}

.btn-tutoring-action:hover {
  border-color: rgba(217, 119, 6, 0.3);
  background: rgba(217, 119, 6, 0.06);
}

.btn-ai-action {
  color: var(--brand-primary);
}

.btn-ai-action:hover {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.06);
}

.header-util-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Arabic Assistance & English Immersion Toggle Button */
.btn-assistance-toggle {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.38rem 0.8rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  user-select: none;
}

.btn-assistance-toggle:hover {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-assistance-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.45rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-assistance-toggle .lang-opt-ar,
.btn-assistance-toggle .lang-opt-en {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.btn-assistance-toggle .lang-opt-divider {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.35;
}

/* When Arabic is active (data-assistance="on") */
html[data-assistance="on"] .btn-assistance-toggle .lang-opt-ar {
  background: var(--brand-primary);
  color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(37,99,235,0.35);
}
html[data-assistance="on"] .btn-assistance-toggle .lang-opt-en {
  color: var(--text-muted);
  opacity: 0.75;
}

/* When English is active (data-assistance="off") */
html[data-assistance="off"] .btn-assistance-toggle .lang-opt-ar {
  color: var(--text-muted);
  opacity: 0.75;
}
html[data-assistance="off"] .btn-assistance-toggle .lang-opt-en {
  background: #059669;
  color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(5,150,105,0.35);
}

.btn-assistance-toggle:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

/* Luma Workshop Buttons (Visible for Admin Only) */
.btn-workshop-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff !important;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0.32rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #b45309;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-workshop-action:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(217, 119, 6, 0.35);
}

/* Only display workshop action buttons to Admin / Super Admin */
body:not(.is-admin-user) .btn-workshop-action {
  display: none !important;
}

.btn-icon-util {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-util:hover {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  transform: translateY(-1px);
}

.btn-logout-util {
  color: var(--text-muted);
}

.btn-logout-util:hover {
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.05);
}

/* ==========================================================================
   DYNAMIC ENGLISH IMMERSION & LTR MODE (html[dir="ltr"] / html[data-assistance="off"])
   ========================================================================== */
html[dir="ltr"] {
  direction: ltr !important;
  text-align: left !important;
}

html[dir="ltr"] body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif !important;
  direction: ltr !important;
  text-align: left !important;
}

html[dir="ltr"] .app-view,
html[dir="ltr"] .workspace-container,
html[dir="ltr"] .tab-panel,
html[dir="ltr"] .card,
html[dir="ltr"] .speech-box,
html[dir="ltr"] .lesson-room-container {
  direction: ltr !important;
  text-align: left !important;
}

html[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] body {
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  direction: rtl;
  text-align: right;
}

html[dir="ltr"] .top-header,
html[dir="ltr"] .nav-tabs,
html[dir="ltr"] .card-header,
html[dir="ltr"] .lesson-focus-topbar {
  direction: ltr;
}

html[dir="ltr"] .brand-wrap {
  flex-direction: row;
}

html[dir="ltr"] .card[style*="border-right"],
html[dir="ltr"] .toast[style*="border-right"] {
  border-right: 1px solid var(--border-subtle) !important;
  border-left: 4px solid var(--brand-primary) !important;
}

html[dir="ltr"] #active-unit-objective {
  border-right: none !important;
  border-left: 3px solid var(--brand-primary) !important;
}

html[dir="ltr"] .data-table th,
html[dir="ltr"] .data-table td,
html[dir="ltr"] .admin-users-table th,
html[dir="ltr"] .admin-users-table td {
  text-align: left;
}

html[dir="ltr"] .level-card::before {
  right: auto;
  left: 0;
}

/* HIDE ARABIC SCAFFOLDING & TRANSLATIONS IN ENGLISH IMMERSION MODE */
html[data-assistance="off"],
html[data-assistance="off"] body,
html[data-assistance="off"] button,
html[data-assistance="off"] input,
html[data-assistance="off"] select,
html[data-assistance="off"] textarea {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

html[data-assistance="on"],
html[data-assistance="on"] body,
html[data-assistance="on"] button,
html[data-assistance="on"] input,
html[data-assistance="on"] select,
html[data-assistance="on"] textarea {
  font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

html[data-assistance="off"] .ar-assistance-only,
html[data-assistance="off"] [data-ar-only],
html[data-assistance="off"] .vocab-meaning-ar,
html[data-assistance="off"] .phonetic-pair-ar,
html[data-assistance="off"] .quiz-hint-ar,
html[data-assistance="off"] .ar-sub-label {
  display: none !important;
}

html[data-assistance="off"] [data-en-only] {
  display: inline-block !important;
}

html[data-assistance="on"] [data-en-only] {
  display: none !important;
}

html[data-assistance="on"] [data-ar-only] {
  display: inline-block !important;
}

html[data-assistance="off"] .fsrs-meaning-text {
  opacity: 0.2;
  filter: blur(4px);
  transition: all 0.2s ease;
}

html[data-assistance="off"] .fsrs-meaning-text:hover {
  opacity: 1;
  filter: blur(0);
}

/* ==========================================================================
   MAIN NAVIGATION TABS — FLOATING SEGMENTED PILL BAR
   ========================================================================== */
.nav-tabs {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 1.5rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 0.55rem 1.05rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.tab-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
  border-color: transparent;
}

.tab-counter-badge {
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}

.tab-btn.active .tab-counter-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.tab-counter-badge.due-badge {
  background: rgba(217, 119, 6, 0.15);
  color: var(--color-warning);
}

.tab-btn.active .tab-counter-badge.due-badge {
  background: #ffffff;
  color: var(--brand-primary);
}

/* Main Workspace Container */
.workspace-container {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  flex: 1;
  container-type: inline-size;
  container-name: workspace;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-panel.active {
  display: block;
}

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

/* Responsive Grid Layout using @container queries */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.grid-3col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
}

@container workspace (min-width: 760px) {
  .grid-2col {
    grid-template-columns: 360px 1fr;
  }
  .grid-3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Cards & Surfaces */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

/* Buttons */
.btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.94;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  border-color: transparent;
}

.btn-success {
  background: #059669;
  color: #ffffff;
  border-color: transparent;
}

.btn-warning {
  background: #d97706;
  color: #ffffff;
  border-color: transparent;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border-color: transparent;
}

/* CEFR Unit List */
.unit-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.unit-item {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
  position: relative;
}

.unit-item:hover,
.unit-item.selected {
  border-color: var(--brand-primary);
  background: var(--bg-surface);
  transform: translateX(-3px);
}

.unit-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
}

.cefr-tag {
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-weight: 800;
  background: var(--brand-primary);
  color: #fff;
}

.rec-tag {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-weight: 700;
}

/* Speech & Phoneme Visualizer Box */
.speech-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}

.target-sentence-box {
  background: var(--bg-surface);
  border: 1px dashed var(--brand-primary);
  border-radius: 12px;
  padding: 1rem;
  margin: 0.75rem 0;
}

.phoneme-words-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
  direction: ltr;
}

.phoneme-word-chip {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.phoneme-word-chip.excellent {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #10b981;
}

.phoneme-word-chip.close {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #f59e0b;
}

.phoneme-word-chip.mispronounced {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

.waveform-canvas {
  width: 100%;
  aspect-ratio: 6 / 1;
  max-height: 75px;
  background: #0f172a;
  border-radius: 10px;
  margin: 0.65rem 0;
  display: block;
}

/* FSRS Spaced Repetition Flashcard */
.fsrs-stage {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.08));
  border: 2px solid var(--brand-primary);
  border-radius: 18px;
  padding: 1.75rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.fsrs-word-big {
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 0.5px;
}

.fsrs-ipa {
  color: var(--brand-primary);
  font-family: monospace;
  font-size: 1.1rem;
  margin: 0.35rem 0 1rem;
}

.fsrs-rating-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: 1.2rem;
}

/* Roleplay Chat Window */
.chat-messages {
  height: 360px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  line-height: 1.5;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
}

/* Forms & Deferred Validation (:user-invalid & :user-valid per modern-web-guidance) */
.field {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}

.field label {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.hint,
.rules-list {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  padding-inline-start: 1rem;
}

.input-control,
textarea.input-control,
select.input-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.error-msg {
  display: none;
  color: var(--color-danger);
  font-size: 0.82rem;
  margin-top: 0.3rem;
  font-weight: 600;
}

/* Show error styles ONLY after user interaction (:user-invalid + fallback class) */
input.input-control:user-invalid,
textarea.input-control:user-invalid,
input.input-control.user-invalid-fallback,
textarea.input-control.user-invalid-fallback {
  border-color: var(--color-danger);
  background-color: rgba(239, 68, 68, 0.08);
}

input.input-control:user-invalid + .error-msg,
textarea.input-control:user-invalid + .error-msg,
input.input-control.user-invalid-fallback + .error-msg,
textarea.input-control.user-invalid-fallback + .error-msg {
  display: block;
}

input.input-control:user-valid,
textarea.input-control:user-valid,
input.input-control.user-valid-fallback {
  border-color: var(--color-success);
}

/* Highlight rules list when error is shown using modern :has() selector */
.field:has(input:user-invalid) .rules-list {
  color: var(--color-danger);
  font-weight: 600;
}

.field:has(input:user-valid) .rules-list {
  color: var(--color-success);
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: right;
}

.data-table th {
  background: var(--bg-elevated);
  font-weight: 700;
}

/* Native HTML <dialog> Modal */
dialog.app-modal {
  margin: auto;
  padding: 1.5rem;
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  max-width: 540px;
  width: calc(100% - 2rem);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

dialog.app-modal::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

/* Welcome Motivation Modal Luxury Aesthetics */
#modal-welcome-motivation[open] {
  animation: modalPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#btn-welcome-modal-continue:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 14px 28px -4px rgba(2, 132, 199, 0.5) !important;
}

/* Toast Notification */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface);
  border-right: 4px solid var(--brand-primary);
  border-top: 1px solid var(--border-subtle);
  border-left: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ==========================================================================
   CLEAN 6-LEVELS GRID, SCHOOL GRADES BAR & STEP-BY-STEP LESSON WIZARD
   ========================================================================== */
.levels-6-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(295px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}

.level-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.level-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  transition: background-color 0.2s ease;
}

.level-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-card-hover);
}

.level-card:hover::before {
  background: var(--brand-primary);
}

.level-card.active-level {
  border-color: var(--brand-primary);
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.05) 0%, rgba(59, 130, 246, 0.03) 100%);
  box-shadow: 0 0 0 1px var(--brand-primary), 0 8px 24px -4px rgba(29, 78, 216, 0.15);
}

.level-card.active-level::before {
  background: var(--brand-primary);
}

.level-num-circle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.25);
}

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

.grade-card-btn {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1rem 0.85rem;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
}

.grade-card-btn:hover {
  border-color: var(--color-success);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.grade-card-btn.active-grade {
  border-color: var(--color-success);
  background: var(--color-success-bg);
  color: #065f46;
  box-shadow: 0 0 0 1px var(--color-success), 0 8px 20px -2px rgba(5, 150, 105, 0.15);
}

html[data-theme="dark"] .grade-card-btn.active-grade {
  background: rgba(5, 150, 105, 0.15);
  color: #34d399;
}

/* 4-Step Lesson Stepper Timeline */
.lesson-stepper-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.5rem;
  background: var(--bg-elevated);
  padding: 0.5rem;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
}

.step-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.75rem 0.6rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.step-tab-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.step-tab-btn.active-step {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

.lesson-step-pane {
  display: none;
  animation: fadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.lesson-step-pane.active-step-pane {
  display: block;
}

.step-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ============================================================================
   ADMIN CONTROL PANEL STYLES
   ============================================================================ */
.modal-lg {
  max-width: 950px;
  width: 95%;
}

.admin-nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  padding-bottom: 0.25rem;
  overflow-x: auto;
}

.admin-nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.admin-nav-tab.active {
  background: var(--brand-primary);
  color: #fff;
}

.admin-tab-pane {
  display: none;
  animation: fadeIn 0.18s ease-out;
}

.admin-tab-pane.active {
  display: block;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}
.role-badge-super_admin { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.role-badge-admin { background: #e0e7ff; color: #3730a3; border: 1px solid #818cf8; }
.role-badge-teacher { background: #dcfce7; color: #166534; border: 1px solid #4ade80; }
.role-badge-student { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.75rem;
}

.admin-users-table th, .admin-users-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: right;
}

.admin-users-table th {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-muted);
  font-weight: 700;
}

.admin-users-table tr:hover {
  background: rgba(37, 99, 235, 0.03);
}

.logo-preview-box {
  width: 120px;
  height: 60px;
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.02);
  overflow: hidden;
}
.logo-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ============================================================================
   TEACHER ASSIGNMENTS & MEDIA MANAGEMENT (PHASE 2)
   ============================================================================ */
.teacher-assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.assign-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.assign-card:hover {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.02);
}

.assign-card.is-assigned {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.08);
}

.assign-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--color-success);
  cursor: pointer;
}

.assign-card-info {
  flex: 1;
}

.assign-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.assign-card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge-assign-tag {
  display: inline-block;
  font-size: 0.74rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin: 0.1rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-assign-foundation {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

/* Cascading Unit & Lesson Checkbox Selectors (AI Lesson Planner & Studio) */
.lp-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.65rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.lp-checkbox-item:hover {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.04);
}
.lp-checkbox-item.is-checked {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}
.lp-checkbox-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}
.lp-checkbox-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  flex: 1;
  line-height: 1.35;
}
.lp-checkbox-badge {
  font-size: 0.72rem;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  font-weight: 600;
}

/* Workbook Green Checkbox Items */
.wb-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.65rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.wb-checkbox-item:hover {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.04);
}
.wb-checkbox-item.is-checked {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
}
.wb-checkbox-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--color-success);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.badge-assign-school {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.studio-notice-box {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.media-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 0.88rem;
}

/* ============================================================================
   TUTORING, LIVE SESSIONS & VIP TEACHERS (PHASE 3)
   ============================================================================ */
.tutoring-teachers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.teacher-tutoring-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.teacher-tutoring-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  border-color: var(--brand-primary);
}

.teacher-tutoring-card.is-vip-card {
  border: 2px solid #eab308;
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.04) 0%, var(--bg-surface) 100%);
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.12);
}

.vip-ribbon {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #eab308;
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.rate-badge {
  font-size: 1.05rem;
  font-weight: 800;
  color: #15803d;
  background: #dcfce7;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #86efac;
}

.tutoring-booking-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tutoring-booking-card:hover {
  border-color: var(--brand-primary);
}

.booking-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}
.booking-status-pending { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.booking-status-confirmed { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.booking-status-completed { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.booking-status-cancelled { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ==========================================================================
   VIEW-BASED ARCHITECTURE & MODERN POLISH (SPA Views)
   ========================================================================== */

.app-view {
  display: none;
}

.app-view.active {
  display: block;
  animation: viewFadeIn 0.28s ease-out;
}

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

/* 1. AUTHENTICATION VIEW (PORTAL LOGIN / REGISTER) */
#view-auth {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.09) 0%, transparent 65%), var(--bg-canvas);
}

#view-auth.active {
  display: flex;
}

.auth-card {
  width: 100%;
  max-width: 490px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  padding: 2.25rem 2rem;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #16a34a, #eab308, #2563eb);
}

.auth-brand-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo-wrapper {
  margin: 0 auto 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-brand-logo-img {
  max-height: 95px;
  max-width: 260px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  background: #ffffff;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.auth-brand-logo {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
  margin-bottom: 0.85rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: var(--bg-elevated);
  padding: 0.3rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.auth-tab-btn {
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.auth-tab-btn.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.demo-pills-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-subtle);
}

.demo-pill-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.demo-pill-btn:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* 2. STANDALONE LESSON FOCUS MODE (NO BORING SCROLL) */
#view-lesson-player {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.lesson-focus-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.btn-back-catalog {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back-catalog:hover {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* 3. SUBSCRIPTION LOCKED & FREE TRIAL BADGES */
.unit-card.is-subscription-locked {
  border-color: #fde047;
  background: linear-gradient(180deg, rgba(254, 240, 138, 0.08) 0%, var(--bg-surface) 100%);
  position: relative;
}

.unit-card.is-subscription-locked:hover {
  border-color: #eab308;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(234, 179, 8, 0.15);
}

.badge-locked-sub {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-free-trial {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* 4. SUBSCRIPTION PAYWALL MODAL STYLING */
.paywall-modal-header {
  text-align: center;
  padding: 1.5rem 1.5rem 1rem;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12) 0%, rgba(37, 99, 235, 0.08) 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.paywall-perk-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.paywall-plan-card {
  padding: 1rem;
  border-radius: 14px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: all 0.2s ease;
  cursor: pointer;
}

.paywall-plan-card.active,
.paywall-plan-card:hover {
  border-color: #eab308;
  background: rgba(234, 179, 8, 0.03);
}

/* 5. USER CHIP & LOGOUT BUTTON IN HEADER */
.btn-logout-header {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout-header:hover {
  background: rgba(220, 38, 38, 0.08);
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.35);
}

/* ==========================================================================
   6. TEACHER AI SUITE & WORKSHEET PRINT STYLES
   ========================================================================== */
.ws-answer-block {
  transition: all 0.25s ease;
}

/* ==========================================================================
   7. LUMA ACADEMY EXECUTIVE APP-SHELL & MODERN VISUAL IDENTITY (v7.0)
   Completely distinct from the student Luma platform!
   ========================================================================== */
.academy-app-shell {
  display: grid;
  grid-template-columns: 370px 1fr;
  min-height: 100dvh;
  background: var(--bg-canvas);
}

/* Base Sidebar Container */
.academy-sidebar {
  background: linear-gradient(180deg, #051610 0%, #082119 25%, #0a2522 60%, #061720 100%);
  background-image: 
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.16) 0%, transparent 45%),
    radial-gradient(circle at 0% 50%, rgba(217, 119, 6, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(2, 132, 199, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, #051610 0%, #082119 25%, #0a2522 60%, #061720 100%);
  color: #f1f5f9;
  border-inline-end: 1px solid rgba(16, 185, 129, 0.22);
  padding: 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  box-shadow: 8px 0 32px rgba(3, 18, 14, 0.45);
  z-index: 40;
  backdrop-filter: blur(16px);
  scrollbar-width: thin;
  scrollbar-color: rgba(52, 211, 153, 0.35) transparent;
}

.academy-sidebar::-webkit-scrollbar {
  width: 5px;
}
.academy-sidebar::-webkit-scrollbar-thumb {
  background: rgba(52, 211, 153, 0.35);
  border-radius: 99px;
}
.academy-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(52, 211, 153, 0.6);
}

/* Light Theme Harmonization for Sidebar */
html[data-theme="light"] .academy-sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 35%, #edf6f1 70%, #e2efe9 100%);
  background-image: 
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 0% 50%, rgba(217, 119, 6, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(2, 132, 199, 0.08) 0%, transparent 45%),
    linear-gradient(180deg, #ffffff 0%, #f7faf8 35%, #edf6f1 70%, #e2efe9 100%);
  color: #0f172a;
  border-inline-end: 1px solid rgba(4, 120, 87, 0.16);
  box-shadow: 6px 0 28px rgba(6, 78, 59, 0.07);
}

/* Brand Header */
.sidebar-brand-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid rgba(16, 185, 129, 0.18);
}
html[data-theme="light"] .sidebar-brand-header {
  border-bottom-color: rgba(4, 120, 87, 0.14);
}

.sidebar-brand-header .brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #10b981;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4), inset 0 0 8px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.sidebar-brand-header .brand-logo:hover {
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.6);
}

.sidebar-brand-titles h1 {
  font-size: 1.15rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ffffff 20%, #a7f3d0 75%, #fde68a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  letter-spacing: -0.3px;
}
html[data-theme="light"] .sidebar-brand-titles h1 {
  background: linear-gradient(135deg, #064e3b 0%, #047857 70%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.system-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.system-status-indicator::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid #10b981;
  animation: statusPulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
  opacity: 0.7;
}
@keyframes statusPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  70% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

.sidebar-brand-sub {
  font-size: 0.68rem;
  font-weight: 800;
  color: #34d399;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 0.15rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
html[data-theme="light"] .sidebar-brand-sub {
  color: #059669;
}

/* Teacher Identity Card (Executive Academic Credential) */
.sidebar-teacher-card {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08) 0%, rgba(6, 78, 59, 0.22) 50%, rgba(15, 23, 42, 0.35) 100%);
  border: 1px solid rgba(52, 211, 153, 0.28);
  border-radius: 16px;
  padding: 0.85rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(3, 24, 18, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.sidebar-teacher-card::before {
  content: '';
  position: absolute;
  top: -30%;
  inset-inline-end: -30%;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.16) 0%, transparent 70%);
  pointer-events: none;
  border-radius: 50%;
}
.sidebar-teacher-card:hover {
  border-color: rgba(52, 211, 153, 0.45);
  box-shadow: 0 6px 24px rgba(4, 120, 87, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}
html[data-theme="light"] .sidebar-teacher-card {
  background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
  border: 1px solid rgba(4, 120, 87, 0.2);
  box-shadow: 0 4px 16px rgba(4, 120, 87, 0.08);
}

.sidebar-teacher-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(217, 119, 6, 0.18) 100%);
  border: 1.5px solid rgba(52, 211, 153, 0.4);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.sidebar-teacher-card:hover .sidebar-teacher-avatar {
  transform: scale(1.08);
}
html[data-theme="light"] .sidebar-teacher-avatar {
  background: linear-gradient(135deg, #ecfdf5 0%, #fef3c7 100%);
  border: 1.5px solid rgba(4, 120, 87, 0.3);
}

.sidebar-teacher-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}
html[data-theme="light"] .sidebar-teacher-name {
  color: #064e3b;
}

.sidebar-teacher-school {
  font-size: 0.74rem;
  color: rgba(203, 213, 225, 0.85);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="light"] .sidebar-teacher-school {
  color: #475569;
}

.sidebar-teacher-card .role-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.22rem 0.55rem;
  border-radius: 99px;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.25) 0%, rgba(245, 158, 11, 0.18) 100%);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  box-shadow: 0 0 8px rgba(217, 119, 6, 0.2);
  white-space: nowrap;
}
html[data-theme="light"] .sidebar-teacher-card .role-badge {
  background: #fffbeb;
  border: 1px solid rgba(217, 119, 6, 0.4);
  color: #b45309;
}

.sidebar-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding-top: 0.65rem;
  margin-top: 0.65rem;
  border-top: 1px dashed rgba(52, 211, 153, 0.2);
}
html[data-theme="light"] .sidebar-kpi-row {
  border-top-color: rgba(4, 120, 87, 0.15);
}

.sidebar-kpi-pill {
  background: rgba(4, 28, 20, 0.6);
  border: 1px solid rgba(52, 211, 153, 0.22);
  border-radius: 10px;
  padding: 0.42rem 0.6rem;
  font-size: 0.76rem;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.sidebar-kpi-pill:hover {
  background: rgba(6, 78, 59, 0.45);
  border-color: rgba(52, 211, 153, 0.45);
  color: #ffffff;
}
.sidebar-kpi-pill strong {
  font-size: 0.9rem;
  font-weight: 900;
  color: #fde68a;
}
html[data-theme="light"] .sidebar-kpi-pill {
  background: #ffffff;
  border: 1px solid rgba(4, 120, 87, 0.18);
  color: #047857;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.05);
}
html[data-theme="light"] .sidebar-kpi-pill strong {
  color: #b45309;
}

/* Section Label */
.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #a7f3d0;
  padding: 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.sidebar-section-label::before {
  content: '◆';
  font-size: 0.55rem;
  color: #d97706;
}
.sidebar-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to left, transparent, rgba(52, 211, 153, 0.25));
}
html[data-theme="light"] .sidebar-section-label {
  color: #047857;
}
html[data-theme="light"] .sidebar-section-label::after {
  background: linear-gradient(to left, transparent, rgba(4, 120, 87, 0.15));
}

/* Navigation Tabs Container */
.academy-sidebar-nav.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

/* Navigation Tab Item */
.academy-sidebar-nav .tab-btn {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: start;
  padding: 0.68rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.84rem;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  gap: 0.6rem;
  white-space: nowrap;
}

.academy-sidebar-nav .tab-btn .tab-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: transform 0.25s ease, background 0.2s ease, border-color 0.2s ease;
}

.academy-sidebar-nav .tab-btn:hover {
  background: rgba(16, 185, 129, 0.1);
  color: #ffffff;
  border-color: rgba(52, 211, 153, 0.35);
  transform: translateX(-4px);
  box-shadow: 0 4px 16px rgba(4, 120, 87, 0.22);
}
html[dir="ltr"] .academy-sidebar-nav .tab-btn:hover {
  transform: translateX(4px);
}

.academy-sidebar-nav .tab-btn:hover .tab-icon {
  transform: scale(1.12);
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.4);
}

html[data-theme="light"] .academy-sidebar-nav .tab-btn {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(4, 120, 87, 0.12);
  color: #334155;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.03);
}
html[data-theme="light"] .academy-sidebar-nav .tab-btn .tab-icon {
  background: #f1f5f9;
  border-color: rgba(4, 120, 87, 0.15);
}
html[data-theme="light"] .academy-sidebar-nav .tab-btn:hover {
  background: #ecfdf5;
  border-color: rgba(4, 120, 87, 0.35);
  color: #064e3b;
  box-shadow: 0 4px 14px rgba(4, 120, 87, 0.1);
}

/* Active State General */
.academy-sidebar-nav .tab-btn.active {
  color: #ffffff !important;
  font-weight: 800 !important;
  box-shadow: 0 6px 20px -2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}
.academy-sidebar-nav .tab-btn.active .tab-icon {
  background: rgba(255, 255, 255, 0.22) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}
.academy-sidebar-nav .tab-btn.active::before {
  content: '';
  position: absolute;
  top: 15%;
  bottom: 15%;
  inset-inline-start: 0;
  width: 4px;
  border-radius: 99px;
  background: #ffffff;
  box-shadow: 0 0 10px #ffffff;
}

/* Individual Content-Matched Active Gradients */
/* 1. ToT Professional Modules (Royal Emerald/Teal Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-platform-levels"].active {
  background: linear-gradient(135deg, #047857 0%, #0d9488 60%, #14b8a6 100%) !important;
  border-color: #5eead4 !important;
  box-shadow: 0 8px 24px -2px rgba(13, 148, 136, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 2. School Curriculum Grades 4-9 (Royal Sapphire Navy Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-school-curriculum"].active {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #3b82f6 100%) !important;
  border-color: #93c5fd !important;
  box-shadow: 0 8px 24px -2px rgba(29, 78, 216, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 3. Lesson Planner (Emerald Pedagogical Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-ai-lesson-plan"].active {
  background: linear-gradient(135deg, #065f46 0%, #059669 60%, #10b981 100%) !important;
  border-color: #6ee7b7 !important;
  box-shadow: 0 8px 24px -2px rgba(5, 150, 105, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 4. Exam & Worksheet Maker (Luma Sky Cyan Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-ai-worksheet"].active {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 60%, #38bdf8 100%) !important;
  border-color: #7dd3fc !important;
  box-shadow: 0 8px 24px -2px rgba(2, 132, 199, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 5. Passage Simplifier & Vocab (Amber Gold Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-ai-simplifier"].active {
  background: linear-gradient(135deg, #92400e 0%, #d97706 60%, #f59e0b 100%) !important;
  border-color: #fde68a !important;
  box-shadow: 0 8px 24px -2px rgba(217, 119, 6, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 6. Pedagogical Trainer Consultation (Royal Violet Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-ai-trainer"].active {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #a855f7 100%) !important;
  border-color: #d8b4fe !important;
  box-shadow: 0 8px 24px -2px rgba(124, 58, 237, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 7. Preparation Book & Portfolio (Slate Indigo Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-prep-book"].active {
  background: linear-gradient(135deg, #1e293b 0%, #334155 60%, #475569 100%) !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 8px 24px -2px rgba(51, 65, 85, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

/* 8. Teacher Settings & Account (Navy Slate Theme) */
.academy-sidebar-nav .tab-btn[data-tab="tab-teacher"].active {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #334155 100%) !important;
  border-color: #94a3b8 !important;
  box-shadow: 0 8px 24px -2px rgba(15, 23, 42, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

.academy-sidebar-nav .tab-btn .tab-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.84rem;
  letter-spacing: -0.15px;
}

/* Badges on Navigation Tabs */
.academy-sidebar-nav .tab-counter-badge {
  background: rgba(4, 28, 20, 0.65) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.72rem;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  font-weight: 800;
  letter-spacing: -0.1px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.academy-sidebar-nav .tab-btn.active .tab-counter-badge {
  background: rgba(0, 0, 0, 0.3) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.35);
}
html[data-theme="light"] .academy-sidebar-nav .tab-btn:not(.active) .tab-counter-badge {
  background: rgba(4, 120, 87, 0.08) !important;
  color: #047857 !important;
  border-color: rgba(4, 120, 87, 0.2);
}

/* Semantic Badges on Specific Tabs */
.tab-counter-badge.badge-tool-plan {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #6ee7b7 !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
}
.tab-counter-badge.badge-tool-worksheet {
  background: rgba(2, 132, 199, 0.18) !important;
  color: #7dd3fc !important;
  border-color: rgba(2, 132, 199, 0.4) !important;
}
.tab-counter-badge.badge-tool-simplifier {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fde68a !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
}
.tab-counter-badge.badge-tool-trainer {
  background: rgba(139, 92, 246, 0.18) !important;
  color: #c4b5fd !important;
  border-color: rgba(139, 92, 246, 0.4) !important;
}

/* Footer Tools & External Links */
.sidebar-footer-tools {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(16, 185, 129, 0.18);
  display: grid;
  gap: 0.45rem;
}
html[data-theme="light"] .sidebar-footer-tools {
  border-top-color: rgba(4, 120, 87, 0.15);
}

.sidebar-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Cairo', sans-serif;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.sidebar-tool-btn:hover {
  background: rgba(16, 185, 129, 0.16);
  color: #ffffff;
  border-color: rgba(52, 211, 153, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(4, 120, 87, 0.25);
}
html[data-theme="light"] .sidebar-tool-btn {
  background: #ffffff;
  border-color: rgba(4, 120, 87, 0.15);
  color: #334155;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.04);
}
html[data-theme="light"] .sidebar-tool-btn:hover {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(4, 120, 87, 0.35);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.12);
}

.sidebar-tool-btn-luma {
  color: #38bdf8 !important;
  border-color: rgba(2, 132, 199, 0.35) !important;
  background: rgba(2, 132, 199, 0.08) !important;
}
.sidebar-tool-btn-luma:hover {
  background: rgba(2, 132, 199, 0.2) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3) !important;
}
html[data-theme="light"] .sidebar-tool-btn-luma {
  background: #f0f9ff !important;
  color: #0284c7 !important;
  border-color: rgba(2, 132, 199, 0.25) !important;
}

.sidebar-tool-btn-catalog {
  color: #fde68a !important;
  border-color: rgba(217, 119, 6, 0.35) !important;
  background: rgba(217, 119, 6, 0.08) !important;
}
.sidebar-tool-btn-catalog:hover {
  background: rgba(217, 119, 6, 0.2) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3) !important;
}
html[data-theme="light"] .sidebar-tool-btn-catalog {
  background: #fffbeb !important;
  color: #b45309 !important;
  border-color: rgba(217, 119, 6, 0.25) !important;
}

.sidebar-util-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.sidebar-util-bar .btn-assistance-toggle {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: #e2e8f0;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0.48rem 0.75rem;
  border-radius: 10px;
  transition: all 0.2s ease;
}
.sidebar-util-bar .btn-assistance-toggle:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.5);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}
html[data-theme="light"] .sidebar-util-bar .btn-assistance-toggle {
  background: #ffffff;
  border-color: rgba(4, 120, 87, 0.2);
  color: #047857;
}
html[data-theme="light"] .sidebar-util-bar .btn-assistance-toggle:hover {
  background: #ecfdf5;
  border-color: #047857;
}

.sidebar-util-bar .btn-icon-util {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  padding: 0.48rem;
  border-radius: 10px;
  font-size: 0.88rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-util-bar .btn-icon-util:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.45);
  color: #ffffff;
  transform: scale(1.08);
}
html[data-theme="light"] .sidebar-util-bar .btn-icon-util {
  background: #ffffff;
  border-color: rgba(4, 120, 87, 0.15);
  color: #334155;
}
html[data-theme="light"] .sidebar-util-bar .btn-icon-util:hover {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(4, 120, 87, 0.35);
}

.sidebar-util-bar .btn-logout-util:hover {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #fca5a5 !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3) !important;
}

.academy-main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

.academy-context-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.academy-crest-pill {
  background: linear-gradient(135deg, #1d4b8f 0%, #0284c7 100%);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.3rem 0.85rem;
  border-radius: 99px;
  border: 1px solid #38bdf8;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

.academy-main-area .workspace-container {
  max-width: 1340px;
  width: 100%;
  margin: 0 auto;
  padding: 1.35rem 1.75rem 2.5rem;
}

/* ==========================================================================
   ACADEMY GLOBAL REPEATING BRAND BANNER (LUMA SIGNATURE + BLUE HEART + MOTTO)
   ========================================================================== */
.academy-global-brand-banner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 247, 255, 0.92) 50%, rgba(236, 253, 245, 0.88) 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 22px;
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.45rem;
  box-shadow: 0 10px 30px -10px rgba(2, 132, 199, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.academy-global-brand-banner:hover {
  box-shadow: 0 14px 36px -8px rgba(2, 132, 199, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  border-color: rgba(56, 189, 248, 0.5);
}

/* Ambient glow accents inside banner */
.academy-global-brand-banner::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.28) 0%, transparent 70%);
  pointer-events: none;
}
.academy-global-brand-banner::after {
  content: '';
  position: absolute;
  bottom: -50px;
  left: -50px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

/* Dark Theme Support */
html[data-theme="dark"] .academy-global-brand-banner,
html[data-theme="emerald-pro"] .academy-global-brand-banner,
.theme-dark .academy-global-brand-banner {
  background: linear-gradient(135deg, rgba(6, 33, 25, 0.85) 0%, rgba(8, 30, 42, 0.9) 55%, rgba(15, 23, 42, 0.88) 100%);
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 10px 32px -8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.academy-global-brand-banner .luma-signature-wrap {
  max-width: 195px;
  width: 100%;
  margin: 0 auto;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  position: relative;
  z-index: 2;
}
.academy-global-brand-banner:hover .luma-signature-wrap {
  transform: scale(1.05);
}

.academy-global-brand-banner .luma-signature-img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 6px 14px rgba(2, 132, 199, 0.3));
  user-select: none;
}

.academy-global-brand-banner .luma-signature-motto {
  margin: 0.5rem auto 0 auto;
  font-family: 'Tajawal', 'Cairo', sans-serif;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.6;
  color: #184396;
  letter-spacing: -0.2px;
  position: relative;
  z-index: 2;
  text-align: center;
}

html[data-theme="dark"] .academy-global-brand-banner .luma-signature-motto,
html[data-theme="emerald-pro"] .academy-global-brand-banner .luma-signature-motto,
.theme-dark .academy-global-brand-banner .luma-signature-motto {
  color: #bae6fd;
  text-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

@media (max-width: 768px) {
  .academy-global-brand-banner {
    padding: 1rem 1.15rem;
    border-radius: 16px;
    margin-bottom: 1.15rem;
  }
  .academy-global-brand-banner .luma-signature-wrap {
    max-width: 155px;
  }
  .academy-global-brand-banner .luma-signature-motto {
    font-size: 0.94rem;
  }
}

.academy-hero-banner {
  background: linear-gradient(135deg, rgba(4, 120, 87, 0.09) 0%, rgba(217, 119, 6, 0.07) 100%);
  border: 1.5px solid var(--border-subtle);
  border-inline-start: 5px solid var(--brand-primary);
  border-radius: 16px;
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

/* Interactive Module, Grade & Unit Cards with Direct Click Affordance */
.level-card,
.grade-overview-card,
.unit-interactive-card {
  cursor: pointer !important;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease !important;
  position: relative;
}

.level-card:hover,
.grade-overview-card:hover,
.unit-interactive-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: var(--shadow-card-hover) !important;
  border-color: var(--brand-primary) !important;
}

/* Focused Grade Topbar & Compact Triple Book Ribbon */
.focused-grade-topbar {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 14px;
  padding: 0.9rem 1.15rem;
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  box-shadow: var(--shadow-xs);
}

.btn-back-overview {
  background: linear-gradient(135deg, #047857, #065f46) !important;
  color: #ffffff !important;
  border: 1px solid #f59e0b !important;
  font-weight: 800 !important;
  padding: 0.55rem 1rem !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 10px rgba(4, 120, 87, 0.22);
}

.compact-grade-pills.school-grades-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
}

.compact-grade-pills .grade-card-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 99px;
  min-height: unset;
}

.triple-books-compact-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.ribbon-book-item {
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  box-shadow: var(--shadow-xs);
}

.ribbon-book-teacher {
  border: 2px solid var(--brand-primary);
}

.ribbon-book-student {
  border: 2px solid #0284c7;
}

.ribbon-book-workbook {
  border: 2px solid #d97706;
}

.ribbon-book-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ribbon-book-badge {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--brand-primary);
}

.ribbon-book-info strong {
  font-size: 0.86rem;
  color: var(--text-primary);
}

.ribbon-book-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Full-Screen Book Viewer Modal */
.fullscreen-book-modal {
  width: 96vw !important;
  max-width: 1440px !important;
  height: 92dvh !important;
  max-height: 92dvh !important;
  padding: 0 !important;
  border-radius: 16px !important;
  border: 2px solid #10b981 !important;
  background: #06120e !important;
  overflow: hidden !important;
}

.fullscreen-book-modal[open] {
  display: flex !important;
  flex-direction: column !important;
}

.fullscreen-book-header {
  padding: 0.75rem 1.25rem;
  background: linear-gradient(90deg, #042f23 0%, #091e18 100%);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ==========================================================================
   8. MULTI-DEVICE ULTRA-RESPONSIVE ARCHITECTURE (DESKTOP • TABLET • MOBILE)
   Ensures 100% smooth layout, touch ergonomics, and zero horizontal overflow
   ========================================================================== */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Ensure Overview & Unit Cards have identical heights and crisp alignment */
.level-card.grade-overview-card,
.unit-interactive-card {
  min-height: 235px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Tablet & Compact Laptop Breakpoint (<= 1080px) */
@media (max-width: 1080px) {
  .academy-app-shell {
    grid-template-columns: 1fr;
  }

  .academy-sidebar {
    position: relative;
    height: auto;
    border-inline-end: none;
    border-bottom: 2px solid var(--brand-primary);
    padding: 0.9rem 1.15rem;
    gap: 0.75rem;
  }

  .sidebar-brand-header {
    padding-bottom: 0.65rem;
  }

  .sidebar-teacher-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
  }

  .sidebar-teacher-card > div:first-child {
    margin-bottom: 0 !important;
  }

  .sidebar-kpi-row {
    border-top: none;
    padding-top: 0;
    display: flex;
    gap: 0.5rem;
  }

  .sidebar-section-label {
    display: none;
  }

  .academy-sidebar-nav.nav-tabs {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.45rem;
    padding-bottom: 0.2rem;
  }

  .academy-sidebar-nav.nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .academy-sidebar-nav .tab-btn {
    width: auto;
    flex: 0 0 auto;
    padding: 0.58rem 0.9rem;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .academy-sidebar-nav .tab-btn.active::before {
    top: auto;
    bottom: 0;
    inset-inline-start: 15%;
    inset-inline-end: 15%;
    width: auto;
    height: 3px;
  }

  .sidebar-footer-tools {
    margin-top: 0;
    padding-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .sidebar-footer-tools > a {
    flex: 1 1 auto;
  }

  .sidebar-util-bar {
    margin-top: 0;
  }

  .academy-context-topbar {
    padding: 0.65rem 1.15rem;
  }

  .academy-main-area .workspace-container {
    padding: 1.1rem 1.15rem 2.25rem;
  }

  .levels-6-grid {
    grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
    gap: 0.95rem;
  }

  .school-group-units-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
  }
}

/* Mobile & Small Phablet Breakpoint (<= 680px) */
@media (max-width: 680px) {
  /* Auth & Orbital Convergence Arena on Mobile */
  #view-auth #animationStage {
    height: 350px !important;
  }

  #view-auth #academyHub {
    width: 15.5rem !important;
    padding: 0.95rem !important;
  }

  #view-auth .satellite-card {
    width: 9.5rem !important;
    padding: 0.6rem !important;
  }

  /* Compact App Sidebar & Sticky Horizontal Tab Bar on Mobile */
  .academy-sidebar {
    padding: 0.75rem 0.85rem;
    gap: 0.6rem;
  }

  .sidebar-brand-header .brand-logo {
    width: 40px;
    height: 40px;
  }

  .sidebar-brand-titles h1 {
    font-size: 1rem;
  }

  .sidebar-teacher-card {
    padding: 0.55rem 0.7rem;
  }

  .sidebar-kpi-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding-top: 0.4rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.14);
  }

  .academy-sidebar-nav .tab-btn {
    padding: 0.52rem 0.75rem;
    font-size: 0.78rem;
    border-radius: 10px;
  }

  .sidebar-footer-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .academy-context-topbar {
    padding: 0.55rem 0.85rem;
    gap: 0.45rem;
  }

  #hdr-gemini-status {
    font-size: 0.76rem !important;
    line-height: 1.35;
  }

  .academy-main-area .workspace-container {
    padding: 0.85rem 0.75rem 2rem;
  }

  .academy-hero-banner {
    padding: 0.9rem 1rem;
    border-radius: 14px;
  }

  .academy-hero-banner h2 {
    font-size: 1.08rem !important;
  }

  /* Force 1-Column Cards on Phones for Maximum Clarity & Zero Horizontal Clipping */
  .levels-6-grid,
  #platform-levels-grid,
  #school-grades-cards-grid,
  .school-group-units-grid,
  #platform-level-units-list,
  .triple-books-compact-ribbon,
  .grid-2col,
  .grid-3col {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .level-card,
  .grade-overview-card,
  .unit-interactive-card,
  .card {
    padding: 0.95rem !important;
    border-radius: 14px !important;
  }

  .focused-grade-topbar {
    padding: 0.75rem 0.85rem;
    flex-direction: column;
    align-items: stretch;
  }

  .compact-grade-pills.school-grades-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.2rem;
  }

  .compact-grade-pills .grade-card-btn {
    flex: 0 0 auto;
    padding: 0.38rem 0.75rem;
  }

  .ribbon-book-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .ribbon-book-actions {
    width: 100%;
    display: flex;
  }

  .ribbon-book-actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* Lesson Player Mobile Optimizations */
  #view-lesson-player {
    padding: 0.75rem 0.65rem 2.25rem;
  }

  .lesson-focus-topbar {
    padding: 0.7rem 0.85rem;
    gap: 0.6rem;
  }

  .lesson-stepper-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    padding: 0.4rem;
  }

  .step-tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 0.6rem 0.85rem;
  }

  #active-lesson-book-ref-banner {
    flex-direction: column;
    align-items: stretch !important;
  }

  /* Full-Screen Book Viewer Overlay on Mobile */
  .fullscreen-book-header {
    padding: 0.6rem 0.75rem !important;
    gap: 0.5rem !important;
  }

  #fs-book-modal-title {
    font-size: 0.88rem !important;
  }

  /* Native Dialog Modals on Mobile */
  dialog.app-modal,
  dialog.modal-lg {
    width: calc(100% - 1rem) !important;
    max-width: calc(100% - 1rem) !important;
    padding: 1rem !important;
    border-radius: 14px !important;
  }
}

@media print {
  .top-header,
  .academy-sidebar,
  .academy-context-topbar,
  .nav-tabs,
  .btn,
  #form-ai-lesson-plan,
  #form-ai-worksheet,
  #billing-plans-grid {
    display: none !important;
  }

  .academy-app-shell {
    display: block !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
  }
}

/* =====================================================================
   STAGE 5: LISTENING LAB & TOT CERTIFICATE STYLING
   ===================================================================== */
.audio-sentence {
  display: block;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.audio-sentence:hover {
  background: rgba(2, 132, 199, 0.06);
}

.audio-sentence.active-sentence-glow {
  background: #e0f2fe !important;
  border: 1.5px solid #0284c7 !important;
  color: #0369a1 !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15) !important;
  transform: translateX(4px);
}

.sentence-en {
  font-size: 1.05rem;
  line-height: 1.5;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

.sentence-ar {
  font-size: 0.84rem;
  color: #0284c7;
  direction: rtl;
  text-align: right;
  margin-top: 0.2rem;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
}

.audio-vocab-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.audio-vocab-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 1px solid #86efac;
  border-radius: 99px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  transition: all 0.2s ease;
}

.audio-vocab-chip:hover {
  border-color: #10b981;
  background: #f0fdf4;
}

.audio-vocab-speak-btn {
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  transition: transform 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.audio-vocab-speak-btn:hover {
  transform: scale(1.15);
  background: #059669;
}

/* Print Certificate Specifics */
@media print {
  body.printing-cert * {
    visibility: hidden;
  }
  body.printing-cert #tot-certificate-print-mount,
  body.printing-cert #tot-certificate-print-mount * {
    visibility: visible;
  }
  body.printing-cert #tot-certificate-print-mount {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    border: 8px double #d97706 !important;
    box-shadow: none !important;
    background: #fffcf2 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}


