/* ==========================================================================
   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 {
  /* Sober & Professional Slate / Royal Enterprise Palette */
  --bg-canvas-light: #f8fafc;
  --bg-canvas-dark: #0b1120;
  --bg-surface-light: #ffffff;
  --bg-surface-dark: #111827;
  --bg-elevated-light: #f1f5f9;
  --bg-elevated-dark: #1e293b;

  --text-primary-light: #0f172a;
  --text-primary-dark: #f8fafc;
  --text-muted-light: #475569;
  --text-muted-dark: #94a3b8;

  --brand-primary-light: #1d4ed8;
  --brand-primary-dark: #38bdf8;
  --brand-accent-light: #2563eb;
  --brand-accent-dark: #60a5fa;

  --border-subtle-light: #e2e8f0;
  --border-subtle-dark: #334155;

  --scrollbar-track-light: #f1f5f9;
  --scrollbar-track-dark: #0b1120;
  --scrollbar-thumb-light: #cbd5e1;
  --scrollbar-thumb-dark: #475569;

  /* Modern Multi-layer Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --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);

  /* 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);
}

/* 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;
}

.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);
}


