:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #283548;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --primary: #6366f1;
  --green: #10b981;
  --red: #ef4444;
  --radius: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 720px;
  padding: 20px 16px 48px;
}

/* Header */
header h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

#meta-line {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 16px;
}

/* Tabs */
#tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  background: var(--surface);
  color: var(--text-dim);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  border-color: var(--tab-color);
  color: var(--text);
  background: var(--surface-2);
}

.tab-count {
  opacity: 0.65;
  margin-left: 4px;
  font-size: 0.75rem;
}

/* Progress */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--green));
  border-radius: 999px;
  transition: width 0.3s;
}

#progress-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 56px;
  text-align: right;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  min-height: 280px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-back {
  cursor: default;
  background: var(--surface-2);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
}

.box-label {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.card-front-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
  flex: 1;
  display: flex;
  align-items: center;
}

.card-back-text {
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-line;
}

.card-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

.card-tip {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: #c7d2fe;
  line-height: 1.5;
}

/* Buttons */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s, opacity 0.15s;
}

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

.btn-flip,
.btn-primary {
  background: var(--primary);
}

.btn-again {
  background: var(--red);
}

.btn-good {
  background: var(--green);
}

.btn-tts {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-tts:hover {
  border-color: var(--text);
}

/* Done screen */
.done-screen {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.done-emoji {
  font-size: 3rem;
}

.done-screen p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.done-screen .btn {
  flex: none;
  padding: 14px 32px;
}

/* Footer */
footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .card-front-text {
    font-size: 1.02rem;
  }
}
