:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --sidebar: #ffffff;
  --sidebar-text: #111827;
  --border: #edf0f5;
  --primary: #ec4899;
  --violet: #8b5cf6;
  --pink: #ec4899;
  --blue: #3b82f6;
  --green: #22c55e;
  --shadow-soft: 0 18px 55px rgba(31, 41, 55, .08);
  --shadow-strong: 0 30px 90px rgba(31, 41, 55, .12);
}

body.dark {
  --bg: #1d1d1e;
  --surface: #1d1d1e;
  --card: #111827;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --sidebar: #1d1d1e;
  --sidebar-text: #f8fafc;
  --border: #1d1d1e;
  --primary: #a78bfa;
  --shadow-soft: 0 18px 55px rgba(0, 0, 0, .24);
  --shadow-strong: 0 30px 90px rgba(0, 0, 0, .34);
}

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

html {
  scroll-behavior: smooth
}

body {
  min-height: 100vh;
  font-family: "Poppins", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(22px);
  opacity: .5;
  pointer-events: none;
  z-index: -1;
}

.orb-1 {
  width: 260px;
  height: 260px;
  background: #c4b5fd;
  top: 60px;
  left: 310px
}

.orb-2 {
  width: 220px;
  height: 220px;
  background: #f9a8d4;
  right: 80px;
  top: 160px
}

.orb-3 {
  width: 180px;
  height: 180px;
  background: #93c5fd;
  right: 25%;
  bottom: 30px
}

.app {
  min-height: 100vh;
  display: flex;
  gap: 24px;
  padding: 22px;
}

.sidebar {
  width: 304px;
  flex-shrink: 0;
  height: calc(100vh - 44px);
  position: sticky;
  top: 22px;
  padding: 24px;
  color: white;
  overflow: hidden auto;
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(109, 93, 246, .98), rgba(139, 92, 246, .96) 42%, rgba(236, 72, 153, .96)),
    radial-gradient(circle at 20% 5%, rgba(255, 255, 255, .28), transparent 25%);
  box-shadow: var(--shadow-strong);
}

.sidebar::-webkit-scrollbar {
  width: 0
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 16%, rgba(255, 255, 255, .23) 0 3px, transparent 4px),
    radial-gradient(circle at 75% 28%, rgba(255, 255, 255, .16) 0 4px, transparent 5px),
    radial-gradient(circle at 55% 76%, rgba(255, 255, 255, .12) 0 5px, transparent 6px);
  pointer-events: none;
}

.sidebar-top,
.brand,
.user-card,
.nav,
.study-goal {
  position: relative;
  z-index: 1
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24);
  backdrop-filter: blur(14px);
}

.brand-mark span {
  font-size: 24px;
  font-weight: 900
}

.brand h1 {
  font-size: 20px;
  line-height: 1
}

.brand p {
  font-size: 12px;
  opacity: .76;
  margin-top: 6px
}

.close-sidebar {
  display: none;
  border: 0;
  color: white;
  background: rgba(255, 255, 255, .16);
  width: 38px;
  height: 38px;
  border-radius: 14px;
  font-size: 24px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  margin-bottom: 22px;
}

.user-avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--primary);
  font-weight: 900;
}

.user-card h3 {
  font-size: 15px
}

.user-card p {
  font-size: 12px;
  opacity: .72
}

.user-level {
  margin-left: auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 12px;
  font-weight: 800;
}

.nav-group {
  margin-top: 18px
}

.nav-group p {
  margin: 0 0 10px 12px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .56;
}

.nav-link {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 17px;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 7px;
  position: relative;
  transition: transform .24s ease, background .24s ease, box-shadow .24s ease;
}

.nav-link .icon {
  width: 26px;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: transform .24s ease;
}

.nav-link:hover {
  transform: translateX(8px);
  background: rgba(255, 255, 255, .15);
}

.nav-link:hover .icon {
  transform: scale(1.16) rotate(-7deg)
}

.nav-link.active {
  background: rgba(255, 255, 255, .22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2), 0 12px 26px rgba(0, 0, 0, .10);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  width: 5px;
  height: 28px;
  border-radius: 999px;
  background: #fff;
}

.study-goal {
  margin-top: 24px;
  padding: 20px;
  border-radius: 26px;
  background: rgba(255, 255, 255, .15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.goal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px
}

.goal-head span {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 12px;
}

.study-goal h3 {
  font-size: 17px
}

.study-goal p {
  font-size: 12px;
  opacity: .76;
  margin: 7px 0 14px;
  line-height: 1.5
}

.goal-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .24);
  overflow: hidden
}

.goal-fill {
  height: 100%;
  width: 62%;
  border-radius: 999px;
  background: #fff
}

.main {
  flex: 1;
  min-width: 0
}

.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-radius: 30px;
  background: var(--surface);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, .72);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: max-content
}

.menu-btn {
  display: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  background: #f0edff;
  color: var(--primary);
  font-size: 22px;
  cursor: pointer;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-transform: none;
}

.topbar h2 {
  margin-top: 4px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 22px;
}

.search-box {
  flex: 1;
  max-width: 480px;
  height: 48px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: #f5f6fb;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 51, .04);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
}

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

.top-actions button,
.avatar {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: #f5f6fb;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 51, .04);
}

.avatar {
  background: linear-gradient(135deg, var(--primary), var(--pink));
  color: white;
  font-weight: 900;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}

.avatar:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(236, 72, 153, .24);
}

.avatar:focus-visible {
  outline: 3px solid rgba(236, 72, 153, .24);
  outline-offset: 3px;
}

.hero {
  min-height: 310px;
  margin-top: 24px;
  padding: 38px;
  border-radius: 38px;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  background:
    linear-gradient(135deg, #6d5df6 0%, #8b5cf6 45%, #ec4899 100%);
  box-shadow: var(--shadow-strong);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, .28), transparent 23%),
    radial-gradient(circle at 22% 92%, rgba(255, 255, 255, .13), transparent 30%);
}

.hero-copy {
  max-width: 600px;
  position: relative;
  z-index: 2
}

.hero-badge {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 13px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.hero h1 {
  margin: 18px 0 14px;
  max-width: 640px;
  font-size: 46px;
  line-height: 1.08;
  letter-spacing: -.04em;
}

.hero p {
  max-width: 560px;
  color: rgba(255, 255, 255, .86);
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 26px
}

.btn-primary,
.btn-secondary {
  border: 0;
  height: 48px;
  padding: 0 20px;
  border-radius: 17px;
  font-weight: 850;
  cursor: pointer;
  font-family: inherit;
}

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

.btn-secondary {
  background: rgba(255, 255, 255, .16);
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2)
}

.hero-visual {
  width: 350px;
  height: 240px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.sun {
  position: absolute;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #ffd166;
  right: 92px;
  top: 4px;
  box-shadow: 0 0 42px rgba(255, 209, 102, .55);
}

.cloud {
  position: absolute;
  width: 86px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .34);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 36px;
  height: 36px;
  left: 14px;
  top: -18px
}

.cloud::after {
  width: 48px;
  height: 48px;
  right: 10px;
  top: -26px
}

.cloud-1 {
  right: 190px;
  top: 55px
}

.cloud-2 {
  right: 20px;
  top: 88px;
  transform: scale(.8);
  opacity: .72
}

.fuji {
  position: absolute;
  bottom: 18px;
  border-left: 112px solid transparent;
  border-right: 112px solid transparent;
  border-bottom: 150px solid rgba(255, 255, 255, .86);
}

.fuji::after {
  content: "";
  position: absolute;
  left: -34px;
  top: 52px;
  border-left: 34px solid transparent;
  border-right: 34px solid transparent;
  border-top: 38px solid rgba(109, 93, 246, .72);
}

.fuji-front {
  right: 66px
}

.fuji-back {
  right: -10px;
  transform: scale(.76);
  opacity: .62
}

.torii {
  position: absolute;
  right: 92px;
  bottom: 0;
  width: 128px;
  height: 86px;
}

.torii-top {
  height: 14px;
  border-radius: 8px;
  background: #ffe8cb;
  box-shadow: 0 8px 0 rgba(255, 232, 203, .7);
}

.torii-mid {
  position: absolute;
  top: 34px;
  left: 12px;
  right: 12px;
  height: 10px;
  border-radius: 6px;
  background: #ffe8cb;
}

.torii-leg {
  position: absolute;
  bottom: 0;
  width: 12px;
  height: 50px;
  border-radius: 6px;
  background: #ffe8cb;
}

.torii-leg.left {
  left: 28px
}

.torii-leg.right {
  right: 28px
}

