/* ==========================================================================
   IVMEDU WEB PLATFORM - GLOBAL STYLESHEET
   Design System, Components, Layouts, Utilities
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Color Palette */
  --primary: #3478f6;
  --primary-hover: #245be8;
  --primary-light: #eaf1ff;
  --primary-gradient: linear-gradient(120deg, #55a8ff 0%, #3478f6 52%, #294fe8 100%);
  --secondary: #35cfe3;
  --secondary-hover: #159fca;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Neutral Shades */
  --bg-main: #eef3f8;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --border-color: #e2e8f0;
  --border-focus: #56d7ec;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --white: #ffffff;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 10px 25px -5px rgba(47, 115, 245, 0.35);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

:root[data-theme='dark'] {
  --bg-main: #0a101c;
  --bg-card: #121d2d;
  --bg-glass: rgba(11, 18, 32, .88);
  --border-color: #263951;
  --border-focus: #56d7ec;
  --text-main: #edf7ff;
  --text-muted: #9eb3c8;
  --text-light: #7890a7;
  --white: #f8fcff;
  --primary-light: #123b72;
}

html[data-theme='dark'] body { background-color: var(--bg-main); color: var(--text-main); }
html[data-theme='light'] .auth-wrapper { background: #f4f8fc; }
html[data-theme='light'] .auth-wrapper::before { opacity: .18; }
html[data-theme='dark'] .navbar { background: var(--bg-glass); border-color: var(--border-color); }
html[data-theme='dark'] .auth-card, html[data-theme='dark'] .modal-content { background: var(--bg-card); color: var(--text-main); border-color: var(--border-color); }

.preference-controls { align-items: center; display: inline-flex; gap: 6px; margin-left: 18px; }
.preference-controls-floating { position: fixed; right: 22px; top: 22px; z-index: 1000; }
.preference-button { background: transparent; border: 0; color: var(--text-muted); cursor: pointer; font: 600 10px/1 'Manrope', sans-serif; min-height: 30px; padding: 0 4px; transition: color .2s ease, transform .2s ease; }
.preference-button:hover { background: transparent; border: 0; color: var(--primary); transform: scale(1.08); }
.theme-switch { align-items: center; background: transparent; border: 1.5px solid currentColor; border-radius: 50%; cursor: pointer; display: inline-flex; height: 36px; justify-content: center; min-width: 36px; width: 36px; padding: 0; position: relative; transition: all .2s ease; }
.preference-button.theme-switch:hover { background: rgba(125, 125, 125, 0.12); border-color: currentColor; color: inherit; transform: scale(1.08); }
.theme-switch::after { display: none !important; }
.theme-switch-moon, .theme-switch-sun { display: inline-flex; align-items: center; justify-content: center; line-height: 1; transition: transform .25s ease; }
.theme-switch-moon svg, .theme-switch-sun svg { display: block; width: 18px; height: 18px; }
.theme-switch-moon { display: inline-flex; }
.theme-switch-sun { display: none; }
.theme-switch.is-dark .theme-switch-moon, html[data-theme='dark'] .theme-switch .theme-switch-moon { display: none !important; }
.theme-switch.is-dark .theme-switch-sun, html[data-theme='dark'] .theme-switch .theme-switch-sun { display: inline-flex !important; }
.site-header .preference-controls { border-left: 1px solid rgba(255,255,255,.2); padding-left: 14px; }
.navbar .nav-container > .preference-controls { margin-left: auto; }
html[data-theme='dark'] .preference-button { border-color: #36516d; color: #b8d0e3; }

@media (max-width: 700px) { .preference-controls { margin-left: 10px; }.preference-controls-floating { right: 14px; top: 14px; } }

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

/* Keep scrolling available while removing native scrollbar chrome throughout
   the app (Chromium/WebKit, Firefox and legacy Edge/IE). */
* {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html, body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

a:hover {
  color: var(--primary-hover);
}

/* Containers */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(circle at 50% 15%, #163665 0%, #0f172a 100%);
  position: relative;
  overflow-x: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.2) 0%, rgba(6, 182, 212, 0.08) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 34px 28px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 1;
}

.auth-card.wide {
  max-width: 480px;
}

.role-tabs-wrap {
  display: flex;
  background: var(--bg-main);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  margin-bottom: 16px;
}

.role-tab-btn {
  flex: 1;
  border: none;
  padding: 9px 6px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.role-tab-btn:hover {
  color: var(--text-main);
}

.role-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-header .logo-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-gradient);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-primary);
}

.auth-header .logo-icon, .login-brand-logo, .role-brand-logo { background: transparent; box-shadow: none; object-fit: contain; }
.login-brand-logo { height: 42px; width: 42px; }
.role-brand-logo { display: block; height: 64px; margin: 0 auto 12px; object-fit: contain; width: 64px; }
.sidebar-logo-image { height: 42px; object-fit: contain; width: auto; max-width: 185px; }

.auth-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Navbar */
.navbar {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 0;
}

.navbar .nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand, .lnav-brand, .sidebar-logo-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  cursor: default !important;
  pointer-events: none !important;
  user-select: none !important;
  text-decoration: none !important;
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
}

.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-light);
  font-size: 18px;
}

.input-wrapper .form-input.has-left-icon {
  padding-left: 44px;
}

.input-wrapper .password-toggle {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 18px;
  z-index: 2;
  pointer-events: auto;
  user-select: none;
}

.input-wrapper .password-toggle:hover {
  color: var(--text-main);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-error.visible {
  display: block;
}

.form-input.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.form-input.is-valid {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

.form-feedback {
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.4;
  min-height: 17px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.form-feedback.error {
  color: var(--danger);
  font-weight: 500;
}

.form-feedback.success {
  color: var(--success);
  font-weight: 500;
}

.form-feedback.hint {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.form-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  border-radius: 4px;
  cursor: pointer;
}

/* Buttons */
.btn,
a.btn,
a.btn-exam-action,
.btn-exam-action,
.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  -webkit-text-fill-color: currentColor !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-block {
  width: 100%;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  filter: grayscale(0.2);
}

.btn:disabled:hover, .btn[disabled]:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* Role Selector (AUTH-002) */
.role-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.role-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.role-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.role-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-primary);
}

.role-card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 12px;
}

.role-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.role-card p {
  font-size: 12px;
  color: var(--text-muted);
}

/* OTP (AUTH-004, AUTH-005) */
.otp-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
}

.otp-input {
  width: 50px;
  height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: all var(--transition-fast);
}

.otp-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.otp-timer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.otp-timer span {
  font-weight: 700;
  color: var(--primary);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Onboarding (AUTH-010) */
.onboarding-slider {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 10px 0;
}

.onboarding-slide {
  display: none;
}

.onboarding-slide.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

.onboarding-illustration {
  width: 130px;
  height: 130px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 58px;
  margin: 0 auto 20px;
  box-shadow: var(--shadow-lg);
}

.onboarding-slide h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text-main);
}

.onboarding-slide p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 24px 0;
}

.onboarding-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--border-color);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.onboarding-dot.active {
  width: 28px;
  background: var(--primary-gradient);
}

.onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  right: calc(22px + env(safe-area-inset-right, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  --toast-accent: var(--info);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px 17px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 11px;
  width: min(380px, calc(100vw - 32px));
  min-height: 58px;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  animation: toast-enter 240ms cubic-bezier(.2,.8,.2,1) both;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.toast.success { --toast-accent: var(--success); }
.toast.error { --toast-accent: var(--danger); }
.toast.warning { --toast-accent: var(--warning); }
.toast.info { --toast-accent: var(--info); }
.toast-icon {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: var(--toast-accent);
  background: color-mix(in srgb, var(--toast-accent) 12%, transparent);
  font-size: 15px;
  font-weight: 700;
}
.toast-message { flex: 1; overflow-wrap: anywhere; }
.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--toast-accent);
  transform-origin: left;
  animation: toast-progress 3s linear forwards;
}
.toast.toast-leaving { animation: toast-exit 180ms ease-in both; }
@keyframes toast-enter {
  from { opacity: 0; transform: translateX(22px) translateY(7px); }
  to { opacity: 1; transform: translateX(0) translateY(0); }
}
@keyframes toast-exit {
  to { opacity: 0; transform: translateX(18px); }
}
@keyframes toast-progress {
  to { transform: scaleX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.toast-leaving { animation-duration: 1ms; }
  .toast-progress { animation: none; transform: scaleX(0); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-backdrop.open .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Dashboard & Account */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  padding: 40px 0;
}

.dashboard-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  height: fit-content;
}

.user-profile-summary {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.user-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-md);
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar-menu a:hover, .sidebar-menu a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-main);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

