:root {
  --background: #F8F7F3;
  --foreground: #0D0C0A;
  --card: #FFFFFF;
  --card-foreground: #0D0C0A;
  --primary: #C41E0E;
  --primary-foreground: #FFFFFF;
  --secondary: #F0EDE6;
  --secondary-foreground: #0D0C0A;
  --muted: #E8E5DE;
  --muted-foreground: #6B6760;
  --accent: #C41E0E;
  --accent-foreground: #FFFFFF;
  --border: #E0DDD6;
  --ring: #C41E0E;
  --radius: 10px;
  --success: #16A34A;
  --warning: #D97706;
}

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

html, body {
  height: 100%;
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  line-height: 1.2;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hanzi {
  font-family: "Noto Serif SC", "Songti SC", "STSong", SimSun, serif;
  font-weight: 600;
}

::-webkit-scrollbar {
  display: none;
}

* {
  scrollbar-width: none;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.app-shell {
  max-width: 512px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--background);
  position: relative;
}

.page-content {
  padding-bottom: 88px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius);
  padding: 12px 16px;
  transition: opacity 150ms, transform 150ms, background-color 150ms;
  min-height: 44px;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover {
  opacity: 0.9;
}

.btn-dark {
  background-color: var(--foreground);
  color: var(--background);
  width: 100%;
  padding: 16px;
}

.btn-dark:hover {
  opacity: 0.9;
}

.btn-danger-outline {
  width: 100%;
  padding: 16px;
  background-color: var(--card);
  border: 1px solid #fecaca;
  color: #ef4444;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}

.btn-danger-outline:hover {
  background-color: #fef2f2;
}

/* ---------- Cards ---------- */

.card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 8px);
}

/* ---------- Forms ---------- */

.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--primary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 14px;
  transition: box-shadow 150ms, border-color 150ms;
}

.form-input::placeholder {
  color: var(--muted-foreground);
}

.form-input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(196, 30, 14, 0.15);
}

.form-input.hanzi-input {
  font-family: "Noto Serif SC", "Songti SC", "STSong", SimSun, serif;
  font-size: 22px;
  font-weight: 600;
}

.form-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
}

.error-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.error-box p {
  color: #dc2626;
  font-size: 14px;
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background-color: var(--secondary);
  border-radius: var(--radius);
}

.info-box p {
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 96px;
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--foreground);
  color: var(--background);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  z-index: 50;
  animation: toast-in 200ms ease-out;
}

.toast-error {
  background-color: #dc2626;
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- State badges ---------- */

.state-badge {
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  border-radius: 999px;
  white-space: nowrap;
}

.state-badge-sm {
  font-size: 10px;
  padding: 2px 6px;
}

.state-badge-md {
  font-size: 12px;
  padding: 2px 8px;
}

.state-badge-New { background-color: #dbeafe; color: #1d4ed8; }
.state-badge-Learning { background-color: #fef3c7; color: #b45309; }
.state-badge-Review { background-color: #dcfce7; color: #15803d; }
.state-badge-Relearning { background-color: #fee2e2; color: #b91c1c; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: flex;
  max-width: 512px;
  margin: 0 auto;
  height: 64px;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.bottom-nav-item:hover {
  color: var(--foreground);
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #ff4d4d);
  border-radius: 0 0 999px 999px;
  box-shadow: 0 2px 8px rgba(196, 30, 14, 0.4);
}

.bottom-nav-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}

.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: linear-gradient(135deg, var(--primary), #e62817);
  color: var(--primary-foreground);
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(196, 30, 14, 0.35);
  border: 1.5px solid #fff;
}

@media (max-width: 380px) {
  .bottom-nav-item {
    gap: 2px;
    font-size: 10px;
  }

  .bottom-nav-icon {
    width: 20px;
    height: 20px;
  }
}

/* ---------- Countdown ---------- */

.countdown-text {
  font-size: 12px;
  font-weight: 500;
}

.countdown-now {
  color: var(--primary);
}

.countdown-later {
  color: var(--muted-foreground);
}

/* ---------- Error pages ---------- */

.error-page {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 8px;
}

.error-hanzi {
  font-size: 64px;
  color: rgba(107, 103, 96, 0.3);
  margin-bottom: 8px;
}

.error-page h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.error-page p {
  color: var(--muted-foreground);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------- Landing page ---------- */

/* ---------- Animated Background Elements ---------- */
.landing-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--background);
  position: relative;
  overflow-x: hidden;
}

.landing-bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  opacity: 0.6;
}

.glow-1 {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, #ff7b7b, #c41e0e);
  top: -100px;
  left: -100px;
  animation: float-glow 8s ease-in-out infinite alternate;
}

.glow-2 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #f0ede6, #ffd5d5);
  bottom: 20%;
  right: -150px;
  animation: float-glow 12s ease-in-out infinite alternate-reverse;
}

.glow-3 {
  width: 250px;
  height: 250px;
  background: linear-gradient(135deg, #ffb3b3, #ffffff);
  top: 40%;
  left: 20%;
  animation: float-glow 10s ease-in-out infinite alternate;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 40px) scale(1.1); }
}

