/* ═══════════════════════════════════════════════════════════
   KHL-GALILEO SCIENCE CENTRE — Global Design System v2.0
   Cosmic Dark Theme | EN/SW Bilingual | AI-Powered Platform
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap&font-display=swap');

/* ── TOKENS ── */
:root {
  --ink:       #07080f;
  --deep:      #0a0b14;
  --navy:      #0d0f1e;
  --blue:      #1a1f3a;
  --mid:       #1e2444;
  --gold:      #c8960a;
  --amber:     #d97706;
  --glow:      #f0b429;
  --teal:      #0891b2;
  --cyan:      #06b6d4;
  --violet:    #7c3aed;
  --rose:      #db2777;
  --green:     #059669;
  --red:       #dc2626;
  --orange:    #ea580c;
  --silver:    #cbd5e1;
  --dim:       #475569;
  --white:     #f1f5f9;
  --off-white: #e2e8f0;

  --card:      rgba(255,255,255,0.04);
  --card-hi:   rgba(255,255,255,0.07);
  --glass:     rgba(255,255,255,0.05);
  --glass-hi:  rgba(255,255,255,0.09);
  --border:    rgba(255,255,255,0.08);
  --border-hi: rgba(200,150,10,0.35);
  --border-tl: rgba(8,145,178,0.30);
  --border-vl: rgba(124,58,237,0.30);

  --shadow-sm:  0 4px 15px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 30px rgba(0,0,0,0.4);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.5);
  --shadow-xl:  0 40px 100px rgba(0,0,0,0.6);
  --glow-gold:  0 0 30px rgba(200,150,10,0.4);
  --glow-teal:  0 0 30px rgba(10,184,212,0.4);
  --glow-cyan:  0 0 40px rgba(0,229,255,0.3);

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 40px;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans:  'Outfit', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', monospace;

  --nav-h: 72px;
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;

  --transition: all 0.25s cubic-bezier(.4,0,.2,1);
  --transition-slow: all 0.5s cubic-bezier(.4,0,.2,1);

  /* ── ALIAS VARS (used by auth.html & others) ── */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #94a3b8;
  --text-dim:       #475569;
  --grad-gold: linear-gradient(135deg, #c8960a, #d97706);
  --grad-teal: linear-gradient(135deg, #0891b2, #06b6d4);
  --grad-violet: linear-gradient(135deg, #7c3aed, #6d28d9);
  --grad-red: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* ── LIGHT MODE OVERRIDES ── */
[data-theme="light"] {
  --ink:       #ffffff;
  --deep:      #f8fafc;
  --navy:      #f1f5f9;
  --blue:      #e2e8f0;
  --mid:       #cbd5e1;
  --gold:      #b07d08;
  --amber:     #b45309;
  --glow:      #d97706;
  --teal:      #0369a1;
  --cyan:      #0284c7;
  --violet:    #6d28d9;
  --rose:      #be185d;
  --green:     #047857;
  --red:       #b91c1c;
  --orange:    #c2410c;
  --silver:    #334155;
  --dim:       #64748b;
  --white:     #0f172a;
  --off-white: #1e293b;

  --card:      rgba(0,0,0,0.04);
  --card-hi:   rgba(0,0,0,0.07);
  --glass:     rgba(255,255,255,0.75);
  --glass-hi:  rgba(255,255,255,0.92);
  --border:    rgba(0,0,0,0.09);
  --border-hi: rgba(180,83,9,0.35);
  --border-tl: rgba(3,105,161,0.3);
  --border-vl: rgba(109,40,217,0.3);

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.1);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl:  0 30px 70px rgba(0,0,0,0.15);
  --glow-gold:  0 0 20px rgba(180,83,9,0.15);
  --glow-teal:  0 0 20px rgba(3,105,161,0.15);
  --glow-cyan:  0 0 25px rgba(2,132,199,0.1);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;
  --text-dim:       #94a3b8;

  --grad-gold:   linear-gradient(135deg,#b07d08,#b45309);
  --grad-teal:   linear-gradient(135deg,#0369a1,#0284c7);
  --grad-violet: linear-gradient(135deg,#6d28d9,#5b21b6);
  --grad-red:    linear-gradient(135deg,#b91c1c,#991b1b);
}
[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 70% 50% at 70% 30%, color-mix(in srgb, var(--color-accent) 4%, transparent) 0%, transparent 65%),
    radial-gradient(ellipse 50% 40% at 20% 80%, color-mix(in srgb, var(--color-violet) 3%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 90% 10%, color-mix(in srgb, var(--color-warning) 3%, transparent) 0%, transparent 55%);
}
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--navy); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--mid); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: var(--blue); }
[data-theme="light"] .topbar { background: var(--color-surface); }
[data-theme="light"] .topbar-search input { color: var(--white); }
[data-theme="light"] .modal-backdrop { background: var(--color-surface); }
[data-theme="light"] .modal { background: var(--deep); }
[data-theme="light"] .toast { background: var(--navy); }
[data-theme="light"] .certificate-preview {
  background: linear-gradient(135deg,var(--color-surface) 0%,var(--color-surface) 50%,var(--color-surface) 100%);
}
[data-theme="light"] #cosmos-bg { opacity: 0.05; }
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg,var(--card) 25%,var(--color-raise-2) 50%,var(--card) 75%);
  background-size: 200% 100%;
}

/* ── THEME TOGGLE BUTTON ── */
#theme-toggle {
  position: fixed; bottom: 5rem; right: 1.5rem; z-index: 9990;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  font-size: 1.1rem; cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px);
}
#theme-toggle:hover { transform: scale(1.12); border-color: var(--border-hi); }

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 70% 50% at 70% 30%, color-mix(in srgb, var(--color-accent) 6%, transparent) 0%, transparent 65%),
    radial-gradient(ellipse 50% 40% at 20% 80%, color-mix(in srgb, var(--color-violet) 5%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 90% 10%, color-mix(in srgb, var(--color-warning) 4%, transparent) 0%, transparent 55%);
  color: var(--silver);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; height: auto; }