.sakura {
  position: absolute;
  color: #ffe4f1;
  font-size: 26px;
  animation: float 5s ease-in-out infinite;
}

.s1 {
  left: 12px;
  top: 20px
}

.s2 {
  right: 34px;
  bottom: 50px;
  animation-delay: 1s
}

.s3 {
  left: 72px;
  bottom: 8px;
  animation-delay: 2s
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) rotate(0)
  }

  50% {
    transform: translateY(-12px) rotate(8deg)
  }
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.stats-row article {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, .7);
}

.stats-row span {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #f2efff;
  font-size: 22px;
}

.stats-row h3 {
  font-size: 20px
}

.stats-row p {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600
}

.section-head {
  margin: 32px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
}

.section-head p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.section-head h2 {
  font-size: 30px;
  letter-spacing: -.03em
}

.section-head button {
  border: 0;
  padding: 12px 18px;
  border-radius: 16px;
  background: white;
  color: var(--primary);
  font-weight: 850;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(176px, 1fr));
  gap: 18px;
}

.level-card {
  min-height: 266px;
  padding: 23px;
  border-radius: 30px;
  position: relative;
  overflow: hidden;
  color: white;
  box-shadow: 0 22px 50px rgba(31, 41, 55, .14);
  transition: transform .28s ease, box-shadow .28s ease;
}

.level-card::before {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: -58px;
  top: -50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .17);
}

.level-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  left: -52px;
  bottom: -60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
}

.level-card:hover {
  transform: translateY(-12px) scale(1.018);
  box-shadow: 0 28px 70px rgba(31, 41, 55, .20);
}

.card-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-top span {
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  font-size: 12px;
  font-weight: 900;
}

.card-top strong {
  font-family: "Noto Sans JP", sans-serif;
  opacity: .35;
  font-size: 28px;
}

.level-card h3 {
  position: relative;
  z-index: 2;
  margin: 14px 0 8px;
  font-size: 58px;
  line-height: 1;
  letter-spacing: -.07em;
}

.level-card p {
  position: relative;
  z-index: 2;
  min-height: 64px;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .86);
}

.card-meta {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  margin: 16px 0;
  font-size: 12px;
  color: rgba(255, 255, 255, .82);
}

.level-card button {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 16px;
  background: white;
  color: #22223b;
  font-weight: 900;
  cursor: pointer;
}

.n1 {
  background: linear-gradient(135deg, #111827, #ec793b)
}

.n2 {
  background: linear-gradient(135deg, #7c3aed, #ec4899)
}

.n3 {
  background: linear-gradient(135deg, #2563eb, #06b6d4)
}

.n4 {
  background: linear-gradient(135deg, #16a34a, #22c55e)
}

.n5 {
  background: linear-gradient(135deg, #bde888, #a4ee81f8)
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 18px;
  margin-top: 22px;
  padding-bottom: 22px;
}

.dictionary-preview,
.ranking-preview {
  padding: 24px;
  border-radius: 30px;
  background: rgba(255, 255, 255, .80);
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-soft);
}

.muted {
  color: var(--muted);
  line-height: 1.7;
  margin-top: 6px
}

.dict-search {
  margin: 20px 0 14px;
  height: 54px;
  border-radius: 18px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f5f6fb;
}

.dict-search span {
  font-family: "Noto Sans JP", sans-serif;
  color: var(--primary);
  font-weight: 900;
}

.dict-search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-family: inherit;
}

.word-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #f2efff, #fff0f8);
}

.word-card h3 {
  font-family: "Noto Sans JP", sans-serif;
  font-size: 34px;
}

.word-card p {
  font-weight: 700
}

.word-card small {
  color: var(--muted);
  font-weight: 700
}

.ranking-preview h2 {
  margin-bottom: 16px
}

.rank-line {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(23, 32, 51, .08);
}

.rank-line:last-child {
  border-bottom: 0
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 30;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

@media(max-width:1280px) {
  .level-grid {
    grid-template-columns: repeat(3, 1fr)
  }

  .hero h1 {
    font-size: 40px
  }
}

@media(max-width:1020px) {
  .app {
    padding: 14px
  }

  .sidebar {
    position: fixed;
    top: 14px;
    left: -330px;
    z-index: 40;
    height: calc(100vh - 28px);
    transition: left .28s ease;
  }

  .sidebar.open {
    left: 14px
  }

  .close-sidebar {
    display: grid;
    place-items: center
  }

  .menu-btn {
    display: grid;
    place-items: center
  }

  .search-box {
    display: none
  }

  .hero-visual {
    display: none
  }

  .bottom-grid {
    grid-template-columns: 1fr
  }
}

@media(max-width:760px) {
  .topbar {
    height: auto;
    align-items: flex-start
  }

  .top-actions button {
    display: none
  }

  .hero {
    padding: 28px;
    min-height: auto
  }

  .hero h1 {
    font-size: 32px
  }

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

  .level-grid {
    grid-template-columns: repeat(2, 1fr)
  }
}

@media(max-width:520px) {
  .app {
    padding: 10px
  }

  .topbar h2 {
    font-size: 17px
  }

  .hero-actions {
    flex-direction: column
  }

  .btn-primary,
  .btn-secondary {
    width: 100%
  }

  .level-grid {
    grid-template-columns: 1fr
  }

  .section-head {
    align-items: flex-start;
    gap: 14px;
    flex-direction: column
  }
}

.sidebar {
  width: 260px !important;
  min-height: 100vh;
  height: 100vh !important;
  background: #ffffff !important;
  padding: 28px 24px !important;
  border-radius: 0 !important;
  border-right: 1px solid #f1f1f4;
  box-shadow: 8px 0 30px rgba(20, 30, 60, 0.04) !important;
  color: #111827 !important;
  overflow-y: auto;
}

.sidebar::before {
  display: none !important;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.logo-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: linear-gradient(135deg, #ff8a80, #ec4899);
  box-shadow: 0 12px 28px rgba(236, 72, 153, 0.28);
}

.sidebar-brand h1 {
  font-size: 22px;
  line-height: 1.1;
  color: #111827;
  font-weight: 800;
  margin: 0;
}

.sidebar-brand p {
  margin-top: 6px;
  font-size: 13px;
  color: #f43f5e;
  font-weight: 700;
}

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

.menu-item {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-radius: 14px;
  color: #1f2937;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.22s ease;
}

.menu-item:hover {
  background: #fff1f6;
  transform: translateX(4px);
}

.menu-item.active {
  background: linear-gradient(135deg, #ffe4ef, #fff0f6);
  color: #ec4899;
  font-weight: 700;
}

.menu-icon {
  width: 25px;
  min-width: 25px;
  height: 25px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: white;
  font-weight: 800;
}

.menu-icon.pink {
  background: #ec4899;
}

.menu-icon.purple {
  background: #7c3aed;
}

.menu-icon.blue {
  background: #228be6;
}

.menu-icon.green {
  background: #22c55e;
}

.menu-icon.orange {
  background: #f97316;
}

.menu-icon.yellow {
  background: #f5b000;
}

.menu-icon.cyan {
  background: #06b6d4;
}

.menu-icon.red {
  background: #f43f5e;
}

.menu-icon.gray {
  background: #64748b;
}

.menu-divider {
  height: 1px;
  background: #edf0f5;
  margin: 14px 0;
}

@media(max-width:1020px) {
  .sidebar {
    position: fixed !important;
    left: -280px;
    top: 0 !important;
    z-index: 40;
    transition: left 0.25s ease;
  }

  .sidebar.open {
    left: 0;
  }
}

/* =========================================================
   DARK MODE - DASHBOARD
   ========================================================= */
body:not(.dark) .bg-orb {
  display: none;
}

body.dark {
  color-scheme: dark;
  background: #080f1f !important;
  background-image: none !important;
}

body.dark .app,
body.dark .main {
  background: transparent !important;
}

/* Remove the large bright circles from the dark background */
body.dark .bg-orb,
body.dark .orb-1,
body.dark .orb-2,
body.dark .orb-3 {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Dark sidebar */
body.dark .sidebar {
  background: #0b1220 !important;
  background-image: none !important;
  color: #f8fafc !important;
  border-right: 1px solid #263449 !important;
  box-shadow: 8px 0 30px rgba(0, 0, 0, .28) !important;
}

body.dark .sidebar-brand h1 {
  color: #f8fafc !important;
}

body.dark .sidebar-brand p {
  color: #fb7185 !important;
}

body.dark .menu-item {
  color: #dbe4f0 !important;
}

body.dark .menu-item:hover {
  background: #17233a !important;
  color: #ffffff !important;
}

body.dark .menu-item.active {
  background: rgba(236, 72, 153, .18) !important;
  color: #f9a8d4 !important;
}

body.dark .menu-divider {
  background: #263449 !important;
}

/* Dark header */
body.dark .topbar {
  background: #111827 !important;
  border-color: #2b3a50 !important;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .24) !important;
}

body.dark .topbar h2 {
  color: #ffffff !important;
}

body.dark .topbar .eyebrow {
  color: #cbd5e1 !important;
}

/* Search fields */
body.dark .search-box,
body.dark .dict-search {
  background: #060b14 !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
}

body.dark .search-box input,
body.dark .dict-search input,
body.dark input {
  color: #ffffff !important;
}

body.dark .search-box input::placeholder,
body.dark .dict-search input::placeholder,
body.dark input::placeholder {
  color: #ffffff !important;
  opacity: .78 !important;
}

/* Theme and notification buttons */
body.dark .top-actions button {
  background: #060b14 !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
}

body.dark .top-actions button:hover {
  background: #17233a !important;
  border-color: #64748b !important;
}

/* Keep the remaining dashboard surfaces consistently dark */
body.dark .stats-row article,
body.dark .dictionary-preview,
body.dark .ranking-preview {
  background: #111827 !important;
  border-color: #2b3a50 !important;
  color: #f8fafc !important;
}

body.dark .stats-row span {
  background: #1f2a44 !important;
}

body.dark .section-head button {
  background: #111827 !important;
  color: #c4b5fd !important;
}

body.dark .word-card {
  background: #17233a !important;
}

body.dark .rank-line {
  border-bottom-color: #2b3a50 !important;
}

/* =========================================================
   FINAL FIXES: HERO + N1 BUTTON + N1 PAGE
   Keep this block at the very end of style.css
   ========================================================= */

/* ---------- HERO: full-width image with text over it ---------- */
.hero {
  position: relative !important;
  min-height: 330px !important;
  margin-top: 24px !important;
  padding: 36px 48px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  border-radius: 30px !important;
  background: #ffffff !important;
  border: 1px solid #e9edf5 !important;
  box-shadow: 0 20px 55px rgba(31, 41, 55, 0.12) !important;
  color: #ffffff !important;
}

.hero::before,
.hero::after {
  content: none !important;
  display: none !important;
}

.hero-background {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  border-radius: inherit !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

.hero-overlay {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.56) 55%,
      rgba(15, 23, 42, 0.16) 100%) !important;
  border-radius: inherit !important;
  z-index: 1 !important;
  pointer-events: none !important;
}

.hero-copy {
  position: relative !important;
  z-index: 2 !important;
  display: block !important;
  width: 100% !important;
  max-width: 720px !important;
  color: #ffffff !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.hero-badge {
  display: inline-flex !important;
  padding: 8px 14px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.16) !important;
  border: 1px solid rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  backdrop-filter: blur(10px);
}

.hero h1,
.hero-copy h1 {
  margin: 18px 0 14px !important;
  max-width: 700px !important;
  color: #ffffff !important;
  font-size: 44px !important;
  line-height: 1.1 !important;
  letter-spacing: -0.04em !important;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.3) !important;
}

.hero p,
.hero-copy p {
  max-width: 640px !important;
  min-height: 0 !important;
  color: rgba(255, 255, 255, 0.92) !important;
  font-size: 16px !important;
  line-height: 1.7 !important;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.28) !important;
}

.hero-actions {
  position: relative !important;
  z-index: 2 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 14px !important;
  margin-top: 24px !important;
}

.hero .btn-primary,
.hero .btn-secondary {
  min-height: 48px !important;
  padding: 0 22px !important;
  border-radius: 16px !important;
  font-family: inherit !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  cursor: pointer !important;
}

.hero .btn-primary {
  border: 0 !important;
  background: #ec4899 !important;
  color: #ffffff !important;
}

.hero .btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  background: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
  backdrop-filter: blur(10px);
}

.hero-visual,
.sun,
.cloud,
.fuji,
.torii,
.sakura {
  display: none !important;
}

#practiceLevels {
  scroll-margin-top: 120px;
}

