/* ===========================
   HANZIHOC - STYLESHEET
   =========================== */

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

:root {
  --red:       #E24B4A;
  --red-light: #FEF0F0;
  --red-dark:  #791F1F;
  --teal:      #1D9E75;
  --teal-light:#E1F5EE;
  --teal-dark: #085041;
  --amber:     #BA7517;
  --amber-light:#FEF4E0;
  --gray-bg:   #F8F7F4;
  --gray-border:#E5E3DC;
  --card-bg:   #ffffff;
  --text:      #1A1A1A;
  --text-muted:#6B6B6B;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow:    0 1px 4px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- NAV ---- */
.nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--gray-border);
  height: 52px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo { font-size: 20px; font-weight: 600; color: var(--red); letter-spacing: -0.5px; }
.nav-logo span { color: var(--text); }
.nav-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--red-light); color: var(--red-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.logout-btn {
  background: none; border: 1px solid var(--gray-border);
  border-radius: 6px; padding: 4px 10px; font-size: 12px;
  cursor: pointer; color: var(--text-muted);
}
.logout-btn:hover { background: var(--gray-bg); }

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: calc(100vh - 52px); }

/* ---- SIDEBAR ---- */
.sidebar {
  width: 210px;
  background: var(--card-bg);
  border-right: 1px solid var(--gray-border);
  padding: 1.25rem 0;
  flex-shrink: 0;
}
.sidebar-section {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem 0.4rem;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 1.25rem;
  cursor: pointer; font-size: 14px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.sidebar-item:hover { background: var(--gray-bg); color: var(--text); }
.sidebar-item.active {
  background: var(--red-light);
  color: var(--red-dark);
  border-left-color: var(--red);
  font-weight: 500;
}
.si-icon { font-size: 16px; }

/* ---- MAIN ---- */
.main {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  padding-bottom: 80px;
}

/* ---- SCREENS ---- */
.screen { display: none; }
.screen.active { display: block; }

/* ---- LOGIN ---- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: var(--gray-bg);
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 36px; font-weight: 700; color: var(--red); text-align: center; margin-bottom: 6px; }
.login-logo span { color: var(--text); }
.login-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 5px; }
.form-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius); font-size: 14px;
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--red); }
.form-error { font-size: 12px; color: var(--red); padding: 6px 10px; background: var(--red-light); border-radius: 6px; margin-bottom: 10px; }
.btn-primary {
  width: 100%; padding: 11px;
  background: var(--red); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
  width: 100%; padding: 11px;
  background: none; color: var(--text);
  border: 1px solid var(--gray-border); border-radius: var(--radius);
  font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { background: var(--gray-bg); }
.login-switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 1rem; }
.login-switch a { color: var(--red); cursor: pointer; text-decoration: underline; }

/* ---- STATS ROW ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-value.red { color: var(--red); }
.stat-value.teal { color: var(--teal); }

/* ---- GREETING ---- */
.page-greeting { margin-bottom: 1.5rem; }
.greeting-text { font-size: 20px; font-weight: 600; }
.greeting-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ---- SECTION ---- */
.section-title { font-size: 15px; font-weight: 500; margin-bottom: 1rem; }
.screen-title { font-size: 17px; font-weight: 600; }
.screen-header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 1.25rem;
}

/* ---- TOPIC CARDS ---- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px; margin-bottom: 1.5rem;
}
.topic-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  cursor: pointer; transition: all 0.15s;
}
.topic-card:hover { border-color: var(--red); box-shadow: 0 2px 10px rgba(226,75,74,0.12); }
.tc-icon { font-size: 26px; margin-bottom: 8px; }
.tc-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.tc-meta { font-size: 11px; color: var(--text-muted); }
.tc-bar { height: 4px; background: var(--gray-border); border-radius: 2px; margin-top: 8px; }
.tc-bar-fill { height: 100%; border-radius: 2px; background: var(--teal); transition: width 0.4s; }
.tc-new-badge {
  display: inline-block; font-size: 10px;
  background: var(--red-light); color: var(--red);
  padding: 1px 6px; border-radius: 20px; margin-left: 4px;
}

/* ---- PROMO BANNER ---- */
.promo-banner {
  background: var(--red-light);
  border-radius: var(--radius-lg);
  padding: 14px 1rem;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: opacity 0.15s;
}
.promo-banner:hover { opacity: 0.85; }
.promo-icon { font-size: 30px; }
.promo-title { font-size: 14px; font-weight: 500; color: var(--red-dark); }
.promo-sub { font-size: 12px; color: var(--red); margin-top: 2px; }