ul, ol { list-style: none; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--deep); }
::-webkit-scrollbar-thumb { background: var(--navy); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

/* ── TYPOGRAPHY ── */
.t-serif { font-family: var(--font-serif); }
.t-mono  { font-family: var(--font-mono); }
.t-caps  { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 3px; text-transform: uppercase; }
.t-label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--amber); }

h1,h2,h3,h4,h5,h6 { color: var(--white); font-family: var(--font-serif); font-weight: 700; line-height: 1.2; }
p { line-height: 1.7; }

/* ── LAYOUT ── */
.container { max-width: 1400px; margin: 0 auto; padding: 0 2rem; }
.section { padding: 5rem 2rem; }
.section-sm { padding: 3rem 2rem; }

/* ── COSMOS CANVAS ── */
#cosmos-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}

/* ── GLASS CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: var(--transition);
}
.card:hover { border-color: var(--color-border); background: var(--card-hi); }
.card-glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.card-glow-gold { border-color: var(--border-hi); box-shadow: var(--glow-gold); }
.card-glow-teal { border-color: var(--border-tl); box-shadow: var(--glow-teal); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px; border-radius: var(--r-sm);
  font-family: var(--font-sans); font-size: 0.875rem; font-weight: 600;
  transition: var(--transition); cursor: pointer; border: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--amber));
  color: var(--ink);
  box-shadow: 0 6px 25px color-mix(in srgb, var(--color-shadow) 21%, transparent);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px color-mix(in srgb, var(--color-shadow) 30%, transparent); }
.btn-teal {
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  color: var(--ink);
  box-shadow: 0 6px 25px color-mix(in srgb, var(--color-shadow) 21%, transparent);
}
.btn-teal:hover { transform: translateY(-2px); box-shadow: 0 12px 40px color-mix(in srgb, var(--color-shadow) 30%, transparent); }
.btn-ghost {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--white);
  backdrop-filter: blur(10px);
}
.btn-ghost:hover { border-color: var(--border-hi); background: color-mix(in srgb, var(--color-primary) 8%, transparent); color: var(--amber); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--silver);
}
.btn-outline:hover { border-color: var(--border-hi); color: var(--amber); }
.btn-danger {
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
  color: var(--red);
}
.btn-danger:hover { background: color-mix(in srgb, var(--color-error) 25%, transparent); }
.btn-sm { padding: 7px 16px; font-size: 0.8rem; }
.btn-lg { padding: 15px 36px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-loading { position: relative; pointer-events: none; }
.btn-loading::after {
  content: ''; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--color-border); border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
}

/* ── FORM INPUTS ── */
.field { margin-bottom: 1.2rem; }
.field label {
  display: block; font-size: 0.78rem; font-weight: 500;
  color: var(--silver); margin-bottom: 6px; letter-spacing: 0.3px;
}
.field label .req { color: var(--red); margin-left: 2px; }
.field-wrap { position: relative; }
.field-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 0.9rem; pointer-events: none; z-index: 1;
}
.field-input {
  width: 100%;
  background: var(--color-raise-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 14px 11px 42px;
  color: var(--white); font-family: var(--font-sans); font-size: 0.88rem;
  outline: none; transition: var(--transition);
}
.field-input::placeholder { color: var(--dim); }
.field-input:focus { border-color: var(--border-hi); background: color-mix(in srgb, var(--color-primary) 5%, transparent); }
.field-input.has-error { border-color: var(--color-error); }
.field-input.has-success { border-color: color-mix(in srgb, var(--color-success) 40%, transparent); }
.field-input-no-icon { padding-left: 14px; }
.field-error { font-size: 0.7rem; color: var(--red); margin-top: 4px; display: none; }
.field-error.show { display: block; }
select.field-input { cursor: pointer; }
select.field-input option { background: var(--deep); color: var(--white); }
textarea.field-input { padding-top: 12px; resize: vertical; min-height: 100px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-gold    { background: color-mix(in srgb, var(--color-primary) 15%, transparent); color: var(--amber); border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent); }
.badge-teal    { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--teal); border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent); }
.badge-green   { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--green); border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent); }
.badge-red     { background: color-mix(in srgb, var(--color-error) 15%, transparent); color: var(--red); border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent); }
.badge-violet  { background: color-mix(in srgb, var(--color-violet) 15%, transparent); color: var(--violet); border: 1px solid color-mix(in srgb, var(--color-violet) 30%, transparent); }
.badge-silver  { background: var(--color-raise-3); color: var(--silver); border: 1px solid var(--border); }