/* ---------- Only the button opens the N1 page ---------- */
.level-card {
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.level-card-link {
  color: inherit;
  text-decoration: none;
}

.level-card-button {
  margin-top: auto;
}

.level-card a.level-card-button,
.level-card button.level-card-button {
  position: relative !important;
  z-index: 3 !important;
  width: 100% !important;
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: #ffffff !important;
  color: #22223b !important;
  text-decoration: none !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  cursor: pointer !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.level-card-button:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.2) !important;
}

/* =========================================================
   JLPT N1 PAGE
   ========================================================= */

body.level-page-body {
  min-height: 100vh !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow-x: hidden !important;
  background: linear-gradient(180deg, #ffffff 0%, #fafaff 100%) !important;
  color: #172033 !important;
}

.level-page-header {
  position: relative !important;
  z-index: 10 !important;
  width: 100% !important;
  min-height: 88px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 18px !important;
  padding: 18px 6% !important;
  background: #ffffff !important;
  border-bottom: 1px solid #e9edf5 !important;
  box-shadow: 0 8px 30px rgba(31, 41, 55, 0.05) !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.back-home-button {
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 18px !important;
  border-radius: 12px !important;
  background: #f5f3ff !important;
  color: #7c3aed !important;
  text-decoration: none !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  transition: 0.2s ease !important;
}

.back-home-button:hover {
  background: #ede9fe !important;
  transform: translateX(-3px) !important;
}

.level-page-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.level-page-logo {
  width: 46px !important;
  height: 46px !important;
  display: grid !important;
  place-items: center !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #ff8a80, #ec407a) !important;
  box-shadow: 0 10px 24px rgba(236, 64, 122, 0.22) !important;
}

.level-page-brand h1 {
  margin: 0 !important;
  color: #172033 !important;
  font-size: 18px !important;
  line-height: 1.1 !important;
}

.level-page-brand p {
  margin-top: 4px !important;
  color: #ec407a !important;
  font-family: "Noto Sans JP", sans-serif !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

.level-page-main {
  position: relative !important;
  z-index: 1 !important;
  width: min(1380px, 92%) !important;
  display: block !important;
  margin: 0 auto !important;
  padding: 34px 0 60px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.level-introduction {
  position: relative !important;
  min-height: 270px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  overflow: hidden !important;
  padding: 40px 46px !important;
  border-radius: 28px !important;
  color: #ffffff !important;
  box-shadow: 0 24px 60px rgba(31, 41, 55, 0.15) !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.n1-introduction {
  background: linear-gradient(135deg, #111827 0%, #4c1d95 55%, #7c3aed 100%) !important;
}

.level-introduction::before {
  content: "" !important;
  position: absolute !important;
  width: 290px !important;
  height: 290px !important;
  top: -120px !important;
  right: -60px !important;
  display: block !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

.level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
  display: block !important;
  max-width: 760px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.level-introduction-badge {
  display: inline-flex !important;
  padding: 8px 15px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.17) !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 800 !important;
}

.level-introduction h2 {
  margin: 16px 0 12px !important;
  color: #ffffff !important;
  font-size: 55px !important;
  line-height: 1 !important;
}

.level-introduction p {
  max-width: 680px !important;
  min-height: 0 !important;
  color: rgba(255, 255, 255, 0.86) !important;
  font-size: 16px !important;
  line-height: 1.7 !important;
}

.level-information {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  margin-top: 24px !important;
}

.level-information span {
  display: inline-flex !important;
  padding: 9px 13px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.13) !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.level-japanese-character {
  position: relative !important;
  z-index: 2 !important;
  display: block !important;
  margin-right: 40px !important;
  color: rgba(255, 255, 255, 0.21) !important;
  font-family: "Noto Sans JP", sans-serif !important;
  font-size: 150px !important;
  font-weight: 900 !important;
}

.learning-section {
  display: block !important;
  margin-top: 42px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.learning-section-title {
  display: block !important;
  margin-bottom: 24px !important;
}

.learning-section-title p {
  min-height: 0 !important;
  color: #7c3aed !important;
  font-size: 13px !important;
  font-weight: 900 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}

.learning-section-title h2 {
  margin-top: 5px !important;
  color: #172033 !important;
  font-size: 30px !important;
  font-weight: 800 !important;
}

.learning-category-grid {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(210px, 1fr)) !important;
  gap: 20px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.learning-category-card {
  position: relative !important;
  min-height: 220px !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 25px !important;
  border: 1px solid #e9edf5 !important;
  border-radius: 22px !important;
  background: #ffffff !important;
  color: #172033 !important;
  text-decoration: none !important;
  box-shadow: 0 13px 35px rgba(31, 41, 55, 0.07) !important;
  visibility: visible !important;
  opacity: 1 !important;
  transition: transform 0.23s ease, box-shadow 0.23s ease, border-color 0.23s ease !important;
}

.learning-category-card:hover {
  transform: translateY(-7px) !important;
  border-color: #d8ccff !important;
  box-shadow: 0 22px 50px rgba(31, 41, 55, 0.12) !important;
}

.category-icon {
  width: 58px !important;
  height: 58px !important;
  display: grid !important;
  place-items: center !important;
  flex-shrink: 0 !important;
  margin-bottom: 20px !important;
  border-radius: 18px !important;
  font-family: "Noto Sans JP", sans-serif !important;
  font-size: 25px !important;
}

.exam-category .category-icon {
  background: #fde8f0 !important;
}

.vocabulary-category .category-icon {
  background: #e8f2ff !important;
}

.grammar-category .category-icon {
  background: #f3e8ff !important;
}

.kanji-category .category-icon {
  background: #fff0df !important;
}

.reading-category .category-icon {
  background: #e8f8ef !important;
}

.listening-category .category-icon {
  background: #e4f8fb !important;
}

.flashcard-category .category-icon {
  background: #fff7d8 !important;
}

.history-category .category-icon {
  background: #eef2ff !important;
}

.category-content {
  display: flex !important;
  flex: 1 !important;
  flex-direction: column !important;
}

.category-content h3 {
  margin-bottom: 9px !important;
  color: #172033 !important;
  font-size: 19px !important;
}

.category-content p {
  min-height: 0 !important;
  color: #6b7280 !important;
  font-size: 14px !important;
  line-height: 1.65 !important;
}

.category-content span {
  margin-top: auto !important;
  padding-top: 18px !important;
  color: #7c3aed !important;
  font-size: 14px !important;
  font-weight: 800 !important;
}

/* ---------- Responsive fixes ---------- */
@media (max-width: 1100px) {
  .learning-category-grid {
    grid-template-columns: repeat(3, minmax(210px, 1fr)) !important;
  }
}

@media (max-width: 900px) {
  .hero {
    min-height: 320px !important;
    padding: 32px 30px !important;
  }

  .hero h1,
  .hero-copy h1 {
    font-size: 38px !important;
  }
}

@media (max-width: 800px) {
  .level-page-header {
    padding: 16px 4% !important;
  }

  .level-page-brand p {
    display: none !important;
  }

  .level-introduction {
    padding: 34px 28px !important;
  }

  .level-japanese-character {
    display: none !important;
  }

  .learning-category-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .hero {
    min-height: 360px !important;
    padding: 28px 22px !important;
    border-radius: 24px !important;
  }

  .hero h1,
  .hero-copy h1 {
    font-size: 32px !important;
  }

  .hero-actions {
    flex-direction: column !important;
  }

  .hero .btn-primary,
  .hero .btn-secondary {
    width: 100% !important;
  }

  .hero-background {
    object-position: 65% center !important;
  }

  .hero-overlay {
    background: rgba(15, 23, 42, 0.68) !important;
  }

  .level-page-brand h1 {
    display: none !important;
  }

  .level-introduction h2 {
    font-size: 45px !important;
  }

  .learning-section-title h2 {
    font-size: 25px !important;
  }

  .learning-category-grid {
    grid-template-columns: 1fr !important;
  }
}

.n2-introduction {
  background: linear-gradient(135deg,
      #0f766e 0%,
      #0d9488 55%,
      #14b8a6 100%);
}

/* Ảnh phủ toàn bộ card đầu trang N1 */
.n1-introduction {
  position: relative !important;
  overflow: hidden !important;

  background:
    url("../../images/n1-header.png") center / cover no-repeat !important;
}

/* Lớp tối để chữ dễ đọc */
.n1-introduction::before {
  content: "" !important;
  display: block !important;

  position: absolute;
  inset: 0;

  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.2) 100%);

  z-index: 0;
}

/* Xóa hình trang trí tím cũ */
.n1-introduction::after {
  display: none !important;
  content: none !important;
}

/* Đưa chữ nổi lên trên ảnh */
.n1-introduction .level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
}

/* Ẩn chữ Nhật trang trí bên phải */
.n1-introduction .level-japanese-character {
  display: none !important;
}

/* Giữ chữ màu trắng */
.n1-introduction h2,
.n1-introduction p,
.n1-introduction span {
  color: #282626 !important;
}

/* Ảnh phủ toàn bộ card đầu trang N1 */
.n2-introduction {
  position: relative !important;
  overflow: hidden !important;

  background:
    url("../../images/n2-header.png") center / cover no-repeat !important;
}

/* Lớp tối để chữ dễ đọc */
.n2-introduction::before {
  content: "" !important;
  display: block !important;

  position: absolute;
  inset: 0;

  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.2) 100%);

  z-index: 0;
}

/* Xóa hình trang trí cũ */
.n2-introduction::after {
  display: none !important;
  content: none !important;
}

/* Đưa chữ nổi lên trên ảnh */
.n2-introduction .level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
}

/* Ẩn chữ Nhật trang trí bên phải */
.n2-introduction .level-japanese-character {
  display: none !important;
}

/* Giữ chữ màu trắng */
.n2-introduction h2,
.n2-introduction p,
.n2-introduction span {
  color: #282626 !important;
}

/* Ảnh phủ toàn bộ card đầu trang N1 */
.n3-introduction {
  position: relative !important;
  overflow: hidden !important;

  background:
    url("../../images/n3-header.png") center / cover no-repeat !important;
}

/* Lớp tối để chữ dễ đọc */
.n3-introduction::before {
  content: "" !important;
  display: block !important;

  position: absolute;
  inset: 0;

  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.2) 100%);

  z-index: 0;
}

