:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3248;
  --primary: #6c63ff;
  --primary-dim: #4d45cc;
  --success: #22c55e;
  --danger: #ef4444;
  --text: #e8eaf6;
  --text-muted: #7b82a0;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

/* ── screens ───────────────────────────────────────────────── */

.screen { display: none; flex-direction: column; height: 100%; }
.screen.active { display: flex; }

/* ── top bar ────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--primary);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  transition: color 0.15s;
}
.icon-btn:hover { color: var(--text); }

/* ── auth screen ────────────────────────────────────────────── */

#auth-screen {
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  gap: 24px;
}

.auth-logo {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -2px;
  text-align: center;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin-top: -16px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

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

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.input-group input:focus { border-color: var(--primary); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* ── buttons ────────────────────────────────────────────────── */

.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:active { background: var(--primary-dim); transform: scale(0.98); }

.btn-success {
  background: var(--success);
  color: white;
  flex: 1;
}
.btn-danger {
  background: var(--danger);
  color: white;
  flex: 1;
}
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── card screen ────────────────────────────────────────────── */

#card-screen {
  padding: 0 16px;
  gap: 16px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.badge.mood { color: #a78bfa; border-color: #4c3c84; background: #1f1440; }
.badge.tense { color: #67e8f9; border-color: #164e63; background: #061f2e; }

.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.card-meaning {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.card-infinitive {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

.card-divider {
  width: 40px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}

.card-person {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-answer {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  opacity: 0;
  transition: opacity 0.25s;
  min-height: 40px;
}

.card-answer.visible { opacity: 1; }

.card-new-badge {
  background: #1a3a1a;
  border: 1px solid #2d6a2d;
  color: #4ade80;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── action buttons ─────────────────────────────────────────── */

.action-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.review-buttons {
  display: flex;
  gap: 10px;
}

/* ── stats bar ──────────────────────────────────────────────── */

.stats-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.stat-item.due .stat-value { color: #f97316; }
.stat-item.new .stat-value { color: #a78bfa; }
.stat-item.done .stat-value { color: var(--success); }

/* ── done screen ────────────────────────────────────────────── */

#done-screen {
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 32px;
}

.done-icon { font-size: 64px; }

.done-title {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.5px;
}

.done-subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 15px;
}

/* ── stats screen ────────────────────────────────────────────── */

#stats-screen {
  padding: 0 16px 16px;
  gap: 16px;
  overflow-y: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stats-card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stats-card-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
}

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

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

/* ── upgrade input (reuse input-group input style) ──────────── */

.upgrade-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.upgrade-input:focus { border-color: var(--primary); }

/* ── tense settings ─────────────────────────────────────────── */

.tense-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 4px 4px;
}

.tense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
  gap: 12px;
}

.tense-row:active { opacity: 0.8; }
.tense-row.active { border-color: var(--primary); background: #1a1640; }

.tense-row-text { flex: 1; }
.tense-row-name { font-size: 15px; font-weight: 500; color: var(--text); }
.tense-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Toggle switch */
.toggle {
  width: 44px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 13px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle.on { background: var(--primary); border-color: var(--primary); }
.toggle.on::after { transform: translateX(18px); background: white; }

/* ── loading ────────────────────────────────────────────────── */

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── transitions ────────────────────────────────────────────── */

.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
