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

:root {
  /* Updated palette for neural/glassmorphism look */
  --bg: #000000;
  --panel: rgba(255, 255, 255, 0.05);
  --muted: #b9b4c9;
  --text: #f3eaff;
  --accent: #7dd3fc;      /* default: helles Blau statt Pink/Lila für ausgeloggte Nutzer */
  --accent-2: #2563eb;    /* sattes Blau als Verlaufspartner */
  /* Komplementärfarbe der Akzentfarbe (wird per JS dynamisch gesetzt),
     Standard-Fallback jetzt passend zum Blau ein warmes Orange */
  --accent-complement: #ff9b4b;
  /* Soft/transparente Varianten für Glass-UI (werden per JS für PRO angepasst) */
  --accent-soft-1: rgba(125, 211, 252, 0.18);
  --accent-soft-2: rgba(37, 99, 235, 0.14);
  --user-accent: var(--accent);
  --user-accent-2: var(--accent-2);
  /* Immer nutzerbezogene Akzentwerte (werden per JS gesetzt, Fallback auf Theme-Werte) */
  --user-accent-soft-1: var(--accent-soft-1);
  --user-accent-soft-2: var(--accent-soft-2);
  /* Standard-Border, wird dynamisch aus der Akzentfarbe abgeleitet */
  /* Rand leicht in Akzentfarbe, aber sehr dezent */
  --border: rgba(125, 211, 252, 0.12);
  --user-accent-border: var(--border);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-strong: rgba(255, 255, 255, 0.12);
  /* Edge-Light für „liquid glass“-Kanten – bewusst dezent */
  --edge-light: rgba(255, 255, 255, 0.479);
  --edge-light-soft: rgba(255, 255, 255, 0.10);
  /* Nur noch ein ganz leichter Akzent-Schimmer in den Kanten */
  --edge-accent: rgba(125, 211, 252, 0.08);
  --shadow: 0 20px 60px rgba(0,0,0,0.45);
  --cgpt-gradient-start: var(--user-cgpt-gradient-start, hsl(222 84% 60% / 100%));
  --cgpt-gradient-end: var(--user-cgpt-gradient-end, hsl(164 79% 71%));
  /* Einheitliche Icon-Farbe: weiß (helle Icons auf dunklem UI) */
  --icon-filter: brightness(0) invert(1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Top navigation */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: rgba(15, 8, 25, 0.6);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: none;
}
.sub-nav {
  top: 52px;
  z-index: 900;
  justify-content: center;
  width: fit-content;
  margin: 0 auto;
  border-radius: 999px;
  padding: 10px;
}
.sub-nav .nav-course-label {
  margin-right: 6px;
  padding: 0 6px;
}
.top-nav .spacer { display: none; }
.top-nav .brand { font-weight: 800; letter-spacing: .02em; }
.nav-toggle { display: none; }
.nav-toggle { background: transparent; border: none; border-radius: 9px; padding: 5px; color: var(--text); position: relative; width: 34px; height: 30px; align-items: center; justify-content: center; }
.nav-toggle .bar { position: absolute; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle .bar:nth-child(1) { transform: translateY(-5px); }
.nav-toggle .bar:nth-child(2) { transform: translateY(0); }
.nav-toggle .bar:nth-child(3) { transform: translateY(5px); }
.nav-toggle.open .bar:nth-child(1) { transform: rotate(45deg); }
.nav-toggle.open .bar:nth-child(2) { opacity: 0; }
.nav-toggle.open .bar:nth-child(3) { transform: rotate(-45deg); }
.nav-menu { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: 1 1 auto; justify-content: flex-end; }

/* Start-style navbar (used across the app for a consistent layout) */
.start-nav-bar {
  justify-content: flex-start;
}
.start-nav {
  justify-content: flex-start;
}
.start-nav #nav-home {
  margin-right: 0;
}
.start-nav .nav-left {
  margin-right: 0;
}
.start-nav .login-link {
  margin-left: auto;
}
.nav-user-group {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: inherit;
  padding: 4px 6px;
  border-radius: 999px;
  cursor: pointer;
}
.nav-user-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}
#nav-user-name {
  font-size: 13px;
  color: #ffffff;
  font-weight: 600;
}
.nav-user-wrap {
  position: relative;
}
.nav-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: rgba(17, 17, 17, 0.72);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: none;
  z-index: 1200;
}
.nav-user-menu.open {
  display: block;
}
.nav-user-menu a,
.nav-user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #ffffff;
  background: transparent;
  border: none;
  font-size: 13px;
  cursor: pointer;
}
.nav-user-menu-icon {
  width: 15px;
  height: 15px;
  object-fit: contain;
  opacity: 0.92;
  flex: 0 0 15px;
}
.nav-user-menu a:hover,
.nav-user-menu button:hover {
  background: rgba(255, 255, 255, 0.12);
}
.dataset-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent-soft-1), var(--accent-soft-2));
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.06em;
}
#nav-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-soft-1), var(--accent-soft-2));
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.06em;
  overflow: hidden;
}
#nav-user.has-avatar {
  border-color: var(--accent);
  background: rgba(255,255,255,0.08);
}
#nav-user.has-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent-soft-1), var(--accent-soft-2));
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.nav-link.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.7);
  pointer-events: none;
}
 #nav-home {
  margin-right: auto;
 }
