/* HSK Flashcards — custom styles on top of Tailwind */

html, body { height: 100%; }
body {
  overscroll-behavior-y: none;
  /* `manipulation` disables the browser's double-tap-to-zoom while keeping
     pan and pinch-scroll-on-element behaviour. Combined with the JS handlers
     in index.html this gives a locked, native-feeling zoom level. */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* iOS Safari auto-zooms when focusing an input whose font-size is < 16px.
   Force the minimum so the page never zooms in on tap-into-input either. */
input, textarea, select { font-size: 16px; }

/* Material Symbols default */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 24px;
  line-height: 1;
  user-select: none;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* Bottom nav items */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  color: #727687;
  transition: color 150ms ease, transform 150ms ease;
  text-decoration: none;
}
.nav-item:hover { color: #0066ff; }
.nav-item.active { color: #0066ff; }
.nav-item.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Flashcard 3D flip */
.card-3d-perspective { perspective: 1200px; }
.card-3d {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.4, 0.0, 0.2, 1);
  will-change: transform;
}
.card-3d.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 1.75rem;
  background: #ffffff;
  box-shadow: 0 20px 40px -12px rgba(0, 80, 203, 0.12);
  border: 1px solid #f2f3ff;
  display: flex;
  flex-direction: column;
}
.card-face.back { transform: rotateY(180deg); }

/* Swipe-out animations */
.swipe-out-left {
  transform: translateX(-150%) rotate(-15deg) !important;
  opacity: 0;
  transition: transform 350ms ease-in, opacity 350ms ease-in;
}
.swipe-out-right {
  transform: translateX(150%) rotate(15deg) !important;
  opacity: 0;
  transition: transform 350ms ease-in, opacity 350ms ease-in;
}

/* Decorative motif behind level cards */
.chinese-motif {
  user-select: none;
  pointer-events: none;
  opacity: 0.07;
  font-family: 'Noto Sans SC', sans-serif;
}

/* Subtle ring pulse for audio button */
@keyframes ring-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}
.ring-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid currentColor;
  animation: ring-pulse 1.2s ease-out infinite;
}

