:root {
  --bg: #f6f8fa; --panel: #fff; --text: #1f2328; --muted: #656d76; --border: #d0d7de;
  --accent: #1f6feb; --accent-text: #fff; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --again: #cf222e; --hard: #bc4c00; --good: #1a7f37; --easy: #1f6feb;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --panel: #161b22; --text: #e6edf3; --muted: #8d96a0; --border: #30363d;
    --accent: #2f81f7; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
    --again: #f85149; --hard: #db6d28; --good: #3fb950; --easy: #2f81f7;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
small, .muted { color: var(--muted); }

#topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
#topbar .brand { font-weight: 700; color: var(--text); }
#topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; }
#topbar nav a { padding: .35rem .6rem; border-radius: 6px; color: var(--muted); }
#topbar nav a.active { background: var(--bg); color: var(--text); font-weight: 600; }
#topbar nav a:hover { text-decoration: none; color: var(--text); }

main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: .8rem; }

button, .btn { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center;
  gap: .35rem; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.small, .btn.small { padding: .25rem .55rem; font-size: .9rem; }
button:disabled { opacity: .5; cursor: default; }
button.icon { padding: .35rem .55rem; }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .6rem; width: 100%; }
textarea { min-height: 5rem; resize: vertical; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
label.inline { display: inline-flex; gap: .4rem; align-items: center; color: var(--text); font-size: 1rem; }
.field { margin-bottom: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

/* paklik */
.deck { display: flex; align-items: center; gap: .6rem; padding: .7rem .2rem; border-bottom: 1px solid var(--border); }
.deck:last-child { border-bottom: 0; }
.deck .name { flex: 1; font-weight: 600; min-width: 8rem; }
.deck .name a { color: var(--text); }
.counts { display: flex; gap: .5rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.c-new { color: var(--easy); } .c-learn { color: var(--bad); } .c-review { color: var(--good); }
.counts span { min-width: 1.8rem; text-align: right; }
.counts .zero { opacity: .35; }

/* kártyalista */
table { width: 100%; border-collapse: collapse; }
td, th { padding: .45rem .4rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--bg); }
.tag { display: inline-block; font-size: .78rem; padding: 0 .4rem; border-radius: 99px; background: var(--bg);
  border: 1px solid var(--border); color: var(--muted); margin: 0 .15rem .15rem 0; }
.badge { font-size: .78rem; padding: .05rem .4rem; border-radius: 4px; border: 1px solid var(--border); white-space: nowrap; }
.badge.new { color: var(--easy); } .badge.due { color: var(--good); } .badge.hard { color: var(--bad); }
.bulkbar { position: sticky; bottom: .5rem; }

/* gyakorlás */
.study-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.card-face { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: .6rem; padding: 1.5rem 1rem; }
.card-face .q { font-size: 2rem; font-weight: 600; word-break: break-word; }
.card-face .a { font-size: 1.6rem; word-break: break-word; }
.card-face .ex { font-style: italic; color: var(--muted); }
.card-face hr { width: 100%; border: 0; border-top: 1px solid var(--border); }
.speak { border: 0; background: none; font-size: 1.3rem; padding: .2rem .4rem; }
.rate-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.rate-btns button { flex-direction: column; justify-content: center; font-weight: 600; padding: .6rem .2rem; }
.rate-btns button small { font-weight: 400; }
.rate-btns .r1 { border-color: var(--again); color: var(--again); }
.rate-btns .r2 { border-color: var(--hard); color: var(--hard); }
.rate-btns .r3 { border-color: var(--good); color: var(--good); }
.rate-btns .r4 { border-color: var(--easy); color: var(--easy); }
.rate-btns .suggested { outline: 3px solid currentColor; outline-offset: 2px; }
.check-result { padding: .6rem .8rem; border-radius: 8px; border: 1px solid var(--border); }
.check-result.ok { border-color: var(--ok); }
.check-result.almost { border-color: var(--warn); }
.check-result.bad { border-color: var(--bad); }
.diff .x { background: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); text-decoration: line-through; }
.diff .m { background: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.mic { font-size: 1.4rem; padding: .7rem 1.1rem; }
.mic.listening { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.modes { display: flex; gap: .3rem; flex-wrap: wrap; }
.modes button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.kbd-hint { font-size: .8rem; color: var(--muted); text-align: center; margin-top: .6rem; }
@media (max-width: 600px) { .kbd-hint { display: none; } .card-face .q { font-size: 1.6rem; } }

/* statisztika */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.bars div.ok { background: var(--good); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.stat b { display: block; font-size: 1.6rem; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: 8px; z-index: 50; max-width: 90vw; }
#toast.err { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text);
  max-width: 520px; width: calc(100% - 2rem); }
dialog::backdrop { background: rgba(0,0,0,.4); }