.nav-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
}
.nav-left #nav-home {
  margin-right: 0;
}
.nav-course-label {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.nav-course-label.is-hidden {
  display: none;
}
#nav-admin {
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}
#nav-admin span {
  display: none;
}
#nav-admin .nav-icon {
  width: 18px;
  height: 18px;
}
#nav-feedback span {
  display: inline;
}
.nav-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}
/* Alle App-Icons weiß einfärben, ohne Assets zu duplizieren */
img[src^="/assets/icons/"],
img[src^="assets/icons/"],
.nav-icon,
.btn-icon,
.course-card-menu-icon,
.cal-arrow-icon,
.img-del-icon {
  filter: var(--icon-filter);
}
/* ChatGPT-Avatar soll farbig bleiben (PNG), daher kein Weiß-Filter */
img[src$="/assets/icons/chatgpt.png"],
img[src$="assets/icons/chatgpt.png"] {
  filter: none;
}
.nav-link:hover { border-color: transparent; background: linear-gradient(135deg, var(--accent-soft-2), var(--accent-soft-1)); }
.nav-link.active {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), var(--accent));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.15) inset,
    0 6px 18px rgba(0, 0, 0, 0.35);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
}
.nav-link-badge {
  display: inline-flex;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f97373;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.nav-link-badge.nav-link-badge-placeholder {
  opacity: 0.6;
}
.nav-link-badge.is-hidden {
  display: none;
}
.nav-right { margin-left: auto; }

/* Mobile tweaks */
@media (max-width: 720px) {
  .top-nav {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'toggle toggle'
      'menu menu';
    row-gap: 8px;
  }
  .top-nav .brand { display: none; }
  .nav-toggle {
    grid-area: toggle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
  }
  #nav-user {
    grid-area: user;
    justify-self: end;
    height: 32px;
    min-width: 32px;
    padding: 0 10px;
    font-size: 13px;
  }
  /* Mit Profilbild immer perfekter Kreis – keine Pill-Form im Mobile */
  #nav-user.has-avatar {
    width: 32px;
    min-width: 32px;
    padding: 0;
  }
  .nav-menu {
    grid-area: menu;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
  }
  .nav-menu.open { max-height: 70vh; }
  .nav-menu .nav-link, .nav-menu .btn { margin-top: 8px; }
  .nav-link { width: 100%; justify-content: center; padding: 10px 12px; font-size: 14px; }
  .nav-left { width: 100%; }
  .nav-left #nav-home { width: auto; justify-content: flex-start; }
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 8px 10px; }
  .app-main { padding: 12px; gap: 12px; }
}

