:root {
  --bg: #f5f5f7;
  --card: #fff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --green: #1db954;
  --red: #e0342c;
  --border: #d2d2d7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #2997ff;
    --border: #38383a;
  }
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
#header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
#header h1 { font-size: 22px; }
#streak { color: var(--muted); font-size: 14px; }
#view { padding: 0 12px; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card.done h2::after { content: " ✓"; color: var(--green); }
.card.collapsed > *:not(h2) { display: none; }

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.4; }
button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--border); }
button.ghost { background: none; color: var(--accent); padding: 6px 8px; }
button.danger { background: var(--red); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin: 4px 0;
}
textarea { min-height: 80px; }

.timer {
  font-size: 40px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 10px 0;
}
.timer.warn { color: var(--red); }

/* review flashcard */
.flashcard {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  margin: 10px 0;
}
.grade-row { display: flex; gap: 10px; }
.grade-row button { flex: 1; }

/* shadowing sentences */
.sentences { max-height: 40vh; overflow-y: auto; margin: 10px 0; }
.sentences p {
  padding: 8px 10px;
  border-radius: 8px;
  margin: 2px 0;
  font-size: 16px;
  line-height: 1.5;
}
.sentences p.active { background: var(--accent); color: #fff; }
.yt-embed { aspect-ratio: 16/9; width: 100%; border: 0; border-radius: 10px; }

/* conversation */
.chat { max-height: 45vh; overflow-y: auto; margin: 10px 0; }
.chat .msg { margin: 6px 0; padding: 10px 12px; border-radius: 12px; max-width: 85%; font-size: 15px; }
.chat .user { background: var(--accent); color: #fff; margin-left: auto; }
.chat .ai { background: var(--bg); border: 1px solid var(--border); }
.chat .pending { opacity: 0.6; font-style: italic; }

.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.entry-list li { list-style: none; padding: 10px 0; border-bottom: 1px solid var(--border); }
.entry-list .cn { color: var(--muted); font-size: 14px; }
.entry-list .en { font-size: 16px; margin-top: 2px; }
.badge { font-size: 12px; color: var(--muted); }

#tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1;
  background: none;
  color: var(--muted);
  border-radius: 0;
  padding: 14px 0;
}
#tabs button.active { color: var(--accent); }

#toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  max-width: 90vw;
  z-index: 10;
}
