/* ==========================================
   BQ24 LAYOUT
   Cleaned layout rules:
   - authenticated header
   - sidebar / app content
   - mobile navigation
   - footer
   - responsive safe-area handling
   ========================================== */

/* ==========================================
   HEADER
   ========================================== */

body[data-view="auth"] #topHeader,
body[data-view="home"] #topHeader,
body[data-view="quiz"] #topHeader,
body[data-view="result"] #topHeader,
body[data-view="maintenance"] #topHeader {
  display: none !important;
}

body[data-view="auth"] main,
body[data-view="maintenance"] main,
body[data-view="quiz"] main {
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
}

.top {
  height: 76px;
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
}

.header-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

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


.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.brand-logo-img {
  height: 48px;
  width: auto;
  max-width: 165px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s ease;
}

.brand-logo-img:hover {
  transform: scale(1.03);
}

.top-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 18px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  border: 2px solid rgba(99, 102, 241, 0.35);
  color: var(--brand-indigo, #818cf8);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.top-context-pill:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: var(--brand-indigo, #818cf8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.live-dot-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 7px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.top-tool-btn,
#fullscreenBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.top-tool-btn:hover,
#fullscreenBtn:hover {
  border-color: var(--card-border-hover, #cbd5e1);
  background: var(--card-bg-subtle, #f8fafc);
  color: var(--brand-indigo, #6366f1);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.top-tool-btn:active,
#fullscreenBtn:active {
  transform: scale(0.96);
}

.header-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.header-user-pill:hover {
  border-color: var(--brand-indigo, #6366f1);
}

.header-profile-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-profile-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 4px 14px 4px 6px;
  border-radius: 22px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  box-sizing: border-box;
}

.header-profile-btn:hover {
  border-color: var(--card-border-hover, #cbd5e1);
  background: var(--card-bg-subtle, #f8fafc);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.header-profile-btn:active {
  transform: scale(0.97);
}

.header-profile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.header-profile-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-profile-chevron {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.header-profile-wrap:hover .header-profile-chevron {
  color: var(--brand-indigo, #6366f1);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 10px 25px -5px rgba(0, 0, 0, 0.25));
  padding: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-dropdown.hidden {
  display: none !important;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.profile-dropdown-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
}

.profile-dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-indigo, #6366f1), var(--brand-cyan, #06b6d4));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-dropdown-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  overflow: hidden;
}

.profile-dropdown-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-dropdown-role {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.profile-dropdown-divider {
  height: 1px;
  background: var(--card-border);
  margin: 4px 0;
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.profile-dropdown-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--brand-indigo, #6366f1);
}

.profile-dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.header-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-indigo, #6366f1), var(--brand-cyan, #06b6d4));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
}

.header-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.header-user-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user-role {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.header-logout-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.header-logout-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.header-actions-group,
.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.theme-toggle-btn:hover {
  border-color: var(--card-border-hover, #cbd5e1);
  background: var(--card-bg-subtle, #f8fafc);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.theme-toggle-btn:active {
  transform: scale(0.96);
}

/* ==========================================
   BASE / MAIN
   ========================================== */

.pill {
  padding: 8px 16px;
  border: 2px solid var(--card-border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--subtle);
  transition: all 0.3s ease;
}

.connection-dot.online {
  background: var(--green);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.hero {
  text-align: center;
  padding: 36px 0 28px;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 2px;
  color: #818cf8;
  font-weight: 900;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  border: 2px solid rgba(99, 102, 241, 0.3);
  margin-bottom: 16px;
  max-width: 100%;
  box-sizing: border-box;
}

.hero h1 {
  font-family: 'Rubik', 'Inter', -apple-system, sans-serif;
  margin: 12px 0;
  font-size: clamp(38px, 5.5vw, 64px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -1.5px;
  color: var(--ink);
  word-break: break-word;
  overflow-wrap: break-word;
}

.hero h1 span {
  background: linear-gradient(135deg, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  max-width: 660px;
  margin: 0 auto;
  font-weight: 600;
  box-sizing: border-box;
}

/* ==========================================
   SIDEBAR & DASHBOARD LAYOUT
   ========================================== */

.app-layout {
  display: flex;
  /* align-items:stretch (flex default) — sidebar fills full app-layout height */
  align-items: stretch;
  gap: 0;
  min-height: calc(100vh - 76px);
  width: 100%;
}

.sidebar {
  width: 250px;
  background: var(--sidebar-bg, #0c1322) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.08)) !important;
  /* Reduced top padding — logo removed, profile card starts from top */
  padding: 16px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* position:sticky keeps nav visible while scrolling */
  position: sticky;
  top: 76px;
  /* min-height: sidebar is at least one viewport tall when content is short */
  min-height: calc(100vh - 76px);
  min-height: calc(100dvh - 76px);
  /* height:auto + NO align-self override = flex stretch = sidebar fills full .app-layout height */
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
  z-index: 20;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-border, rgba(255, 255, 255, 0.08));
}

.sidebar-logout-btn {
  color: var(--sidebar-logout-color, #ef4444) !important;
  margin-top: 4px;
}

@media (hover: hover) {
  .sidebar-logout-btn:hover {
    background: var(--sidebar-logout-hover-bg, rgba(239, 68, 68, 0.12)) !important;
    color: var(--sidebar-logout-hover-text, #f87171) !important;
  }
}

.sidebar-logout-btn .nav-icon,
.sidebar-logout-btn i,
.sidebar-logout-btn svg {
  color: var(--sidebar-logout-color, #ef4444) !important;
  stroke: var(--sidebar-logout-color, #ef4444) !important;
}

/* Sidebar brand header: hidden — logo removed from sidebar (kept in navbar and footer) */
.sidebar-brand-header {
  display: none !important;
}

.sidebar-brand-logo {
  display: none !important;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--sidebar-user-bg, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--sidebar-user-border, rgba(255, 255, 255, 0.08));
  margin-bottom: 8px;
  box-sizing: border-box;
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rubik', 'Inter', -apple-system, sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--sidebar-user-name, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.sidebar-user-role {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--sidebar-user-role, #2563eb);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  line-height: 1.2;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--sidebar-section-label, #64748b);
  padding: 10px 14px 4px;
  user-select: none;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 42px;
  border-radius: 10px;
  color: var(--sidebar-muted, #64748b);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}

@media (hover: hover) {
  .sidebar-nav-item:hover {
    background: var(--sidebar-hover-bg, #f1f5f9);
    color: var(--sidebar-hover-text, #0f172a);
  }

  .sidebar-nav-item:hover .nav-icon,
  .sidebar-nav-item:hover i,
  .sidebar-nav-item:hover svg {
    color: var(--sidebar-hover-text, #0f172a);
  }
}

.sidebar-nav-item.active {
  background: var(--sidebar-active-bg, #2563eb) !important;
  color: var(--sidebar-active-text, #ffffff) !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-nav-item.active .nav-icon,
.sidebar-nav-item.active i,
.sidebar-nav-item.active svg {
  color: var(--sidebar-active-text, #ffffff) !important;
  stroke: var(--sidebar-active-text, #ffffff) !important;
}

.sidebar-nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-icon, #64748b);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.sidebar-nav-item .nav-icon i,
.sidebar-nav-item .nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-logout {
  margin-top: auto;
  color: var(--red-dark) !important;
}

.sidebar-logout:hover {
  background: var(--red-light) !important;
}

.app-content {
  flex: 1;
  padding: 36px 32px 80px;
  max-width: 1100px;
  min-width: 0;
}

/* ==========================================
   MOBILE BOTTOM NAV
   ========================================== */

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 2px solid var(--card-border);
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
  min-height: 44px;
  flex: 1;
  user-select: none;
  touch-action: manipulation;
  box-sizing: border-box;
}

.mobile-nav-item:active {
  transform: scale(0.92);
  background: var(--card-bg-subtle, rgba(255, 255, 255, 0.04));
}

.mobile-nav-item.active {
  color: #818cf8;
}

.mobile-nav-item .mobile-nav-icon {
  font-size: 20px;
}

/* ==========================================
   MOBILE MORE SHEET
   ========================================== */

.mobile-more-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.mobile-more-sheet-backdrop.hidden {
  display: none !important;
}

.mobile-more-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg, #111827);
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  animation: sheetSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .mobile-more-sheet {
  background: #fff;
  border-color: #e2e8f0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
}

@keyframes sheetSlideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.mobile-more-sheet-handle {
  width: 38px;
  height: 4px;
  background: var(--card-border);
  border-radius: 999px;
  margin: 0 auto;
}

.mobile-more-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-close-sheet {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-close-sheet:hover {
  color: var(--ink);
}

.mobile-more-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mobile-more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  background: rgba(148, 163, 184, 0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  box-sizing: border-box;
  min-height: 94px;
}

.mobile-more-item:hover,
.mobile-more-item:active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}

.mobile-more-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

/* ==========================================
   FOOTER
   ========================================== */

.app-footer {
  border-top: 1px solid var(--card-border);
  background: var(--card-bg);
  margin-top: 0;
  padding: 44px 24px 28px;
  position: static;
  width: 100%;
  box-sizing: border-box;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr;
  gap: 36px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.footer-brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  width: fit-content;
}

.footer-logo-img {
  height: 38px;
  width: auto;
  max-width: 125px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
  transition: transform 0.2s ease;
}

.footer-logo-img:hover {
  transform: scale(1.03);
}

.footer-brand-title {
  font-family: 'Rubik', 'Inter', -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.footer-brand-desc,
.footer-col-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.footer-col-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.footer-links-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.footer-nav-link {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-nav-link:hover {
  color: var(--brand-indigo, #6366f1);
}

.footer-link-dot {
  color: var(--muted);
  opacity: 0.5;
  font-weight: 700;
  user-select: none;
}

.footer-divider {
  max-width: 1200px;
  margin: 28px auto 20px;
  height: 1px;
  background: var(--card-border);
  width: 100%;
}

.footer-bottom-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
  width: 100%;
  box-sizing: border-box;
}

.footer-copyright,
.footer-author-text {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}

.footer-author-name {
  color: var(--ink);
  font-weight: 700;
}

/* ==========================================
   GLOBAL VIEWPORT / SAFE AREA
   ========================================== */

html {
  width: 100%;
  max-width: 100vw;
}

body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==========================================
   DESKTOP SIDEBAR & MAIN CONTENT SHELL
   ========================================== */

@media (min-width: 769px) {

  body[data-view="student-dashboard"] #topHeader,
  body[data-view="teacher"] #topHeader {
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
  }

  body[data-view="student-dashboard"] #topHeader .brand,
  body[data-view="teacher"] #topHeader .brand {
    display: inline-flex !important;
  }

  body[data-view="student-dashboard"] main,
  body[data-view="teacher"] main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  .app-layout {
    display: flex;
    margin-left: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .app-content {
    flex: 1;
    margin-left: 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 1024px) {
  .dash-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .header-container {
    padding: 0 18px;
  }
  .top .pill {
    display: none;
  }

  main {
    padding: 20px 14px 60px;
    box-sizing: border-box;
    max-width: 100vw;
    min-width: 0;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .qrbox {
    position: static;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 22px;
    border-radius: var(--radius-lg);
  }

  .actions {
    position: sticky;
    bottom: 12px;
    padding: 14px;
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    border: 2px solid var(--card-border);
    border-radius: var(--radius-md);
    z-index: 20;
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

@media (max-width: 860px) {

  .header-course-pill,
  .header-user-meta,
  .header-profile-name {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .top {
    height: 66px !important;
  }

  .header-container {
    padding: 0 16px !important;
  }

  .header-hamburger-btn {
    display: inline-flex !important;
  }

  /* Fullscreen button is completely HIDDEN on mobile */
  #fullscreenBtn {
    display: none !important;
  }

  /* Theme button is VISIBLE on mobile header in its original place */
  #themeToggleBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    border: 1px solid var(--card-border) !important;
  }

  #themeToggleText {
    display: none !important;
  }

  /* Compact profile button on mobile header: [ ☰ ] [ BQ24 logo ] ... [ AA ] */
  .header-profile-name,
  .header-profile-chevron {
    display: none !important;
  }

  .header-profile-btn {
    height: 40px !important;
    padding: 3px !important;
    border-radius: 50% !important;
    border: 1px solid var(--card-border) !important;
  }

  .header-profile-avatar {
    width: 34px !important;
    height: 34px !important;
    font-size: 13px !important;
  }

  .brand-logo-img {
    height: 38px !important;
    max-width: 125px !important;
  }

  .sidebar {
    display: none !important;
  }

  body[data-view="student-dashboard"] #topHeader,
  body[data-view="teacher"] #topHeader {
    margin-left: 0 !important;
    width: 100% !important;
  }

  body[data-view="student-dashboard"] #topHeader .brand,
  body[data-view="teacher"] #topHeader .brand {
    display: inline-flex !important;
  }

  .mobile-nav {
    display: flex;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .toast {
    bottom: calc(75px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    left: 16px;
    max-width: calc(100vw - 32px);
    justify-content: center;
  }

  .app-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 18px 14px 24px;
  }

  .app-footer {
    padding: 28px 16px calc(72px + env(safe-area-inset-bottom, 16px));
    margin-top: 0;
  }

  #teacher {
    padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .teacher-mobile-nav:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 2px !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .teacher-mobile-nav .mobile-nav-item {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 6px 2px !important;
    font-size: 10px !important;
    gap: 2px !important;
    text-align: center !important;
  }

  .teacher-mobile-nav .mobile-nav-item i,
  .teacher-mobile-nav .mobile-nav-item svg {
    width: 18px !important;
    height: 18px !important;
    margin: 0 auto 2px !important;
  }

  .dash-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .dash-stat-card {
    padding: 14px 10px;
    min-height: auto;
    height: auto;
  }

  .dash-stat-icon {
    width: 34px;
    height: 34px;
    margin: 0 auto 6px;
  }

  .dash-stat-icon svg {
    width: 20px !important;
    height: 20px !important;
  }

  .dash-stat-value {
    font-size: 22px;
    height: auto;
    margin: 0 0 4px;
  }

  .dash-stat-label {
    font-size: 12px;
    min-height: auto;
  }

  .dash-join-card {
    padding: 20px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .dash-join-card .join-input-wrap {
    min-width: 0;
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .dash-join-card .join-input-wrap input {
    min-width: 0;
    flex: 1;
    padding: 12px 14px;
    font-size: 14px;
    letter-spacing: 2px;
  }

  .dash-join-card .join-input-wrap .btn {
    padding: 12px 16px;
    font-size: 13.5px;
    flex-shrink: 0;
  }

  .archive-grid {
    grid-template-columns: 1fr;
  }

  .auth-container {
    padding: 20px 12px 40px;
  }
}

@media (max-width: 767px) {
  #fullscreenBtn {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .top {
    height: 66px;
  }

  .header-container {
    padding: 0 16px;
  }

  .brand-logo-img {
    height: 40px;
    max-width: 135px;
  }

  .theme-toggle-btn {
    height: 42px;
    padding: 0 12px;
  }

  .header-profile-btn {
    height: 42px;
    padding: 3px 10px 3px 4px;
    border-radius: 21px;
  }

  .header-profile-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .header-profile-name {
    max-width: 95px;
    font-size: 13px;
  }

  .top-context-pill {
    display: none !important;
  }

  .connection span:last-child {
    display: none;
  }

  .connection {
    padding: 6px 10px;
  }

  .theme-text {
    display: none;
  }

  .theme-toggle-btn {
    padding: 7px 10px;
  }

  .app-footer {
    padding: 28px 16px calc(72px + env(safe-area-inset-bottom, 16px));
    margin-top: 0;
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .footer-bottom-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .top {
    height: 60px;
  }

  .header-container {
    padding: 0 12px;
  }

  .brand-logo-img {
    height: 34px;
    max-width: 110px;
  }

  .theme-toggle-btn {
    height: 38px;
    padding: 0 10px;
  }

  .header-profile-btn {
    height: 38px;
    padding: 3px 5px 3px 3px;
  }

  .header-profile-name {
    display: none;
  }

  .header-profile-chevron {
    display: none;
  }

  .header-actions-group,
  .top-right {
    gap: 8px;
  }
}

/* =========================================================
   HEADER HAMBURGER BUTTON & MOBILE DRAWER
   ========================================================= */
.header-hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.header-hamburger-btn:hover {
  border-color: var(--card-border-hover, #cbd5e1);
  background: var(--card-bg-subtle, #f8fafc);
  color: var(--brand-indigo, #6366f1);
  transform: translateY(-1px);
}

.header-hamburger-btn:active {
  transform: scale(0.96);
}

@media (max-width: 768px) {
  .header-hamburger-btn {
    display: inline-flex !important;
  }
}

/* Nav Drawer Backdrop */
.nav-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  transition: opacity 0.28s ease;
  opacity: 1;
}

.nav-drawer-backdrop.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Nav Drawer */
.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 85%;
  max-width: 380px;
  height: 100vh;
  height: 100dvh;
  background: var(--card-bg, #0f172a);
  border-right: 1px solid var(--card-border);
  z-index: 550;
  display: flex;
  flex-direction: column;
  box-shadow: 14px 0 40px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  transform: translateX(0);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-drawer.hidden {
  transform: translateX(-100%) !important;
  pointer-events: none;
  visibility: hidden;
}

/* Body scroll lock when drawer is open */
body.drawer-open {
  overflow: hidden !important;
  touch-action: none;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px 20px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.nav-drawer-brand {
  display: flex;
  align-items: center;
}

.nav-drawer-logo {
  height: 38px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

.nav-drawer-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card-bg-subtle, rgba(255, 255, 255, 0.04));
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: manipulation;
}

.nav-drawer-close-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(0.96);
}

.nav-drawer-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.05));
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.nav-drawer-user-card:hover {
  border-color: var(--brand-indigo, #6366f1);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
}

.nav-drawer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  font-size: 14.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.nav-drawer-user-meta {
  flex: 1;
  min-width: 0;
}

.nav-drawer-user-name {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.nav-drawer-user-role-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.2;
}

.nav-drawer-user-role {
  color: var(--brand-indigo, #818cf8);
}

.nav-drawer-user-group {
  color: var(--muted);
}

.nav-drawer-chevron {
  color: var(--muted);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-drawer-user-card:hover .nav-drawer-chevron {
  color: var(--brand-indigo, #6366f1);
  transform: translateX(2px);
}

.nav-drawer-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 14px 20px;
  flex: 1;
  overflow-y: auto;
}

.nav-drawer-group-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
}

.nav-drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  user-select: none;
  touch-action: manipulation;
  box-sizing: border-box;
}

.nav-drawer-item:hover {
  background: var(--card-bg-subtle, rgba(255, 255, 255, 0.05));
  border-color: var(--card-border);
  color: var(--brand-indigo, #818cf8);
  transform: translateX(2px);
}

.nav-drawer-item:active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--brand-indigo, #6366f1);
}

.nav-drawer-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-drawer-item:hover .nav-drawer-icon-wrap {
  transform: scale(1.06);
}

.nav-drawer-icon-wrap.icon-indigo {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
}

.nav-drawer-icon-wrap.icon-amber {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}

.nav-drawer-icon-wrap.icon-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
}

.nav-drawer-icon-wrap.icon-slate {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}

.nav-drawer-icon-wrap.icon-red {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.nav-drawer-label {
  flex: 1;
}

.nav-drawer-item-arrow {
  color: var(--muted);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-drawer-item:hover .nav-drawer-item-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.nav-drawer-divider {
  height: 1px;
  background: var(--card-border);
  margin: 8px 4px;
}

.nav-drawer-item-danger {
  color: var(--ink);
}

.nav-drawer-item-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

/* =========================================================
   ULTRA-COMPACT MOBILE BREAKPOINTS (320px - 360px)
   ========================================================= */
@media (max-width: 360px) {
  .header-container {
    padding: 0 10px !important;
  }

  .brand-logo-img {
    height: 32px !important;
    max-width: 95px !important;
  }

  .header-hamburger-btn {
    width: 38px !important;
    height: 38px !important;
  }

  .nav-drawer {
    width: 88% !important;
  }

  .nav-drawer-user-card {
    margin: 12px 10px;
    padding: 10px 12px;
  }

  .nav-drawer-avatar {
    width: 38px !important;
    height: 38px !important;
    font-size: 13px !important;
  }

  .nav-drawer-menu {
    padding: 4px 8px 16px;
  }

  .nav-drawer-item {
    padding: 8px 10px;
    font-size: 13.5px;
  }

  /* Bottom nav ultra-compact styling */
  .mobile-nav {
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-nav-item {
    padding: 4px 2px !important;
    font-size: 9.5px !important;
    gap: 2px !important;
  }

  .mobile-nav-item svg,
  .mobile-nav-item i {
    width: 18px !important;
    height: 18px !important;
  }
}