/* Global CrackyGPT animated gradient backdrop */
@keyframes cgptGlobalRotate {
  0% {
    transform: rotate(0deg) scale(1.30);
  }
  100% {
    transform: rotate(360deg) scale(1.30);
  }
}

.image-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: flex;
  place-content: center;
  align-items: center;
  overflow: hidden;
  background-color: #000000;
}

/* Keep page content above the global gradient layer. */
body > :not(.image-background):not(script):not(style) {
  position: relative;
  z-index: 1;
}

.image-background .bg {
  position: absolute;
  inset: 0;
}

.image-background .bg1 {
  --size: 750px;
  --speed: 50s;
  --easing: cubic-bezier(0.8, 0.2, 0.2, 0.8);
  position: relative;
  inset: auto;
  width: var(--size);
  height: var(--size);
  filter: blur(calc(var(--size) / 5));
  background-image: linear-gradient(var(--cgpt-gradient-start), var(--cgpt-gradient-end));
  animation: cgptGlobalRotate var(--speed) var(--easing) alternate infinite;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
}

.image-background .bg2 {
  display: none;
}

@media (min-width: 720px) {
  .image-background .bg1 {
    --size: 500px;
  }
}

.image-background * {
  transition: all 0.5s ease-out;
}

/* Glass helpers */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.glass-strong {
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 26px;
}

/* Gemeinsamer „liquid glass“ Edge-Look:
   Kanten wirken so, als würden sie von
   oben links und unten rechts angeleuchtet. */
.glass,
.glass-strong,
.panel,
.btn,
.nav-link,
.dataset-badge,
#nav-user,
/* Aufgaben + Kommentarbereich + Kalender-Kacheln: gleicher Edge-Look */
.hw-item,
.hw-item.active,
.hw-comments,
/* Einzelne Kommentare */
.hw-comment,
.cal-day {
  position: relative;
}

.glass::before,
.glass-strong::before,
.panel::before,
.btn::before,
.nav-link::before,
.dataset-badge::before,
#nav-user::before,
.hw-item::before,
.hw-item.active::before,
.hw-comments::before,
.hw-comment::before,
.cal-day::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  /* etwas schmalerer Licht-Rand */
  padding: 1px;
  /* Lichtflecken an den Ecken oben links & unten rechts */
  background:
    radial-gradient(circle at 0% 0%,
      var(--edge-light),
      var(--edge-light-soft) 40%,
      transparent 65%),
    radial-gradient(circle at 100% 100%,
      var(--edge-light),
      var(--edge-accent) 20%,
      var(--edge-light-soft) 40%,
      transparent 70%);
  background-blend-mode: screen;
  pointer-events: none;
  /* Mitte ausstanzen, nur ein schmaler Rand bleibt sichtbar */
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}

/* Ausgewählte Aufgabe: etwas hellerer Lichtrand */
.hw-item.active::before {
  background:
    radial-gradient(circle at 0% 0%,
      rgba(255, 255, 255, 0.9),
      rgba(255, 255, 255, 0.26) 42%,
      transparent 70%),
    radial-gradient(circle at 100% 100%,
      rgba(255, 255, 255, 0.95),
      rgba(125, 211, 252, 0.32) 24%,
      rgba(255, 255, 255, 0.24) 44%,
      transparent 75%);
}

/* Bei Buttons die Kanten etwas dünner zeichnen */
.btn::before {
  padding: 1px;
}

.app-header {
  padding: 6px 20px 4px 20px;
  border: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
  box-shadow: none;
  margin: 2px auto 0 auto;
  max-width: 1400px;
  text-align: center;
}
.no-app-header .app-header {
  display: none;
}
.app-header h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 50%, var(--accent-complement) 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: modernGradient 8s ease infinite;
}
.pro .app-header h1 {
  text-shadow: 0 0 12px var(--accent-soft-1), 0 0 24px var(--accent-soft-2);
  filter: drop-shadow(0 0 10px var(--accent-soft-2));
}
.brand-sub { color: var(--muted); margin-top: 6px; }

