:root {
  --bg: #f6f7f9; --panel: #fff; --panel-2: #f0f2f5; --line: #e2e5ea; --text: #1d2330; --muted: #6b7383;
  --accent: #3b6ea8; --accent-2: #e8f0fa; --ok: #2f8a57; --ok-bg: #e7f5ec; --warn: #a86a12; --warn-bg: #fdf3e2;
  --err: #b8372f; --err-bg: #fbeaea; --radius: 8px; --font: "Inter", "Segoe UI", "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}
/* светлая — всегда по умолчанию (не по настройке системы): документ должен выглядеть как бумага;
   тёмная — только кнопкой */
:root[data-theme="dark"] {
  --bg: #15181e; --panel: #1c2028; --panel-2: #232833; --line: #2f3542; --text: #e3e7ee; --muted: #8e97a8;
  --accent: #7aa7dc; --accent-2: #24344a; --ok: #6cc391; --ok-bg: #1e3327; --warn: #e2b161; --warn-bg: #3a2f1c;
  --err: #ec8a83; --err-bg: #3e2222; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .err { color: var(--err); } .pad { padding: 10px; }
.card { max-width: 520px; margin: 8vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px; }
.card h1 { font-size: 20px; margin: 0 0 12px; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; font: inherit; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.danger { color: var(--err); }
.inp { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; margin: 6px 0 12px; }
textarea.inp { resize: vertical; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 9px; background: var(--panel-2); margin-left: 6px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.err { background: var(--err-bg); color: var(--err); }
#top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 600; min-width: 0; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.15); max-width: 420px; }
.toast.err { border-color: var(--err); color: var(--err); }
#dlg-wrap { position: fixed; inset: 0; background: rgba(10,15,25,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
#dlg { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.dlg-head { padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--line); }
.dlg-body { padding: 14px 18px; overflow: auto; }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- рецензент ---- */
#layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 0; max-width: 1240px; margin: 0 auto; }
@media (max-width: 900px) { #layout { grid-template-columns: 1fr; } #side { border-left: 0; border-top: 1px solid var(--line); } }
#doc { padding: 24px clamp(14px, 4vw, 56px) 80px; background: var(--panel); min-height: 80vh; font: 17px/1.6 "Times New Roman", "Liberation Serif", "Noto Serif", serif; }
.doc-head h1 { font: 600 22px/1.3 var(--font); margin: 0 0 4px; }
.doc-head { margin-bottom: 20px; font-family: var(--font); }
.blk { position: relative; margin: 0 0 6px; border-radius: 4px; }
.blk .txt { margin: 0; padding: 2px 4px; border-radius: 4px; outline: none; }
.blk p.txt { text-indent: 1.25cm; text-align: justify; }
.blk p.txt.noindent { text-indent: 0; }
.blk .txt[tabindex]:hover { background: var(--accent-2); cursor: text; }
.blk .txt.editing { background: var(--panel); box-shadow: 0 0 0 2px var(--accent); text-indent: 0; }
.blk .txt.changed { box-shadow: inset 3px 0 0 var(--warn); }
.k-heading { display: flex; gap: 6px; align-items: baseline; font-weight: 700; margin-top: 18px; }
.k-heading h2, .k-heading h3, .k-heading h4 { font-size: 1em; margin: 0; flex: 1; }
.formula { display: flex; align-items: center; margin: 8px 0; }
.formula .f { flex: 1; text-align: center; }
.figure, .fig { display: block; max-width: 100%; margin: 8px auto; }
.cap { text-align: center; margin: 2px 0 12px; } .cap.left { text-align: left; }
.cap .txt { display: inline; }
.tblwrap { overflow-x: auto; margin-bottom: 12px; }
table { border-collapse: collapse; font-size: 15px; } td, th { border: 1px solid var(--muted); padding: 3px 8px; vertical-align: top; }
.list .li { padding-left: 1.25cm; } .list .li.l2 { padding-left: 2.25cm; } .list .mk { display: inline-block; min-width: 1.2em; }
pre { font-size: 13px; background: var(--panel-2); padding: 10px; overflow-x: auto; }
.chip { border-radius: 4px; padding: 0 2px; background: var(--accent-2); }
.chip.b, .chip.i, .chip.math, .chip.q { background: none; }
ins { background: var(--ok-bg); color: var(--ok); text-decoration: none; }
del { background: var(--err-bg); color: var(--err); }
mark.cm-mark { background: var(--warn-bg); color: inherit; border-bottom: 2px solid var(--warn); }
.decision { position: absolute; right: -4px; top: -10px; font: 11px var(--font); padding: 0 6px; border-radius: 8px; background: var(--panel-2); }
.decision.accepted { background: var(--ok-bg); color: var(--ok); } .decision.rejected { background: var(--err-bg); color: var(--err); }
#side { border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; max-height: calc(100vh - 50px); position: sticky; top: 50px; }
.side-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#comments { overflow: auto; flex: 1; }
.side-foot { padding: 10px 14px; border-top: 1px solid var(--line); }
.cm { margin: 8px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); font-size: 14px; }
.cm.st-done { opacity: .7; } .cm .quote, .quote { color: var(--muted); font-style: italic; margin: 2px 0 4px; }
.cm .reply { margin-top: 6px; padding: 6px 8px; background: var(--accent-2); border-radius: 6px; }
.cm .row { margin-top: 6px; }
#cm-float { position: absolute; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#pdf-wrap { height: calc(100vh - 52px); } #pdf { width: 100%; height: 100%; border: 0; }
.loading { color: var(--muted); padding: 40px; font-family: var(--font); }

/* ---- панель ---- */
.wrap { max-width: 1000px; margin: 0 auto; padding: 18px; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin: 14px 0; }
.section h2 { font-size: 16px; margin: 0 0 10px; }
.list-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row .t { flex: 1; min-width: 200px; }
code.k { word-break: break-all; font-size: 12.5px; background: var(--panel-2); padding: 2px 5px; border-radius: 4px; }

/* сгенерированные части документа у рецензента */
.tline.center { text-align: center; } .tline.left { text-align: left; } .tline.right { text-align: right; }
.tline.bold { font-weight: 700; }
.tf-head { font: 600 13px var(--font); color: var(--muted); margin: 18px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tfield { font-size: 15px; margin: 2px 0; }
.gh { text-align: center; font-weight: 700; margin: 18px 0 10px; }
.tocl { margin: 2px 0; } .tocl.l2 { padding-left: 1.5em; } .tocl.l3 { padding-left: 3em; }
.abbr { margin: 2px 0; }
.bibe { text-indent: 1.25cm; text-align: justify; margin: 2px 0; }
.blk .bibe .txt, .blk .abbr .txt, .blk .tfield .txt, .blk .tline .txt { display: inline; padding: 1px 2px; }
hr.pagebreak { border: 0; border-top: 2px dashed var(--line); margin: 28px -10px; }
.k-heading.structural { justify-content: center; text-align: center; }
.k-heading.structural.upper .txt { text-transform: uppercase; }

/* страницы документа у рецензента — как у автора в Studio (страница всегда белая, как бумага) */
#pages { padding: 18px 12px 80px; display: flex; flex-direction: column; align-items: center; gap: 18px; background: var(--bg); min-height: 80vh; }
.page { position: relative; background: #fff; box-shadow: 0 1px 4px rgba(20,30,50,.18); width: min(900px, 100%); cursor: pointer; }
.page img { display: block; width: 100%; height: auto; user-select: none; }
.page .pnum { position: absolute; left: -34px; top: 4px; font-size: 12px; color: var(--muted); }
.hl { position: absolute; left: 6%; right: 4%; background: rgba(59,110,168,.12); border-left: 3px solid rgba(59,110,168,.7); pointer-events: none; border-radius: 3px; }
.mk { position: absolute; left: 2.2%; width: 6px; border-radius: 3px; pointer-events: none; }
.mk.edit { background: #e0a020; } .mk.cm { background: #3b6ea8; left: 1.2%; }
.mk-badge { position: absolute; right: 1.5%; font: 600 11px var(--font); padding: 1px 6px; border-radius: 8px; pointer-events: none; }
.mk-badge.edit { background: #fdf3e2; color: #a86a12; } .mk-badge.cm { background: #e8f0fa; color: #3b6ea8; }
#el { padding: 10px 12px; border-bottom: 1px solid var(--line); max-height: 60vh; overflow: auto; }
#el .el-head { font-weight: 600; margin-bottom: 6px; }
#el .blk { font: 16px/1.55 "Times New Roman", "Liberation Serif", serif; }
#el .hint { font-size: 13px; color: var(--muted); margin: 6px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--panel); color: var(--text); padding: 6px 12px; cursor: pointer; font: inherit; }
.seg button.on { background: var(--accent); color: #fff; }
.items .it { padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.items .it:hover { background: var(--panel-2); }
.items .it .k { font-size: 11.5px; font-weight: 600; margin-right: 6px; }
.items .it .k.edit { color: var(--warn); } .items .it .k.cm { color: var(--accent); }
