:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #3fb950;
  --accent2: #58a6ff;
  --danger: #f85149;
  --warn: #d29922;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --bg-card: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --text-dim: #57606a;
    --accent: #1a7f37;
    --accent2: #0969da;
    --danger: #cf222e;
    --warn: #9a6700;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}
.app {
  width: 100%;
  max-width: 560px;
}
.hidden { display: none !important; }

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
}
#home-totals {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.6;
}

button {
  font-family: inherit;
  cursor: pointer;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #06170a;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}
.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

/* drill */
.drill-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
#combo-label {
  color: var(--warn);
  font-weight: 600;
}
.timer-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}
#timer-bar {
  height: 100%;
  background: var(--accent2);
  width: 100%;
}
#sentence {
  font-size: 18px;
  line-height: 1.7;
  margin-bottom: 24px;
}
.target {
  color: var(--accent2);
  font-weight: 700;
  border-bottom: 2px solid var(--accent2);
}
#options {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.opt-btn {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 15px;
}
.opt-btn:disabled { opacity: 0.6; }
.opt-btn.correct {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-card));
}
.opt-btn.wrong {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 15%, var(--bg-card));
}

#feedback {
  border-left: 3px solid var(--border);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  border-radius: 4px;
  background: var(--bg-card);
}
#feedback.fb-correct { border-left-color: var(--accent); }
#feedback.fb-wrong { border-left-color: var(--danger); }
.fb-head { font-weight: 700; margin-bottom: 4px; }
.fb-desc { color: var(--text-dim); margin-bottom: 4px; }
.fb-ja { color: var(--text-dim); }

/* summary */
.sum-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
  text-align: center;
}
.sum-stat-label {
  font-size: 11px;
  color: var(--text-dim);
}
.sum-stat-value {
  font-size: 18px;
  font-weight: 700;
}
.mastery-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.mastery-row:last-child { border-bottom: none; }
.mastery-word { font-size: 14px; }
.mastery-bar { display: flex; gap: 3px; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.dot.on { background: var(--accent); }

/* stats view */
.word-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.word-title { font-size: 16px; font-weight: 700; cursor: pointer; }
.word-tip {
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0 10px;
  line-height: 1.6;
}
.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.tag-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tag-prep { color: var(--accent2); border-color: var(--accent2); }
.tag-conj { color: var(--warn); border-color: var(--warn); }
.tag-adv { color: var(--accent); border-color: var(--accent); }
.tag-verb { color: #d2a8ff; border-color: #d2a8ff; }
.tag-noun { color: #ff7b72; border-color: #ff7b72; }
.tag-pron { color: #79c0ff; border-color: #79c0ff; }
