:root {
  --bg: #faf8f5; --surface: #ffffff; --surface-2: #f2efe9; --text: #23211e; --muted: #6b665e;
  --border: #e3ded5; --accent: #c0392b; --accent-bg: #fbeceb; --ok: #2e7d32; --bad: #c62828; --special: #1565c0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1917; --surface: #23221f; --surface-2: #2c2a26; --text: #ece9e3; --muted: #a39e94;
    --border: #3a3732; --accent: #ef6f5e; --accent-bg: #3a2420; --ok: #81c784; --bad: #ef9a9a; --special: #90caf9;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 "Be Vietnam Pro", system-ui, sans-serif; }
.jp, .k { font-family: "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif; }
.wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
header.top a { color: var(--muted); text-decoration: none; font-size: 14px; }
h1 { font-size: 28px; line-height: 1.3; margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 21px; margin: 40px 0 12px; font-weight: 600; }
h3 { font-size: 17px; margin: 24px 0 8px; font-weight: 600; }
p.lead { color: var(--muted); margin: 0 0 24px; }
a { color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.on { background: var(--accent-bg); color: var(--accent); }
button, input { font: inherit; color: var(--text); }
button { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
button:hover { border-color: var(--muted); }
input[type=text] { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; min-width: 0; }
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 0; }

/* Danh sách buổi học */
.lessons { display: grid; gap: 10px; }
.lesson { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: start; text-decoration: none; color: inherit; }
.lesson .no { font-size: 13px; color: var(--muted); padding-top: 3px; }
.lesson .t { font-weight: 600; }
.lesson .s { font-size: 14px; color: var(--muted); }
a.lesson:hover { border-color: var(--accent); }
.lesson.locked { opacity: .65; }

/* Bảng kana */
.kg { display: grid; grid-template-columns: 32px repeat(5, minmax(0, 1fr)); gap: 6px; margin: 12px 0 8px; }
.kc { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 6px 0; text-align: center; cursor: pointer; user-select: none; }
.kc:hover { border-color: var(--accent); }
.kc .k { font-size: 28px; line-height: 1.2; }
.kc .r { font-size: 12px; color: var(--muted); }
.kc.sp .r { color: var(--special); font-weight: 600; }
.kc.em { border: none; background: transparent; cursor: default; }
.rl { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.hide-r .kc .r { visibility: hidden; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }

/* Luyện tập */
.quiz { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.quiz .big { font-size: 64px; line-height: 1; min-width: 80px; text-align: center; }
.quiz .ctl { flex: 1; min-width: 220px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.msg { font-size: 14px; min-height: 22px; margin-top: 6px; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--bad); }
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 14px; color: var(--muted); }
.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pairs .card { padding: 10px 14px; text-align: center; }
.pairs .k { font-size: 24px; }
.hw li { margin-bottom: 6px; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--accent); }
footer { margin-top: 48px; font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { .kc .k { font-size: 22px; } .quiz .big { font-size: 52px; } h1 { font-size: 24px; } }
