* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  color: #1c1c1c; background: #f3f2ef;
  display: flex; flex-direction: column;
}

header#top {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #262523; color: #f5f3ef;
  border-bottom: 1px solid #000;
}
header .brand { font-weight: 600; letter-spacing: .2px; margin-right: 8px; }
header .spacer { flex: 1; }
.muted { color: #9a9790; }

button {
  font: inherit; padding: 5px 12px; border-radius: 5px;
  border: 1px solid #b9b5ad; background: #fbfaf8; color: #1c1c1c; cursor: pointer;
}
button:hover { background: #fff; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #4b6b3c; border-color: #3b5530; color: #fff; }
button.primary:hover { background: #567a44; }
button.danger { color: #8a2a21; }
header button { border-color: #514d47; background: #3a3835; color: #f0ede8; }
header button:hover { background: #4a4742; }
header button.primary { background: #5d8248; border-color: #4a6a39; }

#progress { height: 4px; background: #e2e0db; position: relative; display: none; }
#progress.on { display: block; }
#progressBar { height: 100%; width: 0; background: #5d8248; transition: width .2s; }
#progressText { position: absolute; right: 10px; top: 6px; font-size: 12px; color: #6b6760; }

main { flex: 1; display: flex; min-height: 0; }

nav#pages {
  width: 132px; overflow-y: auto; background: #e8e6e1;
  border-right: 1px solid #d2cfc8; padding: 6px;
}
nav#pages .p {
  padding: 5px 7px; margin-bottom: 3px; border-radius: 4px; cursor: pointer;
  background: #fbfaf8; border: 1px solid #ddd9d2; font-size: 12px;
}
nav#pages .p.sel { background: #4b6b3c; color: #fff; border-color: #3b5530; }
nav#pages .p .warn { color: #b3541e; font-weight: 600; }
nav#pages .p.sel .warn { color: #ffd9b0; }

#viewWrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#viewTools {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: #e8e6e1; border-bottom: 1px solid #d2cfc8; flex-wrap: wrap;
}
#viewTools .sep { width: 1px; height: 20px; background: #cfccc5; }
#canvasHost { flex: 1; overflow: auto; position: relative; padding: 14px; }
#canvasHost .stage { position: relative; margin: 0 auto; box-shadow: 0 2px 14px rgba(0,0,0,.18); background:#fff; }
canvas#view { display: block; }
#overlay { position: absolute; inset: 0; }

.band {
  position: absolute; border: 3px solid; cursor: move;
  background: transparent;
}
.band .tag {
  position: absolute; left: 0; top: -17px; font-size: 11px; padding: 0 5px;
  border-radius: 3px 3px 0 0; color: #fff; white-space: nowrap;
}
.band.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1b64c4; }
.band .h {
  position: absolute; width: 9px; height: 9px; background: #fff;
  border: 1.5px solid #1b64c4; border-radius: 2px;
}
.band .h.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.band .h.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.band .h.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.band .h.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.band .h.n  { left: 50%; margin-left: -5px; top: -5px; cursor: ns-resize; }
.band .h.s  { left: 50%; margin-left: -5px; bottom: -5px; cursor: ns-resize; }
.band .h.w  { top: 50%; margin-top: -5px; left: -5px; cursor: ew-resize; }
.band .h.e  { top: 50%; margin-top: -5px; right: -5px; cursor: ew-resize; }
.band.nonames .tag { display: none; }

.sysEnd { position: absolute; border-top: 3px dashed #b3541e; left: 0; right: 0; }
.sysEnd span { position: absolute; right: 2px; top: -16px; font-size: 11px; color: #b3541e; background: #fff8f2; padding: 0 4px; }

aside#side {
  width: 330px; background: #e8e6e1; border-left: 1px solid #d2cfc8;
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid #d2cfc8; }
.tabs button { flex: 1; border: 0; border-radius: 0; background: #ddd9d2; font-size: 13px; padding: 7px 2px; }
.tabs button.active { background: #f3f2ef; font-weight: 600; }
.tabpane { padding: 10px; overflow-y: auto; flex: 1; }
.tabpane.hidden { display: none; }
.hint { font-size: 12px; color: #6b6760; margin: 0 0 10px; }
.row { margin-bottom: 9px; }
.row label { display: block; font-size: 13px; }
.row input[type=text], .row select { width: 100%; padding: 4px 6px; font: inherit; margin-top: 2px; }
.row input[type=range] { width: 150px; vertical-align: middle; }

.cluster {
  display: flex; gap: 8px; align-items: center; background: #fbfaf8;
  border: 1px solid #ddd9d2; border-radius: 5px; padding: 6px; margin-bottom: 6px;
}
.cluster img { background: #fff; border: 1px solid #e3e0d9; max-width: 108px; max-height: 34px; }
.cluster .col { flex: 1; min-width: 0; }
.cluster .n { font-size: 11px; color: #83807a; }
.cluster select, .cluster input { width: 100%; font: inherit; padding: 3px 4px; }
.cluster .sw { width: 10px; align-self: stretch; border-radius: 3px; }

.mv, .ck {
  background: #fbfaf8; border: 1px solid #ddd9d2; border-radius: 5px;
  padding: 6px 8px; margin-bottom: 6px; font-size: 13px;
}
.mv input { width: 100%; font: inherit; padding: 3px 4px; margin-top: 3px; }
.ck { cursor: pointer; }
.ck:hover { background: #fff; }
.ck b { color: #b3541e; }

#log {
  max-height: 128px; overflow-y: auto; background: #262523; color: #d6d2c9;
  font: 12px/1.5 Consolas, monospace; padding: 6px 12px; display: none;
}
#log.on { display: block; }
#log .err { color: #ff9b8a; }
#log .ok { color: #a7d98a; }

.sysTop { position: absolute; left: 0; right: 0; border-top: 2px dotted #1b64c4; pointer-events: none; }
.sysTop span {
  position: absolute; left: 2px; top: -15px; font-size: 10px; color: #1b64c4;
  background: #eef4fd; padding: 0 4px; border-radius: 3px;
}
.hidden { display: none; }

/* подписи на рамках — размер и место настраиваются */
.band .tag { font-size: 11px; }
.lab-s .band .tag { font-size: 9px; }
.lab-m .band .tag { font-size: 12px; padding: 1px 6px; }
.lab-l .band .tag { font-size: 15px; padding: 2px 8px; font-weight: 600; }
.lab-off .band .tag { display: none; }
.pos-left .band .tag { left: auto; right: calc(100% + 4px); top: 50%; transform: translateY(-50%); border-radius: 3px; }
.pos-in .band .tag { top: 2px; left: 2px; border-radius: 3px; opacity: .92; }
#canvasHost.padleft { padding-left: 150px; }

/* тем же размером — надписи на линиях систем и концов частей */
.sysTop span, .sysEnd span { font-size: 11px; }
.lab-s .sysTop span, .lab-s .sysEnd span { font-size: 9px; }
.lab-m .sysTop span, .lab-m .sysEnd span { font-size: 12px; }
.lab-l .sysTop span, .lab-l .sysEnd span { font-size: 15px; font-weight: 600; }
.sysTop span { top: -1.45em; }
.sysEnd span { top: -1.5em; }
.pos-left .band .tag { max-width: 142px; overflow: hidden; text-overflow: ellipsis; }

/* сообщение о ходе разбора — в середине окна просмотра */
#canvasHost { position: relative; }
#busy {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(243,242,239,.92); z-index: 5; font-size: 20px; color: #4b4842; text-align: center;
}
#busy.hidden { display: none; }
#progress { height: 4px; }

/* список партий */
.partrow { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-bottom: 1px solid #e3e0d9; }
.partrow .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.partrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partrow .n { color: #83807a; font-size: 12px; }
.partrow .x { border: 0; background: none; color: #8a2a21; font-size: 17px; line-height: 1; padding: 0 4px; cursor: pointer; }
.partrow .x:hover { background: #f3dcd8; border-radius: 3px; }

/* проверено */
.ck.seen { opacity: .5; }

/* окно выбора страниц */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
#modal.hidden { display: none; }
#modal .sheetbox { background: #fbfaf8; border-radius: 8px; padding: 18px 22px; min-width: 330px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
#modal h3 { margin: 0 0 8px; font-size: 16px; }
#modal .row.right { text-align: right; margin-top: 14px; }
#modal .row.right button { margin-left: 8px; }

/* кнопка «о программе» */
header .about {
  width: 24px; height: 24px; padding: 0; border-radius: 5px; flex: none;
  font-weight: 700; line-height: 1;
}
#about { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 60; }
#about.hidden { display: none; }
#about .sheetbox { background: #fbfaf8; border-radius: 8px; padding: 18px 22px; min-width: 320px; max-width: 460px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
#about h3 { margin: 0 0 8px; font-size: 16px; }
#about p { margin: 0; white-space: pre-line; font-size: 13px; color: #4b4842; }

/* подсветка части, к которой относится выбранная рамка */
.mv.hl { outline: 2px solid #b3541e; background: #fff6ef; }
.mv .go { margin-right: 6px; }
.mv .nav { margin-top: 4px; }

/* толщина линий рамок — из настроек */
.fw-s .band { border-width: 2px; }
.fw-m .band { border-width: 4px; }
.fw-l .band { border-width: 6px; }

#about p + p { margin-top: 8px; }
#about a { color: #1b64c4; }
#about #aboutQr { display: block; border: 1px solid #e0dcd4; border-radius: 6px; }

/* в окне «о программе» посвящение, ссылка и QR — по центру */
#about #aboutEns { font-size: 15px; font-weight: 600; color: #2f2b26; text-align: center; }
#about #aboutLinkRow, #about #aboutQrRow, #about #aboutDonateRow { text-align: center; }
#about #aboutQr { margin: 0 auto; }
header .donate {
  color: #b3541e; text-decoration: none; font-size: 13px; padding: 4px 9px;
  border: 1px solid #e3c2ab; border-radius: 5px; white-space: nowrap;
}
header .donate:hover { background: #fbefe6; }
header .donate.hidden { display: none; }