/* ── STAT CARDS ── */
.stat-card { padding: 1.4rem; }
.stat-card .stat-val {
  font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700;
  color: var(--white); line-height: 1; margin-bottom: 4px;
}
.stat-card .stat-label { font-size: 0.75rem; color: var(--dim); }
.stat-card .stat-trend { font-size: 0.72rem; margin-top: 6px; }
.stat-card .stat-trend.up   { color: var(--green); }
.stat-card .stat-trend.down { color: var(--red); }

/* ── PROGRESS BARS ── */
.progress-bar {
  height: 6px; background: var(--color-raise-2);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), var(--amber));
  transition: width 1s ease;
}
.progress-fill.teal { background: linear-gradient(90deg, var(--teal), var(--cyan)); }
.progress-fill.green { background: linear-gradient(90deg, var(--green), var(--color-success)); }
.progress-fill.violet { background: linear-gradient(90deg, var(--violet), var(--color-violet)); }

/* ── TABS ── */
.tabs {
  display: flex; gap: 4px;
  background: var(--color-raise-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 4px;
}
.tab {
  flex: 1; padding: 9px 16px; border-radius: var(--r-sm);
  font-size: 0.85rem; font-weight: 600; color: var(--dim);
  transition: var(--transition); text-align: center; cursor: pointer;
}
.tab.active {
  background: linear-gradient(135deg, var(--gold), var(--amber));
  color: var(--ink);
  box-shadow: 0 4px 15px color-mix(in srgb, var(--color-shadow) 18%, transparent);
}

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.8rem; pointer-events: none;
}
.toast {
  background: var(--deep); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 1rem 1.4rem;
  display: flex; align-items: center; gap: 0.8rem;
  box-shadow: var(--shadow-lg); max-width: 360px;
  transform: translateX(120%); opacity: 0;
  transition: all 0.4s cubic-bezier(.175,.885,.32,1.275);
  pointer-events: all;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { border-color: color-mix(in srgb, var(--color-success) 30%, transparent); }
.toast.error   { border-color: color-mix(in srgb, var(--color-error) 30%, transparent); }
.toast.info    { border-color: color-mix(in srgb, var(--color-accent) 30%, transparent); }
.toast.warning { border-color: color-mix(in srgb, var(--color-warning) 30%, transparent); }
.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: 0.85rem; font-weight: 600; color: var(--white); }
.toast-sub   { font-size: 0.75rem; color: var(--dim); margin-top: 2px; }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--color-background);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; padding: 2rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--deep); border: 1px solid var(--border);
  border-radius: var(--r-xl); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.4s cubic-bezier(.175,.885,.32,1.275) forwards;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 1.8rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 1.5rem 2rem; }