/* Xóa hình trang trí cũ */
.n3-introduction::after {
  display: none !important;
  content: none !important;
}

/* Đưa chữ nổi lên trên ảnh */
.n3-introduction .level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
}

/* Ẩn chữ Nhật trang trí bên phải */
.n3-introduction .level-japanese-character {
  display: none !important;
}

/* Giữ chữ màu trắng */
.n3-introduction h2,
.n3-introduction p,
.n3-introduction span {
  color: #282626 !important;
}

/* Ảnh phủ toàn bộ card đầu trang N1 */
.n4-introduction {
  position: relative !important;
  overflow: hidden !important;

  background:
    url("../../images/n4-header.png") center / cover no-repeat !important;
}

/* Lớp tối để chữ dễ đọc */
.n4-introduction::before {
  content: "" !important;
  display: block !important;

  position: absolute;
  inset: 0;

  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.2) 100%);

  z-index: 0;
}

/* Xóa hình trang trí cũ */
.n4-introduction::after {
  display: none !important;
  content: none !important;
}

/* Đưa chữ nổi lên trên ảnh */
.n4-introduction .level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
}

/* Giữ chữ màu trắng */
.n4-introduction h2,
.n4-introduction p,
.n4-introduction span {
  color: #282626 !important;
}

/* Ảnh phủ toàn bộ card đầu trang N5 */
.n5-introduction {
  position: relative !important;
  overflow: hidden !important;

  background:
    url("../../images/n5-header.png") center / cover no-repeat !important;
}

/* Lớp tối để chữ dễ đọc */
.n5-introduction::before {
  content: "" !important;
  display: block !important;

  position: absolute;
  inset: 0;

  background: linear-gradient(90deg,
      rgba(15, 23, 42, 0.82) 0%,
      rgba(15, 23, 42, 0.55) 55%,
      rgba(15, 23, 42, 0.2) 100%);

  z-index: 0;
}

/* Xóa hình trang trí cũ */
.n5-introduction::after {
  display: none !important;
  content: none !important;
}

/* Đưa chữ nổi lên trên ảnh */
.n5-introduction .level-introduction-content {
  position: relative !important;
  z-index: 2 !important;
}

/* Giữ chữ màu trắng */
.n5-introduction h2,
.n5-introduction p,
.n5-introduction span {
  color: #282626 !important;
}

/* SIDEBAR LUYỆN ĐỀ DROPDOWN */

.sidebar-dropdown {
  width: 100%;
}

