/* No changes needed to this file */
:root {
  --primary-color: #3b82f6;
  --primary-color-dark: #2563eb;
  --background-color: #f9fafb;
  --text-color: #1f2937;
  --secondary-text-color: #6b7280;
  --card-background: #ffffff;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
  --border-color: #e5e7eb;
  --header-bg: rgba(255, 255, 255, 0.85);
  --header-height: 70px;
  --container-padding: 1.5rem;
}

.dark-mode {
  --primary-color: #60a5fa;
  --primary-color-dark: #3b82f6;
  --background-color: #111827;
  --text-color: #f9fafb;
  --secondary-text-color: #9ca3af;
  --card-background: #1f2937;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --border-color: #374151;
  --header-bg: rgba(17, 24, 39, 0.85);
}

/* --- Base Styling (Unchanged) --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
}

/* Auth Guard: Hide content during auth check to prevent flash of protected content */
html.auth-pending {
  visibility: hidden;
  pointer-events: none;
}

html.auth-ready {
  visibility: visible;
  pointer-events: auto;
}

body {
  font-family: 'Poppins', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* --- Header & Navigation --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background-color: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s, border-bottom 0.3s;
}

.header--auto-hide {
  transform: translateY(0);
  transition: transform 0.3s ease, background-color 0.3s, border-bottom 0.3s;
  will-change: transform;
}

.header--hidden {
  transform: translateY(calc(-1 * var(--header-height)));
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
  line-height: 1;
  font-size: 0;
}

#nav {
  display: contents;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-height);
  line-height: 1;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.3s;
}

.nav-links a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: var(--primary-color);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}

.nav-links a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

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

.nav-links a.active {
  color: var(--primary-color);
  font-weight: 600;
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary-color);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: var(--header-height);
  position: relative;
  z-index: 1200;
  margin-left: 1rem;
  line-height: 1;
  font-size: 0;
}

.navbar {
  display: flex;
  align-items: center;
  height: var(--header-height);
  position: relative;
}

.header svg {
  display: block;
}

/* --- Theme Toggle Button Fix --- */
.theme-toggle-btn {
  /* Increased size and padding for better touch target on mobile */
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 0;
  line-height: 1;

  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  /* Use primary color for better contrast and visibility */
  color: var(--primary-color);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  margin-right: 0.5rem;
  box-sizing: border-box;
  vertical-align: middle;
}

.theme-toggle-btn:hover {
  background-color: var(--card-background);
  /* Optional: Darken primary color on hover */
  color: var(--primary-color-dark);
}

.theme-toggle-btn .icon-moon,
.theme-toggle-btn .icon-sun {
  /* Ensure icons fill the button space nicely */
  width: 24px;
  height: 24px;
  display: block;
}

.theme-toggle-btn .icon-moon {
  display: block;
}

.theme-toggle-btn .icon-sun {
  display: none;
}

.dark-mode .theme-toggle-btn .icon-moon {
  display: none;
}

.dark-mode .theme-toggle-btn .icon-sun {
  display: block;
}

.hamburger svg {
  width: 24px;
  height: 24px;
}

/* --- New Navbar Implementation (Hamburger & Menu) --- */

/* Navbar Spacer - Takes up space for flex layout */
.navbar-spacer {
  flex: 1;
  height: var(--header-height);
  line-height: 1;
}

/* User Info Display - Shows on Desktop when logged in */
.user-info-display {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--background-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-right: 0.5rem;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Navbar Hamburger Button */
.navbar-hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  cursor: pointer;
  padding: 0;
  color: var(--text-color);
  border-radius: 8px;
  position: relative;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  margin-left: 0.75rem;
  font-size: 0;
  line-height: 1;
  vertical-align: middle;
}

.navbar-hamburger:hover {
  background-color: var(--card-background);
  color: var(--primary-color-dark);
}

.navbar-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background-color: currentColor;
  transition: all 0.3s ease;
  border-radius: 999px;
}

.navbar-hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(10px, 10px);
}

.navbar-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.navbar-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* Navbar Menu */
.navbar-menu {
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  background-color: var(--card-background);
  border-bottom: 1px solid var(--border-color);
  max-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: max-height 0.3s ease;
  z-index: 999;
}

.navbar-menu.active {
  max-height: 100vh;
}

.navbar-menu-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.navbar-menu-item {
  padding: 0.8rem 1rem;
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background-color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.navbar-menu-item:hover {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.navbar-menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.navbar-menu-divider {
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--secondary-text-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.navbar-dashboard-item svg {
  display: block;
}

.navbar-signout-btn {
  background: none;
  border: 1px solid #e74c3c;
  color: #e74c3c;
}

.navbar-signout-btn:hover {
  background-color: #e74c3c !important;
  color: white;
  border-color: #e74c3c;
}

/* --- Main Content (Unchanged) --- */
main {
  padding: calc(var(--header-height) + 40px) 0 4rem;
}

.welcome-section {
  text-align: center;
  padding-bottom: 4rem;
}

.welcome-section h1,
.content-section h1,
.content-section h2 {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}

.welcome-section p {
  font-size: 1.1rem;
  color: var(--secondary-text-color);
  max-width: 600px;
  margin: 0 auto;
}

.welcome-section .welcome-actions {
  margin: 1.5rem 0 1.75rem;
  text-align: center;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 7rem;
}

.welcome-section #auth-buttons-guest,
.welcome-section #auth-buttons-user {
  display: none;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.welcome-section #auth-buttons-guest {
  align-self: flex-start;
  align-items: center;
}

.welcome-section #auth-buttons-user {
  display: none;
}

.welcome-section .welcome-actions .btn {
  min-width: 220px;
  font-size: 1rem;
  padding: 0.9rem 1.6rem;
}

.welcome-section #auth-buttons-user.home-learning-card {
  display: none;
  width: 100%;
  max-width: none;
  flex: 1 1 100%;
  align-self: stretch;
  margin: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1.75rem;
  text-align: center;
  background: var(--card-background);
}

.welcome-section #auth-buttons-user.home-learning-card .home-learning-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin: 0;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.welcome-section #auth-buttons-user.home-learning-card h2 {
  margin: 0;
  width: 100%;
  font-size: clamp(1.45rem, 2.4vw, 1.95rem);
}

