/* HSK1 with Panpan — kid-friendly theme */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Sarabun:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@500;700;900&display=swap');

:root {
  --coral: #ff6b6b;
  --coral-dark: #ee5253;
  --yellow: #ffd166;
  --yellow-dark: #f4b400;
  --sky: #4ecdc4;
  --sky-dark: #2eb5ab;
  --purple: #a685e2;
  --cream: #fffdf7;
  --cream-soft: #fff6e5;
  --ink: #3a3042;
  --ink-soft: #6b6275;
  --gray-light: #efe9de;
  --border: #eee3d0;
  --green: #4caf82;
  --white: #ffffff;

  --shadow-sm: 0 2px 6px rgba(58,48,66,0.08);
  --shadow-md: 0 6px 20px rgba(58,48,66,0.12);
  --shadow-lg: 0 12px 36px rgba(58,48,66,0.16);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: 0.22s ease;

  --font: 'Sarabun', sans-serif;
  --font-display: 'Baloo 2', 'Sarabun', sans-serif;
  --font-cn: 'Noto Sans SC', sans-serif;
  --container: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.25; }
.cn { font-family: var(--font-cn); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.text-center { text-align: center; }
.d-none { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: 999px; border: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--coral); color: var(--white); }
.btn-primary:hover { background: var(--coral-dark); }
.btn-secondary { background: var(--sky); color: var(--white); }
.btn-secondary:hover { background: var(--sky-dark); }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-yellow:hover { background: var(--yellow-dark); }
.btn-outline { background: transparent; color: var(--coral); border: 2px solid var(--coral); box-shadow: none; }
.btn-outline:hover { background: var(--coral); color: var(--white); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 18px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

/* ── Navbar ──────────────────────────────────────────────────────── */
.navbar {
  background: var(--white); border-bottom: 3px solid var(--yellow);
  position: sticky; top: 0; z-index: 100;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; }
.navbar-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; color: var(--coral); }
.navbar-brand .mascot-mini { width: 40px; height: 40px; }
.navbar-nav { display: flex; align-items: center; gap: 22px; font-weight: 600; }
.navbar-nav a { color: var(--ink-soft); transition: color var(--transition); }
.navbar-nav a:hover, .navbar-nav a.active { color: var(--coral); }
.lang-switch { display: flex; gap: 6px; }
.lang-switch a { padding: 4px 10px; border-radius: 999px; background: var(--gray-light); font-size: 0.85rem; font-weight: 700; }
.lang-switch a.active { background: var(--sky); color: var(--white); }
.navbar-toggle { display: none; background: none; border: none; font-size: 1.6rem; color: var(--ink); }

@media (max-width: 820px) {
  .navbar-nav { position: absolute; top: 100%; left: 0; right: 0; background: var(--white);
    flex-direction: column; align-items: flex-start; padding: 16px 20px; gap: 14px;
    box-shadow: var(--shadow-md); display: none; }
  .navbar-nav.open { display: flex; }
  .navbar-toggle { display: block; }
}

/* ── Hero ────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, var(--yellow) 0%, var(--coral) 100%);
  color: var(--white); padding: 60px 0 80px; position: relative; overflow: hidden;
}
.hero .container { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.hero-text { flex: 1 1 340px; }
.hero-text h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 14px; text-shadow: 0 2px 0 rgba(0,0,0,0.08); }
.hero-text p { font-size: 1.05rem; margin-bottom: 26px; opacity: 0.95; }
.hero-mascot { flex: 1 1 260px; max-width: 320px; margin: 0 auto; }

/* ── Section headings ───────────────────────────────────────────── */
.section { padding: 56px 0; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.section-heading h2 { font-size: 1.6rem; color: var(--ink); }
.section-heading::before { content: ''; width: 8px; height: 32px; background: var(--sky); border-radius: 4px; }

/* ── Course picker ───────────────────────────────────────────────── */
.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.course-card {
  background: var(--white); border-radius: var(--radius-lg); padding: 30px;
  box-shadow: var(--shadow-sm); border: 2px solid var(--border); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--sky); }
.course-card-badge {
  font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; color: var(--white);
  background: var(--coral); padding: 8px 26px; border-radius: 999px;
}
.course-card-desc { color: var(--ink-soft); font-size: 0.95rem; min-height: 44px; }
.course-card-progress { width: 100%; }
.course-card-progress-bar { width: 100%; height: 10px; background: var(--gray-light); border-radius: 999px; overflow: hidden; }
.course-card-progress-bar span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.course-card-progress-label { font-size: 0.8rem; color: var(--ink-soft); margin-top: 6px; }

