/* Pyhřiště – stejná designová rodina jako zářijové materiály:
   papír/inkoust, modrý akcent, Literata + IBM Plex. */

:root {
  --paper: #FAF9F4;
  --ink: #20262E;
  --muted: #5C6470;
  --accent: #2A5CAA;
  --accent-soft: #E8EEF8;
  --ok: #2E7D46;
  --ok-soft: #E5F2E9;
  --fail: #B3372E;
  --fail-soft: #F9E9E7;
  --line: #E2E1D8;
  --line-strong: #C9C8BD;
  --card: #FFFFFE;
  --code-bg: #F1F0E9;
  --term-bg: #14181F;
  --term-ink: #D9DCD6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151920;
    --ink: #E6E7E2;
    --muted: #9AA2AD;
    --accent: #8FB0E8;
    --accent-soft: #1D2735;
    --ok: #6FBF87;
    --ok-soft: #17251B;
    --fail: #E08079;
    --fail-soft: #2B1715;
    --line: #2A303A;
    --line-strong: #3A4250;
    --card: #1A1F28;
    --code-bg: #10141B;
    --term-bg: #0C0F14;
    --term-ink: #D9DCD6;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: .95rem;
  line-height: 1.5;
}

/* ---------- horní lišta ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 1.1rem;
  border-bottom: 2px solid var(--ink);
  background: var(--card);
}
.brand { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.brand-name {
  font-family: "Literata", Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
}
.brand-sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar-right { display: flex; align-items: center; gap: .7rem; }
#studentName {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: .3rem .55rem;
  width: 11.5rem;
}
#studentName:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#studentName.shake { animation: shake .5s; border-color: var(--fail); }
@keyframes shake { 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -3px 0; } }
@media (prefers-reduced-motion: reduce) { #studentName.shake { animation: none; } }

.status {
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  letter-spacing: .06em;
  padding: .25rem .6rem;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}
.status[data-kind="ready"] { color: var(--ok); border-color: var(--ok); }
.status[data-kind="running"] { color: var(--accent); border-color: var(--accent); }
.status[data-kind="error"] { color: var(--fail); border-color: var(--fail); }

/* ---------- rozvržení ---------- */
.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: calc(100vh - 3.2rem);
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: .9rem .6rem;
  background: var(--card);
}
.task-group {
  font-family: "IBM Plex Mono", monospace;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1rem .4rem .3rem;
}
.task-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: .88rem;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 2px;
  padding: .4rem .55rem;
  cursor: pointer;
}
.task-link:hover, .task-link:focus-visible { background: var(--accent-soft); outline: none; }
.task-link.active { background: var(--accent); color: var(--paper); }
.task-badge { color: var(--ok); font-weight: 600; }
.task-link.active .task-badge { color: var(--paper); }

.main { padding: 1.1rem 1.4rem 3rem; max-width: 62rem; }

.mode-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
h1 {
  font-family: "Literata", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 .6rem;
}
#examplePicker {
  font: inherit;
  font-size: .85rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: .3rem .5rem;
  max-width: 100%;
}

.task-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: .8rem 1rem;
  margin: 0 0 .9rem;
}
.task-panel h2 {
  font-family: "Literata", Georgia, serif;
  font-size: 1.1rem;
  margin: 0 0 .3rem;
}
.task-panel p { margin: .3rem 0; }
.task-panel code, .stdin-wrap code {
  font-family: "IBM Plex Mono", monospace;
  font-size: .85em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: .02rem .28rem;
}