.modal-footer { padding: 1rem 2rem 1.8rem; display: flex; gap: 0.8rem; justify-content: flex-end; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--dim); cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover { background: color-mix(in srgb, var(--color-error) 10%, transparent); border-color: color-mix(in srgb, var(--color-error) 30%, transparent); color: var(--red); }

/* ── SIDEBAR LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--deep);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  z-index: 100; transition: width 0.3s ease;
  display: flex; flex-direction: column;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-logo {
  padding: 1.4rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold), var(--amber));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem;
  color: var(--ink);
  box-shadow: 0 4px 20px color-mix(in srgb, var(--color-shadow) 24%, transparent);
}
.sidebar-logo-text { overflow: hidden; white-space: nowrap; }
.sidebar-logo-name {
  font-family: var(--font-serif); font-size: 0.85rem;
  color: var(--white); font-weight: 700; line-height: 1.3;
}
.sidebar-logo-sub {
  font-family: var(--font-mono); font-size: 0.6rem;
  color: var(--amber); letter-spacing: 1px;
}
.sidebar-nav { flex: 1; padding: 1rem 0.8rem; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-label {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 2px;
  color: var(--dim); text-transform: uppercase; padding: 0 0.6rem 0.5rem;
  display: block; overflow: hidden; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 0.65rem 0.8rem; border-radius: var(--r-sm);
  font-size: 0.84rem; color: var(--dim); font-weight: 500;
  transition: var(--transition); cursor: pointer; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden;
  position: relative; text-decoration: none;
}
.nav-item:hover { background: var(--color-raise-2); color: var(--white); }
.nav-item.active {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--amber);
  border-left: 3px solid var(--amber);
}
.nav-item .nav-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto; min-width: 20px; height: 20px;
  background: var(--amber); color: var(--ink);
  border-radius: 10px; font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px; flex-shrink: 0;
}
.nav-item .nav-label { overflow: hidden; }
.sidebar-footer {
  padding: 1rem 0.8rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 0.7rem 0.8rem; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--border);
  overflow: hidden; white-space: nowrap;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: var(--ink);
}
.sidebar-user-name { font-size: 0.82rem; color: var(--white); font-weight: 600; }
.sidebar-user-role { font-size: 0.68rem; color: var(--dim); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.main-content.collapsed-sidebar { margin-left: var(--sidebar-collapsed); }

/* ── TOP BAR ── */
.topbar {
  height: var(--nav-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  padding: 0 2rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-family: var(--font-serif); font-size: 1.2rem; color: var(--white); font-weight: 700; }
.topbar-spacer { flex: 1; }
.topbar-search {
  position: relative; display: flex; align-items: center;
}
.topbar-search input {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 14px 8px 38px;
  color: var(--white); font-size: 0.84rem; outline: none;
  transition: var(--transition); width: 260px;
}
.topbar-search input:focus { border-color: var(--border-hi); background: color-mix(in srgb, var(--color-primary) 5%, transparent); width: 320px; }
.topbar-search .search-icon {
  position: absolute; left: 12px; font-size: 0.85rem; color: var(--dim); pointer-events: none;
}
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: var(--dim); cursor: pointer;
  transition: var(--transition); position: relative;
}
.icon-btn:hover { background: var(--glass); color: var(--white); border-color: var(--color-border); }
.icon-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber); border: 2px solid var(--deep);
}
.lang-toggle {
  display: flex; gap: 2px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 3px;
}
.lang-btn {
  padding: 4px 10px; border-radius: 5px;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  color: var(--dim); cursor: pointer; transition: var(--transition);
}
.lang-btn.active {
  background: linear-gradient(135deg, var(--gold), var(--amber));
  color: var(--ink);
}