.welcome-section #auth-buttons-user.home-learning-card h2.home-learning-title--typing::after {
  content: '_';
  display: inline-block;
  margin-left: 0.08em;
  color: currentColor;
  animation: homeLearningCursorBlink 1s steps(1, end) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .welcome-section #auth-buttons-user.home-learning-card h2.home-learning-title--typing::after {
    animation: none;
  }
}

.welcome-section #auth-buttons-user.home-learning-card p {
  width: 100%;
  max-width: none;
  margin: 0;
}

.welcome-section #auth-buttons-user.home-learning-card .home-learning-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  width: 100%;
}

.welcome-section #auth-buttons-user.home-learning-card .home-learning-actions .btn {
  width: 100%;
  min-width: 0;
}

.welcome-section #auth-buttons-user.home-learning-card.home-learning-card--locked {
  background: var(--card-background);
}

.welcome-section #auth-buttons-user.home-learning-card.home-learning-card--locked .home-learning-badge {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

@keyframes homeLearningCursorBlink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

.content-section {
  padding: 0;
}

.content-section h1,
.content-section h2 {
  text-align: center;
  margin-bottom: 2.5rem;
}

/* --- Card & Grid (Text Cut-off Fix) --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s, box-shadow 0.3s;
  /* FIX: Ensure long text in cards wraps correctly */
  word-break: break-word;
  overflow-wrap: break-word;
}

.card-grid > .card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.99) 0%, rgba(251, 253, 255, 0.98) 42%, rgba(243, 249, 255, 0.97) 74%, rgba(233, 243, 255, 0.95) 100%);
  background-size: 180% 180%;
  border-color: rgba(147, 197, 253, 0.2);
  box-shadow: 0 12px 26px rgba(59, 130, 246, 0.06), 0 3px 8px rgba(15, 23, 42, 0.04), var(--card-shadow);
  animation: class-card-gradient 16s ease-in-out infinite;
}

.dark-mode .card-grid > .card {
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.98) 0%, rgba(30, 41, 59, 0.97) 48%, rgba(29, 78, 216, 0.16) 100%);
  border-color: rgba(96, 165, 250, 0.24);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.28), 0 4px 10px rgba(15, 23, 42, 0.18), var(--card-shadow);
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.95rem;
  color: var(--secondary-text-color);
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.card .status {
  font-weight: 500;
  color: var(--primary-color);
}

@keyframes class-card-gradient {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-grid > .card {
    animation: none;
  }
}

/* =========================================================
   BUTTONS — Match Logo Color Exactly
   ========================================================= */

.btn {
  display: inline-block;
  background-color: var(--primary-color);
  /* same as logo */
  color: #ffffff;

  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  text-align: center;

  border: none;
  cursor: pointer;

  transition: background-color 0.2s ease, transform 0.15s ease;
}

.btn:hover {
  background-color: var(--primary-color-dark);
  /* same family */
}

.btn:active {
  transform: translateY(1px);
}


.btn.disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

/* Auth buttons in header */
.auth-buttons {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-right: 1rem;
  flex-wrap: wrap;
}

.auth-buttons .btn {
  padding: 0.6rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-color-dark);
}

.btn-secondary {
  background-color: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  padding: 0.55rem 1.15rem;
}

.btn-secondary:hover {
  background-color: var(--primary-color);
  color: #ffffff;
}

/* Responsive: hide auth buttons on small screens */
@media (max-width: 768px) {
  .auth-buttons {
    display: none !important;
  }

  .welcome-section #auth-buttons-guest {
    align-self: center;
  }
}

/* --- Footer --- */
.footer {
  padding: 2.5rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  color: var(--secondary-text-color);
  margin-top: 4rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.social-links a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 500;
  position: relative;
  transition: color 0.3s;
}

.social-links a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -4px;
  left: 0;
  background-color: var(--primary-color);
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}

.social-links a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

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

.about-container {
  max-width: 800px;
  text-align: left;
}

.about-container p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  color: var(--secondary-text-color);
}

.about-container a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.about-container a:hover {
  color: var(--primary-color-dark);
  text-decoration: none;
}

/* --- Media Queries (Nav + Layout) --- */
@media (max-width: 1024px) {
  .nav-links {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 1100;
    background-color: var(--header-bg);
    flex-direction: column;
    align-items: center;
    padding: 0;
    gap: 0;
    border-bottom: none;
    display: none !important;
    pointer-events: none;
  }

  .nav-links.active {
    display: flex !important;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    pointer-events: auto;
  }

  .nav-links li {
    width: 100%;
    text-align: center;
  }

  .nav-links a {
    display: block;
    padding: 1rem;
    width: 100%;
  }

  .nav-links a:hover {
    background-color: var(--card-background);
  }

  .nav-links a.active::after {
    display: none;
  }

  .hamburger {
    display: none !important;
  }
}

