:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f6df5;
  --accent-soft: #eef1fe;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --card: #1c2030;
    --text: #e7eaf3;
    --muted: #9aa1b5;
    --line: #2b3044;
    --accent: #7b93ff;
    --accent-soft: #232a45;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Pretendard", -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 0;
}
.topbar h1 { margin: 0 0 10px; font-size: 1.15rem; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar-row .btn { margin-bottom: 8px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab {
  padding: 9px 16px;
  border: none; background: none;
  font-size: .95rem; color: var(--muted);
  border-bottom: 2.5px solid transparent;
  cursor: pointer; white-space: nowrap;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab .badge {
  display: inline-block; margin-left: 4px; padding: 1px 7px;
  font-size: .72rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.section-head h2 { margin: 8px 0; font-size: 1.02rem; }
.hint { color: var(--muted); font-size: .82rem; margin: 4px 0 10px; }
.hidden { display: none !important; }

.daily { margin-bottom: 22px; }
.daily-controls { display: flex; gap: 10px; font-size: .85rem; color: var(--muted); }
.daily-controls select { margin-left: 4px; }
.daily-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.daily-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 12px; text-align: center; cursor: pointer;
  min-height: 92px; display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.daily-card .term { font-weight: 700; font-size: 1.02rem; }
.daily-card .lv { font-size: .7rem; color: var(--accent); }
.daily-card .back { font-size: .85rem; color: var(--muted); }
.daily-card.revealed { background: var(--accent-soft); }

.list-actions { display: flex; gap: 8px; }
.filter-row { display: flex; gap: 12px; align-items: center; margin: 8px 0 12px; }
.filter-row input[type=search] {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--text);
}
.chk { font-size: .85rem; color: var(--muted); white-space: nowrap; }

.word-list { display: flex; flex-direction: column; gap: 8px; }
.word-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
.word-card .row1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.word-card .term { font-weight: 700; font-size: 1.02rem; }
.word-card .reading { color: var(--muted); font-size: .82rem; }
.word-card .meaning { color: var(--text); opacity: .85; font-size: .92rem; }
.word-card .badges { margin-left: auto; display: flex; gap: 4px; }
.pill {
  font-size: .68rem; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pill.wrong { background: rgba(220, 38, 38, .12); color: var(--red); }
.pill.learned { background: rgba(22, 163, 74, .12); color: var(--green); }
.pill.src { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.word-detail { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: .9rem; }
.word-detail .explanation { white-space: pre-wrap; margin-bottom: 8px; }
.word-detail .example { color: var(--muted); font-style: italic; }
.word-detail .stats { color: var(--muted); font-size: .78rem; margin-top: 8px; }
.word-detail .detail-actions { display: flex; gap: 8px; margin-top: 10px; }

.btn {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font-size: .88rem; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: .78rem; }

dialog {
  border: none; border-radius: 14px; padding: 20px;
  background: var(--card); color: var(--text);
  width: min(480px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0 0 14px; }
dialog form label { display: block; margin-bottom: 10px; font-size: .85rem; color: var(--muted); }
dialog form input, dialog form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: .92rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.quiz-progress { color: var(--muted); font-size: .82rem; margin-bottom: 10px; }
.quiz-question { font-size: 1.25rem; font-weight: 700; margin-bottom: 16px; text-align: center; padding: 14px 0; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); text-align: left; font-size: .95rem; cursor: pointer;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent); }
.quiz-option.correct { border-color: var(--green); background: rgba(22,163,74,.12); }
.quiz-option.incorrect { border-color: var(--red); background: rgba(220,38,38,.12); }
.quiz-option:disabled { cursor: default; }
.quiz-feedback { margin-top: 12px; font-weight: 600; text-align: center; min-height: 1.2em; }
.quiz-feedback.good { color: var(--green); }
.quiz-feedback.bad { color: var(--red); }
.quiz-summary { text-align: center; padding: 10px 0; }
.quiz-summary .score { font-size: 2rem; font-weight: 800; margin: 8px 0; }
.quiz-summary ul { text-align: left; color: var(--muted); font-size: .88rem; padding-left: 20px; }

/* 일별 정답률 차트: 단일 시리즈 세로 바, 정답률 0~100% */
.stats { margin-bottom: 22px; }
.hint-inline { font-size: .75rem; color: var(--muted); font-weight: 400; }
.stats-chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 96px; padding: 10px 12px 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative;
}
.stat-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; position: relative; min-width: 0; }
.stat-track {
  width: 100%; max-width: 26px; height: 100%; display: flex; align-items: flex-end; justify-content: center;
  border-radius: 4px 4px 0 0; cursor: default;
}
.stat-bar {
  width: 100%; background: var(--accent);
  border-radius: 4px 4px 0 0;   /* 데이터 끝만 둥글게, 베이스라인은 각지게 */
  min-height: 3px;
  transition: opacity .15s;
}
.stat-col:hover .stat-bar { opacity: .8; }
.stat-empty {
  width: 100%; max-width: 26px; height: 3px;
  background: var(--line); border-radius: 2px;
  align-self: flex-end;
}
.stat-label {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: .62rem; color: var(--muted); white-space: nowrap;
}
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: .78rem; line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.stats-empty-msg { color: var(--muted); font-size: .82rem; align-self: center; margin: 0 auto; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: .85rem;
  box-shadow: var(--shadow); z-index: 100;
}
.empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: .9rem; }