/* ── GRID HELPERS ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.grid-auto-sm { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* ── XP / ACHIEVEMENT ── */
.xp-bar-wrap { background: var(--color-raise-2); border-radius: 10px; height: 10px; overflow: hidden; }
.xp-bar { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--violet), var(--cyan)); transition: width 1.2s ease; }
.achievement-badge {
  width: 60px; height: 60px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; transition: var(--transition); cursor: pointer;
}
.achievement-badge.earned { box-shadow: 0 0 20px color-mix(in srgb, var(--color-shadow) 24%, transparent); }
.achievement-badge.locked { filter: grayscale(1) opacity(0.4); }

/* ── BLOOM LEVELS ── */
.bloom-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 700;
}
.bloom-1 { background: color-mix(in srgb, var(--color-error) 12%, transparent); color: var(--color-error); border: 1px solid color-mix(in srgb, var(--color-error) 25%, transparent); }
.bloom-2 { background: color-mix(in srgb, var(--color-warning) 12%, transparent); color: var(--color-warning); border: 1px solid color-mix(in srgb, var(--color-warning) 25%, transparent); }
.bloom-3 { background: color-mix(in srgb, var(--color-primary) 12%, transparent); color: var(--color-emphasis); border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent); }
.bloom-4 { background: color-mix(in srgb, var(--color-success) 12%, transparent); color: var(--color-success); border: 1px solid color-mix(in srgb, var(--color-success) 25%, transparent); }
.bloom-5 { background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent-text); border: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent); }
.bloom-6 { background: color-mix(in srgb, var(--color-violet) 12%, transparent); color: var(--color-violet); border: 1px solid color-mix(in srgb, var(--color-violet) 25%, transparent); }

/* ── LEADERBOARD ── */
.lb-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--card);
  margin-bottom: 0.5rem; transition: var(--transition);
}
.lb-row:hover { border-color: var(--color-border); background: var(--card-hi); }
.lb-rank {
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700;
  color: var(--dim); width: 24px; text-align: center;
}
.lb-rank.gold   { color: var(--color-emphasis); }
.lb-rank.silver { color: var(--color-text-secondary); }
.lb-rank.bronze { color: var(--color-warning); }
.lb-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: var(--ink);
}
.lb-info { flex: 1; }
.lb-name { font-size: 0.85rem; color: var(--white); font-weight: 600; }
.lb-school { font-size: 0.72rem; color: var(--dim); }
.lb-score { font-family: var(--font-mono); font-size: 0.9rem; color: var(--amber); font-weight: 700; }

