:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.screen.active { display: block; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
}

.header h1 { font-size: 1.5rem; font-weight: 700; }

.header-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.stats-bar {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.section-title {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 20px 0 8px;
  font-weight: 600;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title { font-weight: 600; margin-bottom: 4px; flex: 1; }

.card-meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-daily { background: #1e3a5f; color: #60a5fa; }
.badge-medical { background: #14532d; color: #4ade80; }
.badge-conference { background: #3b0764; color: #c084fc; }
.badge-paper { background: #451a03; color: #fb923c; }
.badge-custom { background: #374151; color: #9ca3af; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-overdue { background: var(--danger); }
.status-upcoming { background: var(--warning); }
.status-normal { background: var(--text-secondary); }

.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: calc(50% - 240px + 24px);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 25px;
  height: 50px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

@media (max-width: 480px) {
  .fab { right: 24px; }
}

.fab:active { background: var(--accent-hover); }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  width: 100%;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

.btn:active { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-secondary); }
.btn-danger { background: var(--danger); }

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  width: auto;
}

.rating-buttons {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.btn-rating {
  flex: 1;
  padding: 16px 8px;
  text-align: center;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.btn-rating.again { border-color: var(--danger); color: var(--danger); }
.btn-rating.again:active { background: rgba(239, 68, 68, 0.15); }
.btn-rating.good { border-color: var(--warning); color: var(--warning); }
.btn-rating.good:active { background: rgba(234, 179, 8, 0.15); }
.btn-rating.easy { border-color: var(--success); color: var(--success); }
.btn-rating.easy:active { background: rgba(34, 197, 94, 0.15); }

input, textarea, select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 12px;
  font-family: inherit;
}

textarea { min-height: 120px; resize: vertical; }

select { appearance: none; cursor: pointer; }

.form-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.divider {
  color: var(--text-secondary);
  text-align: center;
  margin: 24px 0;
  position: relative;
  font-size: 0.85rem;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--bg-card);
}

.divider span {
  background: var(--bg-primary);
  padding: 0 12px;
  position: relative;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}

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

.modal-header h2 { font-size: 1.2rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.word { display: inline; line-height: 1.8; }
.word-correct { color: var(--success); font-weight: 600; }
.word-incorrect { color: var(--danger); font-weight: 600; }
.word-highlight { color: var(--accent); font-weight: 600; }

.score-display {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  margin: 16px 0;
}

.preview-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.preview-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-value { margin-top: 4px; }

.speed-btn {
  background: var(--bg-secondary);
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.speed-btn.active { background: var(--accent); color: #fff; }

.practice-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 8px 0;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 8px;
}

#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 16px;
}

.hidden { display: none !important; }

.text-display {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  line-height: 1.8;
  font-size: 1.1rem;
}

.keywords-list {
  margin: 8px 0;
}

.keyword-item {
  padding: 4px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.keyword-word {
  color: var(--accent);
  font-weight: 500;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
}

.delete-btn:active { opacity: 1; }

.recording-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1s infinite;
  margin-right: 8px;
}

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

/* 3-step practice flow */
.step-checklist {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-secondary);
  gap: 4px;
  transition: color 0.2s;
}

.step-item.active {
  color: var(--accent);
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}

.step-item.active .step-circle {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.step-circle.completed {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.step-content {
  display: none;
}

.step-content.active {
  display: block;
}

.assess-buttons {
  display: flex;
  gap: 12px;
  margin: 16px 0;
}

.btn-assess {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid;
  background: transparent;
  transition: background 0.15s;
}

.btn-assess-pass {
  border-color: var(--success);
  color: var(--success);
}

.btn-assess-pass:active {
  background: rgba(34, 197, 94, 0.15);
}

.btn-assess-fail {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-assess-fail:active {
  background: rgba(239, 68, 68, 0.15);
}

/* STT shadowing button */
.btn-stt {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: background 0.15s;
}

.btn-stt:active { background: var(--accent-hover); }
.btn-stt.recording { background: var(--danger); }

.stt-result {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.stt-score {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.stt-transcript {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