/* Progress ring */
.progress-ring { transform: rotate(-90deg); }
.progress-ring__track { stroke: #e6e7f4; }
.progress-ring__fill {
  stroke: #0066ff;
  transition: stroke-dashoffset 600ms ease;
  stroke-linecap: round;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #ecedfa 0%, #f5f5fb 50%, #ecedfa 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: 0.75rem;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.madmi-loader {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.5rem;
  background: #f5f6ff;
  color: #0066ff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.madmi-loader::before {
  content: '';
  position: absolute;
  inset: -0.35rem;
  border-radius: 1.8rem;
  border: 3px solid rgba(0, 102, 255, 0.12);
  border-top-color: #0066ff;
  animation: madmi-loader-spin 900ms linear infinite;
}
.madmi-loader::after {
  content: '';
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #db3237;
  box-shadow:
    -0.75rem 0.25rem 0 rgba(16, 185, 129, 0.9),
    -1.45rem -0.1rem 0 rgba(249, 115, 22, 0.9);
  animation: madmi-loader-dots 1.05s ease-in-out infinite;
}
.madmi-loader .material-symbols-outlined {
  font-size: 2rem;
  position: relative;
  z-index: 1;
}
.madmi-loader--compact {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
}
.madmi-loader--compact::before {
  inset: -0.2rem;
  border-width: 2px;
  border-radius: 1.05rem;
}
.madmi-loader--compact::after {
  right: 0.38rem;
  bottom: 0.38rem;
  width: 0.32rem;
  height: 0.32rem;
  box-shadow:
    -0.42rem 0.14rem 0 rgba(16, 185, 129, 0.9),
    -0.8rem -0.05rem 0 rgba(249, 115, 22, 0.9);
}
.madmi-loader--compact .material-symbols-outlined {
  font-size: 1.2rem;
}
@keyframes madmi-loader-spin {
  to { transform: rotate(360deg); }
}
@keyframes madmi-loader-dots {
  0%, 100% { transform: translateY(0); opacity: 0.75; }
  50% { transform: translateY(-0.2rem); opacity: 1; }
}

/* Scrollbar hidden */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Settings rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid #ecedfa;
}
.setting-row:last-child { border-bottom: none; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  /* Inside a flex .setting-row a long description can squeeze the toggle —
     pin a min-width and stop shrinking so the pill always renders fully. */
  flex-shrink: 0;
  min-width: 44px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #c2c6d8;
  border-radius: 999px;
  transition: background 200ms ease;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 999px;
  transition: transform 200ms ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.toggle input:checked + .slider { background: #0066ff; }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* Pill chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Hide bottom nav on focused full-screen experiences (e.g., card session) */
body.no-nav #bottom-nav { display: none; }
body.no-nav main#view { padding-bottom: 0; }

/* Subtle entrance animation for views */
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
#view > * { animation: view-in 250ms ease-out; }

/* Grammar is visible as a preview, but only admin accounts can enter it. */
.grammar-preview-card {
  isolation: isolate;
}
.grammar-preview-motif {
  position: absolute;
  right: -0.75rem;
  bottom: -2.25rem;
  z-index: 0;
  color: #10b981;
  font-size: 8rem;
  line-height: 1;
  opacity: 0.08;
  filter: blur(2px);
  pointer-events: none;
}
.grammar-coming-soon-page {
  position: relative;
  min-height: 36rem;
  padding: 1.5rem 1.25rem 2rem;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.grammar-coming-soon-preview {
  position: absolute;
  inset: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  opacity: 0.38;
  filter: blur(6px);
  pointer-events: none;
}
.grammar-preview-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.grammar-preview-block {
  min-height: 8.5rem;
  border: 1px solid #e6e7f4;
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 102, 255, 0.06);
}
.grammar-preview-block--large {
  min-height: 10rem;
  padding: 1.25rem;
}
.grammar-preview-block--large span {
  display: block;
  height: 0.75rem;
  margin-top: 0.75rem;
  border-radius: 999px;
  background: #e6e7f4;
}
.grammar-preview-block--large span:first-child {
  width: 30%;
  margin-top: 0;
  background: #a7f3d0;
}
.grammar-preview-block--large span:nth-child(2) { width: 78%; height: 1.5rem; }
.grammar-preview-block--large span:nth-child(3) { width: 100%; }
.grammar-preview-block--large span:nth-child(4) { width: 72%; }
.grammar-preview-block--short {
  min-height: 7rem;
}
.grammar-coming-soon-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 24rem;
  padding: 1.5rem;
  border: 1px solid #a7f3d0;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  text-align: center;
  backdrop-filter: blur(20px);
}
.grammar-coming-soon-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto;
  border-radius: 1.25rem;
  display: grid;
  place-items: center;
  background: #ecfdf5;
  color: #059669;
}
.grammar-coming-soon-icon .material-symbols-outlined {
  font-size: 2.125rem;
}
.grammar-coming-soon-label {
  margin-top: 1.25rem;
  color: #059669;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.grammar-coming-soon-card h1 {
  margin-top: 0.5rem;
  color: #191b24;
  font-family: Epilogue, Lexend, sans-serif;
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
}
.grammar-coming-soon-copy {
  margin-top: 0.5rem;
  color: #424656;
  font-size: 0.875rem;
  line-height: 1.5rem;
}
.grammar-coming-soon-back {
  min-height: 3rem;
  margin-top: 1.5rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0066ff;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px -4px rgba(0, 102, 255, 0.4);
}

/* Shared network failure state, including regional VPN guidance. */
.connection-error-page {
  min-height: 32rem;
  padding: 2rem 1.25rem;
  display: grid;
  place-items: center;
}
.connection-error-card {
  width: 100%;
  max-width: 24rem;
  padding: 1.5rem;
  border: 1px solid #fecaca;
  border-radius: 2rem;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.1);
}
.connection-error-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1.125rem;
  display: grid;
  place-items: center;
  background: #fef2f2;
  color: #ef4444;
}
.connection-error-icon .material-symbols-outlined {
  font-size: 1.75rem;
}
.connection-error-label {
  margin-top: 1.25rem;
  color: #dc2626;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.connection-error-card h1 {
  margin-top: 0.375rem;
  color: #191b24;
  font-family: Epilogue, Lexend, sans-serif;
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
}
.connection-error-message {
  margin-top: 0.5rem;
  color: #424656;
  font-size: 0.875rem;
  line-height: 1.5rem;
}
.connection-error-vpn {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid #bfdbfe;
  border-radius: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #eff6ff;
  color: #1d4ed8;
}
.connection-error-vpn > .material-symbols-outlined {
  flex: 0 0 auto;
  font-size: 1.375rem;
}
.connection-error-vpn strong {
  display: block;
  color: #1e3a8a;
  font-size: 0.875rem;
}
.connection-error-vpn p {
  margin-top: 0.25rem;
  color: #1e40af;
  font-size: 0.75rem;
  line-height: 1.25rem;
}
.connection-error-retry {
  width: 100%;
  min-height: 3rem;
  margin-top: 1.25rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #0066ff;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 20px -4px rgba(0, 102, 255, 0.4);
}

