/* ============================================================
   Страховка авторского редактора (аудит 2026-08-23, ядро-4):
   индикатор автосейва, диалог конфликта версий, история версий, diff,
   панель Story Bible и карта веток.

   ОТДЕЛЬНЫЙ ФАЙЛ, а не хунк в styles.css: styles.css — общий файл роя, и
   правка его четырьмя руками в один день стоит потерянной работы (хартия §2).
   Подключается <link> из index.html рядом со styles.css.

   Переменные (--ink, --ink3, --line, --raised, --good, --danger, --gold-text)
   объявлены в styles.css: тема книги одна, второй палитры здесь быть не должно.
   ============================================================ */

/* --- индикатор автосейва ---------------------------------------------- */
.editor-draft-note { transition: opacity .2s ease; }

/* --- диалог конфликта версий ------------------------------------------ */
.editor-conflict {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--danger, #b4453a);
  border-radius: 10px;
  background: var(--raised, rgba(0, 0, 0, .03));
}
.editor-conflict .ec-head { display: flex; flex-direction: column; gap: 2px; }
.editor-conflict .ec-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}

/* --- история версий ---------------------------------------------------- */
.editor-history {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line, #ddd);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.editor-history .eh-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px;
}
.editor-history .eh-list { list-style: none; margin: 0; padding: 0; }
.editor-history .eh-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 0; border-top: 1px solid var(--line, #eee);
}
.editor-history .eh-kind { font-weight: 600; }
.editor-history .eh-meta, .editor-history .eh-words {
  color: var(--ink3, #777); font-size: 12px;
}
.editor-history .eh-row button { margin-left: auto; }
.editor-history .eh-row .eh-restore { margin-left: 0; }

/* --- diff (общий для редактора и карты веток) -------------------------- */
.editor-diff {
  margin: 10px 0; padding: 10px 12px;
  border: 1px solid var(--line, #ddd); border-radius: 10px;
  max-height: 320px; overflow: auto;
}
.editor-diff .ed-head { display: flex; align-items: baseline; gap: 10px; }
.ed-body {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap;
  word-break: break-word;
}
.ed-eq { color: var(--ink3, #777); }
.ed-ins { background: rgba(46, 125, 50, .14); border-left: 3px solid var(--good, #2e7d32); padding-left: 6px; }
.ed-del { background: rgba(180, 69, 58, .12); border-left: 3px solid var(--danger, #b4453a); padding-left: 6px; text-decoration: line-through; }
.ed-skip { text-align: center; opacity: .6; }
.epub-hint { display: inline-block; margin-top: 6px; font-size: 12.5px; }

/* --- Story Bible в шторке «Память» ------------------------------------ */
.story-bible { margin: 0 0 10px; }
.story-bible .sb-toggle {
  width: 100%; text-align: left; background: none; border: 1px dashed var(--line, #ddd);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; color: inherit;
}
.story-bible .sb-body { margin-top: 8px; }
.story-bible .sb-head { margin: 10px 0 4px; font-size: 13px; }
.story-bible .sb-list { list-style: none; margin: 0; padding: 0; }
.story-bible .sb-entry {
  padding: 8px 10px; border: 1px solid var(--line, #eee); border-radius: 10px;
  margin-bottom: 6px;
}
.story-bible .sb-entry.locked { border-color: var(--gold-text, #a07b28); }
.story-bible .sb-entry.inactive { opacity: .6; }
.story-bible .sb-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.story-bible .sb-type { font-size: 11.5px; color: var(--ink3, #777); }
.story-bible .sb-content { margin: 4px 0 6px; font-size: 13px; }
.story-bible .sb-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.story-bible .sb-actions button { font-size: 12px; padding: 3px 8px; }
.story-bible .sb-add { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.story-bible .sb-edit-title, .story-bible .sb-edit-content { width: 100%; }

/* --- карта веток ------------------------------------------------------- */
.branch-map-card { max-width: 900px; width: 92vw; }
.bmap-body { max-height: 70vh; overflow: auto; }
/* Дерево шире экрана — прокручиваем ЕГО, а не страницу. */
.bmap-canvas { overflow-x: auto; padding-bottom: 6px; }
.bmap-svg { display: block; }
.bmap-edge { fill: none; stroke: var(--line, #ccc); stroke-width: 2; }
.bmap-node rect {
  fill: var(--raised, #fafafa); stroke: var(--line, #ddd); stroke-width: 1.5;
}
.bmap-node text { font-size: 13px; fill: var(--ink, #222); }
.bmap-node .bmap-sub { font-size: 11px; fill: var(--ink3, #777); }
.bmap-node.mine { cursor: pointer; }
.bmap-node.mine rect { stroke: var(--ink3, #999); }
.bmap-node.current rect { stroke: var(--gold-text, #a07b28); stroke-width: 2.5; }
.bmap-node.published rect { fill: rgba(46, 125, 50, .10); }
.bmap-node.foreign rect { stroke-dasharray: 4 3; }
.bmap-compare { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.bmap-diff-list { list-style: none; margin: 6px 0 0; padding: 0; }
.bmap-diff-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  border-top: 1px solid var(--line, #eee);
}
.bmap-diff-row.diff .bmap-mark { color: var(--danger, #b4453a); font-weight: 700; }
.bmap-diff-row.same .bmap-mark { color: var(--good, #2e7d32); }
.bmap-diff-row.only .bmap-mark { color: var(--ink3, #777); }
.bmap-title { color: var(--ink3, #777); font-size: 12.5px; }

@media (max-width: 640px) {
  .editor-history { max-height: 180px; }
  .editor-diff { max-height: 220px; }
  .branch-map-card { width: 96vw; }
}
