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

:root {
  --primary: #1976D2;
  --primary-dark: #1565C0;
  --primary-light: #BBDEFB;
  --accent: #009688;
  --danger: #E53935;
  --danger-light: #FFEBEE;
  --success: #43A047;
  --success-light: #E8F5E9;
  --warning: #FB8C00;
  --bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --text: #212121;
  --text-secondary: #757575;
  --text-hint: #9E9E9E;
  --border: #E0E0E0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ====== Header ====== */
.app-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* ====== Tab Panel ====== */
.tab-panel {
  display: none;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

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

/* ====== Card ====== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.review-card {
  border-left: 4px solid var(--primary);
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.review-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.badge {
  background: var(--danger);
  color: white;
  font-size: 14px;
  font-weight: 700;
  min-width: 28px;
  height: 28px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.badge:empty {
  display: none;
}

.hint {
  color: var(--text-hint);
  font-size: 14px;
  margin-top: 4px;
}

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  gap: 6px;
}

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

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #C62828;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #388E3C;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* ====== Action Bar ====== */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.action-bar .btn {
  flex: 1;
  min-width: 0;
}

/* ====== Section Header ====== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

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

/* ====== Item List ====== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s;
}

.item-card:active {
  transform: scale(0.98);
}

.item-card .item-type {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-weight: 600;
}

.item-card .item-type.english {
  background: #E3F2FD;
  color: #1565C0;
}

.item-card .item-type.poetry {
  background: #F3E5F5;
  color: #7B1FA2;
}

.item-card .item-content {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card .item-translation {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card .item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-hint);
}

.item-card .item-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.item-card .stage-dots {
  display: flex;
  gap: 2px;
}

.item-card .stage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.item-card .stage-dot.filled {
  background: var(--accent);
}

.item-card .item-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.item-card .item-actions .btn {
  flex: 1;
  padding: 6px 0;
  font-size: 13px;
}

/* ====== Knowledge Item Card ====== */
.knowledge-card .kn-category {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: #E0F2F1;
  color: #00695C;
  font-weight: 600;
  margin-bottom: 6px;
}

.knowledge-card .kn-content {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ====== Search Bar ====== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card-bg);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
}

.filter-select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--card-bg);
  outline: none;
  min-width: 100px;
}

/* ====== Review Session ====== */
.review-progress {
  margin-bottom: 16px;
}

.review-progress span {
  font-size: 13px;
  color: var(--text-secondary);
}

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

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

.flashcard {
  text-align: center;
  padding: 24px 16px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.flashcard-type {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 600;
}

.flashcard-type.english {
  background: #E3F2FD;
  color: #1565C0;
}

.flashcard-type.poetry {
  background: #F3E5F5;
  color: #7B1FA2;
}

.flashcard-content {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

.flashcard-divider {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 16px 0;
}

.flashcard-translation {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.3s ease;
}

.review-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.review-actions .btn {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

/* ====== Review Complete ====== */
.review-complete-card {
  text-align: center;
}

.complete-icon {
  font-size: 48px;
  color: var(--success);
  margin-bottom: 12px;
}

.review-complete-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.review-complete-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ====== Modal ====== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card-bg);
}

.form-input:focus {
  border-color: var(--primary);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* ====== Bottom Nav ====== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px 12px;
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  transition: color 0.2s;
  gap: 2px;
}

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

.nav-icon {
  font-size: 20px;
}

.nav-label {
  font-size: 12px;
  font-weight: 500;
}

/* ====== Detail Modal Body ====== */
#detail-body {
  line-height: 1.8;
}

#detail-body .detail-label {
  font-size: 13px;
  color: var(--text-hint);
  margin-bottom: 2px;
}

#detail-body .detail-value {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
}

#detail-body .detail-value.large {
  font-size: 18px;
  font-weight: 500;
}

/* ====== Empty State ====== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-hint);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
