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

:root {
  --primary: #4F6EF7;
  --primary-light: #E8EBFE;
  --success: #4CAF50;
  --error: #F44336;
  --warning: #FF9800;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-light: #888888;
  --border: #E0E0E0;
  --easy: #4CAF50;
  --medium: #FF9800;
  --hard: #F44336;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #7c4dff 100%);
}
.login-card {
  background: var(--card-bg);
  padding: 48px 36px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
}
.login-subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}
.login-input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.login-input-group input:focus {
  border-color: var(--primary);
}
.login-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  font-size: 16px;
}
.login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
}

/* Navbar */
#navbar {
  background: var(--card-bg);
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.nav-tabs { display: flex; gap: 8px; }
.nav-tab {
  padding: 6px 16px;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  border-radius: 16px;
  transition: all 0.2s;
}
.nav-tab.active { background: var(--primary); color: white; }

/* Pages */
.page { display: none; padding: 20px; margin: 0 auto; width: 90%; max-width: 900px; }
.page.active { display: block; }
#page-words.page.active { max-width: 1400px; width: 98%; margin: 0 auto; padding: 0 12px; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}
.card h2 { font-size: 18px; margin-bottom: 16px; }
.card h3 { font-size: 16px; margin: 16px 0 8px; }

#page-words .card { max-width: none; height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
#page-words .card > h2 { flex-shrink: 0; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat-item {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-item .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-item .stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #3D5CE5; }
.btn-secondary { background: var(--warning); color: white; }
.btn-secondary:hover { background: #F57C00; }
.btn-wrong { background: var(--hard); color: white; }
.btn-wrong:hover { background: #D32F2F; }
.btn-voice {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 16px;
  font-size: 16px;
}
.btn-voice:active { transform: scale(0.98); }
.btn-voice.listening { background: var(--error); animation: pulse 1s infinite; }

.btn-pause {
  background: var(--border);
  color: var(--text);
  width: 100%;
  padding: 10px;
  font-size: 14px;
}
.btn-pause:hover { background: #ccc; }
.btn-pause.paused { background: var(--success); color: white; }

.btn-next {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 16px;
}
.btn-next:hover { background: #3D5CE5; }

/* Paused overlay */
.paused-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.paused-overlay .paused-text {
  background: white;
  padding: 32px 48px;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

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

.btn-icon {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
}

/* Study Card */
.study-card {
  border: 2px solid var(--primary);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  cursor: pointer;
}
#study-progress-text, #review-progress-text { font-size: 14px; color: var(--text-light); }

/* Word Display */
#word-display, #review-word-display {
  text-align: center;
  padding: 16px 16px 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.word-text {
  font-size: 32px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 6px;
  line-height: 1.2;
  font-family: "Inter", sans-serif;
}
.word-text.easy { background: #E8F5E9; color: #2E7D32; }
.word-text.medium { background: #FFF3E0; color: #E65100; }
.word-text.hard { background: #FFEBEE; color: #C62828; }

.word-phonetic { font-size: 14px; color: var(--text-light); }
.difficulty-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: white;
}
.difficulty-badge.easy { background: var(--easy); }
.difficulty-badge.medium { background: var(--medium); }
.difficulty-badge.hard { background: var(--hard); }

/* Word Extra: forms and phrases */
.word-extra {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.8;
}
.word-extra-section { margin-bottom: 8px; }
.word-extra-label {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}
.word-extra-item {
  display: inline;
  margin-right: 12px;
}
.word-extra-item .form-type {
  color: var(--text-light);
  font-size: 12px;
}
.word-extra-item .form-value {
  color: var(--text);
  font-weight: 600;
}
.word-extra-item .phrase-en {
  color: var(--primary);
  font-weight: 500;
}
.word-extra-item .phrase-cn {
  color: var(--text-light);
  font-size: 12px;
  display: none;
}
.word-extra-item.show-meaning .phrase-cn {
  display: inline;
}
.word-extra-item.phrase-clickable {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s;
}
.word-extra-item.phrase-clickable:hover {
  border-bottom-color: var(--primary);
}

/* Countdown Bar */
.countdown-bar {
  height: 4px;
  background: var(--border);
  margin: 12px 0 4px;
  border-radius: 2px;
  overflow: hidden;
}
.countdown-fill {
  height: 100%;
  background: var(--primary);
  width: 100%;
  transition: width 0.1s linear, background 0.3s;
}
.countdown-fill.warning { background: var(--warning); }
.countdown-fill.danger { background: var(--error); }
.timer-text { text-align: center; font-size: 12px; color: var(--text-light); height: 18px; }

/* Options */
.options-container { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; flex: 1; }
.option-item {
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  cursor: default;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.option-item .option-key {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.option-item.correct { border-color: var(--success); background: #E8F5E9; }
.option-item.correct .option-key { background: var(--success); color: white; }
.option-item.wrong { border-color: var(--error); background: #FFEBEE; }
.option-item.wrong .option-key { background: var(--error); color: white; }

/* Feedback */
.feedback {
  text-align: center;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
}
.feedback.correct { color: var(--success); }
.feedback.wrong { color: var(--error); }

/* Voice Section */
.voice-section { text-align: center; margin-top: 16px; }
.voice-status { font-size: 14px; margin-top: 8px; min-height: 24px; font-weight: 500; }
.voice-status.success { color: var(--success); }
.voice-status.error { color: var(--error); }
.voice-status.info { color: var(--text-light); }

.voice-btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.voice-btn-row .btn-pause { flex: 0 0 150px; }
.voice-btn-row .btn-voice-inline { flex: 1; }
.voice-btn-row .btn-pronounce-inline { flex: 0 0 auto; }

.btn-voice-inline {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.btn-voice-inline:active { transform: scale(0.98); }
.btn-voice-inline.listening { background: var(--error); animation: pulse 1s infinite; }

.btn-pronounce-inline {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.btn-pronounce-inline:hover { background: #d0d5fe; }

/* Hidden */
.hidden { display: none !important; }

/* Stage Chart */
.stage-chart { display: flex; gap: 4px; align-items: flex-end; height: 80px; padding: 8px 0; }
.stage-bar {
  flex: 1;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.3s;
}
.stage-bar .stage-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-light);
}
.stage-bar .stage-count {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text);
  white-space: nowrap;
}

/* Trend Chart */
.trend-chart { display: flex; gap: 2px; align-items: flex-end; height: 60px; }
.trend-bar {
  flex: 1;
  background: var(--primary-light);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}

/* Report */
.report-date { font-size: 14px; color: var(--text-light); margin-bottom: 12px; }
.report-content { line-height: 1.8; }
.report-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.report-row:last-child { border-bottom: none; }

/* Wrong Words */
.wrong-words { max-height: 400px; overflow-y: auto; }
.wrong-word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.wrong-word-item .ww-word { font-weight: 600; color: var(--primary); }
.wrong-word-item .ww-meaning { font-size: 13px; color: var(--text-light); }
.wrong-word-item .ww-count { font-size: 12px; color: var(--error); }

/* Words Table */
.words-table-container {
  height: calc(100vh - 120px);
  overflow-y: auto;
  width: 100%;
}
.words-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
.words-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: white;
  padding: 8px 4px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.words-table th:nth-child(1) { width: 4.5%; }
.words-table th:nth-child(2) { width: 10%; }
.words-table th:nth-child(3) { width: 9%; }
.words-table th:nth-child(4) { width: 5.5%; }
.words-table th:nth-child(5) { width: 4.5%; }
.words-table th:nth-child(6) { width: 7%; }
.words-table th:nth-child(7) { width: 8%; }
.words-table th:nth-child(8) { width: 8%; }
.words-table th:nth-child(9) { width: 4%; }
.words-table th:nth-child(10) { width: 4.5%; }
.words-table th:nth-child(11) { width: 3.5%; }
.words-table td:nth-child(1) { text-align: center; }
.words-table td:nth-child(5) { text-align: center; }
.words-table td:nth-child(8) { text-align: center; }
.words-table td:nth-child(9) { text-align: center; }
.words-table td:nth-child(10) { text-align: center; }
.words-table td:nth-child(11) { text-align: center; }
.words-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.words-table tr:hover td { background: var(--primary-light); }
.words-table .wt-word { font-weight: 600; color: var(--primary); }
.words-table .wt-phonetic { color: var(--text-light); font-size: 12px; }
.words-table .wt-difficulty {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: white;
}
.words-table .wt-difficulty.easy { background: var(--easy); }
.words-table .wt-difficulty.medium { background: var(--medium); }
.words-table .wt-difficulty.hard { background: var(--hard); }
.words-table .wt-status { font-size: 13px; }
.words-table .wt-correct { color: var(--success); text-align: center; }
.words-table .wt-wrong { color: var(--error); text-align: center; }

/* Action Buttons */
.action-buttons { display: flex; gap: 12px; margin-top: 16px; }
.action-buttons .btn { flex: 1; }

