/* Vzhled aplikace. Žádné externí fonty ani obrázky – vše je místní. */

:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe6da;
  --ink: #1b2420;
  --muted: #5f6b64;
  --line: #d9d2c2;
  --rail: #15231f;
  --rail-ink: #e9e4d6;
  --rail-muted: #93a39b;
  --primary: #1f6b57;
  --primary-ink: #ffffff;
  --primary-soft: #dcebe4;
  --gold: #d99a2b;
  --ok: #1f7a4d;
  --ok-soft: #dcf0e3;
  --bad: #b3392b;
  --bad-soft: #f7dfda;
  --warn: #8a5a00;
  --warn-soft: #f8ebc9;
  --ma: #3653c7;
  --cj: #b8431f;
  --aj: #0c7a78;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(27, 36, 32, .06), 0 6px 20px rgba(27, 36, 32, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715;
    --surface: #1a221f;
    --surface-2: #232d29;
    --ink: #e8ebe6;
    --muted: #9aa8a0;
    --line: #2f3b36;
    --rail: #0c1210;
    --rail-ink: #e2e6df;
    --rail-muted: #7f8f87;
    --primary: #3fa286;
    --primary-ink: #06130f;
    --primary-soft: #1d3a31;
    --gold: #e3ad4a;
    --ok: #55c088;
    --ok-soft: #173326;
    --bad: #ef8474;
    --bad-soft: #40201b;
    --warn: #e8c26a;
    --warn-soft: #3a2f12;
    --ma: #8fa3ff;
    --cj: #f0946f;
    --aj: #56c7c2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 .7em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- rozvržení ---------- */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--gold); color: #1b1404;
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.brand-name { font-size: 18px; font-weight: 750; letter-spacing: -.01em; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--rail-ink); text-decoration: none; font-weight: 550;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); }
.nav-link.active { background: rgba(255, 255, 255, .12); box-shadow: inset 3px 0 0 var(--gold); }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .85; }