.sidebar-dropdown-toggle {
  width: 100%;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.sidebar-dropdown-toggle .dropdown-arrow {
  margin-left: auto;
  font-size: 18px;
  transition: transform 0.25s ease;
}

.sidebar-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* Danh sách N1 - N5 */
.sidebar-submenu {
  max-height: 0;
  overflow: hidden;

  margin: 0 8px;

  border-radius: 14px;
  background: #f8fafc;

  opacity: 0;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease,
    padding 0.3s ease,
    margin 0.3s ease;
}

.sidebar-dropdown.open .sidebar-submenu {
  max-height: 320px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 8px;

  opacity: 1;
}

.sidebar-submenu a {
  min-height: 42px;

  display: flex;
  align-items: center;

  padding: 0 14px;
  margin-bottom: 4px;

  border-radius: 10px;

  color: #334155;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;

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

.sidebar-submenu a:last-child {
  margin-bottom: 0;
}

.sidebar-submenu a:hover {
  padding-left: 18px;
  background: #fce7f3;
  color: #ec4899;
}

/* DROPDOWN TRONG DARK MODE */
body.dark .sidebar-submenu {
  background: #111c30;
  border: 1px solid #2b3951;
}

body.dark .sidebar-submenu a {
  color: #cbd5e1;
}

body.dark .sidebar-submenu a:hover {
  background: #1e293b;
  color: #f472b6;
}

body.dark .sidebar-dropdown-toggle {
  color: #cbd5e1;
}

body.dark .sidebar-dropdown.open .sidebar-dropdown-toggle {
  background: rgba(236, 72, 153, 0.16);
  color: #f472b6;
}

/* VỊ TRÍ CARD LUYỆN ĐỀ */
#exam-practice {
  scroll-margin-top: 120px;
}

#exam-practice:target {
  border-color: #ec4899;

  box-shadow:
    0 0 0 4px rgba(236, 72, 153, 0.15),
    0 22px 50px rgba(31, 41, 55, 0.15);

  animation: examCardHighlight 1.2s ease;
}

@keyframes examCardHighlight {
  0% {
    transform: scale(0.97);
  }

  60% {
    transform: scale(1.025);
  }

  100% {
    transform: scale(1);
  }
}

/* HEADER MỚI CHO PAGE N1  */
.level-new-header {
  position: sticky;
  top: 0;
  z-index: 1000;

  width: 100%;
  min-height: 78px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 12px 44px;

  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid #e5e7eb;

  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(14px);
}

/* NÚT QUAY LẠI */
.level-header-back {
  min-width: 126px;
  min-height: 46px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  gap: 10px;

  padding: 0 18px;

  border: 1px solid #dbe3ef;
  border-radius: 11px;

  background: #ffffff;
  color: #475569;

  box-shadow:
    0 4px 13px rgba(15, 23, 42, 0.04);

  text-decoration: none;
  font-size: 14px;
  font-weight: 600;

  transition: 0.2s ease;
}

.level-header-back svg {
  width: 20px;
  height: 20px;

  fill: none;
  stroke: currentColor;
  stroke-width: 2;

  stroke-linecap: round;
  stroke-linejoin: round;
}

.level-header-back:hover {
  transform: translateX(-3px);

  border-color: #93c5fd;
  color: #2563eb;
}

/* BUTTON BÊN PHẢI */
.level-header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
}

.level-header-icon {
  position: relative;

  width: 46px;
  height: 46px;

  display: grid;
  place-items: center;

  padding: 0;

  border: 1px solid #dbe3ef;
  border-radius: 12px;

  background: #ffffff;
  color: #334155;

  box-shadow:
    0 4px 13px rgba(15, 23, 42, 0.04);

  cursor: pointer;
  transition: 0.2s ease;
}

.level-header-icon:hover {
  transform: translateY(-2px);

  border-color: #93c5fd;
  color: #2563eb;
}

.level-header-icon svg {
  width: 22px;
  height: 22px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;

  stroke-linecap: round;
  stroke-linejoin: round;
}

.level-theme-sun {
  display: none;
}

.level-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;

  width: 8px;
  height: 8px;

  border: 2px solid #ffffff;
  border-radius: 50%;

  background: #2563eb;
}

/* DARK MODE*/
body.dark .level-new-header {
  background: rgba(18, 19, 22, 0.97);

  border-bottom-color: #303238;

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35);
}

body.dark .level-header-brand {
  color: #ffffff;
}

body.dark .level-header-back,
body.dark .level-header-icon {
  background: #1b1d21;
  color: #e5e7eb;

  border-color: #35373d;

  box-shadow: none;
}

body.dark .level-header-back:hover,
body.dark .level-header-icon:hover {
  background: #24262b;
  color: #ffffff;

  border-color: #55585f;
}

body.dark .level-theme-moon {
  display: none;
}

body.dark .level-theme-sun {
  display: block;
}

body.dark .level-notification-dot {
  border-color: #1b1d21;
}

/* RESPONSIVE */
@media (max-width: 720px) {
  .level-new-header {
    grid-template-columns: auto 1fr auto;

    gap: 12px;
    padding: 10px 14px;
  }

  .level-header-back {
    width: 46px;
    min-width: 46px;
    padding: 0;
  }

  .level-header-back span {
    display: none;
  }

  .level-header-icon {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 480px) {
  .level-header-brand strong {
    display: none;
  }

  .level-header-actions {
    gap: 6px;
  }
}
/* DARK MODE CHO TOÀN BỘ PAGE N1*/
/* Lưu ý: không có khoảng trắng giữa body.dark và .level-page-body */
body.dark.level-page-body {
  background: #0d0f12 !important;
  background-image: none !important;
  color: #f5f5f5;
}
/* Vùng nội dung chính */
body.dark .level-page-main {
  background: transparent;
  color: #f5f5f5;
}

/* Tiêu đề khu vực luyện tập */
body.dark .learning-section-title p {
  color: #60a5fa;
}

body.dark .learning-section-title h2 {
  color: #ffffff;
}
/* Các card Luyện đề, Từ vựng, Ngữ pháp... */
body.dark .learning-category-card {
  background: #17191d !important;
  background-image: none !important;

  border-color: #303238 !important;
  color: #f5f5f5 !important;

  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.28);
}
/* Hover card */
body.dark .learning-category-card:hover {
  background: #202226 !important;
  border-color: #4b5563 !important;

  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.38);
}
/* Tiêu đề trong card */
body.dark .learning-category-card h3 {
  color: #ffffff !important;
}
/* Nội dung mô tả trong card */
body.dark .learning-category-card p {
  color: #a8abb2 !important;
}
/* Chữ liên kết phía dưới card */
body.dark .learning-category-card .category-content span {
  color: #60a5fa !important;
}
/* Khung icon trong từng card */
body.dark .learning-category-card .category-icon {
  background: #25272c !important;
  color: #f5f5f5 !important;
}
/* Ghi đè màu nền riêng của từng icon */
body.dark .exam-category .category-icon,
body.dark .vocabulary-category .category-icon,
body.dark .grammar-category .category-icon,
body.dark .kanji-category .category-icon,
body.dark .reading-category .category-icon,
body.dark .listening-category .category-icon,
body.dark .flashcard-category .category-icon,
body.dark .history-category .category-icon {
  background: #25272c !important;
}
/* Card giới thiệu JLPT N1 */
body.dark .level-introduction {
  border: 1px solid #303238;

  box-shadow:
    0 20px 46px rgba(0, 0, 0, 0.36);
}
/* Badge và thông tin nằm trên ảnh */
body.dark .level-introduction-badge,
body.dark .level-information span {
  background: rgba(0, 0, 0, 0.42) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
}
/* Nội dung trên ảnh */
body.dark .level-introduction h2 {
  color: #ffffff !important;
}

body.dark .level-introduction p {
  color: rgba(255, 255, 255, 0.88) !important;
}
/* =========================================================
   HOME SIDEBAR — BẢN HOÀN CHỈNH
   Chỉ áp dụng cho index.html có body.home-page
   ========================================================= */

.home-page {
  --home-sidebar-open-width: 280px;
  --home-sidebar-mini-width: 84px;
  --home-sidebar-gap: 20px;
}

/* Main luôn chiếm phần còn lại; các section được căn giữa. */
.home-page .main {
  flex: 1 1 0 !important;
  width: 0;
  min-width: 0;
  max-width: none;
  transition:
    width 0.3s ease,
    flex-basis 0.3s ease;
}

.home-page .main > * {
  width: min(100%, 1600px);
  margin-inline: auto;
}

/* ---------------- Desktop ---------------- */

