:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --panel-2: #232b36;
  --border: #2f3a48;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #58cc02;
  --accent-dark: #3f9a00;
  --ok: #58cc02;
  --bad: #ff5a5f;
  --warn: #ffb020;
  --blue: #4da3ff;
  --pad: 16px;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; min-height: 100dvh; }

#app {
  max-width: 760px; margin: 0 auto;
  padding: var(--pad) var(--pad) 0;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: .8rem; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
p { margin: 0 0 8px; }
a { color: var(--blue); }
.muted { color: var(--muted); }
code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font: 0.9em ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- horní lišta ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.topbar h1 { margin: 0; }
.stats { display: flex; gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-weight: 600; white-space: nowrap; }

/* ---------- tlačítka ---------- */
.btn {
  background: var(--accent); color: #0b1a00; border: 0; border-bottom: 4px solid var(--accent-dark);
  border-radius: var(--radius); padding: 12px 24px; min-height: 48px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.btn:disabled { background: var(--panel-2); color: var(--muted); border-bottom-color: var(--border); cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); color: var(--text); border-bottom-color: var(--border); }
.btn.bad { background: var(--bad); border-bottom-color: #c23a3f; color: #fff; }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: .8rem; }
.btn.block { width: 100%; }

/* ---------- úvod ---------- */
.lead { color: var(--muted); margin: 0 0 12px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.quick .btn { text-transform: none; letter-spacing: 0; font-size: .95rem; padding: 10px 12px; }
.search {
  width: 100%; background: var(--panel); color: var(--text); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; font: inherit; margin-bottom: 12px;
}
.search:focus { outline: none; border-color: var(--blue); }
.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.controls .group { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--panel); border: 0; padding: 6px 14px; min-width: 40px; }
.seg button.on { background: var(--blue); color: #04101f; font-weight: 700; }

.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.topic {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  text-align: left; background: var(--panel); border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 14px; cursor: pointer;
}
.topic:hover { border-color: var(--muted); }
.topic.on { border-color: var(--blue); background: #16263a; }
.topic .head { display: flex; align-items: center; gap: 10px; padding-right: 24px; }
.topic .icon { font-size: 1.6rem; line-height: 1; }
.topic .name { font-weight: 700; line-height: 1.25; }
.topic .desc { color: var(--muted); font-size: .85rem; }
.topic .check { position: absolute; top: 10px; right: 12px; color: var(--blue); font-weight: 700; }
.topic .bar { margin-top: auto; }
.topic .learn { margin-top: 10px; width: 100%; text-transform: none; letter-spacing: 0; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.empty { text-align: center; padding: 32px 0; }

/* spodní lepivý panel (úvod, téma, kvíz) */
.sticky-foot {
  position: sticky; bottom: 0; z-index: 5;
  margin: auto calc(-1 * var(--pad)) 0; margin-top: auto;
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--border);
}
.page-end { height: 24px; flex: none; }
.navrow { display: flex; gap: 10px; }
.navrow .btn { flex: 1; }

/* ---------- téma a lekce ---------- */
.back { align-self: flex-start; background: none; border: 0; color: var(--muted); padding: 8px 0; margin-bottom: 4px; min-height: 40px; }
.back:hover { color: var(--text); }
.lessonlist { display: flex; flex-direction: column; gap: 8px; }
.lessonitem {
  display: flex; gap: 12px; align-items: center; text-align: left;
  background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.lessonitem:hover { border-color: var(--muted); }
.lessonitem .num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.lessonitem.read .num { background: var(--accent); color: #0b1a00; }

.lesson { padding-bottom: 16px; overflow-wrap: anywhere; }
.lesson h3 { margin: 22px 0 6px; font-size: 1.05rem; color: var(--blue); }
.lesson ul { padding-left: 20px; margin: 6px 0 12px; }
.lesson li { margin: 3px 0; }
.lesson pre { background: #0a0d11; border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-x: auto; margin: 10px 0; }
.lesson pre code { background: none; border: 0; padding: 0; font-size: .85rem; line-height: 1.45; overflow-wrap: normal; }
.callout { background: #2a2310; border-left: 4px solid var(--warn); border-radius: 6px; padding: 10px 14px; margin: 12px 0; }
.tablewrap { overflow-x: auto; margin: 10px 0; }
.lesson table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.lesson th, .lesson td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.lesson th { background: var(--panel-2); }

.browse { margin: 20px 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.browse summary { cursor: pointer; font-weight: 600; }
.brq { border-top: 1px solid var(--border); padding: 10px 0; margin-top: 10px; overflow-wrap: anywhere; }
.brq .qq { font-weight: 600; }
.brq .aa { margin: 4px 0; color: var(--ok); }
.brq .ee { font-size: .9rem; }

/* ---------- kvíz ---------- */
.quizhead { display: flex; align-items: center; gap: 12px; }
.quizhead .close { background: none; border: 0; color: var(--muted); font-size: 1.8rem; line-height: 1; padding: 4px 10px; min-width: 44px; min-height: 44px; }
.progress { flex: 1; height: 14px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.qwrap { flex: 1; padding: 20px 0 24px; }
.qtopic { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.qtopic .retry { color: var(--warn); margin-left: 8px; }
.qtext { font-size: 1.3rem; font-weight: 700; line-height: 1.35; margin-bottom: 4px; overflow-wrap: anywhere; }
.qhint { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--panel); border: 2px solid var(--border); border-bottom-width: 4px; border-radius: var(--radius);
  padding: 12px 14px; overflow-wrap: anywhere;
}
.opt .k { flex: none; width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 6px; display: grid; place-items: center; font-size: .75rem; color: var(--muted); margin-top: 1px; }
.opt:hover:not(:disabled) { border-color: var(--muted); }
.opt.sel { border-color: var(--blue); background: #16263a; }
.opt.sel .k { border-color: var(--blue); color: var(--blue); }
.opt.right { border-color: var(--ok); background: #14290a; }
.opt.wrong { border-color: var(--bad); background: #2e1517; }
.opt:disabled { cursor: default; }
.cmdinput {
  width: 100%; margin-top: 16px; background: #0a0d11; color: var(--text); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; font: 1rem ui-monospace, Consolas, monospace;
}
.cmdinput:focus { outline: none; border-color: var(--blue); }
.cmdinput.right { border-color: var(--ok); }
.cmdinput.wrong { border-color: var(--bad); }

/* spodní panel kvízu: tlačítko Zkontrolovat → zpětná vazba */
.qfoot {
  position: sticky; bottom: 0; z-index: 5;
  margin: 0 calc(-1 * var(--pad));
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--border);
  max-height: 60vh; max-height: 60dvh; overflow-y: auto;
}
.qfoot.ok { background: #14290a; border-color: var(--ok); }
.qfoot.no { background: #2e1517; border-color: var(--bad); }
.qfoot .title { font-weight: 800; font-size: 1.1rem; margin-bottom: 4px; }
.qfoot.ok .title { color: var(--ok); }
.qfoot.no .title { color: var(--bad); }
.qfoot .answer { margin-bottom: 8px; overflow-wrap: anywhere; }
.qfoot .btn { margin-top: 10px; }

/* ---------- shrnutí ---------- */
.center { text-align: center; margin: auto; padding: 24px 0; width: 100%; }
.big { font-size: 4rem; line-height: 1.2; }
.summary { display: flex; gap: 10px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.summary .stat { padding: 10px 18px; font-size: 1.05rem; }

@media (max-width: 480px) {
  :root { --pad: 14px; }
  h1 { font-size: 1.4rem; }
  .qtext { font-size: 1.15rem; }
  .topics { grid-template-columns: 1fr; }
  .stat { padding: 4px 10px; font-size: .9rem; }
  .btn { padding: 12px 16px; }
}