.landing-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---------- Typography & Hero ---------- */
.landing-hero {
  flex-shrink: 0;
  padding: 120px 24px 60px;
  text-align: center;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), #ff4d4d);
  color: white;
  border-radius: 20px;
  font-size: 36px;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px rgba(196, 30, 14, 0.4);
}

.pulse-animation {
  animation: pulse-logo 2.5s infinite;
}

@keyframes pulse-logo {
  0% { box-shadow: 0 0 0 0 rgba(196, 30, 14, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(196, 30, 14, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 30, 14, 0); }
}

.landing-title {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.text-gradient {
  background: linear-gradient(to right, #0D0C0A, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  color: var(--muted-foreground);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 40px;
  max-width: 80%;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ---------- CTAs ---------- */
.landing-cta {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 320px;
  margin: 0 auto;
}

.landing-btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-glow {
  background: linear-gradient(135deg, var(--primary), #e62817);
  box-shadow: 0 8px 20px rgba(196, 30, 14, 0.3);
}

.btn-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(196, 30, 14, 0.4);
  opacity: 1;
}

.landing-btn-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--foreground);
}

.landing-btn-glass:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}

/* ---------- Features & Landing Sections (Glassmorphism) ---------- */
.landing-section-header {
  text-align: center;
  margin-bottom: 24px;
}

.section-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary);
  background: rgba(196, 30, 14, 0.08);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--foreground);
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.section-desc {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

/* Video Section */
.landing-video-section {
  padding: 0 24px 48px;
}

.video-container-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.05);
  margin-bottom: 24px;
  transition: all 0.3s ease;
}

.video-container-card:hover {
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.video-responsive {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  background: #000;
}

.video-responsive iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-caption-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  background: rgba(240, 237, 230, 0.7);
  border-top: 1px solid rgba(224, 221, 214, 0.7);
}

.video-caption-bar svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* Repetition Cards Grid */
.repetition-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rep-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 20px;
}

.rep-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

.icon-red { background: rgba(239, 68, 68, 0.1); }
.icon-amber { background: rgba(245, 158, 11, 0.1); }
.icon-green { background: rgba(34, 197, 94, 0.1); }

.rep-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 6px;
}

.rep-card p {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* Steps Section */
.landing-steps-section {
  padding: 0 24px 48px;
}

.steps-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px 20px 20px;
}

.step-badge {
  display: inline-block;
  width: fit-content;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  background: rgba(196, 30, 14, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.step-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 6px;
}

.step-card p {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* Features Grid */
.landing-features {
  padding: 0 24px 48px;
}

.features-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.glass-card {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.8);
}

.icon-glow {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(196,30,14,0.1), rgba(196,30,14,0.05));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}

.landing-feature h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--foreground);
}

.landing-feature p {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* Bottom CTA Banner */
.landing-bottom-cta {
  padding: 0 24px 48px;
}

.bottom-cta-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 237, 230, 0.85));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 26px;
  padding: 36px 24px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(196, 30, 14, 0.08);
}

.bottom-cta-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--foreground);
  margin-bottom: 8px;
  letter-spacing: -0.4px;
}

.bottom-cta-sub {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Footer */
.landing-footer {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
  border-top: 1px solid rgba(224, 221, 214, 0.6);
  background: rgba(248, 247, 243, 0.6);
}

/* ---------- Animations ---------- */
.animate-fade-in {
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-up {
  opacity: 0;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Floating Decorations ---------- */
.floating-deco {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.floating-deco .hanzi {
  position: absolute;
  font-size: 80px;
  color: rgba(196, 30, 14, 0.04);
  font-weight: 800;
}

.float-1 { top: 10%; left: 5%; animation: floatY 15s ease-in-out infinite; transform: rotate(-15deg); }
.float-2 { top: 30%; right: -5%; font-size: 120px !important; animation: floatY 20s ease-in-out infinite reverse; transform: rotate(10deg); }
.float-3 { bottom: 25%; left: -10%; font-size: 150px !important; animation: floatY 25s ease-in-out infinite; transform: rotate(20deg); }
.float-4 { bottom: 10%; right: 10%; font-size: 60px !important; animation: floatY 18s ease-in-out infinite reverse; transform: rotate(-5deg); }

@keyframes floatY {
  0% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-30px) rotate(5deg); }
  100% { transform: translateY(0) rotate(0); }
}

/* ---------- Responsive ---------- */

@media (min-width: 768px) {
  .app-shell {
    max-width: 640px;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    max-width: 720px;
  }
}