@keyframes modernGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.app-header p {
  margin: 0;
  color: var(--muted);
}

.app-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}
.app-footer { max-width: 1400px; margin: 0 auto; padding: 12px 16px 24px 16px; color: var(--muted); text-align: center; }
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
.panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 16px;
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

/* Admin-Panel: eigenes, reduziertes Design – kein Blur, weniger Glass */
body.admin-page .image-background {
  display: flex;
}
body.admin-page {
  --bg: #0b0f16;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.14);
  --glass: #0f1522;
  --glass-strong: #0f1522;
  --accent-soft-1: rgba(59, 130, 246, 0.16);
  --accent-soft-2: rgba(16, 185, 129, 0.12);
  background: var(--bg);
}
body.admin-page .top-nav {
  background: #0f1522;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--border);
  justify-content: flex-start;
}
body.admin-page .nav-menu {
  width: 100%;
  flex: 1;
}
body.admin-page .panel,
body.admin-page .glass,
body.admin-page .glass-strong {
  background: #0f1522;
  border-radius: 16px;
  border: 1px solid var(--border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}
body.admin-page .btn {
  background: #141b2d;
  border-radius: 999px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  transition: none;
  filter: none;
  color: var(--text);
  border: 1px solid var(--border);
}
body.admin-page .btn:hover,
body.admin-page .btn:active {
  background: #1b2438;
  transform: none;
  filter: none;
}
/* Navlinks im Admin flach, ohne Verlauf/Glow */
body.admin-page .nav-link {
  background: #141b2d;
  border: 1px solid var(--border);
  box-shadow: none;
  color: var(--text);
}
body.admin-page .nav-link.active {
  box-shadow: none;
  background: #1b2438;
}
body.admin-page #nav-home {
  margin-right: auto;
}
body.admin-page .btn::before,
body.admin-page .panel::before,
body.admin-page .glass::before,
body.admin-page .glass-strong::before,
body.admin-page .nav-link::before,
body.admin-page .dataset-badge::before,
body.admin-page #nav-user::before,
body.admin-page .hw-item::before,
body.admin-page .hw-item.active::before,
body.admin-page .hw-comments::before,
body.admin-page .hw-comment::before,
body.admin-page .cal-day::before {
  display: none;
}
body.admin-page .app-header {
  margin-top: 8px;
}
body.admin-page .app-header h1 {
  background: none;
  -webkit-text-fill-color: inherit;
  color: var(--text);
  text-shadow: none;
  animation: none;
}
/* Keine Outlines im Admin-Panel */
body.admin-page a:focus,
body.admin-page button:focus,
body.admin-page [tabindex]:focus {
  outline: none;
  box-shadow: none;
}

body.admin-page .comment-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
}
body.admin-page .comment-modal {
  width: min(980px, 94vw);
  max-height: 90vh;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.admin-page .comment-modal .hw-comment-editor {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow: auto;
  margin: 0 auto;
  background: #0f1522;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
}
body.admin-page .comment-modal-title {
  color: var(--text);
}
body.admin-page .report-preview-backdrop .hw-comment-images {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
body.admin-page .report-preview-backdrop .hw-comment-images img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #111827;
}

/* Shared buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  /* nur der Akzent-Verlauf – kein zusätzlicher weißer Spot im Inneren */
  background: linear-gradient(135deg, var(--accent-soft-1), var(--accent-soft-2));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.btn-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}
.btn.xs { padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.btn.sm { padding: 8px 12px; border-radius: 999px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
/* Hover-Effekt minimal sichtbar halten, um Linter-Warnung für leere Regel zu vermeiden */
.btn:hover:not([disabled]) { filter: brightness(1.03); }
.btn:active { transform: translateY(1px); }

/* Initiales Lade-Overlay deaktiviert */
.app-init-overlay {
  display: none !important;
}
.app-init-overlay-hidden {
  display: none !important;
}
/* Hide scrollbar (keep scrolling) */
html { scrollbar-width: none; }
body { -ms-overflow-style: none; }
::-webkit-scrollbar { width: 0 !important; height: 0 !important; }
::-webkit-scrollbar-thumb { background: transparent; }
::-webkit-scrollbar-track { background: transparent; }

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.12);
}