/* Big Chinese display tweaks */
.hanzi-xl {
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Hanzi writing course */
.hanzi-hero {
  background: linear-gradient(135deg, #0066ff 0%, #0050cb 100%);
  color: #ffffff;
}
.hanzi-hero::after {
  content: '';
  position: absolute;
  right: -0.7rem;
  bottom: -2.4rem;
  width: 8rem;
  height: 8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.hanzi-app-icon {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  flex-shrink: 0;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(0, 80, 203, 0.22);
}
.hanzi-grid-bg,
.hanzi-writer-target {
  background:
    linear-gradient(#db3237, #db3237) center / 1px 100% no-repeat,
    linear-gradient(90deg, #db3237, #db3237) center / 100% 1px no-repeat,
    linear-gradient(45deg, transparent 49.6%, rgba(219, 50, 55, 0.28) 50%, transparent 50.4%),
    linear-gradient(-45deg, transparent 49.6%, rgba(219, 50, 55, 0.28) 50%, transparent 50.4%);
}
.hanzi-grid-bg {
  border: 1.5px solid rgba(219, 50, 55, 0.4);
  background-color: #fffaf2;
}
.hanzi-filter {
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid #ecedfa;
  background: #ffffff;
  color: #727687;
  font-size: 12px;
  font-weight: 700;
  padding: 0.5rem 0.875rem;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.hanzi-filter.active {
  border-color: #0066ff;
  background: rgba(0, 102, 255, 0.08);
  color: #0066ff;
}
.hanzi-char-card {
  display: block;
  min-width: 0;
  border-radius: 1rem;
  border: 1px solid #ecedfa;
  background: #ffffff;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(0, 102, 255, 0.05);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.hanzi-char-card:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 102, 255, 0.35);
  box-shadow: 0 12px 28px rgba(0, 102, 255, 0.08);
}
.hanzi-char-card.completed {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06), #ffffff 42%);
}
.hanzi-check-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 6px 12px rgba(16, 185, 129, 0.24);
}
.hanzi-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: 999px;
  border: 1px solid #ecedfa;
  background: #ffffff;
  color: #727687;
  padding: 0.75rem 1rem;
  font-size: 13px;
  font-weight: 800;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.hanzi-tab.active {
  border-color: rgba(0, 102, 255, 0.4);
  background: rgba(0, 102, 255, 0.08);
  color: #0066ff;
}
.hanzi-tab.active.radical {
  border-color: rgba(219, 50, 55, 0.28);
  background: rgba(219, 50, 55, 0.08);
  color: #db3237;
}
.hanzi-writer-target {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgba(219, 50, 55, 0.6);
  border-radius: 1.25rem;
  background-color: #fffaf2;
  overflow: hidden;
}
.hanzi-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border-radius: 999px;
  border: 1px solid #ecedfa;
  background: #ffffff;
  color: #191b24;
  padding: 0.75rem 1rem;
  font-size: 13px;
  font-weight: 800;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.hanzi-control.primary {
  border-color: #0066ff;
  background: #0066ff;
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(0, 102, 255, 0.18);
}
.hanzi-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f5f6ff;
  color: #191b24;
  padding: 0.45rem 0.75rem;
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
}

/* Auth page */
.auth-shell {
  position: relative;
  isolation: isolate;
}
.auth-shell::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 22rem;
  background: none;
  pointer-events: none;
}
.auth-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.95;
  filter: blur(6px);
  animation: float-orb 9s ease-in-out infinite;
}
.auth-orb--one {
  top: 2rem;
  right: -3rem;
  width: 12rem;
  height: 12rem;
  background: radial-gradient(circle, rgba(250, 198, 56, 0.52), rgba(250, 198, 56, 0));
}
.auth-orb--two {
  top: 15rem;
  left: -2.25rem;
  width: 9rem;
  height: 9rem;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.35), rgba(0, 102, 255, 0));
  animation-delay: -3s;
}
.auth-hero {
  background:
    linear-gradient(140deg, #0057db 0%, #0a3d9e 58%, #191b24 100%);
}
.auth-stat-pill {
  display: flex;
  min-height: 4.5rem;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.12);
  padding: 0.75rem;
  backdrop-filter: blur(14px);
}
.auth-stat-pill strong {
  font-size: 1.05rem;
  line-height: 1.1;
}
.auth-stat-pill small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.76;
  text-transform: uppercase;
}
.auth-surface {
  position: relative;
}