@media (min-width: 1021px) {
  .home-page .app {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    gap: var(--home-sidebar-gap) !important;
    padding: 16px !important;
    transition: gap 0.3s ease;
  }

  .home-page .sidebar {
    width: var(--home-sidebar-open-width) !important;
    min-width: var(--home-sidebar-open-width) !important;
    flex: 0 0 var(--home-sidebar-open-width) !important;

    height: calc(100vh - 32px) !important;
    min-height: calc(100vh - 32px) !important;

    position: sticky !important;
    top: 16px !important;
    left: auto !important;

    display: flex;
    flex-direction: column;

    padding: 12px !important;
    border: 1px solid #edf0f5 !important;
    border-radius: 22px !important;

    color: #111827 !important;
    background: #ffffff !important;
    background-image: none !important;

    box-shadow:
      8px 0 30px rgba(20, 30, 60, 0.06) !important;

    overflow: visible !important;

    transition:
      width 0.3s ease,
      min-width 0.3s ease,
      flex-basis 0.3s ease,
      padding 0.3s ease;
  }

  .home-page .sidebar::before {
    display: none !important;
  }

  /* Card header nhỏ ở đầu sidebar. */
  .home-page .sidebar-header {
    position: relative;
    z-index: 10;

    width: 100%;
    height: 66px;
    min-height: 66px;
    flex: 0 0 66px;

    margin: 0 0 14px;
    padding: 10px;

    border: 1px solid #e5e9f1;
    border-radius: 16px;

    background: #f7f8fb;

    box-shadow:
      0 7px 18px rgba(15, 23, 42, 0.06);

    overflow: hidden;
  }

  /*
   * Nút luôn ở cùng vị trí trong card header.
   * Sidebar rộng hay hẹp cũng không làm nút chạy.
   */
  .home-page .home-sidebar-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;

    width: 44px;
    height: 44px;

    display: grid;
    place-items: center;

    padding: 0;
    border: 1px solid #d8dee8;
    border-radius: 12px;

    color: #475569;
    background: #ffffff;

    cursor: pointer;

    box-shadow:
      0 4px 11px rgba(15, 23, 42, 0.08);

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

  .home-page .home-sidebar-toggle:hover {
    color: #2563eb;
    border-color: #93c5fd;
    background: #eff6ff;
  }

  .home-page .home-sidebar-toggle:active {
    transform: scale(0.96);
  }

  .home-page .home-sidebar-toggle svg {
    width: 23px;
    height: 23px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }

  .home-page .sidebar-brand {
    height: 44px;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 10px;

    margin: 0 0 0 58px;

    white-space: nowrap;
    overflow: hidden;

    transition:
      width 0.28s ease,
      opacity 0.2s ease,
      transform 0.28s ease;
  }

  .home-page .logo-circle {
    width: 38px;
    min-width: 38px;
    height: 38px;

    font-size: 19px;
    box-shadow:
      0 8px 20px rgba(236, 72, 153, 0.2);
  }

  .home-page .sidebar-brand-copy {
    min-width: 148px;
    overflow: hidden;
  }

  .home-page .sidebar-brand-copy h1 {
    margin: 0;
    color: #111827;
    font-size: 17px;
    line-height: 1.1;
  }

  .home-page .sidebar-brand-copy p {
    margin: 4px 0 0;
    color: #f43f5e;
    font-size: 10px;
    font-weight: 700;
  }

  /* Menu là khu vực cuộn riêng. */
  .home-page .sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;

    display: flex;
    flex-direction: column;
    gap: 6px;

    padding: 2px 2px 4px;

    overflow-y: auto;
    overflow-x: hidden;

    scrollbar-width: thin;
    scrollbar-color: #d8dee8 transparent;
  }

  .home-page .sidebar-menu::-webkit-scrollbar {
    width: 5px;
  }

  .home-page .sidebar-menu::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #d8dee8;
  }

  .home-page .menu-item {
    position: relative;

    width: 100%;
    min-height: 48px;

    display: flex;
    align-items: center;
    gap: 13px;

    margin: 0;
    padding: 0 13px;

    border: 0;
    border-radius: 13px;

    color: #1f2937;
    background: transparent;

    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;

    cursor: pointer;

    transition:
      color 0.2s ease,
      background 0.2s ease,
      transform 0.2s ease,
      width 0.3s ease,
      padding 0.3s ease;
  }

  .home-page .menu-item:hover {
    color: #111827;
    background: #f3f5f9;
    transform: none;
  }

  .home-page .menu-item.active {
    color: #ffffff;
    background: linear-gradient(
      135deg,
      #5b7df4,
      #3f67df
    );
  }

  .home-page .menu-icon {
    width: 27px;
    min-width: 27px;
    height: 27px;
    flex: 0 0 27px;

    border-radius: 8px;
    font-size: 14px;
  }

  .home-page .menu-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;

    opacity: 1;

    transition:
      opacity 0.18s ease,
      width 0.28s ease;
  }

  .home-page .menu-divider {
    width: calc(100% - 16px);
    height: 1px;

    margin: 11px auto;

    flex: 0 0 1px;
    background: #e7ebf1;
  }

  .home-page .settings-divider {
    margin-top: auto;
  }

  /* Dropdown Luyện đề. */
  .home-page .sidebar-dropdown {
    width: 100%;
    flex: 0 0 auto;
  }

  .home-page .sidebar-dropdown-toggle {
    width: 100%;
  }

  .home-page .sidebar-dropdown-arrow {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin-left: auto;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;

    transition:
      transform 0.25s ease,
      opacity 0.18s ease;
  }

  .home-page
    .sidebar-dropdown.open
    .sidebar-dropdown-arrow {
    transform: rotate(180deg);
  }

  .home-page .sidebar-submenu {
    max-height: 0;

    display: grid;
    gap: 4px;

    margin: 0 6px;
    padding: 0 8px;

    border: 0;
    border-radius: 12px;

    background: #f7f9fc;

    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    pointer-events: none;

    transition:
      max-height 0.28s ease,
      margin 0.28s ease,
      padding 0.28s ease,
      opacity 0.2s ease,
      visibility 0.2s ease;
  }

  .home-page
    .sidebar-dropdown.open
    .sidebar-submenu {
    max-height: 280px;

    margin-top: 6px;
    margin-bottom: 6px;
    padding-top: 7px;
    padding-bottom: 7px;

    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .home-page .sidebar-submenu a {
    min-height: 36px;

    display: flex;
    align-items: center;

    margin: 0;
    padding: 0 12px;

    border-radius: 9px;

    color: #475569;
    background: transparent;

    font-size: 13px;
    font-weight: 800;
    text-decoration: none;

    transition:
      color 0.2s ease,
      background 0.2s ease,
      padding 0.2s ease;
  }

  .home-page .sidebar-submenu a:hover {
    padding-left: 16px;
    color: #ec4899;
    background: #fce7f3;
  }

  /* ---------- Trạng thái sidebar mini ---------- */

  .home-page
    .app.home-sidebar-mini {
    gap: 18px !important;
  }

  .home-page
    .app.home-sidebar-mini
    .sidebar {
    width: var(--home-sidebar-mini-width) !important;
    min-width: var(--home-sidebar-mini-width) !important;
    flex-basis: var(--home-sidebar-mini-width) !important;

    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .home-page
    .app.home-sidebar-mini
    .sidebar-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .home-page
    .app.home-sidebar-mini
    .sidebar-brand {
    width: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-8px);
  }

  .home-page
    .app.home-sidebar-mini
    .menu-item {
    width: 56px;
    min-width: 56px;
    height: 50px;
    min-height: 50px;

    justify-content: center;
    gap: 0;

    margin-inline: auto;
    padding: 0;
  }

  .home-page
    .app.home-sidebar-mini
    .menu-label,

  .home-page
    .app.home-sidebar-mini
    .sidebar-dropdown-arrow {
    display: none;
  }

  .home-page
    .app.home-sidebar-mini
    .menu-icon {
    margin: 0;
  }

  .home-page
    .app.home-sidebar-mini
    .sidebar-submenu {
    display: none !important;
  }

  .home-page
    .app.home-sidebar-mini
    .menu-divider {
    width: 44px;
  }

  /*
   * Main tự nhận toàn bộ không gian mới.
   * Không cần đặt width thủ công nên luôn cân đối.
   */
  .home-page
    .app.home-sidebar-mini
    .main {
    flex: 1 1 0 !important;
    width: 0;
    min-width: 0;
  }
}

/* Tooltip tên chức năng ở sidebar mini. */
.sidebar-mini-tooltip {
  position: fixed;
  z-index: 10000;

  min-width: max-content;
  padding: 9px 13px;

  border: 1px solid #d8dee8;
  border-radius: 10px;

  color: #ffffff;
  background: #20242b;

  font-family:
    "Poppins",
    "Noto Sans JP",
    sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;

  pointer-events: none;

  transform: translateY(-50%);

  box-shadow:
    0 10px 28px rgba(15, 23, 42, 0.22);
}

.sidebar-mini-tooltip[hidden] {
  display: none !important;
}

/* ---------------- Dark mode ---------------- */