/* Light mode */
body.light-mode {
  --bg: #f1f1f5;
  --panel: rgba(255, 255, 255, 0.85);
  --muted: #4b5563;
  --text: #0f172a;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-complement: #0ea5a4;
  --accent-soft-1: rgba(37, 99, 235, 0.18);
  --accent-soft-2: rgba(14, 165, 233, 0.14);
  --border: rgba(15, 23, 42, 0.15);
  --glass: rgba(255, 255, 255, 0.8);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --edge-light: rgba(255, 255, 255, 0.95);
  --edge-light-soft: rgba(255, 255, 255, 0.5);
  --edge-accent: rgba(59, 130, 246, 0.24);
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.14);
  --icon-filter: brightness(0) saturate(100%);
}

body.light-mode .top-nav {
  background: rgba(255, 255, 255, 0.45);
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

body.light-mode .nav-user-menu {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
}

body.light-mode .nav-user-menu a,
body.light-mode .nav-user-menu button {
  color: #111111;
}

body.light-mode .nav-user-menu a:hover,
body.light-mode .nav-user-menu button:hover {
  background: rgba(0, 0, 0, 0.08);
}

body.light-mode #nav-user.has-avatar {
  background: rgba(255, 255, 255, 0.9);
}

body.light-mode .image-background {
  background-color: #ffffff;
}

body.light-mode .app-init-overlay {
  display: none !important;
}

/* Merged theme overrides */

:root {
  --bg: #000000;
  --text: #ffffff;
  --muted: #a3a3a3;
  --line: #3f3f3f;
  --panel: #1a1a1a;
  --panel-hover: #232323;
  --panel-active: #2a2a2a;
  --accent: #2b7cff;
  --accent-2: #2b7cff;
  --accent-complement: #9ec2ff;
  --accent-soft-1: rgba(43, 124, 255, 0.2);
  --accent-soft-2: rgba(43, 124, 255, 0.14);
  --border: #3f3f3f;
  --glass: rgba(18, 18, 18, 0.9);
  --glass-strong: rgba(23, 23, 23, 0.9);
  --edge-light: rgba(255, 255, 255, 0.82);
  --edge-light-soft: rgba(255, 255, 255, 0.18);
  --edge-accent: rgba(255, 255, 255, 0.14);
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.58);
}

html,
body {
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, Segoe UI, sans-serif;
}

.image-background {
  display: flex;
}

/* Navbar in CrackyGPT style */
.top-nav {
  position: sticky;
  top: 12px;
  width: fit-content;
  max-width: calc(100vw - 24px);
  margin: 0 auto 8px;
  padding: 5px;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sub-nav {
  position: static;
  margin-top: 18px;
}

.sub-nav .nav-link {
  min-width: 0;
  padding: 7px 10px;
}

.top-nav .nav-menu {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  flex-wrap: wrap;
}

.top-nav .nav-link {
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: #ffffff;
  border-radius: 999px;
  min-width: 116px;
  min-height: 36px;
  padding: 7px 13px;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-shadow: none;
}

.top-nav .nav-link:hover {
  background: var(--panel-hover);
  border-color: transparent;
}

.top-nav .nav-link.active {
  background: rgba(210, 210, 210, 0.14);
  border-color: transparent;
  font-weight: 600;
  box-shadow: none;
  position: relative;
}

.top-nav .nav-link.active::before {
  content: "";
  display: block;
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 0% 0%,
      rgba(255, 255, 255, 0.85),
      rgba(255, 255, 255, 0.24) 40%,
      transparent 65%),
    radial-gradient(circle at 100% 100%,
      rgba(255, 255, 255, 0.9),
      rgba(255, 255, 255, 0.3) 24%,
      rgba(255, 255, 255, 0.2) 44%,
      transparent 75%);
  background-blend-mode: screen;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.top-nav .nav-icon {
  width: 14px;
  height: 14px;
  filter: brightness(0) invert(1);
}

.top-nav .nav-user-group {
  margin-left: auto;
  align-items: center;
  gap: 6px;
}

.top-nav .nav-user-btn {
  border: 0;
  background: transparent;
  color: #fff;
  border-radius: 999px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

body #nav-user-name {
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
}

.top-nav #nav-user {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #111111;
  color: #ffffff;
  font-size: 9px;
  line-height: 18px;
}