/* ── Roadmap / day grid ─────────────────────────────────────────── */
.roadmap-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px;
}
.day-card {
  background: var(--white); border-radius: var(--radius-md); padding: 18px 14px;
  text-align: center; box-shadow: var(--shadow-sm); border: 2px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
}
.day-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.day-card .day-num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; color: var(--coral); }
.day-card .day-title { font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; min-height: 34px; }
.day-card.is-review { border-color: var(--purple); background: #f6f1ff; }
.day-card.is-exam { border-color: var(--coral); background: #fff0ee; }
.day-card.is-completed { border-color: var(--green); }
.day-card.is-completed::after { content: '✓'; position: absolute; top: -10px; right: -10px;
  width: 28px; height: 28px; background: var(--green); color: var(--white); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; box-shadow: var(--shadow-sm); }
.day-card.is-locked { opacity: 0.55; filter: grayscale(0.4); pointer-events: none; }
.day-card .badge { display: inline-block; margin-top: 6px; font-size: 0.7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: var(--yellow); color: var(--ink); }

/* ── Flashcards ──────────────────────────────────────────────────── */
.flashcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.flashcard {
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  border: 2px solid var(--border); padding: 22px 16px; text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.flashcard:hover { transform: translateY(-4px) rotate(-1deg); box-shadow: var(--shadow-md); }
.flashcard .icon-wrap { width: 84px; height: 84px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center;
  background: var(--cream-soft); border-radius: 50%; }
.flashcard .icon-wrap svg { width: 56px; height: 56px; }
.flashcard .hanzi { font-family: var(--font-cn); font-size: 2.1rem; font-weight: 700; color: var(--ink); }
.flashcard .pinyin { color: var(--sky-dark); font-weight: 600; margin: 4px 0; }
.flashcard .meaning { font-size: 0.9rem; color: var(--ink-soft); margin-top: 10px; justify-content: center; }
.flashcard .meaning .en { display: block; font-style: italic; opacity: 0.85; }
.flashcard .listen-btn {
  margin-top: 6px; background: var(--yellow); border: none; border-radius: 999px;
  width: 36px; height: 36px; font-size: 1rem; box-shadow: var(--shadow-sm);
}
.flashcard .listen-btn:hover { background: var(--yellow-dark); }
.flashcard .example { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 0.82rem; color: var(--ink-soft); }
.listen-btn-sm { flex-shrink: 0; background: var(--yellow); border: none; border-radius: 999px;
  width: 24px; height: 24px; font-size: 0.75rem; box-shadow: none; padding: 0; line-height: 1; }
.listen-btn-sm:hover { background: var(--yellow-dark); }

/* ── Grammar box ─────────────────────────────────────────────────── */
.grammar-box { background: var(--white); border-radius: var(--radius-md); padding: 26px; box-shadow: var(--shadow-sm); border-left: 6px solid var(--sky); }
.grammar-box h3 { color: var(--sky-dark); margin-bottom: 10px; }
.grammar-examples { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.grammar-example { background: var(--cream-soft); border-radius: var(--radius-sm); padding: 12px 16px; }
.grammar-example .cn { font-size: 1.2rem; font-weight: 700; }
.grammar-example .pinyin { color: var(--sky-dark); font-size: 0.9rem; }
.grammar-example .tr { font-size: 0.85rem; color: var(--ink-soft); margin-top: 2px; }

/* ── Lesson intro / mascot bubble ───────────────────────────────── */
.mascot-intro { display: flex; align-items: flex-start; gap: 16px; background: var(--white);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 30px; }
.mascot-intro .mascot-icon { width: 72px; flex-shrink: 0; }
.speech-bubble { background: var(--cream-soft); border-radius: var(--radius-md); padding: 14px 18px; position: relative; flex: 1; }

/* ── Quiz ────────────────────────────────────────────────────────── */
.quiz-question { background: var(--white); border-radius: var(--radius-md); padding: 22px; box-shadow: var(--shadow-sm);
  margin-bottom: 20px; border: 2px solid var(--border); }
.quiz-question .qnum { display: inline-block; background: var(--sky); color: var(--white); font-weight: 700;
  border-radius: 999px; width: 28px; height: 28px; text-align: center; line-height: 28px; margin-right: 8px; }
.quiz-question .qtext { font-size: 1.1rem; font-weight: 600; margin: 10px 0 16px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.quiz-option { display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--cream-soft); border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; font-weight: 600; transition: all var(--transition); }
.quiz-option:hover { border-color: var(--sky); }
.quiz-option input { display: none; }
.quiz-option input:checked + span { color: var(--coral); }
.quiz-option.selected { border-color: var(--coral); background: #fff0ee; }
.quiz-option.correct { border-color: var(--green); background: #eafaf1; }
.quiz-option.wrong { border-color: var(--coral-dark); background: #ffe8e6; }
.quiz-fill input[type=text] { width: 100%; padding: 10px 14px; border-radius: var(--radius-sm); border: 2px solid var(--border); font-size: 1rem; }
.quiz-result { text-align: center; background: var(--white); border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow-md); }
.quiz-result .score { font-family: var(--font-display); font-size: 3rem; color: var(--coral); font-weight: 800; }

/* ── Forms ───────────────────────────────────────────────────────── */
.auth-wrap { max-width: 440px; margin: 60px auto; background: var(--white); border-radius: var(--radius-lg);
  padding: 36px; box-shadow: var(--shadow-md); }
.auth-wrap h1 { text-align: center; margin-bottom: 24px; color: var(--coral); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
.form-group input { width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 2px solid var(--border);
  font-size: 1rem; font-family: var(--font); transition: border-color var(--transition); }
.form-group input:focus { outline: none; border-color: var(--sky); }
.form-error { background: #ffe8e6; color: var(--coral-dark); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; }
.form-success { background: #eafaf1; color: #2f8a5f; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 0.9rem; color: var(--ink-soft); }
.auth-switch a { color: var(--sky-dark); font-weight: 700; }

/* ── Account dashboard ──────────────────────────────────────────── */
.account-layout { display: flex; gap: 30px; align-items: flex-start; flex-wrap: wrap; }
.account-sidebar { flex: 0 0 220px; background: var(--white); border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-sm); }
.account-sidebar .avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--yellow); margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 800; color: var(--white); }
.account-nav { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.account-nav a { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600; color: var(--ink-soft); }
.account-nav a.active, .account-nav a:hover { background: var(--cream-soft); color: var(--coral); }
.account-content { flex: 1 1 460px; }
.progress-stats { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-pill { background: var(--white); border-radius: var(--radius-md); padding: 16px 22px; box-shadow: var(--shadow-sm); text-align: center; }
.stat-pill .num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; color: var(--sky-dark); }
.stat-pill .label { font-size: 0.8rem; color: var(--ink-soft); }
table.quiz-history { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
table.quiz-history th, table.quiz-history td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
table.quiz-history th { background: var(--cream-soft); font-family: var(--font-display); }

/* ── Worksheet ───────────────────────────────────────────────────── */
.worksheet-header { text-align: center; margin-bottom: 30px; }
.tracing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; margin: 12px 0 20px; }
.tracing-box { aspect-ratio: 1; border: 2px solid var(--ink-soft); position: relative; background: var(--white); border-radius: 6px; }
.tracing-box::before, .tracing-box::after { content: ''; position: absolute; background: var(--border); }
.tracing-box::before { top: 0; bottom: 0; left: 50%; width: 1px; }
.tracing-box::after { left: 0; right: 0; top: 50%; height: 1px; }
.tracing-box .ghost { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-cn); font-size: 2.4rem; color: var(--border); z-index: 0; }
.tracing-box svg { width: 100%; height: 100%; position: relative; z-index: 1; }
.stroke-practice-block { margin-bottom: 22px; }
.stroke-step-label { font-size: 0.8rem; color: var(--ink-soft); margin: 10px 0 6px; font-weight: 600; }
.match-row { display: flex; align-items: center; justify-content: space-between; background: var(--white); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer { background: var(--ink); color: rgba(255,255,255,0.8); padding: 34px 0; text-align: center; margin-top: 60px; font-size: 0.9rem; }
.site-footer .mascot-mini { width: 46px; margin: 0 auto 10px; }

@media (max-width: 600px) {
  .account-layout { flex-direction: column; }
  .account-sidebar { width: 100%; }
}
