:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2233;
  --muted: #6b7288;
  --line: #e3e6ef;
  --accent: #4f6bed;
  --accent-soft: #e8ecfd;
  --ok: #1f9d57;
  --ok-soft: #e2f6ea;
  --bad: #d64545;
  --bad-soft: #fbe6e6;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141722;
    --card: #1e2230;
    --text: #e8eaf2;
    --muted: #9aa1b8;
    --line: #2f3446;
    --accent: #7d93ff;
    --accent-soft: #283158;
    --ok: #4cc983;
    --ok-soft: #1d3a2a;
    --bad: #ff7a7a;
    --bad-soft: #432426;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.8rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.hero { margin-bottom: 20px; }
.back { color: var(--accent); text-decoration: none; display: inline-block; margin-bottom: 14px; }

.search {
  width: 100%; padding: 12px 14px; font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px;
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 12px 0;
}
.topic-link {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  text-decoration: none; color: inherit; transition: border-color .15s, transform .15s;
}
.topic-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.topic-link .t { font-weight: 600; }
.topic-link .meta { font-size: .85rem; color: var(--muted); }
.score-pill {
  flex-shrink: 0; font-size: .85rem; padding: 4px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.tag {
  display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent);
  margin-bottom: 6px;
}
.topic-head { margin-bottom: 16px; }

.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 5px; position: sticky; top: 8px; z-index: 5; }
.tabs button {
  flex: 1; font: inherit; font-size: .95rem; padding: 10px 6px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Výpisky */
.notes h2:first-child { margin-top: 8px; }
.notes ul { padding-left: 1.2em; margin: 0; }
.notes li { margin: 6px 0; }
.notes .term { font-weight: 700; color: var(--accent); }
.notes p { margin: 8px 0; }

/* Kartičky */
.flash-wrap { perspective: 1000px; margin: 16px 0; }
.flash {
  position: relative; min-height: 230px; cursor: pointer; transform-style: preserve-3d;
  transition: transform .45s;
}
.flash.flipped { transform: rotateY(180deg); }
.flash .face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 24px; backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.3rem; font-weight: 600;
}
.flash .back-face { transform: rotateY(180deg); font-weight: 500; font-size: 1.15rem; background: var(--accent-soft); }
.flash .hint { position: absolute; bottom: 10px; font-size: .8rem; color: var(--muted); font-weight: 400; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.btn {
  font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

/* Test */
.q-num { font-size: .85rem; color: var(--muted); }
.q-text { font-size: 1.2rem; font-weight: 600; margin: 6px 0 14px; }
.opt {
  display: block; width: 100%; text-align: left; font: inherit; padding: 12px 14px; margin: 8px 0;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.answer-input {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; color: inherit;
  border: 2px solid var(--line); background: var(--card); margin-bottom: 10px;
}
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .explain { color: var(--text); margin-top: 4px; font-size: .95rem; }

.result { text-align: center; }
.result .big { font-size: 3rem; font-weight: 800; line-height: 1.1; }
.result .grade { font-size: 1.2rem; margin: 6px 0 16px; }
.mistake { border-left: 4px solid var(--bad); }
.mistake .your { color: var(--bad); }
.mistake .right { color: var(--ok); font-weight: 600; }

.setup label { display: block; margin: 8px 0; }
.setup select { font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: inherit; }