@media (max-width: 768px) {
  :root {
    --container-padding: 1.1rem;
  }

  main {
    padding-top: calc(var(--header-height) + 30px);
  }

  .welcome-section h1,
  .content-section h1,
  .content-section h2 {
    font-size: 1.75rem;
  }

  /* Optional: Further reduction of card content size on very small screens */
  .card h3 {
    font-size: 1.15rem;
  }

  .card p {
    font-size: 0.9rem;
  }

  .social-links {
    gap: 1rem 1.5rem;
  }

  /* Hide user info on mobile */
  .user-info-display {
    display: none !important;
  }

  /* Adjust navbar menu on mobile */
  .navbar-menu-content {
    padding: 0.75rem;
    gap: 0.3rem;
  }

  .navbar-menu-item {
    padding: 0.7rem 0.8rem;
    font-size: 0.9rem;
  }

  .navbar-menu-divider {
    padding: 0.6rem 0.8rem;
    font-size: 0.75rem;
    margin-top: 0.3rem;
  }

  /* Stack buttons on mobile */
  .welcome-section .welcome-actions {
    flex-direction: column !important;
    align-items: center;
    min-height: 10rem;
  }

  .welcome-section .welcome-actions .btn {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  :root {
    --container-padding: 0.9rem;
  }
}

/* --- Button Row Styling (for Notes/Practice buttons) --- */
.card .btn-row {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card .btn-row .btn {
  margin: 0;
  width: 100%;
}


.welcome-section p+p {
  margin-top: 1rem;
}

/* css extra for footer */

.footer-credit {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #374151;
}

.dark-mode .footer-credit {
  color: var(--secondary-text-color);
}

.footer-usage {
  max-width: 640px;
  margin: 0.5rem auto 0;
  font-size: 0.8rem;
  color: #9ca3af;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
/* =========================================================
   WATERMARK SYSTEM — Educational Attribution (Refined)
   ========================================================= */

/* Subtle background watermark */
.notes-page::before {
  content: "RaushanSYNC · Educational Content";
  position: fixed;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-28deg);

  /* Smaller and safer sizing */
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: 0.12em;

  color: var(--text-color);
  opacity: 0.025;

  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
  text-align: center;
}

/* Ensure content stays above watermark */
.notes-container {
  position: relative;
  z-index: 1;
}

/* Footer watermark line */
.notes-watermark {
  margin-top: 4rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--secondary-text-color);
  opacity: 0.85;
}

/* =========================================================
   NOTES PAGES — RaushanSYNC Knowledge Layout
   ========================================================= */

.notes-page {
  padding-top: calc(var(--header-height) + 40px);
  padding-bottom: 4rem;
}

.notes-container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* Header */

.notes-header {
  text-align: center;
  margin-bottom: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.notes-header-left {
  flex: 1;
}

@media (min-width: 768px) {
  .notes-header {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
    gap: 2rem;
  }
}

.notes-header h1 {
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
}

.notes-header p {
  color: var(--secondary-text-color);
  font-size: 1rem;
}

/* Section Headings */

.notes-container h2 {
  margin-top: 3.2rem;
  margin-bottom: 1rem;
  font-size: 1.7rem;
  color: var(--primary-color);
}

.notes-container h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.6rem;
  font-size: 1.2rem;
}

/* =========================================================
   VIDEO LESSONS — Responsive Embeds
   ========================================================= */

.video-lesson {
  margin-top: 2.5rem;
}

.video-lesson h2 {
  margin-top: 0;
}

.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-description {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.08);
  border-left: 4px solid var(--primary-color);
  color: var(--secondary-text-color);
  font-size: 0.95rem;
  line-height: 1.6;
}

.video-description p {
  margin: 0;
}

/* Video Solution Btn design on practice and adv practice page. */
.video-solution-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--primary-color);
  background-color: rgba(59, 130, 246, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.15);

  padding: 6px 10px;
  border-radius: 6px;

  transition:
    color 0.2s ease,
    background-color 0.2s ease,
    transform 0.1s ease,
    border-color 0.2s ease;
}

.video-solution-btn:hover {
  background-color: rgba(59, 130, 246, 0.08);
  color: var(--primary-color-dark);
  border-color: rgba(59, 130, 246, 0.25);
}

.video-solution-btn:active {
  transform: translateY(1px);
}

.video-solution-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

/* Dark-mode adjustments to ensure strong contrast against dark backgrounds */
.dark-mode .video-solution-btn {
  color: var(--primary-color);
  background-color: rgba(96, 165, 250, 0.06);
  border-color: rgba(96, 165, 250, 0.12);
}

.dark-mode .video-solution-btn:hover {
  background-color: rgba(96, 165, 250, 0.16);
  color: var(--primary-color-dark);
  border-color: rgba(96, 165, 250, 0.2);
}

.dark-mode .video-solution-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.6);
  outline-offset: 2px;
}

/* Text */

.notes-container p {
  margin-bottom: 0.8rem;
}

.notes-container ul,
.notes-container ol {
  padding-left: 1.4rem;
  margin-bottom: 1rem;
}

.notes-container li {
  margin-bottom: 0.4rem;
}

/* Information Blocks */

.notes-box {
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary-color);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin: 1.4rem 0;
  box-shadow: var(--card-shadow);
}

.notes-box.example {
  border-left-color: #7dd3fc;
}

.notes-box.summary {
  border-left-color: #22c55e;
}

.notes-box.careful {
  border-left-color: #f07c78;
}

.notes-box h2 {
  margin-top: 0;
}

/* Tables */

.notes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background-color: var(--card-background);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.notes-table th,
.notes-table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem 0.8rem;
  text-align: left;
}

.notes-table th {
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.04);
}

.dark-mode .notes-table th {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Diagrams */

.notes-diagram {
  text-align: center;
  margin: 2rem 0;
}

.notes-diagram img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

.notes-diagram figcaption {
  font-size: 0.9rem;
  color: var(--secondary-text-color);
  margin-top: 0.4rem;
}

.support-improvement-card {
  margin: 1rem 0;
  padding: 2rem 1.25rem;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: var(--card-background);
  text-align: center;
}

.support-improvement-card p {
  margin-bottom: 1rem;
  color: var(--secondary-text-color);
  font-size: 0.95rem;
}

.support-improvement-card .support-improvement-card__thanks {
  margin: 1rem 0 0;
}

/* =========================================================
   PRACTICE PAGE COMPONENTS (additional css)
   ========================================================= */

.question-card {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
  box-shadow: var(--card-shadow);
}

.question-card ul,
.question-card ol {
  margin-top: 0.6rem;
  padding-left: 1.2rem;
}

.question-card li {
  margin-bottom: 0.4rem;
}

/* Palette Blocks */

.palette {
  background: var(--card-background);
  border-radius: 14px;
  padding: 1.3rem 1.5rem;
  margin: 1.8rem 0;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
}

.palette.important {
  background: var(--card-background);
  border-left: 1px solid var(--border-color);
}

.palette.optional {
  background: var(--card-background);
  border-left: 1px solid var(--border-color);
}

.palette strong {
  display: block;
  margin-bottom: 0.6rem;
}


/* =========================================================
   PRACTICE PAGE — Layout Width Fix (Laptop/Desktop)
   ========================================================= */

.practice-page .notes-container {
  max-width: 1200px;
  /* same as homepage container */
}


.practice-page .question-card,
.practice-page .palette {
  padding: 1.6rem 2rem;
}


/* =========================================================
   ADVANCED PRACTICE PAGE EXTENSIONS (additional css) 
   ========================================================= */


.palette.note {
  background: var(--card-background);
  border-left: 1px solid var(--border-color);
}

/* Blockquote styling for quoted text */
.notes-container blockquote {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--primary-color);
  background: rgba(0, 0, 0, 0.03);
  font-style: italic;
  border-radius: 6px;
}