/* ── SUBJECT COLORS ── */
.subj-physics  { --sc: #00b4d8; }
.subj-chemistry{ --sc: #e8a020; }
.subj-biology  { --sc: #64c864; }
.subj-math     { --sc: #b46dff; }
.subj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sc); flex-shrink: 0; }

/* ── VIRTUAL LAB ── */
.lab-canvas {
  background: var(--color-overlay); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  position: relative;
}
.lab-toolbar {
  display: flex; gap: 0.5rem; padding: 0.8rem;
  background: var(--color-overlay); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.lab-tool {
  padding: 6px 12px; border-radius: var(--r-sm); font-size: 0.78rem;
  background: var(--card); border: 1px solid var(--border);
  color: var(--silver); cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 5px;
}
.lab-tool:hover { border-color: var(--border-hi); color: var(--amber); }
.lab-tool.active { background: color-mix(in srgb, var(--color-primary) 10%, transparent); border-color: var(--border-hi); color: var(--amber); }

/* ── ANIMATIONS ── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn  { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 30px color-mix(in srgb, var(--color-shadow) 24%, transparent); }
  50%      { box-shadow: 0 0 60px color-mix(in srgb, var(--color-shadow) 42%, transparent), 0 0 100px color-mix(in srgb, var(--color-shadow) 18%, transparent); }
}
@keyframes cosmicFloat {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-20px) rotate(5deg); }
}
@keyframes orbitRing {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes starTwinkle {
  0%,100% { opacity: 0.3; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.2); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.anim-fade-up  { animation: fadeUp 0.6s ease forwards; }
.anim-slide-in { animation: slideIn 0.5s ease forwards; }
.anim-float    { animation: cosmicFloat 6s ease-in-out infinite; }
.anim-pulse    { animation: pulseGlow 3s ease-in-out infinite; }
.anim-orbit    { animation: orbitRing 20s linear infinite; }
.anim-orbit-rev { animation: orbitRing 15s linear infinite reverse; }

/* ── SHIMMER SKELETON ── */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--color-raise-2) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ── OTP INPUT ── */
.otp-inputs { display: flex; gap: 0.6rem; justify-content: center; }
.otp-input {
  width: 50px; height: 56px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-sm); text-align: center;
  font-family: var(--font-mono); font-size: 1.4rem;
  color: var(--white); outline: none; transition: var(--transition);
}
.otp-input:focus { border-color: var(--border-hi); background: color-mix(in srgb, var(--color-primary) 5%, transparent); }

/* ── PASSWORD STRENGTH ── */
.pass-bars { display: flex; gap: 4px; margin: 6px 0 4px; }
.pass-bar  { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.3s; }
.pass-bar.weak   { background: var(--red); }
.pass-bar.medium { background: var(--amber); }
.pass-bar.strong { background: var(--green); }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar-search input { width: 180px; }
  .topbar-search input:focus { width: 220px; }
  .section { padding: 3rem 1.2rem; }
  .container { padding: 0 1.2rem; }
}
@media (max-width: 480px) {
  .otp-input { width: 40px; height: 48px; font-size: 1.2rem; }
  .topbar-search { display: none; }
}

/* ── CYBER SECURITY INDICATOR ── */
.security-shield {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--green); opacity: 0.8;
}
.security-shield::before { content: '🛡'; font-size: 0.75rem; }

/* ── SUBSCRIPTION TIERS ── */
.tier-card {
  border-radius: var(--r-xl); padding: 2rem 1.8rem;
  background: var(--card); border: 2px solid var(--border);
  position: relative; overflow: hidden; transition: var(--transition);
}
.tier-card:hover { transform: translateY(-6px); }
.tier-card.popular { border-color: var(--border-hi); }
.tier-card.popular::before {
  content: 'MOST POPULAR';
  position: absolute; top: 16px; right: -28px;
  font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 1px;
  color: var(--ink); background: var(--amber);
  padding: 4px 36px; transform: rotate(45deg);
}
.tier-price {
  font-family: var(--font-mono); font-size: 2.4rem; color: var(--white);
  font-weight: 700; line-height: 1;
}
.tier-price sup { font-size: 1rem; vertical-align: top; margin-top: 6px; }
.tier-price sub { font-size: 0.8rem; color: var(--dim); }

/* ── CERTIFICATE ── */
.certificate-preview {
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-surface-elevated) 50%, var(--color-surface-elevated) 100%);
  border: 3px solid var(--gold);
  border-radius: var(--r-lg); padding: 3rem;
  position: relative; overflow: hidden;
  box-shadow: 0 0 60px color-mix(in srgb, var(--color-shadow) 18%, transparent), inset 0 0 60px color-mix(in srgb, var(--color-shadow) 30%, transparent);
}
.certificate-preview::before {
  content: '';
  position: absolute; inset: 12px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  border-radius: var(--r-md); pointer-events: none;
}

