:root {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #667069;
  --line: #dcd8cf;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe9;
  --warn: #b3261e;
  --sidebar-w: 320px;
  --top-h: 52px;
  --page-w: 880px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171a18; --panel: #222724; --ink: #ecefec; --muted: #9aa59d;
    --line: #363d38; --accent: #6fbf94; --accent-ink: #10201a; --accent-soft: #24352c; --warn: #f2b8b5;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.muted { color: var(--muted); }
.pad { padding: 24px; }
.spacer { flex: 1; }
a { color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn { border: 0; background: transparent; color: inherit; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- horná lišta ---- */
.topbar { position: fixed; z-index: 30; top: 0; left: 0; right: 0; height: var(--top-h); display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.book-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bookSel { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
#menuBtn { display: none; }

/* ---- bočné menu ---- */
.sidebar { position: fixed; z-index: 20; top: var(--top-h); bottom: 0; left: 0; width: var(--sidebar-w); overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line); padding-bottom: 40px; }
.search { position: sticky; top: 0; background: var(--panel); padding: 10px 12px; border-bottom: 1px solid var(--line); z-index: 2; }
.search input { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.results { margin-top: 8px; max-height: 45vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.results a { display: block; padding: 8px 10px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 13px; }
.results a:last-child { border-bottom: 0; }
.results a:hover { background: var(--accent-soft); }
.results small { color: var(--muted); display: block; }
.results .none { padding: 10px; color: var(--muted); font-size: 13px; }

.grp { margin: 0; }
.grp-h { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: transparent; color: var(--muted);
  padding: 14px 14px 6px; font: 600 12px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; cursor: pointer; text-align: left; }
.grp-h .chev { transition: transform .15s; }
.grp.closed .chev { transform: rotate(-90deg); }
.grp.closed .grp-items { display: none; }
.item { display: flex; align-items: stretch; margin: 1px 8px; border-radius: 8px; }
.item a.go { flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 7px 10px; color: var(--ink); text-decoration: none; border-radius: 8px; }
.item a.go .t { overflow: hidden; text-overflow: ellipsis; }
.item a.go .pg { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item:hover { background: var(--accent-soft); }
.item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.item.active a.go .t { font-weight: 650; }
a.dl { display: inline-flex; align-items: center; justify-content: center; width: 34px; color: var(--muted); border-radius: 8px; text-decoration: none; }
a.dl:hover { color: var(--accent); background: var(--panel); }
a.dl svg { width: 18px; height: 18px; }

/* ---- obsah ---- */
.content { margin-left: var(--sidebar-w); padding: calc(var(--top-h) + 20px) 24px 80px; outline: none; }
.sec { max-width: var(--page-w); margin: 0 auto 36px; scroll-margin-top: calc(var(--top-h) + 12px); }
.sec-h { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  position: sticky; top: calc(var(--top-h) + 6px); z-index: 5; }
.sec-h h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.sec-h .rng { color: var(--muted); font-size: 13px; white-space: nowrap; }
.sec-h .btn { white-space: nowrap; }
.page { position: relative; margin: 14px auto 0; background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  width: 100%; scroll-margin-top: calc(var(--top-h) + 70px); overflow: hidden; }
.page img { display: block; width: 100%; height: auto; }
.page .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 13px; }
.page .lbl { position: absolute; left: 8px; top: 8px; background: rgba(20,30,25,.7); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.page:hover .lbl { opacity: 1; }

/* tlačidlo „Kopírovať pozíciu“ na diagrame */
.dg { position: absolute; border: 0; }
.dg .cp { position: absolute; right: 2px; top: 2px; display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 6px; cursor: pointer;
  background: rgba(20,40,30,.86); color: #fff; font: 600 11px/1 system-ui, sans-serif; padding: 5px 7px; opacity: .0; transition: opacity .12s; }
.page:hover .dg .cp, .dg .cp:focus-visible, .dg:hover .cp { opacity: 1; }
.dg .cp:hover { background: var(--accent); }
.dg.unverified .cp::after { content: "?"; margin-left: 3px; opacity: .8; }
@media (hover: none) { .dg .cp { opacity: .92; } }

/* ---- okná ---- */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--ink); width: min(440px, 94vw); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg-inner { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dlg label.side { flex-direction: row; align-items: center; gap: 8px; }
.dlg input, .dlg select, .dlg textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.dlg textarea { font: 12.5px/1.4 ui-monospace, Consolas, monospace; resize: none; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.diag-board svg { width: 100%; height: auto; display: block; border-radius: 6px; }
.err { color: var(--warn); margin: 0; font-size: 14px; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2b25; color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }

.scrim { position: fixed; z-index: 15; inset: 0; background: rgba(0,0,0,.4); }

/* ---- prihlásenie ---- */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.login-logo { font-size: 44px; color: var(--accent); line-height: 1; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 12px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.login-card .btn { justify-content: center; padding: 10px; }

/* ---- mobil ---- */
@media (max-width: 900px) {
  #menuBtn { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; width: min(88vw, 340px); box-shadow: 0 0 24px rgba(0,0,0,.25); }
  body.menu-open .sidebar { transform: none; }
  .content { margin-left: 0; padding: calc(var(--top-h) + 12px) 10px 60px; }
  .zoom, #pwBtn { display: none; }
  .brand { font-size: 15px; }
  .book-title { display: none; }
}
@media print { .topbar, .sidebar, .dg { display: none !important; } .content { margin: 0; padding: 0; } .sec-h { position: static; } }

/* ---- dashboard ---- */
.home-btn { text-decoration: none; }
.dash { max-width: 780px; margin: 0 auto; padding: calc(var(--top-h) + 34px) 20px 60px; }
.dash h1 { margin: 0 0 4px; font-size: 26px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 26px; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.06); transition: border-color .15s, transform .1s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile-ico { font-size: 34px; margin-bottom: 10px; }
.tile-t { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.tile-d { color: var(--muted); font-size: 13.5px; line-height: 1.4; }

/* ---- úlohy: výber sekcie ---- */
.ulohy-wrap { max-width: 980px; margin: 0 auto; padding: calc(var(--top-h) + 26px) 16px 60px; }
.ulohy-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.name-field { display: flex; align-items: center; gap: 8px; }
.name-field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; width: 180px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; color: var(--ink); font: inherit; }
.cat-card:hover { border-color: var(--accent); }
.cat-card .ct { font-weight: 650; margin-bottom: 4px; }
.cat-card .cr { color: var(--muted); font-size: 12.5px; }
.cat-card .cbar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.cat-card .cbar > i { display: block; height: 100%; background: var(--accent); }
.cat-group-h { font: 600 12px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.cat-group-h:first-child { margin-top: 0; }

/* ---- hracia doska ---- */
.play { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; justify-content: center; }
.play-board { width: min(92vw, 480px); }
.board-svg { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.15); user-select: none; touch-action: manipulation; }
.sq-light { fill: var(--board-light, #eef0e6); }
.sq-dark { fill: var(--board-dark, #7c9473); }
.coord-lbl { fill: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 600; user-select: none; }
.sq-sel { fill: #f6d365 !important; }
.sq-move circle { fill: rgba(20,40,30,.35); }
.sq-move.cap circle { fill: none; stroke: rgba(20,40,30,.45); stroke-width: 3; }
.sq-last { fill: #f4e58a !important; }
.sq-hint { stroke: #d94f4f; stroke-width: 3; fill: none; }
.piece { cursor: grab; }
.play-side { flex: 1; min-width: 260px; max-width: 380px; }
.play-side h2 { margin: 0 0 6px; font-size: 18px; }
.play-meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.play-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.play-msg { min-height: 44px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; margin-bottom: 12px; }
.play-msg.warn { background: #fbeceb; color: var(--warn); }
.play-msg.win { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.play-links { display: flex; gap: 8px; flex-wrap: wrap; }
.promo-pick { display: flex; gap: 8px; margin-top: 10px; }
.promo-pick button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.promo-pick button svg { width: 30px; height: 30px; }

/* ---- kontá, správa, prehľad, updater ---- */
.who { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.tile-admin { border-style: dashed; }
.dash.wide { max-width: 1100px; }
.dash h2 { font-size: 18px; margin: 28px 0 10px; }
.dash h3 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; }
.card label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.card input[type=text], .card input[type=number], .card input[type=password], .card input[type=url], .card select,
.filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; min-width: 0; width: 100%; }
.card label.chk, label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.chk input { width: auto; margin: 0; }
.form-grid { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pw-row { display: flex; gap: 6px; align-items: center; }
.pw-row input { flex: 1; }
.tile-picks { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px 4px; margin: 4px 0 10px; }
.tile-picks legend { font-size: 13px; color: var(--muted); padding: 0 6px; display: flex; gap: 10px; align-items: center; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.form-actions .spacer { flex: 1; }
.btn.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.big { padding: 11px 18px; font-size: 15px; font-weight: 600; flex: 1; justify-content: center; }
.ok-msg { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.err-box { background: #fbeceb; color: #8c1d18; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.del-form { display: flex; gap: 10px; align-items: center; margin: -6px 0 18px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 26px 0 10px; }
.card .list-head { margin-top: 0; }
.list-head h1, .list-head h2 { margin: 0; font-size: 20px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.card .table-wrap { border-radius: 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { opacity: .55; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl code { font-size: 12.5px; }
.ico-list span { margin-right: 4px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.small { font-size: 12.5px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 200px; }
.upd-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; }
.ftp-box { border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px 2px; margin: 4px 0 12px; }
.ftp-box legend { display: flex; gap: 16px; padding: 0 6px; }
.ftp-box legend label { margin: 0; }
.upd-controls { display: flex; gap: 10px; margin: 6px 0 12px; }
.upd-status { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; border-left: 4px solid var(--accent); }
.upd-links { margin-top: 12px; font-size: 13.5px; display: grid; gap: 4px; word-break: break-all; }
.pgn-content { background: #16201b; color: #9fe0b8; padding: 12px; border-radius: 8px; font: 12px/1.45 Consolas, "SF Mono", monospace; white-space: pre-wrap; word-break: break-word; height: 280px; overflow: auto; margin: 0; }
.log-box { font: 11.5px/1.5 Consolas, "SF Mono", monospace; max-height: 170px; overflow: auto; word-break: break-all; }
.link-group { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.link-group:last-child { border-bottom: 0; }
.lg-h { font-weight: 600; font-size: 13.5px; min-width: 240px; }
.lg-items { display: flex; flex-wrap: wrap; gap: 6px; }
.links-tbl input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; font-size: 13px; }
.links-tbl td { padding: 5px 6px; }
@media (max-width: 820px) {
  .upd-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .lg-h { min-width: 0; width: 100%; }
  .who { display: none; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .err-box { background: #3a1f1e; color: #f2b8b5; }
}

/* ---- tlačová stránka ---- */
.tlac-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.tlac-form select, .tlac-form input[type=number] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
.sheet { max-width: 900px; margin: 0 auto; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 14px; }
.sheet-item { text-align: center; }
.sheet-item .lbl { font-weight: 650; font-size: 13px; margin-bottom: 4px; }
.sheet-item svg { width: 100%; height: auto; border: 1px solid #999; }
.sol-list { columns: 2; font-size: 13px; line-height: 1.7; }
.sol-list div { break-inside: avoid; }
@media print {
  :root { --bg: #fff; --panel: #fff; --ink: #111; --muted: #444; --line: #ccc; }
  .tlac-form, .no-print { display: none !important; }
  .ulohy-wrap { padding-top: 0 !important; }
  .sheet { max-width: none; }
  .sheet-page { page-break-after: always; }
}

/* ---- pätička ---- */
.site-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 22px 12px 16px; opacity: .75; }