.dark-mode .notes-container blockquote {
  background: rgba(255, 255, 255, 0.04);
}

/* Improve answer readability */
.notes-box p {
  margin-bottom: 0.6rem;
}

/* Tighter list spacing inside answers */
.notes-box ul li {
  margin-bottom: 0.3rem;
}

/* Navigation buttons */
.navigation-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}

/* =========================================================
   HOMEPAGE WELCOME SECTION — FINAL FIX
   ========================================================= */

/* Home-only spacing tighten to match global section density */
.home-page .welcome-section {
  padding-bottom: 2.5rem;
}

/* Reduce oversized hero padding/margins without touching other palettes */
.home-page .welcome-section .hero-palette {
  padding: 1.55rem 1.75rem;
  margin: 0.75rem 0 1.1rem;
}

.home-page .welcome-section .welcome-actions {
  margin: 1rem 0 1rem;
  min-height: 4.5rem;
}

html.home-hero-reserved .home-page .welcome-section .welcome-actions {
  min-height: 16rem;
}

/* Apply left alignment ONLY to non-hero palettes */
.welcome-section .palette:not(.hero-palette) p {
  text-align: left;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}


/* Prevent strong from breaking lines in intro text */
.welcome-section .palette strong {
  display: inline;
}

/* Reduce artificial gap between heading and palette */
.welcome-section h1 {
  margin-bottom: 1rem;
}

.welcome-section .palette {
  margin-top: 1rem;
}


/* =========================================================
   HERO PALETTE — Hub-style intro consistency
   ========================================================= */

.hero-palette {
  text-align: center;
  padding: 2rem 2.5rem;
}

/* Text should feel editorial, not instructional */
.hero-palette p {
  max-width: none;
  /* allow full width */
  margin: 0.8rem 0;
  /* no horizontal centering */
  text-align: center;
  font-size: 1.05rem;
}


/* Keep emphasis inline (no forced line breaks) */
.hero-palette strong {
  display: inline;
  font-weight: 600;
}

/* Softer, calmer italic line */
.hero-palette em {
  font-size: 0.95rem;
  opacity: 0.85;
}

/* Tighten relationship with heading */
.welcome-section h1 {
  margin-bottom: 1.2rem;
}

/* =========================================================
   STRONG TEXT — Hub-level emphasis consistency
   ========================================================= */

.welcome-section .hero-palette strong {
  color: var(--text-color);
  font-weight: 600;
}

/* =========================================================
   HERO LINK — remove underline, keep emphasis
   ========================================================= */

.welcome-section .hero-palette a {
  text-decoration: none;
  font-weight: 600;
  color: var(--primary-color);
}

.welcome-section .hero-palette a:hover {
  text-decoration: none;
  color: var(--primary-color-dark);
}

/* =========================================================
   HERO ATTRIBUTION — blockquote style (non-italic)
   ========================================================= */

.hero-palette .hero-attribution {
  margin-top: 1.2rem;
  padding: 0.8rem 1.2rem;

  font-size: 0.95rem;
  line-height: 1.6;

  color: var(--secondary-text-color);
  text-align: center;

  border-left: 4px solid var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;

  font-style: normal;
  /* explicitly non-italic */
}

.profile-help-panel {
  width: min(620px, 95%);
  height: auto;
  max-height: min(86vh, 560px);
}

.profile-help-body {
  position: relative;
  z-index: 1;
  padding: 1.1rem 1.15rem 0;
  display: grid;
  gap: 0.8rem;
}

.profile-help-copy {
  margin: 0;
  color: var(--text-color);
  font-size: 1rem;
  line-height: 1.65;
}

.profile-help-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding: 1rem 1.15rem 1.2rem;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.78) 0%, rgba(248, 250, 252, 0.96) 100%);
}

.dark-mode .profile-help-actions {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.72) 0%, rgba(15, 23, 42, 0.94) 100%);
}

.profile-help-actions .btn {
  min-width: 210px;
}

@media (min-width: 769px) {
  .profile-help-actions .btn {
    min-height: 52px;
    display: inline-flex;

  html.home-hero-reserved .home-page .welcome-section .welcome-actions {
    min-height: 20rem;
  }
    align-items: center;
    justify-content: center;
  }

  .profile-help-actions .btn-secondary {
    padding: 0.75rem 1.5rem;
  }
}

.future-roadmap-card {
  width: 100%;
  max-width: none;
  margin: 1.25rem 0 0;
  padding: 1.85rem 2rem 2rem;
  text-align: center;
}

.future-roadmap-card h2 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
}

.future-roadmap-card p {
  max-width: none;
  margin: 0.8rem auto 0;
}

.future-roadmap-actions {
  display: flex;
  justify-content: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 1.55rem;
}

.future-roadmap-actions .btn {
  min-width: 210px;
}

@media (max-width: 768px) {
  .future-roadmap-actions {
    flex-direction: column;
    align-items: center;
  }

  .future-roadmap-actions .btn {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 768px) {
  .profile-help-panel {
    width: min(100%, 560px);
  }

  .welcome-section #auth-buttons-user.home-learning-card {
    align-items: center;
    text-align: center;
  }

  .welcome-section #auth-buttons-user.home-learning-card p {
    text-align: center;
  }

  .welcome-section #auth-buttons-user.home-learning-card .home-learning-actions {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .welcome-section #auth-buttons-user.home-learning-card .home-learning-actions .btn {
    max-width: 280px;
  }

  .profile-help-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-help-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

/* =========================================================
   HERO ATTRIBUTION — Mobile flattening
   ========================================================= */

@media (max-width: 768px) {
  .hero-palette .hero-attribution {
    margin-top: 0.8rem;
    padding: 0;

    background: none;
    border-left: none;
    border-radius: 0;

    font-size: 0.9rem;
    opacity: 0.9;
  }

  .hero-palette p {
    line-height: 1.5;
  }

  .home-page .welcome-section .hero-palette {
    padding: 1.2rem 1.25rem;
    margin: 0.95rem 0 1.2rem;
  }
}

/* support-link div in footer*/
.support-link {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  text-align: center;
}

.support-link a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--secondary-text-color);
  text-decoration: none;

  transition: color 0.2s ease, opacity 0.2s ease;
}

.support-link a:hover {
  color: var(--text-color);
  opacity: 0.9;
}

/* Quiz css */