/* Premium lock states */
.locked-level-card .level-card-content {
  filter: blur(1.8px);
  transform: scale(0.985);
  opacity: 0.82;
}
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem;
}
.lock-surface {
  position: relative;
  display: flex;
  min-height: calc(100% - 0.25rem);
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.lock-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.56), rgba(236, 237, 250, 0.2));
}
.lock-surface__halo {
  position: absolute;
  left: 50%;
  bottom: -30%;
  width: 8rem;
  height: 8rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.14), rgba(0, 102, 255, 0));
}
.lock-badge {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0066ff;
  box-shadow: 0 10px 22px rgba(0, 102, 255, 0.16);
}

/* HSK 7–9 "Mastery Tier" banner — visually distinct from HSK 1–6 cards.
   Soft cream-to-champagne gradient (very light, not a solid thick colour),
   big 九 motif, diagonal "Coming Soon" ribbon. Click is captured by JS and
   shows a toast — the link target is dummy. */
.hsk79-card {
  cursor: pointer;
  isolation: isolate;
}
.hsk79-bg {
  position: absolute;
  inset: 0;
  /* Very pale, mostly-white wash with the faintest hint of warm gold so it
     still reads as a special "tier" without being bold or heavy. */
  background: linear-gradient(135deg, #ffffff 0%, #fffbf2 45%, #fdf3da 80%, #f7e4b4 100%);
}
.hsk79-glow {
  position: absolute;
  inset: 0;
  /* Soft warm orbs in the corners to add depth without saturation. */
  background:
    radial-gradient(circle at 105% 110%, rgba(252, 211, 77, 0.30), transparent 55%),
    radial-gradient(circle at 0% 0%, rgba(167, 139, 250, 0.10), transparent 55%);
  pointer-events: none;
}
.hsk79-motif {
  position: absolute;
  right: -2.5rem;
  bottom: -3.5rem;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
  font-size: 14rem;
  line-height: 1;
  color: rgba(180, 132, 33, 0.14);
  transform: rotate(6deg);
  pointer-events: none;
  user-select: none;
}
.hsk79-ribbon {
  position: absolute;
  top: 18px;
  right: -42px;
  width: 160px;
  text-align: center;
  padding: 5px 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #5b3a07;
  background: linear-gradient(to right, #fef3c7, #fbbf24 55%, #f59e0b);
  transform: rotate(35deg);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25);
  z-index: 20;
}
.hsk79-card::after {
  /* Soft warm-toned inner border for a polished finish. */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(245, 158, 11, 0.22);
  z-index: 11;
}
.hsk79-card:hover .hsk79-glow {
  opacity: 1.15;
}
/* Smaller screens: shrink motif so it doesn't overflow */
@media (max-width: 380px) {
  .hsk79-motif { font-size: 11rem; right: -1.75rem; bottom: -3rem; }
  .hsk79-ribbon { right: -48px; font-size: 9px; }
}

/* Premium page */
.premium-hero-card {
  background: linear-gradient(145deg, #0057db 0%, #0a3d9e 50%, #171b2a 100%);
}
.premium-hero-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.92;
  filter: blur(8px);
}
.premium-hero-orb--one {
  top: -2rem;
  right: -3rem;
  width: 11rem;
  height: 11rem;
  background: radial-gradient(circle, rgba(250, 198, 56, 0.55), rgba(250, 198, 56, 0));
}
.premium-hero-orb--two {
  bottom: -2.5rem;
  left: -2rem;
  width: 9rem;
  height: 9rem;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
}
.premium-glass-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1.75rem;
  background: rgba(255, 255, 255, 0.84);
  padding: 1.25rem;
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.premium-glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.35), rgba(236, 237, 250, 0.1));
  pointer-events: none;
}
.premium-glass-card > * {
  position: relative;
  z-index: 1;
}
.premium-stat-card {
  display: flex;
  min-height: 4.25rem;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1.2rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.8rem;
}
.premium-stat-card strong {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  color: #191b24;
}
.premium-stat-card small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #727687;
  text-transform: uppercase;
}
.premium-step {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}
.premium-step__index {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 102, 255, 0.12);
  color: #0066ff;
  font-size: 0.78rem;
  font-weight: 700;
}
.premium-card-stage {
  position: relative;
  width: 9.5rem;
  height: 11.25rem;
}
.premium-card-stack {
  position: absolute;
  inset: 0;
}
.premium-card-stack--back {
}
.premium-card-stack--front {
}
.premium-mini-card {
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
  border-radius: 1.8rem;
  padding: 1.1rem;
  transform: translate3d(var(--tx), var(--ty), 0) rotate(var(--rot));
  box-shadow: 0 22px 45px rgba(9, 16, 40, 0.2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: premium-sway 5.8s ease-in-out infinite;
}
.premium-card-stack--back .premium-mini-card {
  --tx: -0.7rem;
  --ty: 0.7rem;
  --rot: -8deg;
  animation-delay: -2.2s;
}
.premium-card-stack--front .premium-mini-card {
  --tx: 0.65rem;
  --ty: -0.2rem;
  --rot: 6deg;
}
.premium-mini-card--glass {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08)),
    linear-gradient(145deg, rgba(0, 102, 255, 0.24), rgba(9, 61, 158, 0.34));
}
.premium-mini-card--violet {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08)),
    linear-gradient(145deg, rgba(155, 37, 171, 0.42), rgba(55, 68, 213, 0.28));
}
.premium-mini-card__eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.premium-mini-card strong {
  font-size: 1.45rem;
  line-height: 1.1;
  font-weight: 800;
  color: #ffffff;
}
.premium-mini-card small {
  display: block;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
}
.premium-benefit-card {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.9rem;
  align-items: flex-start;
  border-radius: 1.35rem;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.95rem;
}
.premium-benefit-icon {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(0, 102, 255, 0.12), rgba(0, 102, 255, 0.06));
  color: #0066ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.account-session-card {
  background: linear-gradient(135deg, #f8faff 0%, #eef3ff 100%);
}
.streak-summary-card {
  border-color: #fed7aa;
  background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%);
}
.streak-summary-icon {
  background: #ffffff;
}
.streak-summary-title {
  color: #7c2d12;
}
.streak-summary-copy {
  color: rgba(154, 52, 18, 0.7);
}