/* ---- HSK FILTER ---- */
.hsk-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.hsk-btn {
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--gray-border);
  border-radius: 20px; cursor: pointer;
  background: var(--card-bg); color: var(--text-muted);
  transition: all 0.15s;
}
.hsk-btn:hover, .hsk-btn.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ---- STUDY ---- */
.study-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 1rem;
}
.back-btn {
  background: none; border: 1px solid var(--gray-border);
  border-radius: 8px; padding: 7px 14px;
  font-size: 13px; cursor: pointer; color: var(--text-muted);
  white-space: nowrap;
}
.back-btn:hover { background: var(--gray-bg); }
.study-progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.study-progress-bar { flex: 1; height: 6px; background: var(--gray-border); border-radius: 3px; }
.study-progress-fill { height: 100%; border-radius: 3px; background: var(--red); transition: width 0.3s; }
.study-prog-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.study-topic-label {
  text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 1rem;
}

/* ---- VISIBILITY TOGGLES ---- */
.visibility-toggles {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 1rem;
}
.vis-btn {
  padding: 5px 14px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--gray-border);
  border-radius: 20px; cursor: pointer;
  background: var(--card-bg); color: var(--text-muted);
  transition: all 0.15s; user-select: none;
}
.vis-btn.active { background: var(--red-light); color: var(--red-dark); border-color: var(--red); }

/* ---- FLASHCARD ---- */
.flashcard {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: 18px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  min-height: 260px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.flashcard:active { transform: scale(0.98); }
.fc-hanzi { font-size: 76px; line-height: 1; margin-bottom: 12px; transition: opacity 0.2s; }
.fc-pinyin { font-size: 22px; color: var(--red); letter-spacing: 1px; margin-bottom: 8px; transition: opacity 0.2s; }
.fc-meaning { font-size: 17px; color: var(--text); transition: opacity 0.2s; }
.fc-hint { font-size: 12px; color: var(--text-muted); margin-top: 14px; }
.fc-hidden { opacity: 0; pointer-events: none; }

/* ---- CARD ACTIONS ---- */
.card-actions { display: flex; gap: 10px; }
.btn-relearn {
  flex: 1; padding: 13px;
  border: 1px solid var(--amber);
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; background: var(--amber-light); color: var(--amber);
  transition: all 0.15s;
}
.btn-relearn:hover { background: var(--amber); color: #fff; }
.btn-known {
  flex: 1; padding: 13px;
  border: 1px solid var(--teal);
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  cursor: pointer; background: var(--teal-light); color: var(--teal-dark);
  transition: all 0.15s;
}
.btn-known:hover { background: var(--teal); color: #fff; }

/* ---- DONE NOTICE ---- */
.study-done-notice {
  text-align: center; padding: 3rem 1.5rem;
  background: var(--card-bg); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-border);
}
.done-icon { font-size: 52px; margin-bottom: 12px; }
.done-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.done-sub { font-size: 14px; color: var(--text-muted); }

/* ---- QUIZ MODE LIST ---- */
.quiz-mode-list { display: grid; gap: 10px; }
.quiz-mode-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 16px 1rem;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.quiz-mode-card:hover { border-color: var(--red); box-shadow: 0 2px 10px rgba(226,75,74,0.1); }
.qmc-icon { font-size: 30px; flex-shrink: 0; }
.qmc-name { font-size: 15px; font-weight: 500; margin-bottom: 3px; }
.qmc-desc { font-size: 12px; color: var(--text-muted); }

/* ---- QUIZ ---- */
.quiz-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin-bottom: 1rem;
}
.quiz-hanzi { font-size: 64px; text-align: center; line-height: 1; margin-bottom: 8px; }
.quiz-pinyin { font-size: 20px; color: var(--red); text-align: center; margin-bottom: 1.25rem; }
.quiz-instruction { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt {
  padding: 14px 12px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius); font-size: 13px;
  cursor: pointer; transition: all 0.18s;
  background: var(--card-bg); color: var(--text);
  text-align: left; line-height: 1.4;
}
.quiz-opt:hover { border-color: var(--red); background: var(--red-light); }
.quiz-opt.correct { background: var(--teal-light); border-color: var(--teal); color: var(--teal-dark); }
.quiz-opt.wrong { background: var(--red-light); border-color: var(--red); color: var(--red-dark); }

/* ---- RESULT ---- */
.result-card {
  background: var(--card-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  max-width: 420px; margin: 0 auto;
}
.result-emoji { font-size: 52px; margin-bottom: 10px; }
.result-score { font-size: 28px; font-weight: 700; margin-bottom: 6px; }
.result-msg { font-size: 15px; color: var(--text-muted); margin-bottom: 0; }

/* ---- LEARNED LIST ---- */
.search-input {
  padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  width: 200px;
}
.search-input:focus { outline: none; border-color: var(--red); }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-btn {
  padding: 4px 12px; font-size: 12px;
  border: 1px solid var(--gray-border);
  border-radius: 20px; cursor: pointer;
  background: var(--card-bg); color: var(--text-muted);
  transition: all 0.15s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--red-light); color: var(--red-dark); border-color: var(--red);
}
.word-list { background: var(--card-bg); border: 1px solid var(--gray-border); border-radius: var(--radius-lg); overflow: hidden; }
.word-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 1rem;
  border-bottom: 1px solid var(--gray-border);
  transition: background 0.1s;
}
.word-item:last-child { border-bottom: none; }
.word-item:hover { background: var(--gray-bg); }
.wi-hanzi { font-size: 28px; min-width: 44px; cursor: pointer; }
.wi-info { flex: 1; min-width: 0; }
.wi-pinyin { font-size: 11px; color: var(--red); margin-bottom: 2px; }
.wi-meaning { font-size: 13px; }
.wi-tag {
  font-size: 10px; background: var(--teal-light);
  color: var(--teal-dark); padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}