/* Quiz Styles */
.quiz-header {
  margin-bottom: 1.25rem;
}

.quiz-card {
  border: 1px solid var(--border-color, #dcdfe4);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  background: var(--card-bg, #ffffff);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.quiz-card h3 {
  margin: 0 0 0.75rem;
}

.quiz-options {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.quiz-card ul,
.quiz-card ol {
  padding-left: 1.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 60ch;
}

.quiz-card li {
  max-width: 100%;
}

.quiz-card h3,
.quiz-card p {
  max-width: 60ch;
}

.quiz-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
}

.quiz-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color, #dcdfe4);
  background: var(--input-bg, #ffffff);
  color: inherit;
  max-width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.quiz-input:focus,
.quiz-input:focus-visible {
  border-color: #2b6cff;
  box-shadow: 0 0 0 3px rgba(43, 108, 255, 0.2);
}

.quiz-btn {
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 10px;
  padding: 0.55rem 1.15rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid var(--primary-color, #3b82f6);
  background: linear-gradient(135deg, var(--primary-color, #3b82f6) 0%, var(--primary-color-dark, #2563eb) 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(59, 130, 246, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.quiz-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 12px 22px rgba(59, 130, 246, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.quiz-btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.quiz-btn:focus-visible {
  outline: 3px solid rgba(46, 124, 255, 0.35);
  outline-offset: 2px;
}

.quiz-feedback {
  margin-top: 0.65rem;
  font-weight: 600;
}

.quiz-feedback.correct {
  color: #157347;
}

.quiz-feedback.incorrect {
  color: #b02a37;
}

.quiz-answer {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(21, 115, 71, 0.08);
}

.quiz-answer.show {
  display: block;
}

.quiz-section-title {
  margin-top: 2rem;
}

.quiz-inline-hint {
  font-size: 0.95rem;
  opacity: 0.85;
}

.dark-mode .quiz-card {
  background: #1c2432;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.dark-mode .quiz-option {
  background: rgba(255, 255, 255, 0.08);
}

.dark-mode .quiz-input {
  background: #0f131a;
  border-color: rgba(255, 255, 255, 0.18);
  color: #f5f7fb;
}

.dark-mode .quiz-btn {
  background: linear-gradient(135deg, var(--primary-color, #3b82f6), var(--primary-color-dark, #2563eb));
  color: #ffffff;
  border-color: rgba(59, 130, 246, 0.9);
}

.dark-mode .quiz-answer {
  background: rgba(25, 135, 84, 0.2);
}

/* quiz color exp */
.quiz-option.correct-option {
    background-color: #d4edda !important;
    border-left: 4px solid #28a745;
    color: #155724 !important;
}

.quiz-option.incorrect-option {
    background-color: #f8d7da !important;
    border-left: 4px solid #dc3545;
    color: #721c24 !important;
}

.dark-mode .quiz-option.correct-option {
    background-color: rgba(40, 167, 69, 0.15) !important;
    border-left: 4px solid #28a745;
    color: #d4edda !important;
}

.dark-mode .quiz-option.incorrect-option {
    background-color: rgba(220, 53, 69, 0.15) !important;
    border-left: 4px solid #dc3545;
    color: #f8d7da !important;
}

.quiz-feedback.correct {
    color: #28a745;
}

.quiz-feedback.incorrect {
    color: #dc3545;
}

.btn-support-improvement-card {
  display: inline-block;
  padding: 10px 18px;
  margin-top: 12px;

  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;

  color: var(--accent-color, #2563eb);
  background: transparent;
  border: 1.5px solid var(--accent-color, #2563eb);
  border-radius: 8px;

  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.btn-support-improvement-card:hover {
  background-color: rgba(37, 99, 235, 0.08);
  color: var(--accent-color, #2563eb);
  transform: translateY(-1px);
}

.btn-support-improvement-card:active {
  transform: translateY(0);
}

.btn-support-improvement-card:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 3px;
}


/* =========================================================
   OFFLINE PAGE — Calm, Consistent Layout
   ========================================================= */

.offline-intro {
  margin-bottom: 1.5rem;
}

.offline-page .navigation-buttons {
  flex-wrap: wrap;
}

.offline-page .navigation-buttons .btn {
  flex: 1 1 160px;
}

.offline-page .offline-indicator {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--secondary-text-color);
}

.offline-page .nav-links a {
  font-weight: 600;
}


/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
    position: sticky;
    top: 1rem;
    z-index: 95;
    margin: -1.35rem 0 1.8rem;
    padding: 0.7rem 0.85rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 18px -14px rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.header--auto-hide ~ main .breadcrumb {
    transition: top 0.3s ease;
}
body:has(.header--hidden) .breadcrumb {
    top: -10rem;
}
body:not(:has(.header--hidden)) .breadcrumb {
    top: calc(var(--header-height) + 1rem);
}

.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.4rem;
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    line-height: 1.4;
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
}

.breadcrumb ol li + li::before {
    content: "›";
    margin-right: 0.4rem;
    color: var(--secondary-text-color);
    opacity: 0.65;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    padding: 0.12rem 0.25rem;
    border-radius: 6px;
    transition: color 0.2s, background-color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary-color-dark);
    background: rgba(59, 130, 246, 0.08);
}

.breadcrumb [aria-current="page"] {
    color: var(--text-color);
    font-weight: 600;
}

.dark-mode .breadcrumb {
    box-shadow: 0 8px 18px -14px rgba(0, 0, 0, 0.7);
}

.dark-mode .breadcrumb a:hover {
    background: rgba(96, 165, 250, 0.14);
}

@media (max-width: 640px) {
    .breadcrumb {
        margin-top: -1.1rem;
        padding: 0.65rem 0.7rem;
    }

    .breadcrumb ol {
        gap: 0.15rem 0.3rem;
        font-size: 0.8rem;
    }
}

/* =========================================================
   GLOBAL AI QUIZ CHAT
   ========================================================= */

/* Global AI quiz chat styles (scoped to AI classes only) */

:root {
    --ai-chat-accent: #2563eb;
    --ai-chat-accent-strong: #1d4ed8;
    --ai-chat-bg: #ffffff;
    --ai-chat-surface: #f8fafc;
    --ai-chat-border: #e2e8f0;
    --ai-chat-text: #0f172a;
    --ai-chat-muted: #64748b;
    --ai-chat-user-bubble: #2563eb;
    --ai-chat-user-text: #ffffff;
    --ai-chat-ai-bubble: #f1f5f9;
    --ai-chat-ai-text: #0f172a;
    --ai-chat-overlay: rgba(2, 6, 23, 0.68);
    --ai-chat-aurora-1: rgba(14, 165, 233, 0.42);
    --ai-chat-aurora-2: rgba(99, 102, 241, 0.34);
    --ai-chat-aurora-3: rgba(34, 211, 238, 0.28);
    --ai-chat-ring: rgba(56, 189, 248, 0.35);
}

.dark-mode {
    --ai-chat-bg: #0b1220;
    --ai-chat-surface: #111b2e;
    --ai-chat-border: #223049;
    --ai-chat-text: #e2e8f0;
    --ai-chat-muted: #93a6c6;
    --ai-chat-user-bubble: #3b82f6;
    --ai-chat-user-text: #ffffff;
    --ai-chat-ai-bubble: #16243b;
    --ai-chat-ai-text: #dbe7ff;
    --ai-chat-overlay: rgba(2, 6, 23, 0.76);
    --ai-chat-aurora-1: rgba(6, 182, 212, 0.35);
    --ai-chat-aurora-2: rgba(59, 130, 246, 0.33);
    --ai-chat-aurora-3: rgba(99, 102, 241, 0.3);
    --ai-chat-ring: rgba(125, 211, 252, 0.33);
}

.discuss-ai-btn {
    margin-left: 0.5rem;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border: 1px solid rgba(56, 189, 248, 0.55);
    background: linear-gradient(120deg, #0ea5e9 0%, #2563eb 46%, #06b6d4 100%);
    background-size: 220% 220%;
    color: #ffffff;
    text-shadow: 0 1px 0 rgba(2, 6, 23, 0.25);
    box-shadow: 0 14px 26px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: ai-btn-flow 6s linear infinite;
    transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.25s ease, filter 0.25s ease;
}

.discuss-ai-btn::before {
    content: "";
    position: absolute;
    top: -180%;
    left: -45%;
    width: 34%;
    height: 440%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0));
    transform: rotate(18deg);
    opacity: 0;
    pointer-events: none;
    animation: ai-btn-scan 3.6s ease-in-out infinite;
}

.discuss-ai-btn::after {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 42%);
    opacity: 0.55;
    pointer-events: none;
}

.discuss-ai-btn:hover {
    border-color: rgba(125, 211, 252, 0.9);
    filter: brightness(1.08);
    box-shadow: 0 16px 30px rgba(14, 165, 233, 0.42), 0 0 0 1px rgba(56, 189, 248, 0.35) inset;
}

.discuss-ai-btn:active {
    transform: translateY(0);
    filter: brightness(1.01);
    box-shadow: 0 8px 16px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.discuss-ai-btn:focus-visible {
    outline: 3px solid rgba(34, 211, 238, 0.4);
    outline-offset: 2px;
}

.dark-mode .discuss-ai-btn {
    border-color: rgba(103, 232, 249, 0.6);
    background: linear-gradient(120deg, #0284c7 0%, #1d4ed8 48%, #0e7490 100%);
    box-shadow: 0 16px 30px rgba(2, 132, 199, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

@keyframes ai-btn-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes ai-btn-scan {
    0%,
    22% {
        opacity: 0;
        transform: translateX(-240%) rotate(18deg);
    }
    34% {
        opacity: 0.55;
    }
    58% {
        opacity: 0;
        transform: translateX(330%) rotate(18deg);
    }
    100% {
        opacity: 0;
        transform: translateX(330%) rotate(18deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .discuss-ai-btn {
        animation: none;
    }

    .discuss-ai-btn::before {
        animation: none;
        opacity: 0;
    }
}

.discuss-ai-btn[hidden] {
    display: none !important;
}

.ai-chat-modal[hidden] {
    display: none !important;
}

.ai-chat-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(0.75rem, 2.2vh, 1.35rem) 0.8rem;
}

.ai-chat-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(56% 60% at 18% 12%, var(--ai-chat-aurora-1), transparent 72%),
        radial-gradient(52% 55% at 82% 8%, var(--ai-chat-aurora-2), transparent 68%),
        radial-gradient(45% 45% at 50% 96%, var(--ai-chat-aurora-3), transparent 72%),
        var(--ai-chat-overlay);
    backdrop-filter: blur(9px) saturate(1.12);
    will-change: opacity;
    animation: ai-chat-overlay-in 320ms ease both;
}

.ai-chat-panel {
    position: relative;
    z-index: 1;
    width: min(900px, 95%);
    height: min(86vh, 780px);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 1.12rem;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.93) 0%, rgba(248, 250, 252, 0.9) 50%, rgba(239, 246, 255, 0.95) 100%);
    box-shadow: 0 24px 70px rgba(2, 6, 23, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.35) inset;
    backdrop-filter: blur(16px) saturate(1.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: top center;
    will-change: transform, opacity;
    animation: ai-chat-panel-in 460ms cubic-bezier(0.18, 0.82, 0.24, 1) both;
}

.ai-chat-panel::before {
    content: "";
    position: absolute;
    inset: -22%;
    pointer-events: none;
    background:
        radial-gradient(48% 42% at 16% 23%, var(--ai-chat-aurora-1), transparent 73%),
        radial-gradient(36% 36% at 85% 15%, var(--ai-chat-aurora-2), transparent 74%),
        radial-gradient(33% 30% at 53% 86%, var(--ai-chat-aurora-3), transparent 78%);
    opacity: 0.95;
    animation: ai-chat-aurora 14s linear infinite;
}

.ai-chat-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    border: 1px solid var(--ai-chat-ring);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28) inset;
}

.dark-mode .ai-chat-panel {
    border-color: rgba(71, 85, 105, 0.7);
    background: linear-gradient(160deg, rgba(11, 18, 32, 0.95) 0%, rgba(12, 24, 44, 0.94) 48%, rgba(6, 20, 38, 0.96) 100%);
    box-shadow: 0 26px 72px rgba(2, 6, 23, 0.72), 0 0 0 1px rgba(148, 163, 184, 0.16) inset;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
    padding: 0.88rem 1rem;
    border-bottom: 1px solid var(--ai-chat-border);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9) 0%, rgba(248, 250, 252, 0.65) 100%);
    backdrop-filter: blur(8px);
}

.dark-mode .ai-chat-header {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.86) 0%, rgba(15, 23, 42, 0.58) 100%);
}

.ai-chat-header h2 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--ai-chat-text);
}

