* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #4A90D9;
  --primary-dark: #357ABD;
  --success: #52C41A;
  --danger: #FF4D4F;
  --warning: #FAAD14;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-secondary: #999999;
  --border: #E8E8E8;
  --nav-height: 60px;
  --header-height: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Pages */
.page {
  display: none;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 20px);
}

.page.active {
  display: block;
}

/* Header */
.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 600;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.btn-back {
  position: absolute;
  left: 12px;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.word-counter {
  position: absolute;
  right: 16px;
  font-size: 14px;
  opacity: 0.9;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card-bg);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  padding: 6px 0;
  transition: color 0.2s;
}

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

.nav-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

.nav-label {
  font-size: 11px;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  padding: 14px 32px;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  padding: 12px 32px;
}

.btn-large {
  width: 80%;
  max-width: 320px;
}

.btn-warning {
  background: var(--warning);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  padding: 14px 32px;
}

.btn-warning:active {
  background: #e6a012;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 32px;
}

/* Home Page */
.home-content {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.book-switch {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--primary);
  width: 100%;
  max-width: 400px;
}

.book-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: var(--card-bg);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.book-btn.active {
  background: var(--primary);
  color: white;
}

.stat-cards {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.stat-card {
  flex: 1;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

#card-review .stat-number {
  color: var(--warning);
}

#card-streak .stat-number {
  color: var(--success);
}

.home-progress {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 8px;
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Learn Page */
.learn-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - var(--nav-height) - 100px);
  padding: 24px 20px;
}

.word-display {
  width: 100%;
  text-align: center;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-full {
  font-size: 54px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.word-full.phrase {
  font-size: 42px;
  gap: 8px;
}

.syllable-block {
  padding: 4px 2px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.syllable-block.active {
  background: rgba(74, 144, 217, 0.18);
}

.meaning-area {
  margin-top: 32px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.phonetic {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.meaning {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.example {
  font-size: 19px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 12px 20px;
  background: var(--card-bg);
  border-radius: 8px;
  max-width: 360px;
  margin: 0 auto;
}

.tap-hint {
  margin-top: 40px;
  font-size: 20px;
  color: var(--primary);
  animation: pulse 1.5s ease infinite;
  cursor: pointer;
}

.learn-footer {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.learn-footer .btn-large {
  width: auto;
  flex: 1;
  max-width: 200px;
}

/* Review Page */
.review-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
}

.review-word {
  font-size: 40px;
  font-weight: 700;
  margin-bottom: 8px;
}

.review-phonetic {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.review-options {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-option {
  width: 100%;
  padding: 16px 20px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.review-option:active {
  transform: scale(0.98);
}

.review-option.correct {
  border-color: var(--success);
  background: rgba(82, 196, 26, 0.1);
  color: var(--success);
}

.review-option.wrong {
  border-color: var(--danger);
  background: rgba(255, 77, 79, 0.1);
  color: var(--danger);
}

.review-result {
  margin-top: 20px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.review-result.correct-text {
  color: var(--success);
}

.review-result.wrong-text {
  color: var(--danger);
}

.review-footer {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 16px;
}

/* Wordlist Page */
.wordlist-content {
  padding: 16px;
}

.unit-group {
  margin-bottom: 24px;
}

.unit-group-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-left: 4px;
}

.unit-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.unit-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: calc(50% - 5px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.2s;
}

.unit-card:active {
  transform: scale(0.97);
}

.unit-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.unit-card-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.unit-progress-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.unit-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Unit Words Page */
.unit-words-content {
  padding: 12px 16px;
}

.word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.word-item:last-child {
  border-bottom: none;
}

.word-item-left {
  display: flex;
  flex-direction: column;
}

.word-item-word {
  font-size: 17px;
  font-weight: 600;
}

.word-item-phonetic {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.word-item-meaning {
  font-size: 14px;
  color: var(--text-secondary);
}

.word-item-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.word-item-status.new {
  background: var(--bg);
  color: var(--text-secondary);
}

.word-item-status.learning {
  background: rgba(74, 144, 217, 0.1);
  color: var(--primary);
}

.word-item-status.mastered {
  background: rgba(82, 196, 26, 0.1);
  color: var(--success);
}

/* Stats Page */
.stats-content {
  padding: 24px 20px;
}

.stats-overview {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.stats-item {
  flex: 1;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px 8px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stats-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stats-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stats-detail {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 4px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.stats-row:last-child {
  border-bottom: none;
}

/* Settings Page */
.settings-content {
  padding: 24px 20px;
}

.settings-item {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 15px;
}

.settings-item select {
  font-size: 15px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Responsive */
@media (min-width: 600px) {
  .stat-cards, .home-progress, .review-options {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }
}
