:root {
  --bg: #16161d; --panel: #20202a; --panel2: #2a2a36; --text: #e8e8ef; --muted: #9a9aab; --line: #34343f;
  --radical: #00a1f1; --kanji: #f100a1; --vocabulary: #a100f1;
  --ok: #2fbf71; --bad: #e5484d; --warn: #f5a524;
  --jp: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans JP", sans-serif; }
a { color: inherit; }
button, .btn {
  font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--kanji); border-color: var(--kanji); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.jp { font-family: var(--jp); }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.5em; }

/* Layout */
nav { display: flex; gap: 4px; align-items: center; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
nav .brand { font-weight: 700; margin-right: 12px; text-decoration: none; }
nav a.link { text-decoration: none; padding: 6px 10px; border-radius: 6px; color: var(--muted); }
nav a.link.active, nav a.link:hover { color: var(--text); background: var(--panel2); }
nav .badge { background: var(--kanji); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
nav .badge.r { background: var(--radical); }
main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 300px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; }

/* Dashboard */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.big-actions a { display: block; text-decoration: none; border-radius: 12px; padding: 22px; color: #fff; }
.big-actions .lessons { background: linear-gradient(135deg, #f100a1, #b0007a); }
.big-actions .reviews { background: linear-gradient(135deg, #00a1f1, #0071aa); }
.big-actions .n { font-size: 40px; font-weight: 700; line-height: 1; }
.big-actions .empty { opacity: .45; }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 90px; background: var(--panel2); border-radius: 8px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat.apprentice { border-bottom: 3px solid #dd0093; }
.stat.guru { border-bottom: 3px solid #882d9e; }
.stat.master { border-bottom: 3px solid #294ddb; }
.stat.enlightened { border-bottom: 3px solid #0093dd; }
.stat.burned { border-bottom: 3px solid #555; }
.bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--ok); }
.forecast { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.forecast div { flex: 1; background: var(--radical); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.forecast-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tr.today { background: #2a1f30; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--panel2); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px; text-decoration: none; color: #fff; font-family: var(--jp); font-size: 18px; min-height: 34px; border-bottom: 3px solid transparent; }
.chip small { font-family: system-ui, sans-serif; font-size: 12px; opacity: .85; }
.chip.radical { background: var(--radical); } .chip.kanji { background: var(--kanji); } .chip.vocabulary { background: var(--vocabulary); }
.chip.locked { opacity: .35; }
.chip.s-app { border-bottom-color: #ffd0ee; } .chip.s-guru { border-bottom-color: #c99ae0; }
.chip.s-master { border-bottom-color: #9bb0ff; } .chip.s-enl { border-bottom-color: #8ad7ff; } .chip.s-burn { border-bottom-color: #222; }
img.rad { width: 1em; height: 1em; filter: brightness(0) invert(1); vertical-align: middle; }

/* Item display */
.hero { text-align: center; color: #fff; border-radius: 12px; padding: 28px 12px; margin-bottom: 16px; }
.hero.radical { background: var(--radical); } .hero.kanji { background: var(--kanji); } .hero.vocabulary { background: var(--vocabulary); }
.hero .ch { font-family: var(--jp); font-size: 84px; line-height: 1.15; }
.hero .ch img.rad { width: 84px; height: 84px; }
.hero .meaning { font-size: 22px; }
.section { margin: 16px 0; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.mnemonic { line-height: 1.7; }
.hint { background: var(--panel2); border-radius: 8px; padding: 8px 12px; margin-top: 8px; font-size: 14px; }
.mk-radical { background: var(--radical); color: #fff; padding: 0 4px; border-radius: 3px; }
.mk-kanji { background: var(--kanji); color: #fff; padding: 0 4px; border-radius: 3px; }
.mk-vocabulary { background: var(--vocabulary); color: #fff; padding: 0 4px; border-radius: 3px; }
.mk-reading, .mk-meaning { background: #444; color: #fff; padding: 0 4px; border-radius: 3px; }
.readings { display: flex; gap: 24px; flex-wrap: wrap; }
.readings .r { font-family: var(--jp); font-size: 20px; }
.readings .r.no { color: var(--muted); font-size: 16px; }
.sentence { margin-bottom: 10px; }
.sentence .ja { font-family: var(--jp); font-size: 18px; }

/* Quiz */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.prompt { text-align: center; padding: 14px; border-radius: 0 0 12px 12px; font-size: 18px; }
.prompt.meaning { background: #e8e8ef; color: #222; }
.prompt.reading { background: #333; color: #fff; }
.hero.q { border-radius: 12px 12px 0 0; margin-bottom: 0; padding: 40px 12px; }
#answer { width: 100%; text-align: center; font-size: 26px; padding: 14px; border-radius: 10px; margin-top: 12px; font-family: var(--jp); }
#answer.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
#answer.bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.feedback { min-height: 1.6em; text-align: center; margin: 8px 0; }
.feedback.warn { color: var(--warn); }
.quiz-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kbd { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }

.lesson-nav { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 12px 0; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--panel2); cursor: pointer; }
.dots span.on { background: var(--kanji); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button.on { background: var(--kanji); border-color: var(--kanji); color: #fff; }
.group { margin-bottom: 18px; }
.group h3 { font-size: 14px; color: var(--muted); margin: 0 0 6px; }

@media (max-width: 600px) {
  .big-actions { grid-template-columns: 1fr; }
  .hero .ch { font-size: 64px; }
  nav a.link { padding: 6px 6px; }
}

/* Grammar */
:root { --grammar: #e07b00; }
.chip.grammar { background: var(--grammar); font-size: 16px; }
.hero.grammar { background: var(--grammar); }
.hero.grammar .ch { font-size: 44px; }
.hero.cloze { padding: 28px 20px; }
.cloze-ja { font-size: 30px; line-height: 1.6; }
.cloze-kana { font-size: 18px; opacity: .9; margin-top: 4px; }
.cloze-en { font-size: 16px; opacity: .9; margin-top: 10px; }
.blank { display: inline-block; min-width: 3em; border-bottom: 3px solid #fff; padding: 0 4px; }
.blank.filled { background: rgba(255, 255, 255, .25); border-radius: 4px; border-bottom-color: var(--ok); }
.blank.filled.bad { border-bottom-color: var(--bad); }
.sentence .blank.filled { background: #3a2a14; color: #ffb35c; border-bottom: 0; }
.prompt #kanaBtn { margin-left: 8px; padding: 2px 10px; font-size: 13px; }
.structure { font-size: 17px; background: var(--panel2); border-radius: 6px; padding: 4px 10px; margin-bottom: 4px; display: inline-block; margin-right: 6px; }
.kana { font-size: 14px; }