.wi-level {
  font-size: 10px; padding: 2px 7px; border-radius: 20px;
  white-space: nowrap; font-weight: 500;
}

/* ---- PROGRESS ---- */
.topic-prog-item {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.tpi-icon { font-size: 20px; min-width: 28px; }
.tpi-info { flex: 1; }
.tpi-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.tpi-count { font-size: 12px; color: var(--text-muted); }
.tpi-bar { height: 5px; background: var(--gray-border); border-radius: 3px; }
.tpi-fill { height: 100%; border-radius: 3px; background: var(--teal); }
.hsk-level-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  background: var(--card-bg); border: 1px solid var(--gray-border);
  border-radius: var(--radius); padding: 10px 12px;
}
.hsk-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; white-space: nowrap;
}
.hsk-num { font-size: 14px; font-weight: 500; }
.hsk-sub { font-size: 11px; color: var(--text-muted); }

/* ---- EMPTY / NOTICE ---- */
.empty-notice {
  background: var(--amber-light); color: var(--amber);
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 1rem;
}
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }

/* ---- BOTTOM NAV ---- */
.bottom-nav { display: none; }

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .bottom-nav {
    display: block;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--gray-border);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    z-index: 100;
  }
  .bottom-nav { display: flex; }
  .bn-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    cursor: pointer; padding: 4px 0;
    color: var(--text-muted); font-size: 11px;
    transition: color 0.15s;
  }
  .bn-item.active { color: var(--red); }
  .bn-icon { font-size: 22px; }
  .main { padding: 1rem; padding-bottom: 90px; }
  .fc-hanzi { font-size: 58px; }
  .quiz-options { grid-template-columns: 1fr; }
  .stats-row { gap: 6px; }
  .stat-value { font-size: 20px; }
  .screen-header { flex-direction: column; align-items: flex-start; }
  .search-input { width: 100%; }
}

@media (max-width: 400px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .card-actions { flex-direction: column; }
}