@media (min-width: 1021px) {
  body.dark.home-page .sidebar {
    color: #e5e7eb !important;
    background: #181a1f !important;
    border-color: #303238 !important;

    box-shadow:
      8px 0 30px rgba(0, 0, 0, 0.28) !important;
  }

  body.dark.home-page .sidebar-header {
    background: #24272d;
    border-color: #373b43;
  }

  body.dark.home-page .home-sidebar-toggle {
    color: #e5e7eb;
    background: #30343b;
    border-color: #474c56;
  }

  body.dark.home-page
    .home-sidebar-toggle:hover {
    color: #bfdbfe;
    background: #27364d;
    border-color: #60a5fa;
  }

  body.dark.home-page
    .sidebar-brand-copy h1 {
    color: #ffffff;
  }

  body.dark.home-page .menu-item {
    color: #e2e8f0 !important;
  }

  body.dark.home-page .menu-item:hover {
    color: #ffffff !important;
    background: #272b32 !important;
  }

  body.dark.home-page .menu-item.active {
    color: #ffffff !important;
    background: linear-gradient(
      135deg,
      #526ee9,
      #365bd4
    ) !important;
  }

  body.dark.home-page .menu-divider {
    background: #343841 !important;
  }

  body.dark.home-page .sidebar-submenu {
    background: #22262d;
    border: 0;
  }

  body.dark.home-page .sidebar-submenu a {
    color: #cbd5e1;
  }

  body.dark.home-page
    .sidebar-submenu a:hover {
    color: #f9a8d4;
    background: #342331;
  }
}

/* ---------------- Mobile: giữ cơ chế sidebar cũ ---------------- */

@media (max-width: 1020px) {
  .home-page .app {
    display: block;
    padding: 14px !important;
  }

  .home-page .main {
    width: 100%;
  }

  .home-page .home-sidebar-toggle {
    display: none !important;
  }

  .home-page .sidebar {
    width: min(286px, calc(100vw - 28px)) !important;
    min-width: 0 !important;

    height: calc(100vh - 28px) !important;
    min-height: 0 !important;

    position: fixed !important;
    top: 14px !important;
    left: -320px !important;
    z-index: 40;

    display: block;

    padding: 18px !important;
    border-radius: 22px !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    transition: left 0.28s ease;
  }

  .home-page .sidebar.open {
    left: 14px !important;
  }

  .home-page .sidebar-header {
    min-height: 58px;

    display: flex;
    align-items: center;

    margin-bottom: 18px;
    padding: 0;
  }

  .home-page .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;

    margin: 0;
  }

  .home-page .sidebar-brand-copy {
    display: block;
  }

  .home-page .sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .home-page .menu-item {
    width: 100%;
    min-height: 48px;

    display: flex;
    align-items: center;
    gap: 13px;

    padding: 0 13px;
  }

  .home-page .menu-label {
    display: inline;
  }

  .home-page .sidebar-dropdown-arrow {
    width: 18px;
    height: 18px;
    margin-left: auto;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;

    transition: transform 0.25s ease;
  }

  .home-page
    .sidebar-dropdown.open
    .sidebar-dropdown-arrow {
    transform: rotate(180deg);
  }

  .home-page .sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
  }

  .home-page
    .sidebar-dropdown.open
    .sidebar-submenu {
    max-height: 280px;
    margin: 7px 8px;
    padding: 8px;
    opacity: 1;
  }
}
/* =========================================================
   UNIFIED DARK THEME — XÁM VỪA, KHÔNG DÙNG ĐEN ĐẬM
   Dùng chung cho trang chủ và các page N1–N5.
   ========================================================= */

html.dark {
  color-scheme: dark;

  --dark-page: #34383f;
  --dark-page-soft: #383d45;
  --dark-surface: #3f444c;
  --dark-surface-soft: #484e57;
  --dark-surface-hover: #525965;
  --dark-border: #5c6470;
  --dark-text: #f4f6f8;
  --dark-muted: #c5cad1;
  --dark-primary: #8ab4ff;
  --dark-primary-soft: #3d5274;
  --dark-shadow:
    0 14px 34px rgba(19, 23, 29, 0.20);
}

html.dark body,
body.dark {
  background: var(--dark-page) !important;
  background-image: none !important;
  color: var(--dark-text) !important;
}

body.dark .app,
body.dark .main,
body.dark.level-page-body,
html.dark body.level-page-body {
  background: var(--dark-page) !important;
  background-image: none !important;
  color: var(--dark-text) !important;
}

/* Header dùng chung */
body.dark .topbar,
body.dark .level-new-header,
body.dark .level-page-header,
body.dark .sidebar-header {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface) !important;
  background-image: none !important;
  color: var(--dark-text) !important;
  box-shadow: var(--dark-shadow) !important;
}

/* Sidebar trang chủ */
body.dark.home-page .sidebar {
  border-color: var(--dark-border) !important;
  background: #393e46 !important;
  background-image: none !important;
  color: var(--dark-text) !important;
}

body.dark.home-page .sidebar-header {
  background: #434951 !important;
}

body.dark.home-page .home-sidebar-toggle,
body.dark .level-header-back,
body.dark .level-header-icon,
body.dark .level-header-icon-button,
body.dark .n1-header-icon-button {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface-soft) !important;
  color: var(--dark-text) !important;
}

body.dark.home-page .menu-item {
  color: #edf0f4 !important;
}

body.dark.home-page .menu-item:hover,
body.dark.home-page
  .menu-item.is-selected {
  background: var(--dark-primary-soft) !important;
  color: #edf5ff !important;
}

body.dark.home-page .sidebar-submenu {
  border-color: var(--dark-border) !important;
  background: #454b54 !important;
}

body.dark.home-page .sidebar-submenu a {
  color: #e3e7ec !important;
}

body.dark.home-page .sidebar-submenu a:hover {
  background: #52617a !important;
  color: #ffffff !important;
}

body.dark.home-page .menu-divider {
  background: var(--dark-border) !important;
}

/* Các card/surface phổ biến ở trang chủ */
body.dark .stats-row article,
body.dark .dictionary-preview,
body.dark .ranking-preview,
body.dark .learning-category-card,
body.dark .level-card,
body.dark .goal,
body.dark .topbar,
body.dark .notification-panel,
body.dark .level-notification-dropdown {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface) !important;
  background-image: none !important;
  color: var(--dark-text) !important;
  box-shadow: var(--dark-shadow) !important;
}

body.dark .word-card,
body.dark .rank-line,
body.dark .stats-row span,
body.dark .section-head button {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface-soft) !important;
  color: var(--dark-text) !important;
}

body.dark .search-box,
body.dark .dict-search,
body.dark input,
body.dark select,
body.dark textarea {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface-soft) !important;
  color: var(--dark-text) !important;
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: var(--dark-muted) !important;
  opacity: 1 !important;
}

/* Trang giới thiệu N1–N5 */
body.dark.level-page-body,
html.dark body.level-page-body {
  --level-dark-page: var(--dark-page);
  --level-dark-surface: var(--dark-surface);
  --level-dark-soft: var(--dark-surface-soft);
  --level-dark-border: var(--dark-border);
  --level-dark-text: var(--dark-text);
  --level-dark-muted: var(--dark-muted);
}

body.dark .level-page-main {
  background: var(--dark-page) !important;
  color: var(--dark-text) !important;
}

body.dark .learning-section-title h2,
body.dark .level-page-brand h1,
body.dark .learning-category-card h3 {
  color: var(--dark-text) !important;
}

body.dark .learning-section-title p,
body.dark .learning-category-card p,
body.dark .learning-category-card
  .category-content span,
body.dark .level-page-brand p {
  color: var(--dark-muted) !important;
}

body.dark .learning-category-card {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface) !important;
  color: var(--dark-text) !important;
}

body.dark .learning-category-card:hover {
  border-color: #86adf0 !important;
  background: var(--dark-surface-hover) !important;
}

body.dark .learning-category-card
  .category-icon {
  border-color: var(--dark-border) !important;
  background: var(--dark-surface-soft) !important;
}

/*
 * Phần giới thiệu giữ được màu nhận diện từng level,
 * chỉ phủ một lớp xám nhẹ để không lệch tông.
 */
body.dark .level-introduction {
  border-color:
    rgba(208, 214, 223, 0.35) !important;
  box-shadow: var(--dark-shadow) !important;
  filter: saturate(0.88) brightness(0.88);
}

body.dark .level-introduction h2 {
  color: #ffffff !important;
}

body.dark .level-introduction p,
body.dark .level-introduction-badge,
body.dark .level-information span {
  color: #eef2f6 !important;
}
/* =========================================================
   FIX: CARD N1–N5 GIỮ NGUYÊN MÀU GỐC TRONG DARK MODE
   Chỉ áp dụng tại trang chủ.
   ========================================================= */