.rail-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 4px; }
.ai-state { font-size: 13px; color: var(--rail-muted); display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 6px; border-radius: 8px; }
.ai-state:hover { background: rgba(255, 255, 255, .07); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #7d8a84; flex: none; }
.dot.on { background: #58c98f; }
.rail-quit { background: none; border: 0; color: var(--rail-muted); font: inherit; font-size: 13px; text-align: left; padding: 6px; border-radius: 8px; cursor: pointer; }
.rail-quit:hover { color: var(--rail-ink); background: rgba(255, 255, 255, .07); }
.rail-user { background: none; border: 0; color: var(--rail-ink); font: inherit; font-size: 13px; text-align: left; padding: 6px; border-radius: 8px; cursor: pointer; }
.rail-user:hover { background: rgba(255, 255, 255, .07); }
.rail-user .muted { color: var(--rail-muted); }
.login { max-width: 380px; margin: 10vh auto 0; }
.login h1 { margin: 0; font-size: 24px; }
.login .brand-mark { width: 40px; height: 40px; }

.main { padding: 28px 34px 60px; min-width: 0; }
.main.wide { padding: 0; }
.page { max-width: 1060px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .lead { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 0 8px 0 4px; }
  .brand-name { display: none; }
  .nav-link span { display: none; }
  .rail-foot { margin: 0 0 0 auto; display: flex; }
  .rail-quit { display: none; }
  .main { padding: 18px 16px 50px; }
}

/* ---------- prvky ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h2 { margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid .card + .card { margin-top: 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, .nav-link:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice:focus-within {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--primary); padding-inline: 8px; }
.btn.quiet:hover { background: var(--primary-soft); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 12px 20px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ai { background: var(--primary-soft); color: var(--primary); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { appearance: none; background: none; border: 0; font: inherit; font-weight: 650; color: var(--muted); padding: 9px 14px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--subject, var(--primary)); }

.subject-ma { --subject: var(--ma); }
.subject-cj { --subject: var(--cj); }
.subject-aj { --subject: var(--aj); }
.subject-tag { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--subject, var(--primary)); }

.notice { border-radius: 10px; padding: 11px 14px; background: var(--warn-soft); color: var(--warn); border: 1px solid transparent; }
.notice.info { background: var(--primary-soft); color: var(--ink); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice a { color: inherit; font-weight: 650; }

label.field { display: grid; gap: 5px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--subject, var(--primary)); border-radius: 999px; transition: width .3s; }
.bar.ok > i { background: var(--ok); }
.bar.mid > i { background: var(--gold); }
.bar.low > i { background: var(--bad); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .bar > i { transition: none; } }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }

table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }
.table td.right, .table th.right { text-align: right; }

/* ---------- testy ---------- */

.test-list { display: grid; gap: 0; padding: 0; overflow: hidden; }
.year-head { padding: 8px 18px; background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--muted); letter-spacing: .03em; }
.test-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(0, 2fr) auto; gap: 14px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.test-row .name { font-weight: 650; }
.test-row .files { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 720px) { .test-row { grid-template-columns: 1fr; gap: 8px; } }

/* ---------- prohlížeč PDF ---------- */

.viewer { display: flex; flex-direction: column; height: 100vh; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-bar .title { font-weight: 700; margin-right: auto; }
.pdf-scroll { flex: 1; overflow: auto; background: var(--surface-2); padding: 18px; }
.pdf-pages { display: grid; gap: 14px; justify-items: center; }
.pdf-page { background: #fff; box-shadow: var(--shadow); border-radius: 4px; position: relative; max-width: 100%; }
.pdf-page canvas { display: block; border-radius: 4px; max-width: 100%; height: auto; }
.pdf-page .page-no { position: absolute; top: 6px; right: 8px; font-size: 11px; color: #555; background: rgba(255, 255, 255, .85); padding: 1px 6px; border-radius: 6px; }
.pdf-msg { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- úloha ---------- */

.task { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr); height: 100vh; }
.task-pdf { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); height: 100vh; }
.task-side { display: flex; flex-direction: column; height: 100vh; min-width: 0; background: var(--surface); }
.task-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.task-body { flex: 1; overflow: auto; padding: 18px; display: grid; gap: 16px; align-content: start; }
.task-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.task-text { font-size: 16px; white-space: pre-wrap; }
.task-context { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; }
@media (max-width: 980px) {
  .task { grid-template-columns: 1fr; height: auto; }
  .task-pdf { height: 60vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .task-side { height: auto; }
}

.part { display: grid; gap: 8px; }
.part-label { font-weight: 700; }
.choices { display: grid; gap: 6px; }
.choices.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); }
.choice:hover { border-color: var(--muted); }
.choice input { accent-color: var(--primary); margin: 0; transform: translateY(1px); }
.choice .letter { font-weight: 750; min-width: 1.1em; }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.locked { cursor: default; }
.verdict { display: flex; gap: 8px; align-items: baseline; font-weight: 650; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict.mid { color: var(--warn); }
.answer-key { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }

.listen { position: sticky; top: -18px; z-index: 1; margin: -18px -18px 0; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.listen audio { width: 100%; }
.listen .row { gap: 8px; align-items: center; }

.ai-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ai-box > header { padding: 8px 12px; background: var(--primary-soft); font-weight: 700; display: flex; gap: 8px; align-items: center; }
.ai-box > div { padding: 12px 14px; }
.rich p { margin: 0 0 .6em; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 0 0 .6em; padding-left: 1.3em; }
.rich code { font-family: var(--mono); font-size: .93em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.chat-msg { padding: 9px 12px; border-radius: 10px; background: var(--surface-2); }
.chat-msg.me { background: var(--primary-soft); justify-self: end; max-width: 90%; }
.chat { display: grid; gap: 8px; }

.progress-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.progress-dots i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-2); }
.progress-dots i.ok { background: var(--ok); }
.progress-dots i.bad { background: var(--bad); }
.progress-dots i.mid { background: var(--gold); }
.progress-dots i.now { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- přehled a statistiky ---------- */

.subject-card { border-top: 4px solid var(--subject); display: grid; gap: 10px; align-content: start; }
.big-number { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.topic-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(90px, 1fr) 64px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: 0; }
.mode-card { display: grid; gap: 6px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.mode-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow); }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.shell.bare { grid-template-columns: minmax(0, 1fr); }
.shell.bare .rail { display: none; }

.task.solo { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; }
.task.solo .task-side { max-width: 820px; width: 100%; margin: 0 auto; height: auto; min-height: 100vh; border-inline: 1px solid var(--line); }
.day-bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; }
.day-bars .day { flex: 1; display: grid; gap: 4px; justify-items: center; align-content: end; height: 100%; font-size: 11px; color: var(--muted); }
.day-bars .day i { width: 100%; max-width: 26px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.page > * + * { margin-top: 14px; }
.page > .page-head + * { margin-top: 0; }
input[type=checkbox], input[type=radio] { width: auto; }

details.share { padding: 12px 18px; }
details.share > summary { cursor: pointer; font-weight: 700; }
details.share[open] > summary { margin-bottom: 10px; }

/* ---------- doplňky: paleta znaků, záložky, plán, tisk ---------- */
.symbols { display: flex; flex-wrap: wrap; gap: 4px; }
.symbols button { min-width: 30px; padding: 3px 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 7px; font: inherit; cursor: pointer; }
.symbols button:hover { border-color: var(--muted); }
.star { background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 8px; }
.star.on { color: var(--gold); }
.star:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.photo-row img { max-height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; align-items: end; }
.estimate { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 4px; }
.bad-text { color: var(--bad); font-weight: 650; }
.print-part { margin-top: 8px; display: grid; gap: 2px; }
.print-lines { margin-top: 10px; border-bottom: 1px solid var(--line); padding-bottom: 44px; }
input[type=date] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
button.choice { font: inherit; color: inherit; text-align: left; width: 100%; }

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --ink: #000; --muted: #444; --line: #bbb; color-scheme: light; }
  .rail, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { font-size: 12pt; }
}