.ai-chat-header-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.ai-chat-subtitle {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--ai-chat-muted);
    max-width: 58ch;
}

.ai-chat-subtitle[hidden] {
    display: none !important;
}

.ai-chat-close {
    width: 2.05rem;
    height: 2.05rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    background: rgba(255, 255, 255, 0.62);
    color: var(--ai-chat-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* --- STEP 4: Progress Tick System --- */

/* Completion Tick Toggle Button */
.progress-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.375rem;
    border: 2px solid transparent;
    background-color: var(--card-background);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    line-height: 1;
    position: relative;
    flex-shrink: 0;
}

.progress-tick:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dark-mode .progress-tick:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Blue = Incomplete */
.progress-tick.incomplete {
    border-color: #60a5fa;
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.08);
}

.dark-mode .progress-tick.incomplete {
    border-color: #93c5fd;
    color: #93c5fd;
}

/* Green = Completed */
.progress-tick.completed {
    border-color: #10b981;
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.08);
}

.dark-mode .progress-tick.completed {
    border-color: #6ee7b7;
    color: #6ee7b7;
}

.progress-tick.loading {
    opacity: 0.6;
    cursor: not-allowed;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.progress-tick.error {
    border-color: #ef4444;
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.08);
}

.dark-mode .progress-tick.error {
    border-color: #fca5a5;
    color: #fca5a5;
}