@keyframes float-orb {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, -12px, 0) scale(1.04); }
}
@keyframes premium-sway {
  0%, 100% { transform: translate3d(var(--tx), var(--ty), 0) rotate(var(--rot)); }
  25% { transform: translate3d(calc(var(--tx) - 6px), calc(var(--ty) - 5px), 0) rotate(calc(var(--rot) - 3deg)); }
  50% { transform: translate3d(calc(var(--tx) + 3px), calc(var(--ty) - 10px), 0) rotate(calc(var(--rot) + 2.5deg)); }
  75% { transform: translate3d(calc(var(--tx) + 7px), calc(var(--ty) - 4px), 0) rotate(calc(var(--rot) + 4deg)); }
}

/* Global dark mode. The app is built from static Tailwind utility classes,
   so this override layer maps the existing light tokens to dark surfaces. */
html.theme-dark,
body.theme-dark {
  background: #0b0f1a;
  color: #f5f7ff;
  color-scheme: dark;
}
body.theme-dark {
  background:
    radial-gradient(circle at 50% -12rem, rgba(0, 102, 255, 0.16), transparent 28rem),
    #0b0f1a;
}
.theme-dark #app,
.theme-dark .bg-surface {
  background-color: #0f1320 !important;
}
.theme-dark #app {
  border-color: #273049 !important;
}
.theme-dark #app-header,
.theme-dark .bg-surface\/90 {
  background-color: rgba(15, 19, 32, 0.9) !important;
}
.theme-dark #bottom-nav {
  background-color: rgba(23, 27, 42, 0.92) !important;
  border-color: #273049 !important;
}
.theme-dark .bg-white,
.theme-dark .bg-white\/90,
.theme-dark .bg-white\/95,
.theme-dark .card-face,
.theme-dark .auth-surface,
.theme-dark .premium-glass-card,
.theme-dark .premium-stat-card,
.theme-dark .premium-benefit-card {
  background-color: #171b2a !important;
  border-color: #273049 !important;
}
.theme-dark .bg-surface-container,
.theme-dark .bg-surface-container\/40,
.theme-dark .bg-surface-container\/50,
.theme-dark .bg-surface-container\/60,
.theme-dark .bg-surface\/70 {
  background-color: #22283b !important;
}
.theme-dark .bg-surface-container-high {
  background-color: #273049 !important;
}
.theme-dark .text-text-main,
.theme-dark .card-face,
.theme-dark .hanzi-control,
.theme-dark .hanzi-pill,
.theme-dark .premium-stat-card strong,
.theme-dark .text-text-main\/70 {
  color: #f5f7ff !important;
}
.theme-dark .text-text-sub {
  color: #c4cbdf !important;
}
.theme-dark .text-outline,
.theme-dark .placeholder\:text-outline::placeholder {
  color: #8f99b8 !important;
}
.theme-dark .border-surface-container,
.theme-dark .border-surface-container-high,
.theme-dark .border-outline-variant {
  border-color: #273049 !important;
}
.theme-dark .shadow-card,
.theme-dark .shadow-soft,
.theme-dark .shadow-button,
.theme-dark .shadow-2xl,
.theme-dark .shadow-lg {
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28) !important;
}
.theme-dark .setting-row {
  border-color: #273049;
}
.theme-dark input,
.theme-dark textarea,
.theme-dark select {
  background-color: #171b2a;
  color: #f5f7ff;
  border-color: #273049;
}
.theme-dark input::placeholder,
.theme-dark textarea::placeholder {
  color: #7d87a4;
}
.theme-dark .toggle .slider {
  background: #4b556f;
}
.theme-dark .toggle .slider::before {
  background: #f5f7ff;
}
.theme-dark .progress-ring__track {
  stroke: #273049;
}
.theme-dark .skeleton {
  background: linear-gradient(90deg, #1a2031 0%, #273049 50%, #1a2031 100%);
  background-size: 200% 100%;
}
.theme-dark .madmi-loader {
  background: #171b2a;
}
.theme-dark .madmi-loader::before {
  border-color: rgba(77, 148, 255, 0.18);
  border-top-color: #4d94ff;
}
.theme-dark .grammar-preview-block,
.theme-dark .grammar-coming-soon-card,
.theme-dark .connection-error-card {
  background: rgba(23, 27, 42, 0.96);
  border-color: #273049;
}
.theme-dark .grammar-preview-block--large span {
  background: #273049;
}
.theme-dark .grammar-preview-block--large span:first-child {
  background: #065f46;
}
.theme-dark .grammar-coming-soon-card h1,
.theme-dark .connection-error-card h1 {
  color: #f5f7ff;
}
.theme-dark .grammar-coming-soon-copy,
.theme-dark .connection-error-message {
  color: #c4cbdf;
}
.theme-dark .grammar-coming-soon-icon {
  background: rgba(5, 150, 105, 0.16);
}
.theme-dark .connection-error-icon {
  background: rgba(239, 68, 68, 0.14);
}
.theme-dark .connection-error-vpn {
  border-color: #1e3a8a;
  background: rgba(30, 64, 175, 0.18);
}
.theme-dark .connection-error-vpn strong {
  color: #bfdbfe;
}
.theme-dark .connection-error-vpn p {
  color: #93c5fd;
}
.theme-dark .nav-item {
  color: #8f99b8;
}
.theme-dark .nav-item:hover,
.theme-dark .nav-item.active {
  color: #4d94ff;
}
.theme-dark .hanzi-char-card,
.theme-dark .hanzi-filter,
.theme-dark .hanzi-tab,
.theme-dark .hanzi-control,
.theme-dark .hanzi-pill {
  background: #171b2a;
  border-color: #273049;
}
.theme-dark .hanzi-char-card.completed {
  border-color: rgba(52, 211, 153, 0.42);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.14), #171b2a 48%);
}
.theme-dark .hanzi-filter.active,
.theme-dark .hanzi-tab.active {
  background: rgba(77, 148, 255, 0.13);
  border-color: rgba(77, 148, 255, 0.42);
}
.theme-dark .hanzi-tab.active.radical {
  background: rgba(255, 94, 99, 0.14);
  border-color: rgba(255, 94, 99, 0.36);
}
.theme-dark .hanzi-grid-bg,
.theme-dark .hanzi-writer-target {
  background:
    linear-gradient(#ff5e63, #ff5e63) center / 1px 100% no-repeat,
    linear-gradient(90deg, #ff5e63, #ff5e63) center / 100% 1px no-repeat,
    linear-gradient(45deg, transparent 49.6%, rgba(255, 94, 99, 0.26) 50%, transparent 50.4%),
    linear-gradient(-45deg, transparent 49.6%, rgba(255, 94, 99, 0.26) 50%, transparent 50.4%);
  background-color: #111725;
  border-color: rgba(255, 94, 99, 0.52);
}
.theme-dark .bg-red-50 {
  background-color: rgba(219, 50, 55, 0.14) !important;
}
.theme-dark .\!bg-red-50 {
  background-color: rgba(219, 50, 55, 0.14) !important;
}
.theme-dark .hover\:bg-red-50:hover,
.theme-dark .hover\:bg-red-100:hover {
  background-color: rgba(219, 50, 55, 0.22) !important;
}
.theme-dark .bg-rose-50,
.theme-dark .bg-rose-100 {
  background-color: rgba(244, 63, 94, 0.14) !important;
}
.theme-dark .bg-indigo-50,
.theme-dark .bg-indigo-100 {
  background-color: rgba(99, 102, 241, 0.16) !important;
}
.theme-dark .bg-blue-50,
.theme-dark .bg-blue-100,
.theme-dark .bg-cyan-50,
.theme-dark .bg-cyan-100,
.theme-dark .bg-primary-soft {
  background-color: rgba(77, 148, 255, 0.15) !important;
}
.theme-dark .bg-orange-50,
.theme-dark .bg-orange-100,
.theme-dark .bg-amber-50,
.theme-dark .bg-amber-100,
.theme-dark .bg-yellow-50,
.theme-dark .bg-yellow-100 {
  background-color: rgba(249, 115, 22, 0.15) !important;
}
.theme-dark .bg-purple-50,
.theme-dark .bg-purple-100,
.theme-dark .bg-pink-50,
.theme-dark .bg-pink-100 {
  background-color: rgba(168, 85, 247, 0.16) !important;
}
.theme-dark .bg-green-50,
.theme-dark .bg-green-100,
.theme-dark .bg-teal-50,
.theme-dark .bg-teal-100,
.theme-dark .bg-emerald-50,
.theme-dark .bg-emerald-100,
.theme-dark .\!bg-emerald-50 {
  background-color: rgba(16, 185, 129, 0.14) !important;
}
.theme-dark .bg-amber-200\/60,
.theme-dark .bg-emerald-200\/60 {
  background-color: rgba(39, 48, 73, 0.82) !important;
}
.theme-dark .bg-primary\/5,
.theme-dark .bg-primary\/10 {
  background-color: rgba(77, 148, 255, 0.14) !important;
}
.theme-dark .border-orange-100,
.theme-dark .border-amber-200,
.theme-dark .border-emerald-200,
.theme-dark .border-indigo-200,
.theme-dark .border-indigo-300,
.theme-dark .border-red-100,
.theme-dark .border-rose-200 {
  border-color: #273049 !important;
}
.theme-dark .account-session-card {
  background: linear-gradient(135deg, #20263a 0%, #171b2a 100%) !important;
  border: 1px solid #2d3652;
}
.theme-dark .streak-summary-card {
  background: #171b2a !important;
  border-color: #273049 !important;
}
.theme-dark .streak-summary-icon {
  background: #0f1320 !important;
}
.theme-dark .streak-summary-title {
  color: #f5f7ff !important;
}
.theme-dark .streak-summary-copy {
  color: #c4cbdf !important;
}
.theme-dark .hsk79-bg {
  background: linear-gradient(135deg, #171b2a 0%, #202337 52%, #302a1f 100%);
}
.theme-dark .hsk79-card::after {
  border-color: rgba(245, 158, 11, 0.28);
}
.theme-dark .lock-surface {
  border-color: rgba(39, 48, 73, 0.9);
  background: rgba(23, 27, 42, 0.72);
}
.theme-dark .lock-surface::before {
  background: linear-gradient(145deg, rgba(39, 48, 73, 0.62), rgba(15, 19, 32, 0.26));
}
.theme-dark .lock-badge {
  background: #22283b;
}
.theme-dark .premium-card-stack .premium-mini-card,
.theme-dark .auth-stat-pill {
  border-color: rgba(255, 255, 255, 0.12);
}