/* ---------- editor ---------- */
.editor-host { border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.CodeMirror {
  height: auto;
  min-height: 14rem;
  max-height: 46vh;
  font-family: "IBM Plex Mono", monospace;
  font-size: .9rem;
  line-height: 1.55;
}
.CodeMirror-scroll { min-height: 14rem; max-height: 46vh; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .7rem 0; }
.toolbar-spacer { flex: 1; }
.btn {
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: .42rem .95rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.primary:hover:not(:disabled) { color: var(--paper); filter: brightness(1.1); }
.btn.danger:hover:not(:disabled) { border-color: var(--fail); color: var(--fail); }
.btn.accent { border-color: var(--accent); color: var(--accent); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--accent); border-color: transparent; }

/* ---------- vstup ---------- */
.stdin-wrap { margin: 0 0 .7rem; font-size: .88rem; }
.stdin-wrap summary { cursor: pointer; color: var(--muted); }
.stdin-wrap summary:hover { color: var(--accent); }
#stdinBox {
  width: 100%;
  margin-top: .4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: .85rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: .5rem .6rem;
  resize: vertical;
}
.stdin-note { color: var(--muted); font-size: .82rem; margin: .4rem 0 0; }

/* ---------- terminál ---------- */
.terminal {
  background: var(--term-bg);
  color: var(--term-ink);
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  min-height: 8rem;
  max-height: 40vh;
  overflow: auto;
  padding: .7rem .85rem;
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: .86rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.t-out { color: var(--term-ink); }
.t-err { color: #F09A93; }
.t-sys { color: #8C97A6; font-style: italic; }
.t-echo { color: #9FC1F2; }
.term-input-row { display: inline-flex; }
.term-input-row::before { content: "› "; color: #9FC1F2; }
.term-input {
  font: inherit;
  color: #9FC1F2;
  background: none;
  border: none;
  border-bottom: 1px solid #9FC1F2;
  outline: none;
  width: 14rem;
}

/* ---------- výsledky testů ---------- */
.results {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  padding: .7rem .9rem;
}
.results-head {
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .4rem;
}
.result-row { padding: .3rem .2rem; border-top: 1px solid var(--line); font-size: .9rem; }
.result-row:first-of-type { border-top: none; }
.result-row.ok { color: var(--ok); }
.result-row.fail { color: var(--fail); }
.result-row.pending { color: var(--muted); }
.result-detail {
  margin: .4rem 0 .2rem;
  padding: .5rem .7rem;
  background: var(--fail-soft);
  border-radius: 2px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.results-foot { margin-top: .6rem; font-weight: 600; }
.results-foot.ok { color: var(--ok); }
.results-foot.fail { color: var(--fail); }

/* ---------- mobil ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .topbar { flex-wrap: wrap; }
  #studentName { width: 9rem; }
}

/* ---------- účty (mode-ucet) ---------- */
body.mode-ucet #studentName { display: none; }
.whoami {
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.login-overlay[hidden] { display: none; }
.login-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.login-box {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent);
  border-radius: 3px;
  padding: 1.4rem 1.6rem 1.5rem;
  width: 100%;
  max-width: 22rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.login-box h2 {
  font-family: "Literata", Georgia, serif;
  font-size: 1.3rem;
  margin: 0 0 .3rem;
}
.login-hint { color: var(--muted); font-size: .85rem; margin: 0 0 .9rem; }
.login-box label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin: .6rem 0;
}
.login-box input {
  display: block;
  width: 100%;
  margin-top: .25rem;
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: .45rem .6rem;
}
.login-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-err { color: var(--fail); font-size: .85rem; min-height: 1.2em; margin: .5rem 0; }
.login-box .btn { width: 100%; margin-top: .3rem; }

/* ---------- hláška o vkládání ---------- */
.paste-hint {
  display: none;
  margin-top: .4rem;
  padding: .45rem .7rem;
  font-size: .85rem;
  color: var(--amber-ink, #7A4E0F);
  background: var(--fail-soft);
  border: 1px dashed var(--fail);
  border-radius: 2px;
  color: var(--fail);
}
.paste-hint.show { display: block; }

/* změna hesla */
.heslo-akce { display: flex; gap: 8px; align-items: center; }
.heslo-akce .btn { flex: 0 0 auto; }