.top-nav .nav-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 180px;
  max-width: calc(100vw - 24px);
  border: 1px solid #555555;
  border-radius: 12px;
  background: rgba(17, 17, 17, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.top-nav .nav-user-menu.open {
  display: block;
}

.top-nav .nav-user-menu a,
.top-nav .nav-user-menu button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  text-align: left;
  font: inherit;
  text-decoration: none;
  padding: 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.top-nav .nav-user-menu a:hover,
.top-nav .nav-user-menu button:hover {
  background: #232323;
}

.top-nav .nav-user-menu-icon {
  width: 13px;
  height: 13px;
  filter: brightness(0) invert(1);
}

/* Remove the old glossy edges for a cleaner CrackyGPT look */
.glass::before,
.glass-strong::before,
.panel::before,
.btn::before,
.nav-link::before,
.dataset-badge::before,
#nav-user::before,
.hw-item::before,
.hw-item.active::before,
.hw-comments::before,
.hw-comment::before,
.cal-day::before {
  display: none;
}

.panel,
.glass,
.glass-strong {
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header h1 {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #ffffff;
  color: #ffffff;
  animation: none;
  text-shadow: none;
  filter: none;
}

.brand-sub,
.app-header p,
.app-footer,
.app-footer small,
.muted {
  color: var(--muted);
}

.app-footer a {
  color: #ffffff;
}

.register-link a,
.forgot-link a,
.login-link a {
  color: #ffffff;
}

.register-link,
.forgot-link,
.login-link {
  color: var(--muted);
}

/* CrackyGPT-like neutral buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn:hover:not([disabled]) {
  filter: none;
  background: var(--panel-hover);
  border-color: var(--line);
}

.btn:active {
  transform: none;
}

.btn.sm {
  padding: 7px 10px;
}

.btn.xs {
  padding: 6px 10px;
}

.btn.lg {
  padding: 10px 14px;
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
textarea,
select {
  border: 1px solid var(--line);
  background: #0f0f0f;
  color: #ffffff;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
input[type="number"]::placeholder,
input[type="search"]::placeholder,
textarea::placeholder {
  color: #7f7f7f;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #5f5f5f;
  box-shadow: 0 0 0 1px #5f5f5f;
}

/* Homework / tasks / handwriting colorful exceptions -> neutral CrackyGPT style */
.hw-rewrite-btn,
.hw-ai-btn,
#btn-handwriting-creator {
  background: #2b7cff !important;
  border-color: #2b7cff !important;
  color: #ffffff !important;
  box-shadow: none !important;
  animation: none !important;
}

.hw-rewrite-btn:hover,
.hw-ai-btn:hover,
#btn-handwriting-creator:hover {
  background: #2267d8 !important;
  border-color: #2267d8 !important;
  box-shadow: none !important;
}

.ai-preset,
.ai-preset.active,
.ai-preset.is-active {
  border-radius: 999px;
  background: #1a1a1a;
  border: 1px solid var(--line);
  box-shadow: none;
}

.ai-preset.active,
.ai-preset.is-active {
  background: #2e2e2e;
  border-color: #5a5a5a;
}

.hw-item,
.hw-comments,
.hw-comment,
.hw-task-editor,
.hw-comment-editor,
.cal-grid,
.cal-day,
.course-card,
.course-empty,
.profile-displayname-section,
.profile-score-section,
.profile-leaderboard-section,
.profile-accent-section,
.profile-reminder-dialog {
  background: rgba(20, 20, 20, 0.86);
  border-color: var(--line);
}