/* Header Tick Container */
.page-header-tick {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.page-header-tick-label {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    user-select: none;
}

/* Wrapper used on notes pages to hold the header tick and label */
.notes-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: center;
}

@media (min-width: 768px) {
  .notes-header-actions {
    margin-left: auto;
  }
}

.notes-header-actions .page-header-tick-label {
  font-size: 0.95rem;
  color: var(--secondary-text-color);
  margin-right: 0.25rem;
}

/* Slightly larger header tick to match page heading scale */
.notes-header-actions .progress-tick {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.15rem;
  box-shadow: 0 6px 20px rgba(16,24,40,0.04);
  border-radius: 0.5rem;
}

/* Inline Tick (next to section headings) */
.section-tick {
    display: inline-flex;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Tick in article/practice list */
.item-tick {
    display: inline-flex;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

/* Progress indicator in dashboard */
.progress-stats-updated {
    animation: highlight 0.5s ease;
}

@keyframes highlight {
    0% {
        background-color: rgba(16, 185, 129, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .progress-tick {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
}

/* --- STEP 4: Quiz Score Display --- */

.quiz-score-card {
    border-radius: 0.75rem;
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
    border-left: 4px solid;
}

.quiz-score-card.success {
    background-color: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
    color: var(--text-color);
}

.dark-mode .quiz-score-card.success {
    background-color: rgba(16, 185, 129, 0.15);
}

.quiz-score-card.warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
    color: var(--text-color);
}

.dark-mode .quiz-score-card.warning {
    background-color: rgba(245, 158, 11, 0.15);
}

.quiz-score-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.score-display {
    margin: 1.5rem 0;
}

.score-number {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.score-text {
    font-size: 1.1rem;
    color: var(--secondary-text-color);
    margin: 0.5rem 0;
}

.score-status {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1rem 0;
}

.score-note {
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    margin-top: 1rem;
    font-style: italic;
}

.dark-mode .ai-chat-close {
    border-color: rgba(148, 163, 184, 0.26);
    background: rgba(15, 23, 42, 0.65);
}

.ai-chat-close:hover {
    transform: translateY(-1px);
    color: var(--ai-chat-text);
    border-color: rgba(56, 189, 248, 0.58);
}

.ai-chat-close:focus-visible {
    outline: 3px solid rgba(34, 211, 238, 0.34);
    outline-offset: 2px;
}

.ai-chat-context {
    position: relative;
    z-index: 1;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--ai-chat-border);
    color: var(--ai-chat-muted);
    font-size: 0.83rem;
    line-height: 1.45;
    background: linear-gradient(180deg, rgba(241, 245, 249, 0.78) 0%, rgba(241, 245, 249, 0.62) 100%);
}

.dark-mode .ai-chat-context {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.65) 0%, rgba(15, 23, 42, 0.52) 100%);
}

.ai-chat-history {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 1.1rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.66) 0%, rgba(248, 250, 252, 0.92) 100%);
    display: flex;
    flex-direction: column;
    gap: 0.72rem;
}

.dark-mode .ai-chat-history {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.56) 0%, rgba(11, 18, 32, 0.88) 100%);
}

.ai-chat-history::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-history::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
}

.dark-mode .ai-chat-history::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.55);
}

.ai-chat-message {
    position: relative;
    max-width: 85%;
    padding: 0.66rem 0.84rem;
    border-radius: 0.9rem;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
    font-size: 0.95rem;
    border: 1px solid transparent;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
    animation: ai-chat-msg-in 300ms ease both;
}

.ai-chat-message p {
    margin: 0;
}

.ai-chat-message p + p {
    margin-top: 0.52rem;
}

.ai-chat-message ul,
.ai-chat-message ol {
    margin: 0.5rem 0 0.2rem 1.1rem;
    padding: 0;
}

.ai-chat-message li + li {
    margin-top: 0.2rem;
}

.ai-chat-message strong {
    font-weight: 700;
}

.ai-chat-message em {
    font-style: italic;
}

.ai-chat-message code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.86em;
    padding: 0.08rem 0.34rem;
    border-radius: 0.35rem;
    background: rgba(15, 23, 42, 0.08);
}

.dark-mode .ai-chat-message code {
    background: rgba(148, 163, 184, 0.2);
}