body.dark.home-page .level-card {
  border-color: transparent !important;
  color: #ffffff !important;
  background-color: transparent !important;
  background-image: none;
  box-shadow:
    0 22px 50px rgba(17, 24, 39, 0.22) !important;
}

body.dark.home-page .level-card.n1 {
  background:
    linear-gradient(
      135deg,
      #111827,
      #ec793b
    ) !important;
}

body.dark.home-page .level-card.n2 {
  background:
    linear-gradient(
      135deg,
      #7c3aed,
      #ec4899
    ) !important;
}

body.dark.home-page .level-card.n3 {
  background:
    linear-gradient(
      135deg,
      #2563eb,
      #06b6d4
    ) !important;
}

body.dark.home-page .level-card.n4 {
  background:
    linear-gradient(
      135deg,
      #16a34a,
      #22c55e
    ) !important;
}

body.dark.home-page .level-card.n5 {
  background:
    linear-gradient(
      135deg,
      #bde888,
      #a4ee81f8
    ) !important;
}

body.dark.home-page .level-card h3,
body.dark.home-page .level-card p,
body.dark.home-page .level-card .card-meta,
body.dark.home-page .level-card .card-top {
  color: #ffffff !important;
}

body.dark.home-page .level-card p,
body.dark.home-page .level-card .card-meta {
  color:
    rgba(255, 255, 255, 0.86) !important;
}

body.dark.home-page
  .level-card .card-top span {
  color: #ffffff !important;
  background:
    rgba(255, 255, 255, 0.20) !important;
}

body.dark.home-page
  .level-card .level-card-button,
body.dark.home-page
  .level-card button {
  border-color: transparent !important;
  background: #ffffff !important;
  color: #22223b !important;
}

/* =========================================================
   MENU ĐANG ĐƯỢC CHỌN — DÙNG CHUNG CHO CÁC MỤC TƯƠNG LAI
   ========================================================= */

.home-page .menu-item.is-selected {
  color: #1d4ed8 !important;
  background: #dbeafe !important;
  box-shadow:
    inset 0 0 0 1px
      rgba(59, 130, 246, 0.24),
    0 6px 16px
      rgba(37, 99, 235, 0.08);
}

.home-page
  .menu-item.is-selected:hover {
  color: #1d4ed8 !important;
  background: #bfdbfe !important;
}

body.dark.home-page
  .menu-item.is-selected {
  color: #e4efff !important;
  background: #324f80 !important;
  box-shadow:
    inset 0 0 0 1px
      rgba(138, 180, 255, 0.40),
    0 7px 18px
      rgba(19, 23, 29, 0.18);
}

body.dark.home-page
  .menu-item.is-selected:hover {
  color: #ffffff !important;
  background: #3b5d94 !important;
}

/* =========================================================
   CARD LUYỆN ĐỀ ĐƯỢC TRỎ TỪ SIDEBAR
   ========================================================= */

.learning-category-card.exam-category {
  scroll-margin-top: 110px;
}

.learning-category-card.is-linked-target {
  outline: 3px solid
    rgba(59, 130, 246, 0.64);
  outline-offset: 5px;

  box-shadow:
    0 0 0 9px
      rgba(59, 130, 246, 0.12),
    0 20px 44px
      rgba(37, 99, 235, 0.18) !important;

  animation:
    jlptPracticeCardPulse
    0.72s ease 2;
}

body.dark
  .learning-category-card.is-linked-target {
  outline-color:
    rgba(138, 180, 255, 0.82);

  box-shadow:
    0 0 0 9px
      rgba(138, 180, 255, 0.16),
    0 20px 44px
      rgba(19, 23, 29, 0.25) !important;
}

@keyframes jlptPracticeCardPulse {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}


/* =========================================================
   FIX 2026-07 — HOME SIDEBAR + HEADER ACTIONS
   ========================================================= */

/* Theme and notification buttons use the same surface palette as the header. */
body.home-page .top-actions > button.level-header-icon {
  border: 1px solid #dbe3ef !important;
  background: linear-gradient(145deg, #ffffff, #edf2f8) !important;
  color: #475569 !important;
  box-shadow:
    0 8px 17px rgba(49, 65, 95, 0.10),
    inset 1px 1px 0 rgba(255, 255, 255, 0.92) !important;
}

body.home-page .top-actions > button.level-header-icon:hover {
  border-color: #c4d0df !important;
  background: linear-gradient(145deg, #ffffff, #e6edf6) !important;
  color: #31507f !important;
}

html.dark body.home-page .top-actions > button.level-header-icon,
body.dark.home-page .top-actions > button.level-header-icon {
  border-color: var(--dark-border, #5c6470) !important;
  background: linear-gradient(145deg, #555c66, #454b54) !important;
  color: var(--dark-text, #f4f6f8) !important;
  box-shadow:
    0 9px 18px rgba(0, 0, 0, 0.18),
    inset 1px 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html.dark body.home-page .top-actions > button.level-header-icon:hover,
body.dark.home-page .top-actions > button.level-header-icon:hover {
  border-color: #778291 !important;
  background: linear-gradient(145deg, #626a75, #4d545e) !important;
  color: #ffffff !important;
}

@media (max-width: 1020px) {
  /* The off-canvas sidebar must stay above the shared topbar. */
  body.home-page .overlay {
    z-index: 1600 !important;
  }

  body.home-page .sidebar {
    z-index: 1700 !important;
  }

  body.home-page .topbar {
    z-index: 1200 !important;
  }

  body.home-page.sidebar-mobile-open {
    overflow: hidden;
  }

  body.home-page.sidebar-mobile-open .topbar {
    pointer-events: none;
  }

  /* Keep a dedicated hamburger inside the opened sidebar for closing it. */
  body.home-page .home-sidebar-toggle {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    z-index: 2 !important;

    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;

    display: grid !important;
    place-items: center !important;

    padding: 0 !important;
    border: 1px solid #d8dee8 !important;
    border-radius: 12px !important;

    color: #475569 !important;
    background: #ffffff !important;

    box-shadow:
      0 6px 14px rgba(15, 23, 42, 0.10) !important;

    cursor: pointer;
    flex: 0 0 44px;
  }

  body.home-page .home-sidebar-toggle svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }

  body.home-page .sidebar-header {
    gap: 12px;
  }

  html.dark body.home-page .home-sidebar-toggle,
  body.dark.home-page .home-sidebar-toggle {
    border-color: #626b77 !important;
    background: #505761 !important;
    color: #f4f6f8 !important;
  }
}

/* FIX 2026-07-06 — LEVEL HERO TEXT + SPLIT-SCREEN SIDEBAR SCROLL */
/* Badge level đã được xóa khỏi HTML; rule này là lớp bảo vệ cho cache/file cũ. */
.level-page-body .level-introduction-badge {
  display: none !important;
}

/* Chữ trên ảnh header N1–N5 luôn màu đen ở cả light và dark mode. */
.level-page-body .level-introduction h2,
.level-page-body .level-introduction p,
.level-page-body .level-information span,
html.dark body.level-page-body .level-introduction h2,
html.dark body.level-page-body .level-introduction p,
html.dark body.level-page-body .level-information span,
body.dark.level-page-body .level-introduction h2,
body.dark.level-page-body .level-introduction p,
body.dark.level-page-body .level-information span {
  color: #111827 !important;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.42);
}

html.dark body.level-page-body .level-introduction,
body.dark.level-page-body .level-introduction {
  filter: none !important;
}

html.dark body.level-page-body .level-information span,
body.dark.level-page-body .level-information span {
  border: 1px solid rgba(17, 24, 39, 0.12) !important;
  background: rgba(255, 255, 255, 0.58) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

@media (max-width: 1020px) {
  /* Sidebar là một cột cố định; chỉ menu bên trong cuộn. */
  body.home-page .sidebar {
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(100dvh - 28px) !important;
    overflow: hidden !important;
    overscroll-behavior: contain;
  }

  body.home-page .sidebar-header {
    flex: 0 0 auto !important;
  }

  body.home-page .sidebar-menu {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding-bottom: 24px !important;
    scrollbar-width: thin;
  }

  body.home-page .sidebar-menu::-webkit-scrollbar {
    width: 5px;
  }

  body.home-page .sidebar-menu::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.62);
  }
}

/* Kanji levels that have not been implemented yet. */
.home-page .sidebar-submenu a.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto;
}

.home-page .sidebar-submenu a.is-disabled:hover {
  transform: none;
  background: transparent;
}