.course-card:hover,
.course-card.active,
.hw-item:hover,
.hw-item.active,
.cal-day.active {
  border-color: #5f5f5f;
  box-shadow: none;
}

.profile-reminder-backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.profile-reminder-dialog::after,
.landing-main::before,
.landing-main::after,
.landing-hero::before,
.landing-hero::after {
  display: none;
}

/* Landing pages inherit the same visual language */
body.landing-page {
  --landing-panel: rgba(18, 18, 18, 0.9);
  --landing-panel-strong: rgba(23, 23, 23, 0.94);
  --landing-line: rgba(255, 255, 255, 0.2);
  --landing-line-soft: rgba(255, 255, 255, 0.12);
  --landing-text: #ffffff;
  --landing-muted: #b3b3b3;
  --landing-mint: #ffffff;
  --landing-amber: #d1d5db;
  --landing-sky: #9ca3af;
  --landing-ink: #000000;
  --accent: #2b7cff;
  --accent-2: #2b7cff;
  --accent-soft-1: rgba(43, 124, 255, 0.2);
  --accent-soft-2: rgba(43, 124, 255, 0.14);
}

body.landing-page .image-background {
  display: flex;
}

body.landing-page .landing-hero,
body.landing-page .landing-shot,
body.landing-page .landing-stat-card {
  background: rgba(18, 18, 18, 0.9);
  border-color: var(--line);
  box-shadow: none;
}

body.landing-page .landing-btn-primary {
  color: #ffffff;
  background: #2b7cff;
}

body.landing-page .landing-btn-secondary {
  color: #ffffff;
  background: #1a1a1a;
  border-color: var(--line);
}

body.light-mode {
  --bg: #f5f7fb;
  --text: #0f172a;
  --muted: #6b7280;
  --line: #d5dbe6;
  --panel: #ffffff;
  --panel-hover: #eef2f7;
  --panel-active: #e5ecf7;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-complement: #0f766e;
  --accent-soft-1: rgba(37, 99, 235, 0.16);
  --accent-soft-2: rgba(29, 78, 216, 0.12);
  --border: #d5dbe6;
  --glass: rgba(255, 255, 255, 0.9);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --edge-light: rgba(255, 255, 255, 0.96);
  --edge-light-soft: rgba(255, 255, 255, 0.6);
  --edge-accent: rgba(37, 99, 235, 0.22);
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
}

/* Keep html background in sync with body.light-mode to avoid dark overscroll strips */
html[data-theme="light"] {
  --bg: #f5f7fb;
  background: #f5f7fb;
}

body.light-mode .top-nav {
  background: rgba(255, 255, 255, 0.45);
  border-color: var(--line);
}

body.light-mode .top-nav .nav-link {
  color: #0f172a;
}

body.light-mode .top-nav .nav-link:hover {
  background: rgba(148, 163, 184, 0.10);
}

body.light-mode .top-nav .nav-link.active {
  background: rgba(143, 143, 143, 0.265);
}

body.light-mode .top-nav .nav-icon,
body.light-mode .top-nav .nav-user-menu-icon {
  filter: brightness(0) saturate(100%);
}

body.light-mode .top-nav .nav-user-btn,
body.light-mode #nav-user-name {
  color: #111111;
}

body.light-mode .top-nav #nav-user {
  background: #ffffff;
  color: #111111;
  border-color: var(--line);
}

body.light-mode .top-nav .nav-user-menu {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
}

body.light-mode .top-nav .nav-user-menu a,
body.light-mode .top-nav .nav-user-menu button {
  color: #111111;
}

body.light-mode .top-nav .nav-user-menu a:hover,
body.light-mode .top-nav .nav-user-menu button:hover {
  background: #f1f1f1;
}

body.light-mode .panel,
body.light-mode .glass,
body.light-mode .glass-strong {
  background: rgba(255, 255, 255, 0.92);
}