.ai-chat-message.ai-user {
    align-self: flex-end;
    background: linear-gradient(140deg, #1d4ed8 0%, #2563eb 48%, #0ea5e9 100%);
    color: var(--ai-chat-user-text);
    border-bottom-right-radius: 0.25rem;
    border-color: rgba(96, 165, 250, 0.42);
    box-shadow: 0 14px 24px rgba(37, 99, 235, 0.33);
    white-space: pre-wrap;
}

.ai-chat-message.ai-assistant {
    align-self: flex-start;
    background: linear-gradient(145deg, rgba(241, 245, 249, 0.95) 0%, rgba(226, 232, 240, 0.78) 100%);
    color: var(--ai-chat-ai-text);
    border-bottom-left-radius: 0.25rem;
    border-color: rgba(148, 163, 184, 0.32);
}

.dark-mode .ai-chat-message.ai-assistant {
    background: linear-gradient(145deg, rgba(22, 36, 59, 0.92) 0%, rgba(15, 30, 52, 0.84) 100%);
    border-color: rgba(71, 85, 105, 0.58);
}

.ai-chat-message.ai-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.16rem;
    min-width: 8.4rem;
    line-height: 1.2;
    white-space: nowrap;
    font-size: 0.93rem;
    color: var(--ai-chat-muted);
}

.ai-chat-thinking-label {
    display: inline-block;
    font-size: 0.93rem;
    line-height: 1.2;
    color: var(--ai-chat-muted);
    letter-spacing: 0.1px;
}

.ai-chat-thinking-dots {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 1.8rem;
    gap: 0.02rem;
    line-height: 1;
}

.ai-chat-thinking-dots span {
    display: inline-block;
    width: 0.58rem;
    text-align: center;
    opacity: 0.16;
    color: var(--ai-chat-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    animation: ai-chat-dot-fade 1.2s ease-in-out infinite;
}

.ai-chat-thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.ai-chat-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.7rem;
    position: relative;
    z-index: 1;
    padding: 0.92rem 1rem 1rem;
    border-top: 1px solid var(--ai-chat-border);
    background: linear-gradient(180deg, rgba(241, 245, 249, 0.9) 0%, rgba(248, 250, 252, 0.75) 100%);
}

.dark-mode .ai-chat-input-row {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.86) 0%, rgba(15, 23, 42, 0.7) 100%);
}

.ai-chat-label {
    display: none;
}

#ai-chat-input {
    width: 100%;
    resize: vertical;
    min-height: 2.6rem;
    max-height: 8rem;
    border: 1px solid var(--ai-chat-border);
    border-radius: 0.7rem;
    padding: 0.66rem 0.78rem;
    font: inherit;
    color: var(--ai-chat-text);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 1px 1px rgba(148, 163, 184, 0.2);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.dark-mode #ai-chat-input {
    background: rgba(15, 23, 42, 0.72);
    box-shadow: inset 0 1px 1px rgba(2, 6, 23, 0.5);
}

#ai-chat-input:focus {
    outline: 2px solid rgba(34, 211, 238, 0.3);
    border-color: rgba(56, 189, 248, 0.75);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16), inset 0 1px 1px rgba(148, 163, 184, 0.2);
}

#ai-chat-send {
    border: 1px solid rgba(125, 211, 252, 0.6);
    border-radius: 0.7rem;
    padding: 0.65rem 1.08rem;
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(120deg, #0ea5e9 0%, #2563eb 48%, #4f46e5 100%);
    background-size: 220% 220%;
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.33), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.22s ease, filter 0.22s ease;
    animation: ai-send-flow 5s linear infinite;
}

#ai-chat-send:hover:not([disabled]) {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 12px 24px rgba(14, 165, 233, 0.4), 0 0 0 1px rgba(56, 189, 248, 0.28) inset;
}

#ai-chat-send:active:not([disabled]) {
    transform: translateY(0);
}

#ai-chat-send:focus-visible {
    outline: 3px solid rgba(34, 211, 238, 0.36);
    outline-offset: 2px;
}

#ai-chat-send[disabled] {
    opacity: 0.8;
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
}

body.ai-chat-open {
    overflow: hidden;
}

@keyframes ai-chat-overlay-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes ai-chat-panel-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes ai-chat-aurora {
    0% {
        transform: translate3d(-3%, 0, 0) rotate(0deg) scale(1);
    }
    50% {
        transform: translate3d(3%, -1.5%, 0) rotate(180deg) scale(1.02);
    }
    100% {
        transform: translate3d(-3%, 0, 0) rotate(360deg) scale(1);
    }
}

@keyframes ai-chat-msg-in {
    from {
        opacity: 0;
        transform: translateY(7px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ai-chat-dot-fade {
    0%,
    20%,
    100% {
        opacity: 0.16;
    }
    40%,
    60% {
        opacity: 1;
    }
}

@keyframes ai-send-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat-overlay,
    .ai-chat-panel,
    .ai-chat-panel::before,
    .ai-chat-message,
    #ai-chat-send,
    .ai-chat-thinking-dots span {
        animation: none !important;
    }

    .ai-chat-panel,
    .ai-chat-message,
    #ai-chat-send:hover:not([disabled]) {
        transform: none;
    }
}

@media (max-width: 700px) {
    .ai-chat-modal {
        padding: 0.42rem;
    }

    .ai-chat-panel {
        width: 100%;
        height: 92vh;
        height: 92dvh;
        border-radius: 0.95rem;
    }

    .ai-chat-context {
        display: none;
    }

    .discuss-ai-btn {
        margin-left: 0;
        margin-top: 0.45rem;
    }

    .ai-chat-input-row {
        grid-template-columns: 1fr;
    }
}



/* =========================================================
   PRINT STYLES
   ========================================================= */
@media print {
  .notes-page::before {
    opacity: 0.06;
  }

  .header,
  .footer,
  .theme-toggle-btn,
  .hamburger {
    display: none !important;
  }

  .notes-container {
    max-width: 100%;
    padding: 0;
  }

  .notes-box,
  .notes-table,
  .notes-diagram img {
    box-shadow: none;
  }
}

/* Custom styles for Quiz Submit button */
#quiz-submit-btn {
    display: inline-block;
    font-size: 1.15rem;
    padding: 12px 24px;
    margin: 1.5rem 0;
    font-weight: 700;
    color: #ffffff;
    background-color: var(--primary-color, #4a90e2);
    border: 3px solid #357abd;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    max-width: 300px;
}

#quiz-submit-btn:hover {
    background-color: #357abd;
    border-color: #285e92;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

#quiz-submit-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark-mode #quiz-submit-btn {
    background-color: transparent;
    color: var(--primary-color, #60a5fa);
    border: 3px solid var(--primary-color, #60a5fa);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.dark-mode #quiz-submit-btn:hover {
    background-color: rgba(96, 165, 250, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
}