/* ── AI CHAT ── */
.ai-chat-bubble {
  padding: 0.9rem 1.2rem; border-radius: var(--r-md);
  max-width: 80%; font-size: 0.88rem; line-height: 1.6;
}
.ai-chat-bubble.ai {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent); border: 1px solid var(--border-tl);
  color: var(--silver); border-bottom-left-radius: 4px;
}
.ai-chat-bubble.user {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent); border: 1px solid var(--border-hi);
  color: var(--silver); border-bottom-right-radius: 4px; margin-left: auto;
}
.ai-typing { display: flex; gap: 4px; align-items: center; padding: 0.6rem; }
.ai-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal); animation: aiDot 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDot { 0%,80%,100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* ── COSMIC PARTICLE ── */
.particle {
  position: absolute;
  border-radius: 50%;
  background: var(--color-primary);
  animation: particleFloat linear infinite;
  pointer-events: none;
}
@keyframes particleFloat {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-400px) translateX(var(--dx, 0)) scale(0); opacity: 0; }
}

/* ── CHEATING DETECTION OVERLAY ── */
.anti-cheat-warning {
  position: fixed; inset: 0; z-index: 9998;
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.anti-cheat-warning.show { display: flex; }
.anti-cheat-box {
  background: var(--deep); border: 2px solid var(--color-error);
  border-radius: var(--r-xl); padding: 3rem; text-align: center; max-width: 480px;
  box-shadow: 0 0 60px color-mix(in srgb, var(--color-shadow) 18%, transparent);
}

/* ── LIVE FEED ITEMS ── */
.feed-item {
  display: flex; gap: 1rem; padding: 0.8rem;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--card); margin-bottom: 0.6rem;
  animation: feedIn 0.4s ease;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; margin-top: 6px; box-shadow: 0 0 8px color-mix(in srgb, var(--color-shadow) 36%, transparent); }
.feed-text { font-size: 0.8rem; color: var(--silver); line-height: 1.5; }
.feed-time { font-family: var(--font-mono); font-size: 0.66rem; color: var(--dim); margin-top: 2px; }

/* ── UTILITY ── */
.text-gold   { color: var(--amber); }
.text-teal   { color: var(--teal); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-violet { color: var(--violet); }
.text-dim    { color: var(--dim); }
.text-white  { color: var(--white); }
.text-muted  { color: var(--dim); font-size: 0.82rem; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-700      { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.p-1  { padding: 0.5rem; }
.p-2  { padding: 1rem; }
.p-3  { padding: 1.5rem; }
.p-4  { padding: 2rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-1  { gap: 0.5rem; }
.flex-gap-2  { gap: 1rem; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.show   { display: block !important; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.rounded-full { border-radius: 9999px; }
.cursor-pointer { cursor: pointer; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ── Small screens (phones) ─────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Home header: brand on one line, compact buttons, language switch moves out of the way */
  .navbar .nav-brand-sub { display: none; }
  .navbar .nav-brand-name { font-size: .82rem; line-height: 1.15; max-width: 9.5rem; }
  .navbar .lang-toggle { display: none; }
  .navbar .nav-actions { gap: 6px; }
  .navbar .nav-actions .btn-sm { padding: 7px 11px; font-size: .78rem; }
  /* Dashboard welcome banner: stack instead of squeezing into one column */
  .xp-hero { flex-direction: column; align-items: stretch; text-align: left; gap: 14px; }
  .xp-hero-info { width: 100%; }
  .xp-hero-stats { gap: 8px; }
  .xp-stat { flex: 1 1 calc(50% - 8px); }
  .topbar :is(.search-wrap, .topbar-search, .search-box) { display: none; }
  /* Dashboards: the main column must shrink to the screen, not grow to its widest child */
  .main { min-width: 0; max-width: 100vw; }
  .topbar { min-width: 0; }
  .admin-hero, .admin-hero-stats, .admin-actions { flex-wrap: wrap; }
  .live-bar { flex-wrap: wrap; row-gap: 6px; }
  .live-bar .live-sep { display: none; }
}
/* Phone: the header has room only for the menu and buttons */
@media (max-width: 600px) {
  .topbar-left { min-width: 0; flex: 1 1 auto; }
  .topbar-left > div:not(.search-wrap) { min-width: 0; }
  .topbar-greeting, .topbar-date { display: none; }   /* the page's own heading card shows the title */
}

/* Phones: frosted-glass blur is very slow to draw on small devices — use solid panels */
@media (max-width: 900px) {
  *, *::before, *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