body.light-mode .app-header h1 {
  -webkit-text-fill-color: #0f172a;
  color: #0f172a;
}

body.light-mode .app-footer a,
body.light-mode .register-link a,
body.light-mode .forgot-link a,
body.light-mode .login-link a,
body.light-mode .btn {
  color: #0f172a;
}

body.light-mode input[type="text"],
body.light-mode input[type="password"],
body.light-mode input[type="email"],
body.light-mode input[type="number"],
body.light-mode input[type="date"],
body.light-mode input[type="search"],
body.light-mode textarea,
body.light-mode select {
  background: #ffffff;
  color: #0f172a;
}

body.light-mode input[type="text"]::placeholder,
body.light-mode input[type="password"]::placeholder,
body.light-mode input[type="email"]::placeholder,
body.light-mode input[type="number"]::placeholder,
body.light-mode input[type="search"]::placeholder,
body.light-mode textarea::placeholder {
  color: #64748b;
}

body.light-mode input[type="text"]:focus,
body.light-mode input[type="password"]:focus,
body.light-mode input[type="email"]:focus,
body.light-mode input[type="number"]:focus,
body.light-mode input[type="date"]:focus,
body.light-mode input[type="search"]:focus,
body.light-mode textarea:focus,
body.light-mode select:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 1px #94a3b8;
}

body.light-mode .ai-preset,
body.light-mode .ai-preset.active,
body.light-mode .ai-preset.is-active {
  background: #ffffff;
}

body.light-mode .ai-preset.active,
body.light-mode .ai-preset.is-active {
  background: #eef2f7;
}

body.light-mode .hw-item,
body.light-mode .hw-comments,
body.light-mode .hw-comment,
body.light-mode .hw-task-editor,
body.light-mode .hw-comment-editor,
body.light-mode .cal-grid,
body.light-mode .cal-day,
body.light-mode .course-card,
body.light-mode .course-empty,
body.light-mode .profile-displayname-section,
body.light-mode .profile-score-section,
body.light-mode .profile-leaderboard-section,
body.light-mode .profile-accent-section,
body.light-mode .profile-reminder-dialog {
  background: rgba(255, 255, 255, 0.9);
}

body.light-mode .course-card:hover,
body.light-mode .course-card.active,
body.light-mode .hw-item:hover,
body.light-mode .hw-item.active,
body.light-mode .cal-day.active {
  border-color: #94a3b8;
}

body.light-mode .profile-reminder-backdrop {
  background: rgba(15, 23, 42, 0.35);
}

body.light-mode.landing-page {
  --landing-panel: rgba(255, 255, 255, 0.9);
  --landing-panel-strong: rgba(255, 255, 255, 0.96);
  --landing-line: rgba(15, 23, 42, 0.16);
  --landing-line-soft: rgba(15, 23, 42, 0.08);
  --landing-text: #0f172a;
  --landing-muted: #6b7280;
  --landing-mint: #2563eb;
  --landing-amber: #0f766e;
  --landing-sky: #1d4ed8;
  --landing-ink: #0f172a;
}

body.light-mode.landing-page .landing-hero,
body.light-mode.landing-page .landing-shot,
body.light-mode.landing-page .landing-stat-card {
  background: rgba(255, 255, 255, 0.92);
}

body.light-mode.landing-page .landing-btn-primary {
  color: #ffffff;
  background: #2563eb;
}

body.light-mode.landing-page .landing-btn-secondary {
  color: #0f172a;
  background: #ffffff;
}

@media (max-width: 900px) {
  .top-nav {
    width: min(96vw, 760px);
    border-radius: 20px;
    padding: 7px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .top-nav .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .top-nav .nav-menu {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .top-nav .nav-menu.open {
    display: flex;
  }

  .top-nav .nav-link {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    border-radius: 12px;
  }

  .top-nav .nav-user-group {
    margin-left: auto;
  }

  .sub-nav {
    width: min(96vw, 760px);
  }
}
