:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2e0d9;
  --accent: #1f4e79;
  --again: #b3261e;
  --hard: #b26a00;
  --good: #2e7d32;
  --easy: #1565c0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #222220;
    --text: #f0efea;
    --muted: #a3a29c;
    --line: #34332f;
    --accent: #7fb2e5;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 16px 0;
}
.topbar h1 { font-size: 17px; margin: 0 0 6px; }
.tabs { display: flex; gap: 4px; }
.tab {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 8px 0; font-size: 15px; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 560px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.card-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
h2 { font-size: 16px; margin: 0 0 10px; }
button { font: inherit; cursor: pointer; }
.primary, .secondary {
  border-radius: 10px; padding: 12px 16px; font-size: 16px;
}
.primary { background: var(--accent); color: #fff; border: none; width: 100%; }
.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.big { padding: 16px; font-size: 18px; font-weight: 600; }
.link { background: none; border: none; color: var(--accent); padding: 4px 0; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 99px;
  background: var(--accent); color: #fff;
}
.study-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.study-head #quit-btn { margin-left: auto; }
.flashcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; min-height: 220px; margin-bottom: 12px;
}
.front { font-size: 20px; margin: 4px 0 8px; }
.hint { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 15px; }
.back { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.answer { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.audio-row { display: flex; gap: 8px; margin-top: 10px; }
.audio-row button { padding: 8px 12px; font-size: 14px; }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade {
  border: none; border-radius: 10px; padding: 14px 4px; color: #fff; font-size: 15px; font-weight: 600;
}
.grade.again { background: var(--again); }
.grade.hard { background: var(--hard); }
.grade.good { background: var(--good); }
.grade.easy { background: var(--easy); }
.summary-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.summary-row:last-child { border-bottom: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.row input[type="number"] { width: 80px; font-size: 16px; padding: 4px 6px; }
.deck-setting { border-bottom: 1px solid var(--line); padding: 6px 0; }
.file-label { display: inline-block; margin-left: 8px; }
.file-label input { display: none; }
.bar-track { background: var(--bg); border-radius: 99px; height: 8px; margin: 4px 0 10px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin: 8px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .col .bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .col span { font-size: 10px; color: var(--muted); margin-top: 2px; }