html[data-theme='dark'] .badge-success { background: #123d32; color: #8ce9bc; }
html[data-theme='dark'] .badge-warning { background: #493414; color: #ffd18a; }
html[data-theme='dark'] .badge-danger { background: #4a2229; color: #ffadb1; }
html[data-theme='dark'] .badge-info { background: #143c55; color: #96dbfa; }

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

/* ==========================================================================
   Student Profile & Academic Identity Components (EPIC-02)
   ========================================================================== */
.profile-banner {
  background: var(--primary-gradient);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  color: white;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.profile-banner-user {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-avatar-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-full);
  border: 4px solid white;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--bg-card);
  cursor: pointer;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-placeholder {
  width: 100%;
  height: 100%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 800;
}

.profile-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.profile-avatar-wrapper:hover .profile-avatar-overlay {
  opacity: 1;
}

/* Stats Counter Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.stat-box-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-box-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* Study Preferences Toggle Pills (STD-009) */
.pref-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pref-pill {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pref-pill:hover {
  border-color: var(--primary);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.pref-pill.selected {
  background: var(--primary-gradient);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}

/* Badges Showcase Grid (STD-011) */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}

.badge-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  transition: transform var(--transition-fast);
}

.badge-card-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.badge-card-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

@media (max-width: 768px) {
  .auth-card {
    padding: 28px 20px;
  }
  .role-cards-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .otp-input {
    width: 42px;
    height: 50px;
    font-size: 20px;
  }
}

/* ==========================================================================
   PREMIUM MODERN UI COMPONENTS & MICRO-INTERACTIONS
   ========================================================================== */

/* Modern Top Navigation Bar */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 150;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
}

/* Interactive KPI Cards */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.kpi-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.kpi-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Ambient Lo-Fi & Focus Sound Widget */
.focus-audio-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.sound-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sound-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.sound-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sound-pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

/* AI Assistant Rich Chat UI */
.ai-chat-container {
  display: flex;
  flex-direction: column;
  height: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-main);
}

.chat-bubble {
  max-width: 82%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.chat-prompt-starters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.prompt-starter-btn {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.ai-chat-composer {
  padding: 16px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ── TABS & FILTER CHIPS ── */
.feed-filters-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 24px;
}

.filter-chip {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  padding: 9px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.filter-chip.active {
  background: var(--primary-gradient);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}

/* ── GLOBAL PERSISTENT SIDEBAR ── */
.global-app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 20px 14px 32px;
  overflow: hidden;
  z-index: 1050;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

html[data-theme='dark'] .global-app-sidebar {
  background: #121d2d;
  border-right-color: #263951;
  box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
}

.global-app-sidebar::-webkit-scrollbar {
  width: 5px;
}
.global-app-sidebar::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

body.has-global-sidebar {
  padding-left: 300px !important;
}

/* Shared app shell: every authenticated content page uses one content rhythm. */
body.has-global-sidebar .navbar,
body.has-global-sidebar .app-topbar {
  display: none !important;
}

body.has-global-sidebar > .container,
body.has-global-sidebar > main,
body.has-global-sidebar > .page-container {
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
  padding-left: 32px !important;
  padding-right: 32px !important;
  width: 100% !important;
}

body.has-global-sidebar .container {
  max-width: none;
}

body.has-global-sidebar .navbar .nav-brand,
body.has-global-sidebar .app-topbar .topbar-logo {
  display: none !important;
}

body.has-global-sidebar .navbar .nav-container {
  justify-content: flex-end;
}

body.has-global-sidebar .app-topbar {
  justify-content: flex-end;
}

body.has-global-sidebar .dashboard-sidebar {
  display: none !important;
}

body.has-global-sidebar .dashboard-grid {
  display: block;
  padding-top: 20px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.sidebar-menu {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-section-label {
  padding: 12px 14px 5px;
  margin-top: 5px;
  border-top: 1px solid var(--border-color);
  color: var(--text-light);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-menu a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-menu a.active {
  background: #e7f8ff !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.12);
}

html[data-theme='dark'] .sidebar-menu a.active {
  background: #123b72 !important;
  color: #edf7ff !important;
}

.sidebar-preference-controls {
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  margin: 16px 0 18px !important;
  min-height: 44px;
  padding: 8px 12px !important;
  width: 100%;
}

.sidebar-preference-controls::before {
  color: var(--text-muted);
  content: 'Görünüm';
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-preference-controls .theme-switch {
  color: var(--text-main);
}

/* ==========================================================================
   MOBILE RESPONSIVENESS & OFF-CANVAS SIDEBAR SYSTEM
   ========================================================================== */

/* Mobile Elements Base (Hidden on Desktop) */
.mobile-sidebar-toggle-wrap {
  display: none;
}

.mobile-sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-md);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4.5px;
  width: 38px;
  height: 38px;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-sidebar-toggle-btn:hover,
.mobile-sidebar-toggle-btn:focus-visible {
  background: rgba(47, 115, 245, 0.08);
  outline: none;
}

.mobile-sidebar-toggle-btn .hamburger-bar {
  display: block;
  width: 20px;
  height: 2.2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.mobile-topbar-brand {
  display: none;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.sidebar-mobile-close {
  display: none;
}

.sidebar-mobile-backdrop {
  display: none;
}

/* Tablet & Mobile Breakpoint (<= 992px) */
@media (max-width: 992px) {
  body.has-global-sidebar {
    padding-left: 0 !important;
  }

  body.has-global-sidebar .navbar .nav-container {
    display: flex;
    justify-content: space-between !important;
  }

  body.has-global-sidebar .app-topbar {
    justify-content: space-between !important;
  }

  body.has-global-sidebar .navbar,
  body.has-global-sidebar .app-topbar {
    display: block !important;
  }

  body.has-global-sidebar > .container,
  body.has-global-sidebar > main,
  body.has-global-sidebar > .page-container {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .mobile-sidebar-toggle-wrap {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
  }

  .mobile-sidebar-toggle-btn {
    display: inline-flex !important;
  }

  .mobile-topbar-brand {
    display: inline-flex !important;
  }

  /* Global Sidebar Transforms into Off-Canvas Drawer */
  .global-app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease;
    z-index: 1200;
    width: 280px;
    max-width: 85vw;
    box-shadow: none;
  }

  .global-app-sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.25) !important;
  }

  /* Backdrop Overlay */
  .sidebar-mobile-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1190;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .sidebar-mobile-backdrop.active,
  body.sidebar-mobile-open .sidebar-mobile-backdrop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  body.sidebar-mobile-open {
    overflow: hidden !important;
  }

  /* Close Button in Sidebar Header */
  .sidebar-mobile-close {
    display: flex !important;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    background: rgba(47, 115, 245, 0.08);
    border: none;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    transition: all 0.2s ease;
  }

  .sidebar-mobile-close:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
  }
}

/* Standard Mobile Breakpoint (<= 768px) */
@media (max-width: 768px) {
  .container {
    padding: 0 16px !important;
  }

  .card {
    padding: 20px 16px !important;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    padding-top: 14px !important;
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Stats Grids */
  .stats-grid,
  [class*="stats-grid"],
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .stat-box {
    padding: 14px 10px !important;
  }

  .stat-box-number {
    font-size: 22px !important;
  }

  .stat-box-label {
    font-size: 11px !important;
  }

  /* Profile Banners */
  .profile-banner {
    padding: 22px 16px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px !important;
  }

  .profile-banner-user {
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .profile-banner > div:last-child {
    width: 100% !important;
    align-items: flex-start !important;
  }

  .profile-banner > div:last-child > div {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  .profile-avatar-wrapper {
    width: 76px !important;
    height: 76px !important;
    flex-shrink: 0 !important;
  }

  /* Tables Touch Scroll Container */
  .table-responsive,
  .table-container,
  .card > table,
  div:has(> .data-table),
  div:has(> .net-input-table) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block;
  }

  .data-table,
  .net-input-table {
    min-width: 500px !important;
  }

  /* Modals */
  .modal-backdrop {
    padding: 12px !important;
  }

  .modal-card {
    padding: 22px 16px !important;
    max-height: 90vh !important;
    width: 100% !important;
  }

  /* Social Feed */
  .feed-card,
  .post-creator-card {
    padding: 18px 14px !important;
  }

  .feed-filters-bar {
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding-bottom: 8px !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .filter-chip {
    flex-shrink: 0 !important;
    padding: 7px 14px !important;
    font-size: 12px !important;
  }

  /* Timer & Gamification */
  .timer-card {
    padding: 28px 16px !important;
  }

  .timer-display {
    font-size: 54px !important;
    margin: 18px 0 !important;
  }

  .gamification-hero {
    grid-template-columns: 1fr !important;
    padding: 24px 18px !important;
    gap: 16px !important;
    text-align: center;
  }

  .mission-card {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .app-topbar {
    padding: 10px 16px !important;
  }
}

/* Small Smartphone Breakpoint (<= 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 12px !important;
  }

  .stats-grid,
  [class*="stats-grid"],
  .stat-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .ig-nav-tabs {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .ig-tab-btn {
    padding: 8px 6px !important;
    font-size: 11.5px !important;
  }

  .timer-display {
    font-size: 44px !important;
  }

  .auth-card {
    padding: 22px 14px !important;
  }

  .modal-card [style*="grid-template-columns: 1fr 1fr"],
  .auth-card [style*="grid-template-columns: 1fr 1fr"],
  .modal-password-grid,
  .register-password-grid {
    grid-template-columns: 1fr !important;
  }

  .toast-container {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px !important;
    left: 12px !important;
    align-items: stretch;
  }

  .toast {
    width: 100% !important;
  }

  .topic-breakdown-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
}

/* ========================================================================== 
   APP SHELL — shared application interface (excludes landing and auth pages)
   ========================================================================== */
html.app-shell-pending body {
  --app-sidebar-width: 304px;
  --app-frame-gap: 20px;
  padding-left: calc(var(--app-sidebar-width) + var(--app-frame-gap));
  background: #eef3f8;
}

html.app-shell-pending body::before {
  position: fixed;
  z-index: 1040;
  top: var(--app-frame-gap);
  bottom: var(--app-frame-gap);
  left: var(--app-frame-gap);
  width: var(--app-sidebar-width);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 18px 44px rgba(23, 50, 85, .07);
  content: '';
}

html.app-shell-pending body.has-global-sidebar::before {
  display: none;
}

html.app-shell-pending body .navbar,
html.app-shell-pending body .app-topbar {
  display: none !important;
}

body.has-global-sidebar {
  --app-sidebar-width: 250px;
  --app-space: 16px;
  --app-widget-radius: 12px;
  --app-frame-gap: 0px;
  --app-content-gap: 24px;
  --app-widget-gap: 0px;
  --app-widget-padding: 16px;
  --sidebar-brand-height: auto;
  --sidebar-profile-height: auto;
  --app-surface: #ffffff;
  --bg-card: #ffffff;
  --app-surface-muted: #f8fafc;
  --app-line: var(--border-color, #e2e8f0);
  --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  background: #f8fafc;
  padding-left: var(--app-sidebar-width) !important;
  overflow-x: hidden;
}

html[data-theme='dark'] body.has-global-sidebar {
  --app-surface: #0f172a;
  --bg-card: #0f172a;
  --app-surface-muted: #1e293b;
  --app-line: rgba(255, 255, 255, 0.08);
  --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  background: #090d16;
}

body.has-global-sidebar > .container,
body.has-global-sidebar > main,
body.has-global-sidebar > .page-container {
  box-sizing: border-box;
  max-width: none !important;
  margin: 0 auto !important;
  padding: var(--app-frame-gap) !important;
  min-width: 0;
  overflow-x: hidden;
  width: 100%;
}

body.has-global-sidebar .app-mosaic {
  display: grid;
  align-content: start;
  gap: var(--app-content-gap);
  padding: var(--app-frame-gap) !important;
}

body.has-global-sidebar .app-mosaic > * {
  margin-bottom: 0 !important;
}

body.has-global-sidebar .app-mosaic > .stats-grid,
body.has-global-sidebar .app-mosaic > [class*='grid'] {
  margin-top: 0 !important;
}

body.has-global-sidebar .dashboard-grid,
body.has-global-sidebar .dashboard-content {
  gap: var(--app-content-gap) !important;
}

/* Every app-level mosaic/grid follows the same spacing rhythm. */
body.has-global-sidebar .app-mosaic > .stats-grid,
body.has-global-sidebar .app-mosaic > [class*='grid'],
body.has-global-sidebar .dashboard-content > [class*='grid'],
body.has-global-sidebar .dashboard-grid > [class*='grid'] {
  gap: var(--app-content-gap) !important;
}

/* Floating, calm sidebar — same outside gap as the content canvas. */
body.has-global-sidebar .global-app-sidebar {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: var(--app-sidebar-width) !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  border: 0 !important;
  border-right: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: 0 !important;
  background: var(--app-surface) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 1050 !important;
}

html[data-theme='dark'] body.has-global-sidebar .global-app-sidebar {
  border-right-color: var(--app-line, rgba(255, 255, 255, 0.08)) !important;
  background: var(--app-surface) !important;
}

body.has-global-sidebar .sidebar-brand-group {
  padding: 14px 16px !important;
  border: none !important;
  border-bottom: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.has-global-sidebar .sidebar-logo-brand {
  margin: 0 !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  color: var(--primary) !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

body.has-global-sidebar .sidebar-logo-image { width: auto !important; height: 42px !important; max-width: 185px !important; object-fit: contain !important; }

body.has-global-sidebar .user-profile-summary {
  margin: 0 0 10px 0 !important;
  padding: 14px !important;
  border: 1px solid var(--app-line, var(--border-color)) !important;
  background: var(--bg-card) !important;
  border-radius: 14px !important;
}

body.has-global-sidebar .sidebar-profile-row {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

body.has-global-sidebar .sidebar-avatar-container {
  width: 42px !important;
  height: 42px !important;
  margin: 0 !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
}

body.has-global-sidebar #sidebarAvatarImg,
body.has-global-sidebar #sidebarAvatarPlaceholder {
  width: 42px !important;
  height: 42px !important;
  font-size: 18px !important;
  border-radius: 50% !important;
}

body.has-global-sidebar .sidebar-avatar-overlay {
  display: none !important;
}

body.has-global-sidebar .user-profile-summary h3,
body.has-global-sidebar .user-profile-summary p {
  text-align: left;
}

body.has-global-sidebar .user-profile-summary h3 {
  font-size: 14px !important;
  letter-spacing: -.15px;
}

body.has-global-sidebar .user-profile-summary p {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}

body.has-global-sidebar .sidebar-follow-stats {
  justify-content: flex-start !important;
  gap: 24px !important;
  gap: 14px !important;
  margin-top: 14px !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

body.has-global-sidebar .sidebar-follow-stats a {
  text-align: left !important;
}

body.has-global-sidebar .sidebar-menu {
  gap: 3px;
  padding: 0 2px;
}

body.has-global-sidebar .sidebar-menu a {
  min-height: 48px;
  padding: 13px 12px;
  border-radius: 13px;
  color: var(--text-muted) !important;
  font-size: 13px;
  font-weight: 650 !important;
  letter-spacing: -.1px;
}

body.has-global-sidebar .sidebar-menu a:hover {
  background: transparent;
  color: var(--primary) !important;
}

body.has-global-sidebar .sidebar-menu a.active {
  background: var(--primary-gradient) !important;
  color: #fff !important;
  box-shadow: 0 10px 22px rgba(47, 115, 245, .20);
}

body.has-global-sidebar .sidebar-section-label {
  margin: 12px 0 4px;
  padding: 12px 10px 5px;
  border-top: 1px solid var(--app-line);
  color: var(--text-light);
  font-size: 10px;
  letter-spacing: .1em;
}

body.has-global-sidebar .sidebar-preference-controls {
  order: 3;
  min-height: 42px;
  margin: auto 2px 0 !important;
  padding: 8px 10px !important;
  border: 0;
  border-top: 1px solid var(--app-line);
}

body.has-global-sidebar .sidebar-preference-controls::before {
  color: var(--text-muted);
  font-size: 10px;
}

body.has-global-sidebar .preference-button,
body.has-global-sidebar .theme-switch {
  color: var(--text-main);
}

/* Shared content components: quiet surfaces, equal rhythm and no heavy borders. */
body.has-global-sidebar .card,
body.has-global-sidebar .stat-box,
body.has-global-sidebar .feed-card,
body.has-global-sidebar .post-creator-card,
body.has-global-sidebar .timer-card,
body.has-global-sidebar .analytics-card,
body.has-global-sidebar .exam-card,
body.has-global-sidebar .message-thread,
body.has-global-sidebar .settings-card {
  background: var(--app-surface) !important;
  border: 0 !important;
  border-radius: 22px !important;
  box-shadow: var(--app-shadow) !important;
}

body.has-global-sidebar .card,
body.has-global-sidebar .stat-box,
body.has-global-sidebar .feed-card,
body.has-global-sidebar .post-creator-card,
body.has-global-sidebar .timer-card,
body.has-global-sidebar .focus-audio-widget,
body.has-global-sidebar .gamification-hero,
body.has-global-sidebar .analytics-card,
body.has-global-sidebar .exam-card,
body.has-global-sidebar .message-thread,
body.has-global-sidebar .profile-banner,
body.has-global-sidebar .settings-card {
  padding: var(--app-widget-padding) !important;
}

body.has-global-sidebar .profile-banner,
body.has-global-sidebar .gamification-hero {
  border-radius: 22px !important;
  box-shadow: var(--app-shadow) !important;
}

body.has-global-sidebar .card-title,
body.has-global-sidebar .section-title,
body.has-global-sidebar h1,
body.has-global-sidebar h2,
body.has-global-sidebar h3 {
  letter-spacing: -.035em;
}

body.has-global-sidebar h1 {
  font-size: clamp(28px, 3vw, 42px) !important;
  line-height: 1.1 !important;
}

body.has-global-sidebar .card-title {
  margin-bottom: 18px;
  font-size: 19px;
  line-height: 1.25;
}

body.has-global-sidebar .stats-grid,
body.has-global-sidebar [class*="stats-grid"],
body.has-global-sidebar .stat-cards-grid {
  gap: var(--app-content-gap) !important;
}

body.has-global-sidebar .stat-box {
  min-height: 142px;
  padding: var(--app-widget-padding) !important;
  text-align: left;
}

body.has-global-sidebar .stat-box-number {
  font-size: clamp(26px, 2.2vw, 34px);
  letter-spacing: -.05em;
}

body.has-global-sidebar .data-table th {
  background: transparent;
  border-bottom-color: var(--app-line);
  color: var(--text-light);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

body.has-global-sidebar .data-table td {
  border-bottom-color: var(--app-line);
  padding: 16px;
}

body.has-global-sidebar .form-input,
body.has-global-sidebar .form-select,
body.has-global-sidebar .form-textarea,
body.has-global-sidebar input:not([type='checkbox']):not([type='radio']),
body.has-global-sidebar select,
body.has-global-sidebar textarea {
  border: 1px solid var(--app-line) !important;
  border-radius: 8px !important;
  background: var(--app-surface-muted) !important;
  box-shadow: none !important;
}

body.has-global-sidebar .btn {
  min-height: 40px;
  border-radius: 8px;
  box-shadow: none;
  font-weight: 600;
}

body.has-global-sidebar .btn-primary {
  background: var(--primary-gradient);
  border-color: var(--primary);
  box-shadow: 0 10px 22px rgba(47, 115, 245, .18);
}

body.has-global-sidebar .btn-secondary {
  background: transparent;
  border-color: var(--app-line);
  color: var(--text-main);
}

body.has-global-sidebar .filter-chip,
body.has-global-sidebar .badge {
  border-radius: 999px;
  box-shadow: none;
}

body.has-global-sidebar .filter-chip {
  border-color: var(--app-line);
  background: var(--app-surface);
  color: var(--text-muted);
}

body.has-global-sidebar .filter-chip.active {
  background: var(--primary-gradient);
  border-color: var(--primary);
  color: #fff;
}

/* Page-specific widgets inherit the same surface instead of each page inventing a card. */
body.has-global-sidebar [class$='-card'],
body.has-global-sidebar [class*='-card '],
body.has-global-sidebar [class$='-panel'],
body.has-global-sidebar [class*='-panel '],
body.has-global-sidebar [class$='-box'],
body.has-global-sidebar [class*='-box '] {
  border-color: transparent;
  border-radius: 18px;
}

body.has-global-sidebar .exam-list-item,
body.has-global-sidebar .feed-post,
body.has-global-sidebar .message-item,
body.has-global-sidebar .notification-item,
body.has-global-sidebar .mission-card,
body.has-global-sidebar .topic-breakdown-row,
body.has-global-sidebar .connection-card,
body.has-global-sidebar .setting-row,
body.has-global-sidebar .toggle-row {
  border-color: var(--app-line) !important;
  border-radius: 14px;
}

body.has-global-sidebar .progress-track,
body.has-global-sidebar .progress-bar-bg,
body.has-global-sidebar .progress-container {
  background: #eaf0f7;
}

html[data-theme='dark'] body.has-global-sidebar .progress-track,
html[data-theme='dark'] body.has-global-sidebar .progress-bar-bg,
html[data-theme='dark'] body.has-global-sidebar .progress-container {
  background: rgba(255, 255, 255, .11);
}

body.has-global-sidebar .page-header,
body.has-global-sidebar .content-header,
body.has-global-sidebar .section-header {
  margin-bottom: var(--app-content-gap) !important;
}

/* Compact sidebar profile: keeps every role's navigation visible without scrolling. */
body.has-global-sidebar .global-app-sidebar {
  padding: var(--app-widget-padding) !important;
}

body.has-global-sidebar .sidebar-profile-summary {
  padding: 2px 2px 14px !important;
  margin-bottom: 8px !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-logo-brand {
  margin-bottom: 14px !important;
}

body.has-global-sidebar .sidebar-profile-row {
  display: flex;
  align-items: center;
  gap: 11px;
}

body.has-global-sidebar .sidebar-avatar-container {
  flex: 0 0 48px;
  width: 48px !important;
  height: 48px !important;
  margin: 0 !important;
}

body.has-global-sidebar #sidebarAvatarImg,
body.has-global-sidebar #sidebarAvatarPlaceholder {
  width: 48px !important;
  height: 48px !important;
  font-size: 19px !important;
}

body.has-global-sidebar .sidebar-profile-identity {
  min-width: 0;
  flex: 1;
}

body.has-global-sidebar .sidebar-profile-user-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--app-line, var(--border-color));
  transition: all 0.15s ease;
  flex-shrink: 0;
  text-decoration: none;
  margin-left: auto;
}

body.has-global-sidebar .sidebar-profile-user-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(52, 120, 246, 0.08);
}

body.has-global-sidebar .sidebar-profile-summary h3 {
  overflow: hidden;
  margin: 0 !important;
  color: var(--text-main) !important;
  font-size: 14px !important;
  line-height: 1.3;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.has-global-sidebar .sidebar-profile-summary p {
  margin-top: 2px;
  text-align: left;
}

body.has-global-sidebar .sidebar-follow-stats {
  gap: 0 !important;
  margin-top: 12px !important;
  padding: 9px 0 0 !important;
}

body.has-global-sidebar .sidebar-follow-stats a {
  min-width: 78px;
}

body.has-global-sidebar .sidebar-follow-stats a span:first-child {
  font-size: 13px !important;
}

body.has-global-sidebar .sidebar-follow-stats a span:last-child {
  font-size: 10px !important;
}

body.has-global-sidebar .sidebar-menu {
  flex: 0 0 auto;
  overflow: visible;
  gap: 2px;
}

body.has-global-sidebar .sidebar-menu a {
  position: relative;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 12.5px;
}

body.has-global-sidebar .sidebar-section-label {
  margin: 8px 0 2px;
  padding: 9px 8px 4px;
}

body.has-global-sidebar .sidebar-preference-controls {
  order: 2;
  flex: 0 0 auto;
  min-height: 38px;
  margin-top: auto !important;
  padding: 6px 8px !important;
}

body.has-global-sidebar .sidebar-utility-dock,
body.has-global-sidebar > .app-mobile-bottom-nav,
.sidebar-utility-dock,
.app-mobile-bottom-nav {
  display: none !important;
}

body.has-global-sidebar .sidebar-utility-link {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: var(--text-muted);
  transition: none;
}

body.has-global-sidebar .sidebar-utility-link.active {
  background: var(--primary-gradient);
  color: #fff;
}

body.has-global-sidebar .sidebar-utility-link:hover:not(.active) {
  background: transparent !important;
  color: var(--primary) !important;
  -webkit-text-fill-color: currentColor !important;
}

body.has-global-sidebar .sidebar-utility-link.active {
  color: #fff;
}

body.has-global-sidebar .sidebar-utility-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.has-global-sidebar .sidebar-utility-divider {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: var(--app-line);
}

body.has-global-sidebar .sidebar-logout-link:hover {
  background: rgba(194, 65, 75, .10);
  color: #c2414b;
}

body.has-global-sidebar .community-hub-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--app-content-gap);
  padding: 4px;
  border-radius: 14px;
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

body.has-global-sidebar .community-hub-title {
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}

body.has-global-sidebar .community-hub-nav a {
  padding: 8px 11px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

body.has-global-sidebar .community-hub-nav a.active,
body.has-global-sidebar .community-hub-nav a:hover {
  background: rgba(47, 115, 245, .10);
  color: var(--primary);
}

/* Sidebar composition: brand, centered navigation, then a contained profile widget. */
body.has-global-sidebar .global-app-sidebar {
  position: fixed;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--app-widget-padding) !important;
}

body.has-global-sidebar .sidebar-brand-group {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  flex: 0 0 auto;
  order: 1;
  padding: 14px 16px;
}

body.has-global-sidebar .sidebar-logo-brand {
  position: static;
  gap: 10px !important;
  margin: 0 !important;
  color: var(--text-main) !important;
  font-size: 23px !important;
  font-weight: 800 !important;
}

body.has-global-sidebar .sidebar-brand-group {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

body.has-global-sidebar .sidebar-brand-group .sidebar-brand-settings {
  align-items: center;
  color: var(--text-muted);
  display: inline-flex;
  height: 36px;
  justify-content: center;
  margin-bottom: 0;
  margin-left: auto;
  margin-right: -4px;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
  width: 36px;
}

body.has-global-sidebar .sidebar-brand-group .sidebar-brand-settings:hover {
  color: var(--primary);
  background-image: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.has-global-sidebar .sidebar-brand-group .sidebar-brand-settings svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 19px;
}

body.has-global-sidebar .sidebar-logo-brand .sidebar-logo-image { width: auto !important; height: 42px !important; max-width: 185px !important; object-fit: contain !important; }

body.has-global-sidebar .sidebar-menu {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0;
}

body.has-global-sidebar .sidebar-navigation-group {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
  order: 3;
  margin-top: 0;
}

body.has-global-sidebar .sidebar-menu a {
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 12px;
}

body.has-global-sidebar .sidebar-section-label {
  height: 1px;
  margin: 12px 0;
  padding: 0;
  overflow: hidden;
  border-top: 1px solid var(--app-line);
  color: transparent;
  font-size: 0;
}

body.has-global-sidebar .sidebar-profile-summary {
  order: 2;
  flex: 0 0 auto;
  margin: 0 0 12px 0 !important;
  padding: 14px !important;
  border: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: 14px !important;
  background: var(--bg-card) !important;
  box-shadow: var(--shadow-sm);
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-logo-brand {
  border: 0 !important;
}

body.has-global-sidebar .sidebar-profile-row {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-profile-row {
  align-items: center;
  gap: 11px;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-avatar-container {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  flex: 0 0 44px;
  height: 44px !important;
  margin: 0 !important;
  overflow: visible;
  padding: 0;
  position: relative;
  width: 44px !important;
}

body.has-global-sidebar .sidebar-profile-summary #sidebarAvatarImg,
body.has-global-sidebar .sidebar-profile-summary .sidebar-avatar-placeholder,
body.has-global-sidebar #sidebarAvatarImg,
body.has-global-sidebar #sidebarAvatarPlaceholder {
  border: 1.5px solid var(--app-line, var(--border-color)) !important;
  border-radius: 50% !important;
  height: 44px !important;
  object-fit: cover;
  overflow: hidden;
  width: 44px !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-avatar-placeholder,
body.has-global-sidebar #sidebarAvatarPlaceholder {
  align-items: center;
  background: var(--primary-light, #eaf1ff) !important;
  color: var(--primary) !important;
  display: flex;
  font-size: 17px;
  font-weight: 800;
  justify-content: center;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-avatar-overlay {
  display: none !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-profile-identity h3,
body.has-global-sidebar .sidebar-profile-summary h3,
body.has-global-sidebar .user-profile-summary h3 {
  color: var(--text-main) !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  letter-spacing: -.015em;
  line-height: 1.3;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-profile-identity p,
body.has-global-sidebar .sidebar-profile-summary p,
body.has-global-sidebar .user-profile-summary p {
  color: var(--text-muted) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.35;
  margin: 2px 0 0 !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-follow-stats,
body.has-global-sidebar .sidebar-follow-stats {
  align-items: stretch;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px !important;
  min-height: 48px;
  padding: 6px 8px !important;
  background: var(--app-surface-muted, rgba(0, 0, 0, 0.02)) !important;
  border: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: 10px !important;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-stat-link {
  align-content: center;
  display: grid;
  gap: 2px;
  justify-items: start;
  min-width: 0;
  padding: 0 4px;
  text-decoration: none;
  transition: opacity .16s ease;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-stat-link + .sidebar-stat-link {
  border-left: 1px solid var(--app-line, var(--border-color)) !important;
  padding-left: 12px;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-stat-link:hover { opacity: .78; }

body.has-global-sidebar .sidebar-profile-summary .sidebar-stat-value,
body.has-global-sidebar .sidebar-follow-stats a span:first-child {
  color: var(--text-main) !important;
  -webkit-text-fill-color: var(--text-main) !important;
  font-size: 13px !important;
  font-weight: 850;
  line-height: 1.1;
}

body.has-global-sidebar .sidebar-profile-summary .sidebar-stat-label,
body.has-global-sidebar .sidebar-follow-stats a span:last-child {
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
  font-size: 10px !important;
  font-weight: 650;
  line-height: 1.2;
}

body.has-global-sidebar .sidebar-follow-stats > div {
  display: none !important;
}

body.has-global-sidebar .sidebar-preference-controls {
  order: 2;
  flex: 0 0 auto;
  margin: 8px 0 0 !important;
  padding: 7px 8px !important;
}

body.has-global-sidebar .sidebar-preference-controls .theme-switch {
  height: 20px;
  min-height: 20px;
  min-width: 40px;
}

body.has-global-sidebar .sidebar-preference-controls .theme-switch.is-dark::after {
  transform: translateX(22px);
}

body.has-global-sidebar .sidebar-utility-dock,
body.has-global-sidebar .sidebar-utility-dock::before {
  display: none !important;
}

/* Stable sidebar hierarchy: brand -> profile -> navigation -> utility icons. */
body.has-global-sidebar .sidebar-menu {
  margin-top: 0 !important;
}

body.has-global-sidebar .sidebar-utility-dock {
  margin-top: auto;
}

/* The logo is a separate widget above the actual sidebar surface. */
body.has-global-sidebar .sidebar-brand-widget-external {
  box-sizing: border-box;
  left: var(--app-frame-gap);
  position: fixed;
  top: var(--app-frame-gap);
  width: var(--app-sidebar-width);
  z-index: 1051;
  padding: var(--app-widget-padding) !important;
}

body.has-global-sidebar .sidebar-profile-widget-external {
  box-sizing: border-box;
  left: var(--app-frame-gap);
  position: fixed;
  top: calc(var(--app-frame-gap) + var(--sidebar-brand-height) + var(--app-widget-gap));
  width: var(--app-sidebar-width);
  z-index: 1051;
  padding: var(--app-widget-padding) !important;
}

/* App widgets use surface and shadow separation; no hard outer borders. */
body.has-global-sidebar .global-app-sidebar,
body.has-global-sidebar .sidebar-brand-widget-external,
body.has-global-sidebar [class$='-card'],
body.has-global-sidebar [class*='-card '],
body.has-global-sidebar [class$='-panel'],
body.has-global-sidebar [class*='-panel '],
body.has-global-sidebar [class$='-box'],
body.has-global-sidebar [class*='-box '],
body.has-global-sidebar .exam-list-item,
body.has-global-sidebar .feed-post,
body.has-global-sidebar .message-item,
body.has-global-sidebar .notification-item,
body.has-global-sidebar .mission-card,
body.has-global-sidebar .topic-breakdown-row,
body.has-global-sidebar .connection-card,
body.has-global-sidebar .setting-row,
body.has-global-sidebar .toggle-row {
  border: 0 !important;
}

body.has-global-sidebar .global-app-sidebar {
  top: calc(var(--app-frame-gap) + var(--sidebar-brand-height) + var(--sidebar-profile-height) + (var(--app-widget-gap) * 2));
  box-sizing: border-box;
  min-width: 0;
}

body.has-global-sidebar .app-mosaic > *,
body.has-global-sidebar .dashboard-content > *,
body.has-global-sidebar [class$='-card'],
body.has-global-sidebar [class*='-card '],
body.has-global-sidebar [class$='-panel'],
body.has-global-sidebar [class*='-panel '],
body.has-global-sidebar [class$='-box'],
body.has-global-sidebar [class*='-box '] {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

/* Do not mix legacy card margins with the single mosaic gap system. */
body.has-global-sidebar .app-mosaic > *,
body.has-global-sidebar .dashboard-content > *,
body.has-global-sidebar .card,
body.has-global-sidebar .stats-grid,
body.has-global-sidebar .focus-audio-widget,
body.has-global-sidebar .timer-card,
body.has-global-sidebar [class$='-card'],
body.has-global-sidebar [class*='-card '] {
  margin-bottom: 0 !important;
}

/* Some pages place their cards inside a visible state wrapper. Keep that
   wrapper in the same mosaic rhythm instead of relying on legacy margins. */
body.has-global-sidebar .app-mosaic > *:not([style*='display: none']):has(> .card) {
  display: grid !important;
  gap: var(--app-content-gap) !important;
}

body.has-global-sidebar .sidebar-brand-widget-external,
body.has-global-sidebar .sidebar-profile-widget-external,
body.has-global-sidebar .global-app-sidebar {
  overflow: hidden;
}

@media (max-width: 992px) {
  body.has-global-sidebar .sidebar-widget-stack > .sidebar-brand-widget-external {
    left: 20px;
    top: 20px;
    width: min(304px, calc(100vw - 40px));
  }

  body.has-global-sidebar .global-app-sidebar {
    top: calc(20px + var(--sidebar-brand-height) + var(--sidebar-profile-height) + (var(--app-widget-gap) * 2));
  }

  body.has-global-sidebar .sidebar-profile-widget-external {
    left: 20px;
    top: calc(20px + var(--sidebar-brand-height) + var(--app-widget-gap));
    width: min(304px, calc(100vw - 40px));
  }
}

@media (max-height: 760px) and (min-width: 993px) {
  body.has-global-sidebar .sidebar-menu {
    margin-top: 0 !important;
  }

  body.has-global-sidebar .sidebar-profile-summary {
    padding: 11px !important;
  }

  body.has-global-sidebar .sidebar-follow-stats {
    display: flex !important;
  }
}

@media (max-height: 760px) and (min-width: 993px) {
  body.has-global-sidebar .global-app-sidebar {
    padding: 12px !important;
  }

  body.has-global-sidebar .sidebar-profile-summary .sidebar-logo-brand {
    margin-bottom: 10px !important;
  }

  body.has-global-sidebar .sidebar-follow-stats {
    display: flex !important;
    margin-top: 8px !important;
    padding: 7px 9px !important;
  }

  body.has-global-sidebar .sidebar-menu a {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  body.has-global-sidebar .sidebar-section-label {
    margin-top: 5px;
    padding-top: 6px;
  }
}

@media (max-width: 992px) {
  html.app-shell-pending body {
    padding-left: 0;
  }

  html.app-shell-pending body::before {
    display: none;
  }

  body.has-global-sidebar {
    padding-left: 0 !important;
  }

  body.has-global-sidebar > .container,
  body.has-global-sidebar > main,
  body.has-global-sidebar > .page-container {
    padding: 16px !important;
  }

  body.has-global-sidebar .navbar,
  body.has-global-sidebar .app-topbar {
    display: none !important;
  }
}

@media (max-width: 640px) {
  body.has-global-sidebar .card,
  body.has-global-sidebar .feed-card,
  body.has-global-sidebar .post-creator-card,
  body.has-global-sidebar .timer-card,
  body.has-global-sidebar .analytics-card,
  body.has-global-sidebar .exam-card,
  body.has-global-sidebar .settings-card {
    border-radius: 18px !important;
  padding: var(--app-widget-padding) !important;
  }

  body.has-global-sidebar h1 {
    font-size: 28px !important;
  }

  body.has-global-sidebar .stat-box {
    min-height: 122px;
  padding: var(--app-widget-padding) !important;
  }
}

/* Responsive sidebar stack: no fixed child offsets, one flow controls all three widgets. */
body.has-global-sidebar .sidebar-widget-stack {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--app-widget-gap);
  inset: var(--app-frame-gap) auto var(--app-frame-gap) var(--app-frame-gap);
  position: fixed;
  width: var(--app-sidebar-width);
  z-index: 1050;
}

body.has-global-sidebar .sidebar-widget-stack > .sidebar-brand-widget-external,
body.has-global-sidebar .sidebar-widget-stack > .sidebar-profile-widget-external {
  flex: 0 0 auto;
  left: auto;
  order: 1;
  position: static;
  top: auto;
  width: 100%;
}

body.has-global-sidebar .sidebar-widget-stack > .sidebar-profile-widget-external {
  order: 2;
}

body.has-global-sidebar .sidebar-widget-stack > .global-app-sidebar {
  bottom: auto;
  flex: 1 1 auto;
  left: auto;
  min-height: 0;
  order: 3;
  position: static;
  top: auto;
  width: 100%;
}

@media (max-width: 992px) {
  body.has-global-sidebar .sidebar-widget-stack {
    bottom: 20px;
    left: 20px;
    top: 20px;
    width: min(304px, calc(100vw - 40px));
    z-index: 1200;
    transform: translateY(calc(-100% - 20px));
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
  }

  body.has-global-sidebar.sidebar-mobile-open .sidebar-widget-stack {
    transform: translateY(0);
    pointer-events: auto;
  }

  body.has-global-sidebar .sidebar-widget-stack > .global-app-sidebar,
  body.has-global-sidebar .sidebar-widget-stack > .global-app-sidebar.mobile-open {
    transform: none !important;
    box-shadow: none !important;
  }
}

/* Final sidebar rhythm overrides: the three widgets share the app spacing system. */
@media (min-width: 993px) {
  body.has-global-sidebar .sidebar-menu a {
    min-height: 48px;
    padding-bottom: 13px;
    padding-top: 13px;
  }
}

@media (max-width: 992px) {
  body.has-global-sidebar .sidebar-profile-widget-external {
    left: 20px;
    top: calc(92px + var(--app-widget-gap));
    width: min(304px, calc(100vw - 40px));
  }

  body.has-global-sidebar .global-app-sidebar {
    left: 20px;
    top: calc(246px + var(--app-widget-gap));
    width: min(304px, calc(100vw - 40px));
  }
}

/* Responsive spacing scale: each viewport range owns one fixed rhythm. */
@media (max-width: 767px) {
  body.has-global-sidebar {
    --app-space: 12px;
    --app-frame-gap: 12px;
    --app-content-gap: 12px;
    --app-widget-gap: 12px;
    --app-widget-padding: 12px;
  }

  body.has-global-sidebar .sidebar-widget-stack {
    inset: 12px;
    width: min(304px, calc(100vw - 24px));
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  body.has-global-sidebar {
    --app-space: 16px;
    --app-frame-gap: 16px;
    --app-content-gap: 16px;
    --app-widget-gap: 16px;
    --app-widget-padding: 16px;
  }

  body.has-global-sidebar .sidebar-widget-stack {
    inset: 16px;
    width: min(304px, calc(100vw - 32px));
  }
}

@media (min-width: 1200px) {
  body.has-global-sidebar {
    --app-space: 20px;
    --app-frame-gap: 20px;
    --app-content-gap: 20px;
    --app-widget-gap: 20px;
    --app-widget-padding: 20px;
  }

  body.has-global-sidebar .sidebar-widget-stack {
    inset: 20px;
    width: 304px;
  }
}

/* One padding source for every app widget at every breakpoint. */
body.has-global-sidebar .sidebar-brand-widget-external,
body.has-global-sidebar .sidebar-profile-widget-external,
body.has-global-sidebar .sidebar-profile-summary,
body.has-global-sidebar .global-app-sidebar,
body.has-global-sidebar .card,
body.has-global-sidebar .stat-box,
body.has-global-sidebar .feed-card,
body.has-global-sidebar .post-creator-card,
body.has-global-sidebar .timer-card,
body.has-global-sidebar .focus-audio-widget,
body.has-global-sidebar .gamification-hero,
body.has-global-sidebar .analytics-card,
body.has-global-sidebar .exam-card,
body.has-global-sidebar .message-thread,
body.has-global-sidebar .profile-banner,
body.has-global-sidebar .settings-card,
body.has-global-sidebar .connection-card,
body.has-global-sidebar .mission-card {
  padding: var(--app-widget-padding) !important;
}

/* Widget-to-widget spacing uses the same responsive rhythm as widget padding. */
body.has-global-sidebar .sidebar-widget-stack {
  gap: var(--app-widget-gap) !important;
}

body.has-global-sidebar .app-mosaic,
body.has-global-sidebar .dashboard-grid,
body.has-global-sidebar .dashboard-content,
body.has-global-sidebar .stats-grid,
body.has-global-sidebar .stat-cards-grid,
body.has-global-sidebar .app-mosaic > [class*='grid'],
body.has-global-sidebar .dashboard-content > [class*='grid'],
body.has-global-sidebar .dashboard-grid > [class*='grid'] {
  gap: var(--app-content-gap) !important;
  row-gap: var(--app-content-gap) !important;
  column-gap: var(--app-content-gap) !important;
}

/* Sidebar-to-content separation is part of the same responsive rhythm. */
body.has-global-sidebar {
  --app-sidebar-content-gap: var(--app-space);
}

@media (min-width: 993px) {
  body.has-global-sidebar {
    padding-left: calc(var(--app-sidebar-width) + var(--app-sidebar-content-gap)) !important;
  }
}

@media (max-width: 992px) {
  body.has-global-sidebar > .container,
  body.has-global-sidebar > main,
  body.has-global-sidebar > .page-container {
    padding-left: var(--app-sidebar-content-gap) !important;
    padding-right: var(--app-sidebar-content-gap) !important;
  }
}

/* The page shell owns one horizontal inset so content stays separated from the sidebar. */
body.has-global-sidebar .app-mosaic {
  margin-top: 0 !important;
  padding-bottom: 48px !important;
  padding-left: 32px !important;
  padding-right: 32px !important;
  padding-top: 24px !important;
  max-width: 1200px !important;
}

/* Page title widget: sleek modern borderless header */
body.has-global-sidebar .app-page-title-widget {
  box-sizing: border-box;
  display: flex !important;
  align-items: center;
  position: relative;
  min-height: auto !important;
  height: auto !important;
  margin: 0 0 16px 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

/* Normalize every flat card surface in the app. Gradient cards/widgets are
   intentionally excluded by their page-specific rules and remain unchanged. */
html.flat-ui body.has-global-sidebar .global-app-sidebar,
html.flat-ui body.has-global-sidebar .classmates-card,
html.flat-ui body.has-global-sidebar .class-overview-card {
  background: var(--app-surface) !important;
}

/* Shared page-title accent: removed heavy side bar */
body.has-global-sidebar .app-page-title-widget::before {
  display: none !important;
}

body.has-global-sidebar .app-page-title-widget h1 {
  margin: 0 !important;
  color: var(--text-main) !important;
  font-size: clamp(22px, 2.2vw, 28px) !important;
  font-weight: 800 !important;
  letter-spacing: -0.03em;
  line-height: 1.2 !important;
}

body.has-global-sidebar .app-legacy-page-title {
  display: none !important;
}

/* Keep the sidebar and the content column on the exact same top baseline. */
body.has-global-sidebar .sidebar-widget-stack {
  margin-top: 0 !important;
  top: var(--app-frame-gap) !important;
}

/* Every primary app surface shares one rounded silhouette. Inner controls,
   avatars, badges and list rows keep their own smaller corner treatment. */
html.flat-ui body.has-global-sidebar :is(
  .global-app-sidebar,
  .sidebar-brand-widget-external,
  .sidebar-profile-widget-external,
  .card,
  .kpi-card,
  .stat-box,
  .ai-chat-container,
  .focus-audio-widget,
  .timer-card,
  .feed-card,
  .feed-post,
  .post-creator-card,
  .profile-banner,
  .analytics-card,
  .exam-card,
  .settings-card,
  .connection-card,
  .detail-card,
  .ig-header-card,
  .dashboard-sidebar,
  .message-thread,
  .gamification-hero,
  .class-identity-widget,
  .class-capacity-widget,
  .classmates-card,
  .modal-card,
  .modal-content,
  .navbar,
  .app-topbar
) {
  border-radius: var(--app-widget-radius) !important;
}

@media (max-width: 640px) {
  body.has-global-sidebar { --app-widget-radius: 10px; }
}

/* Flat visual system: clean text shadows */
*,
*::before,
*::after {
  text-shadow: none !important;
}

/* Standalone navigation widget shared by every authenticated mobile page. */
.app-mobile-header {
  display: none;
}

@media (max-width: 992px) {
  body.has-global-sidebar > .navbar,
  body.has-global-sidebar > .app-topbar {
    display: none !important;
  }

  body.has-global-sidebar > .app-mobile-header {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    height: 56px;
    margin: 0 !important;
    padding: 8px 16px !important;
    border-radius: 0 !important;
    background: var(--app-surface, #ffffff);
    border-bottom: 1px solid var(--app-line, var(--border-color));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1100;
  }

  .app-mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 20px;
    font-weight: 800;
  }

  .app-mobile-header-brand img {
    width: 30px;
    height: 30px;
    object-fit: contain;
  }

  .app-mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  body.has-global-sidebar .app-mobile-settings-link {
    display: none;
    place-items: center;
    width: 40px;
    height: 44px;
    color: var(--text-muted);
  }

  body.has-global-sidebar.sidebar-mobile-open .app-mobile-settings-link {
    display: grid;
  }

  .app-mobile-settings-link svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .app-mobile-settings-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 8px;
  }

  body.has-global-sidebar .app-mobile-header .mobile-sidebar-toggle-btn {
    display: inline-flex !important;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    background: transparent;
  }

  body.has-global-sidebar .app-mobile-header .mobile-sidebar-toggle-btn:hover,
  body.has-global-sidebar .app-mobile-header .mobile-sidebar-toggle-btn:focus-visible {
    background: transparent;
  }

  body.has-global-sidebar .app-mobile-header .mobile-sidebar-toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
}

/* Clean modern flat surface and border hierarchy */
html.flat-ui body *,
html.flat-ui body *::before,
html.flat-ui body *::after {
  text-shadow: none !important;
}

body.has-global-sidebar .card,
body.has-global-sidebar .kpi-card,
body.has-global-sidebar .stat-box,
body.has-global-sidebar .profile-banner,
body.has-global-sidebar .feed-card,
body.has-global-sidebar .feed-post,
body.has-global-sidebar .settings-card,
body.has-global-sidebar .modal-card,
body.has-global-sidebar .modal-content {
  border: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: var(--app-widget-radius, 12px) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.has-global-sidebar input,
body.has-global-sidebar select,
body.has-global-sidebar textarea {
  border: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: 8px !important;
}

/* The global flat reset must not erase the outline of the theme control. */
.theme-switch,
html.flat-ui body .theme-switch,
html.flat-ui body.has-global-sidebar .theme-switch {
  border: 1px solid currentColor !important;
}

/* Manrope needs a little more breathing room than the former condensed face. */
body.has-global-sidebar,
body.has-global-sidebar button,
body.has-global-sidebar input,
body.has-global-sidebar select,
body.has-global-sidebar textarea {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body.has-global-sidebar h1,
body.has-global-sidebar h2,
body.has-global-sidebar h3,
body.has-global-sidebar h4,
body.has-global-sidebar .card-title,
body.has-global-sidebar .section-title {
  letter-spacing: -.045em;
}

body.has-global-sidebar p,
body.has-global-sidebar li,
body.has-global-sidebar label,
body.has-global-sidebar .sidebar-menu a,
body.has-global-sidebar .sidebar-section-label {
  letter-spacing: -.012em;
}

/* Sidebar navigation text follows the same muted/selected treatment as its icons. */
body.has-global-sidebar .sidebar-menu a:not(.active) {
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
}

body.has-global-sidebar .sidebar-menu a.active,
body.has-global-sidebar .sidebar-menu a.active:hover {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

body.has-global-sidebar .sidebar-menu a:hover:not(.active) {
  background-color: transparent !important;
  background-image: var(--primary-gradient) !important;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  box-shadow: none !important;
}

/* Keep role navigation reachable even when the browser height is short. */
body.has-global-sidebar .sidebar-navigation-group {
  min-height: 0;
  overflow: hidden;
}

body.has-global-sidebar .sidebar-navigation-group > .sidebar-menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body.has-global-sidebar .sidebar-navigation-group > .sidebar-utility-dock {
  flex: 0 0 auto;
}

@media (max-width: 992px) {
  body.has-global-sidebar .sidebar-widget-stack > .sidebar-brand-widget-external {
    position: relative;
    padding-right: 52px !important;
  }

  body.has-global-sidebar .sidebar-brand-widget-external .sidebar-mobile-close {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
  }
}

@media (max-width: 767px) {
  body.has-global-sidebar .sidebar-widget-stack {
    inset: 0 !important;
    width: 100vw;
    height: auto;
    padding: var(--app-frame-gap);
    background: transparent;
  }

  body.has-global-sidebar .sidebar-widget-stack > .global-app-sidebar {
    min-height: 0;
    width: 100% !important;
    max-width: none;
    align-self: stretch;
  }
}

@media (max-width: 992px) {
  body.has-global-sidebar > .app-mobile-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 1100;
  }

  body.has-global-sidebar.sidebar-mobile-open > .app-mobile-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 1250;
  }

  /* Off-canvas mobile drawer with higher z-index than backdrop */
  body.has-global-sidebar .global-app-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 290px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 16px 14px 28px !important;
    background: var(--bg-card, #ffffff) !important;
    border-right: 1px solid var(--border-color, #e2e8f0) !important;
    box-shadow: none !important;
    z-index: 1300 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
    visibility: hidden;
  }

  html[data-theme='dark'] body.has-global-sidebar .global-app-sidebar {
    background: #121d2d !important;
    border-right-color: #263951 !important;
  }

  body.has-global-sidebar .global-app-sidebar.mobile-open,
  body.has-global-sidebar.sidebar-mobile-open .global-app-sidebar {
    transform: translateX(0) !important;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.3) !important;
    pointer-events: auto !important;
    visibility: visible !important;
  }

  /* Backdrop Overlay: dim background without covering the sidebar */
  .sidebar-mobile-backdrop {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.55) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 1200 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease, visibility 0.25s ease !important;
  }

  .sidebar-mobile-backdrop.active,
  body.sidebar-mobile-open .sidebar-mobile-backdrop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  body.has-global-sidebar .mobile-sidebar-toggle-btn .hamburger-bar {
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  body.has-global-sidebar.sidebar-mobile-open .mobile-sidebar-toggle-btn .hamburger-bar:first-child {
    transform: translateY(6.7px) rotate(45deg);
  }

  body.has-global-sidebar.sidebar-mobile-open .mobile-sidebar-toggle-btn .hamburger-bar:nth-child(2) {
    opacity: 0;
  }

  body.has-global-sidebar.sidebar-mobile-open .mobile-sidebar-toggle-btn .hamburger-bar:last-child {
    transform: translateY(-6.7px) rotate(-45deg);
  }
}

/* Bottom navigation has been removed */
body.has-global-sidebar > .app-mobile-bottom-nav {
  display: none !important;
}

@media (max-width: 767px) {
  body.has-global-sidebar .sidebar-widget-stack .sidebar-utility-dock,
  body.has-global-sidebar > .app-mobile-bottom-nav {
    display: none !important;
  }

  body.has-global-sidebar > .app-mobile-bottom-nav::before {
    display: none !important;
  }

  body.has-global-sidebar .sidebar-widget-stack {
    padding-bottom: var(--app-frame-gap);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 3fr) minmax(0, 1fr);
  }

  body.has-global-sidebar .sidebar-widget-stack > .global-app-sidebar {
    grid-row: 1;
    min-height: 0;
    height: 100%;
  }

  body.has-global-sidebar .sidebar-widget-stack > .sidebar-profile-widget-external {
    grid-row: 2;
    min-height: 0;
    height: 100%;
  }

  body.has-global-sidebar .app-mosaic {
    padding-bottom: var(--app-content-gap) !important;
  }
}

/* One restrained elevation for primary widgets; inner rows stay flat. */
html.flat-ui body.has-global-sidebar :is(
  .global-app-sidebar,
  .sidebar-brand-widget-external,
  .sidebar-profile-widget-external,
  .app-mobile-header,
  .app-mobile-bottom-nav,
  .card,
  .stat-box,
  .post-creator-card,
  .focus-audio-widget,
  .timer-card,
  .analytics-panel,
  .exam-history-card,
  .settings-card,
  .notifications-panel,
  .search-workspace,
  .chat-main,
  .chat-sidebar,
  .class-overview-card,
  .class-capacity-widget,
  .classmates-card,
  .student-overview-panel,
  .profile-banner,
  .gamification-hero,
  .detail-card,
  .connection-card,
  .unassigned-class-card
) {
  box-shadow: var(--app-shadow) !important;
}

/* ==========================================================================
   GLOBAL FIXED TOP-RIGHT CONTROLS (Always fixed in top right, independent of menu)
   ========================================================================== */
.app-global-fixed-top-actions {
  position: fixed !important;
  top: 16px !important;
  right: 24px !important;
  z-index: 9999 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: auto !important;
}

body.has-global-sidebar .app-global-fixed-top-actions {
  top: 16px !important;
  right: 24px !important;
}

.topbar-action-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  height: 36px !important;
  padding: 0 12px !important;
  background: var(--app-surface, #ffffff) !important;
  border: 1px solid var(--app-line, var(--border-color)) !important;
  border-radius: 8px !important;
  color: var(--text-main) !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  position: relative !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  box-sizing: border-box !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  line-height: 1 !important;
}

.topbar-action-btn:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04)) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  transform: none !important;
}

/* Theme Switch Button */
.topbar-action-btn.theme-switch {
  width: 38px !important;
  padding: 0 !important;
  color: var(--text-main) !important;
}

.topbar-action-btn.theme-switch .theme-switch-moon {
  display: block !important;
}

.topbar-action-btn.theme-switch .theme-switch-sun {
  display: none !important;
}

html[data-theme='dark'] .topbar-action-btn.theme-switch .theme-switch-moon {
  display: none !important;
}

html[data-theme='dark'] .topbar-action-btn.theme-switch .theme-switch-sun {
  display: block !important;
}

/* Notification Bell Button */
.topbar-action-btn.notification-bell-btn {
  width: 38px !important;
  padding: 0 !important;
  position: relative !important;
}

.topbar-notification-badge {
  position: absolute !important;
  top: -4px !important;
  right: -4px !important;
  min-width: 18px !important;
  height: 18px !important;
  padding: 0 5px !important;
  background: #ef4444 !important;
  color: #ffffff !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  border-radius: 999px !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45) !important;
  line-height: 1 !important;
  pointer-events: none !important;
}

.topbar-notification-badge.has-unread {
  display: flex !important;
}

/* Search Trigger Button */
.topbar-action-btn.search-trigger-btn {
  width: 38px !important;
  padding: 0 !important;
  color: var(--text-main) !important;
}

/* Logout Button */
.topbar-action-btn.logout-btn {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
  color: #ef4444 !important;
  padding: 0 14px !important;
}

.topbar-action-btn.logout-btn:hover {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

/* Hide community hub sub-nav per user request */
.community-hub-nav {
  display: none !important;
}

/* Global Search Modal Overlay & Dialog */
.global-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.60);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 18px 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.global-search-overlay.open {
  opacity: 1;
  visibility: visible;
}

.global-search-dialog {
  background: var(--bg-card);
  border: 1px solid var(--app-line, var(--border-color));
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  transform: translateY(-8px);
  transition: transform 0.2s ease;
}

.global-search-overlay.open .global-search-dialog {
  transform: translateY(0);
}

.global-search-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--app-line, var(--border-color));
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
}

.global-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  background: var(--app-surface-muted, #f8fafc);
  border: 1px solid var(--app-line, var(--border-color));
  border-radius: 10px;
  padding: 8px 12px;
}

.global-search-input-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.global-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  font-family: inherit;
}

.global-search-input::placeholder {
  color: var(--text-muted);
}

.global-search-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.global-search-close-btn:hover {
  background: var(--app-surface-muted, var(--bg-main));
  color: var(--text-main);
}

.global-search-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--app-line, var(--border-color));
  background: var(--app-surface-muted, #f8fafc);
  overflow-x: auto;
}

.global-search-tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.global-search-tab-btn:hover {
  color: var(--text-main);
}

.global-search-tab-btn.active {
  background: var(--bg-card);
  border-color: var(--app-line, var(--border-color));
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.global-search-body {
  padding: 12px 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 220px;
}

.global-search-state {
  text-align: center;
  padding: 40px 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.global-search-state-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--app-surface-muted, #f8fafc);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.global-search-state h4 {
  color: var(--text-main);
  font-size: 14.5px;
  margin: 0 0 4px;
}

.global-search-state p {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.global-search-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.global-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--app-line, var(--border-color));
  background: var(--bg-card);
  transition: all 0.15s ease;
}

.global-search-item:hover {
  background: var(--app-surface-muted, #f8fafc);
}

.global-search-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.global-search-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--app-line, var(--border-color));
  background: var(--primary-light, #eaf1ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: 750;
  font-size: 14px;
}

.global-search-item-meta {
  min-width: 0;
}

.global-search-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-search-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.global-search-role-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-weight: 600;
}

.global-search-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.global-search-follow-btn {
  padding: 4px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  transition: all 0.15s ease;
}

.global-search-follow-btn.following {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--app-line, var(--border-color));
}

.global-search-msg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--app-line, var(--border-color));
  color: var(--text-muted);
  background: transparent;
  text-decoration: none;
  transition: all 0.15s ease;
}

.global-search-msg-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Responsive adjustment on mobile */
@media (max-width: 992px) {
  .app-global-fixed-top-actions {
    display: none !important;
  }

  .app-mobile-header-actions .topbar-action-btn {
    height: 36px !important;
    padding: 0 10px !important;
  }

  .app-mobile-header-actions .topbar-action-btn.theme-switch,
  .app-mobile-header-actions .topbar-action-btn.notification-bell-btn {
    width: 36px !important;
    padding: 0 !important;
  }

  .app-mobile-header-actions .topbar-action-btn.logout-btn {
    padding: 0 !important;
    width: 36px !important;
  }

  .app-mobile-header-actions .topbar-action-btn.logout-btn span {
    display: none !important;
  }
}

/* ==========================================================================
   WEB & CHROME TAB NOTIFICATIONS (WebNotificationManager)
   ========================================================================== */
.web-notif-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 32px);
}

.web-notif-card {
  pointer-events: auto;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-left: 4px solid var(--primary, #2459e8);
  border-radius: var(--radius-lg, 12px);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  animation: webNotifSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.web-notif-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -5px rgba(0, 0, 0, 0.2);
}

.web-notif-card.hide {
  animation: webNotifSlideOut 0.25s ease forwards;
}

.web-notif-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-hover, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.web-notif-card-content {
  flex: 1;
  min-width: 0;
}

.web-notif-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.web-notif-card-msg {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.web-notif-card-time {
  font-size: 11px;
  color: var(--text-light, #94a3b8);
  margin-top: 4px;
}

.web-notif-card-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.web-notif-card-close:hover {
  color: var(--danger, #ef4444);
}

@keyframes webNotifSlideIn {
  from {
    opacity: 0;
    transform: translateX(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes webNotifSlideOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(50px) scale(0.95);
  }
}

