:root {
  --bg: #14171c;
  --panel: #1c2129;
  --panel-2: #232a34;
  --line: #333c48;
  --text: #e6eaf0;
  --muted: #97a2b2;
  --accent: #4da3ff;
  --ok: #37c98b;
  --warn: #f0b429;
  --err: #ef5a5a;
  --white-checker: #f2f0e9;
  --black-checker: #2b2f36;
  --suggest: #37c98b;
  --last: #f0b429;
  --hit: #ef5a5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Roboto, system-ui, sans-serif;
}

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.hint { color: var(--muted); font-size: 12px; }

.layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(430px, 520px);
  gap: 16px; padding: 16px; align-items: start;
}
@media (max-width: 1150px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.panel-head.sep { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.panel-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin: 0; font-weight: 600; }

/* ---------------- deska ---------------- */
#board-wrap { width: 100%; }
#board { width: 100%; height: auto; display: block; }

.pips { display: flex; gap: 8px; }
.pip-badge {
  font-size: 12px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--muted);
}
.pip-badge b { color: var(--text); }
.pip-badge.white b { color: #fff; }

.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.swatch { display: inline-block; width: 20px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.swatch.suggested { background: var(--suggest); }
.swatch.last { background: var(--last); }
.swatch.hit { background: var(--hit); }

/* ---------------- status ---------------- */
.status {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 12px;
}
.status.state-ok { border-color: rgba(55,201,139,.5); }
.status.state-warn { border-color: rgba(240,180,41,.55); }
.status.state-err { border-color: rgba(239,90,90,.6); }
.status-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.state-ok .dot { background: var(--ok); }
.state-warn .dot { background: var(--warn); }
.state-err .dot { background: var(--err); }
.state-err #status-text { color: var(--err); }
.state-warn #status-text { color: var(--warn); }
.state-ok #status-text { color: var(--ok); }

.counters { display: flex; gap: 10px; margin-top: 9px; }
.counter {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; display: grid; gap: 1px;
}
.counter.bad { border-color: var(--err); background: rgba(239,90,90,.09); }
.counter .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.counter .value { font-size: 17px; }
.counter .value b { font-variant-numeric: tabular-nums; }
.counter.bad .value b { color: var(--err); }
.counter .detail { font-size: 11px; color: var(--muted); }

.messages { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.messages li { font-size: 12.5px; padding-left: 16px; position: relative; }
.messages li::before { content: "▸"; position: absolute; left: 2px; }
.messages li.err { color: var(--err); }
.messages li.warn { color: var(--warn); }

/* ---------------- tabulky ---------------- */
.tables { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; padding: 4px 4px; text-align: center;
  border-bottom: 1px solid var(--line);
}
.grid th:first-child { text-align: left; }
.grid td { padding: 1px 2px; }
.grid td.num {
  width: 34px; color: var(--muted); font-size: 12px; text-align: right;
  padding-right: 6px; white-space: nowrap;
}
.grid td.num.home-w { color: #cfe6ff; }
.grid td.num.home-b { color: #ffd9a8; }
.rowlab { font-size: 12px; color: var(--muted); white-space: nowrap; padding-right: 6px; }

.cell {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 4px 6px; text-align: center; font-size: 13.5px;
  font-variant-numeric: tabular-nums; outline: none;
}
.cell:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(77,163,255,.22); }
.cell.filled { background: #2a3644; font-weight: 600; }
.cell.conflict { border-color: var(--err); background: rgba(239,90,90,.14); }
.grid tr.active-row .cell { background: #2d3646; }

.subgrid { margin-top: 12px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.small-grid { max-width: 300px; }

/* ---------------- ovládací prvky ---------------- */
.row { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.row > label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row > input[type=text] {
  flex: 1; min-width: 180px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; outline: none;
}
.row > input[type=text]:focus { border-color: var(--accent); }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 11px; cursor: pointer; font-size: 12.5px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.analyze-row { margin-top: 14px; align-items: center; }
.file-label { display: inline-flex; align-items: center; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button {
  background: transparent; color: var(--muted); border: 0; padding: 5px 12px;
  cursor: pointer; font-size: 12.5px;
}
.segmented button.active { background: var(--accent); color: #06121f; font-weight: 600; }

.die {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font-size: 14px;
}

/* ------------- načtení z obrázku ------------- */
.drop {
  border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 12px; background: var(--panel-2); text-align: center;
  transition: border-color .12s, background .12s; outline: none;
}
.drop:focus, .drop:hover { border-color: var(--accent); }
.drop.over { border-color: var(--accent); background: rgba(77,163,255,.1); }
.drop.busy { opacity: .6; }
.drop-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.drop a { color: var(--accent); }
.drop .check { margin-top: 6px; }

.recog {
  border: 1px solid var(--suggest); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 12px; background: rgba(55,201,139,.07);
}
.recog.hidden { display: none; }
.recog.fail { border-color: var(--err); background: rgba(239,90,90,.08); }
.recog-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
#recog-img { width: 100%; border-radius: 6px; display: block; border: 1px solid var(--line); }
.recog .messages { margin: 8px 0; }
.recog .btn-row { margin-top: 9px; }

/* ------------- textový zápis pozice ------------- */
.quick-block { margin-bottom: 12px; }
.quick-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.quick-head label { font-size: 12px; color: var(--muted); }
.mono {
  width: 100%; resize: vertical; min-height: 46px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px;
  font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  font-size: 13px; line-height: 1.5; outline: none; letter-spacing: .3px;
}
.mono:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(77,163,255,.18); }
.mono.bad { border-color: var(--err); box-shadow: 0 0 0 2px rgba(239,90,90,.16); }
.quick-hint.bad { color: var(--err); }
.quick-hint.good { color: var(--ok); }

.micro { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; }
.micro.warn { color: var(--warn); }
.micro code { background: var(--panel-2); padding: 1px 4px; border-radius: 3px; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; font-size: 10.5px; font-family: inherit;
}
.check { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------- engine ---------------- */
.badge {
  font-size: 11px; padding: 2px 9px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.strong { border-color: rgba(55,201,139,.55); color: var(--ok); }
.badge.weak { border-color: rgba(240,180,41,.55); color: var(--warn); }
.row.hidden, .btn-row.hidden { display: none; }

/* ---------------- analýza ---------------- */
.analysis { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.analysis.hidden { display: none; }
.analysis-head { display: flex; align-items: baseline; justify-content: space-between; }
.analysis-head h3 { font-size: 13px; margin: 0; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); }
.candidates { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.candidates li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
.candidates li:hover { border-color: var(--accent); }
.candidates li.sel { border-color: var(--suggest); background: rgba(55,201,139,.1); }
.candidates li.best .mv { color: var(--ok); }
.candidates .rank { font-size: 11px; color: var(--muted); width: 16px; flex: none; }
.candidates .mv { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13.5px; flex: 1; }
.candidates .sc { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.candidates .sc b { color: var(--text); font-weight: 600; }
.candidates .loss { color: var(--warn); }
#play-row { margin-top: 8px; }
