:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #17202a;
  --muted: #667484;
  --border: #dfe5ec;
  --accent: #2456d8;
  --accent-dark: #1c46b0;
  --ok: #0e8a5f;
  --danger: #c93b3b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 34, 60, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }

.topnav {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 22px; position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.brand span { color: var(--accent); }
.nav-links { display: flex; gap: 14px; flex: 1; }
.nav-links a { color: var(--muted); padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav-links a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user { color: var(--muted); }

.container { max-width: 1060px; margin: 0 auto; padding: 26px 20px 60px; }
.container.narrow { max-width: 460px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font: inherit; font-size: 14px;
  padding: 7px 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f3f8; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #bcd0f7; border-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  background: #eef2fa; border: 1px solid #dbe4f6; color: #2c4a8a;
  font-size: 12.5px; border-radius: 20px; padding: 3px 11px;
}
.chip b { font-weight: 600; }

/* --- проекты на дашборде --- */
.project-card { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.project-card .actions { display: flex; gap: 8px; flex-shrink: 0; }
.event-feed { list-style: none; margin: 0; padding: 0; }
.event-feed li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.event-feed li:last-child { border-bottom: none; }
.event-feed .who { font-weight: 600; }

/* --- редактор проекта --- */
.link-row { display: flex; gap: 8px; margin: 8px 0; }
.link-row input {
  flex: 1; font: 13px/1.3 monospace; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; color: var(--muted); background: #fafbfd;
}
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--muted); cursor: pointer; background: #fbfcfe;
}
.dropzone.dragover { border-color: var(--accent); background: #eef3fd; }
.progress { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .15s; }

.block-card { padding: 14px 18px; }
.block-card > header { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.block-card .chevron { color: var(--muted); transition: transform .15s; }
.block-card.open .chevron { transform: rotate(90deg); }
.block-card .hint { margin: 6px 0 0; }
.block-card .block-hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.block-card .block-body { margin-top: 14px; }
.block-empty { color: var(--muted); font-style: italic; padding: 8px 0; }
.badge { background: #eef2fa; color: #2c4a8a; font-size: 12px; border-radius: 12px; padding: 2px 9px; }

.pages-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.thumb { width: 190px; }
.thumb img {
  width: 100%; height: 120px; object-fit: contain; background: #fff;
  border: 1px solid var(--border); border-radius: 6px; display: block;
  cursor: zoom-in;
}
.thumb .thumb-actions { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
.thumb select { font-size: 12.5px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; width: 100%; }
.thumb .row { gap: 4px; }
.thumb .pos { font-size: 12px; color: var(--muted); }

/* --- просмотр --- */
.meta-card h1 { margin-bottom: 4px; }
.page-frame {
  position: relative; margin: 0 0 18px; max-width: 760px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff;
}
.page-frame img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #fff; display: block;
}
.page-frame figcaption {
  padding: 7px 12px; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--border); background: #fafbfd;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.wm { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.wm .wm-cell {
  position: absolute; transform: rotate(-22deg); white-space: nowrap;
  font-size: 13px; font-weight: 600; color: rgba(30, 50, 90, .12);
}
.wm .wm-corner {
  position: absolute; right: 8px; bottom: 8px; font-size: 11px;
  background: rgba(255, 255, 255, .75); color: #55677e;
  border-radius: 4px; padding: 1px 7px; transform: none;
}
.page-collapsed {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px dashed var(--border); border-radius: 8px; padding: 9px 13px;
  margin-bottom: 10px; max-width: 760px; background: #fbfcfe;
}
.page-collapsed.is-hidden { background: #f3f4f6; opacity: .75; border-style: solid; }
.save-state { font-size: 14px; }

/* --- таблицы --- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
details.session summary { cursor: pointer; padding: 4px 0; }
.event-line { font-size: 13px; color: var(--muted); padding: 2px 0 2px 18px; }

/* --- модал --- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 25, 45, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px; max-width: 380px; width: 92%;
  box-shadow: 0 10px 40px rgba(10, 20, 40, .25); text-align: center;
}
.modal .row { justify-content: center; margin-top: 14px; }

/* --- прочее --- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #222c3d; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 200; box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
.toast.error { background: var(--danger); }
.hero { text-align: center; padding: 60px 20px 30px; }
.hero h1 { font-size: 34px; }
.hero p.lead { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 auto 26px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; text-align: left; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step-num { color: var(--accent); font-weight: 700; font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- профили автопросмотра --- */
.profile-bar { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.profile-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.profile-chip { display: inline-flex; align-items: center; gap: 6px; }
.pf-emoji { font-size: 15px; }
.profile-desc { margin: 4px 0 0; min-height: 18px; }
.pf-about { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.pf-about summary { cursor: pointer; color: var(--accent); font-size: 13px; user-select: none; }
.pf-about-item { margin-top: 12px; }
.pf-about-item b { font-size: 14px; }
.pf-about-item p {
  white-space: pre-wrap; font-size: 13px; line-height: 1.5;
  color: var(--text); margin: 4px 0 0; overflow-wrap: break-word;
}
.pf-about-item p a { word-break: break-all; }

/* --- фильтр «взгляд инвестора» в личном кабинете --- */
.lens-chip { display: inline-flex; align-items: center; gap: 5px; }
.lens-chip.lens-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lens-chip.lens-all { border-style: dashed; color: var(--muted); }
.lens-badge { background: #eaf6ef; color: #0e5c40; }

/* --- личные профили зрителя (обучение и шеринг) --- */
.chip-wrap { display: inline-flex; align-items: center; gap: 3px; }
.mine-mark {
  background: #e8f0fe; color: #1c46b0; border-radius: 9px;
  font-size: 11px; padding: 0 6px; margin-left: 2px;
}
.share-btn { padding: 3px 7px; }
.share-btn:hover { background: #eef2fa; }

/* --- мелкий текст: предупреждения и зум слайда --- */
.small-flag {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  background: #fff3cd; color: #7a5b00; border: 1px solid #e6d178;
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
}
.warn-banner { border-color: #e6d178; background: #fffaf0; }
.warn-banner b { color: #7a5b00; }
.warn-line { color: #8a6d00; margin-top: 4px; }
.thumb { position: relative; }
.page-frame { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(10, 16, 28, .92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 16px;
}
.lightbox .page-frame { margin: 0; cursor: default; max-width: min(96vw, 1500px); }
.lightbox .page-frame img { max-height: 92vh; width: auto; max-width: 100%; }
.profile-mark { margin-left: auto; flex-shrink: 0; }
.profile-mark-skip { background: #f7eaea; color: var(--danger); }
.block-card.profile-target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 86, 216, .14); }
.block-card.profile-skipped { opacity: .55; }
.profile-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  width: 330px; max-width: calc(100vw - 36px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(20, 34, 60, .18);
  padding: 14px 16px;
}
.pp-title { font-weight: 700; margin-bottom: 6px; }
.pp-note { font-size: 13px; margin-bottom: 6px; }
.pp-progress { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pp-actions { gap: 8px; margin-top: 4px; }
.block-card, .page-frame { scroll-margin-top: 64px; }

/* --- вопросы блока и ИИ-анализ в редакторе --- */
.block-questions { margin: 2px 0 10px; }
.block-questions summary {
  cursor: pointer; color: var(--accent); font-size: 13px; user-select: none;
  padding: 3px 0;
}
.block-questions .q-list { margin: 8px 0 4px; padding-left: 20px; font-size: 13.5px; }
.block-questions .q-list li { margin: 3px 0; color: var(--text); }
.analysis-box {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.5;
  background: #f2f6ff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 10px;
}
.analysis-box.err { background: #fdf1f1; color: var(--danger); }

/* --- редактор персонажей в админке --- */
details.pf-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
details.pf-item summary { cursor: pointer; font-weight: 600; user-select: none; }
.pf-edit { margin-top: 10px; }
.pf-rules { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 13px; }
.pf-rules th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.pf-rules td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pf-rules input[type="number"], .pf-rules select { width: 100%; min-width: 72px; }
.pf-rules .pf-note { width: 100%; }
.pf-rules tbody tr[data-block] td:first-child { white-space: nowrap; }

/* --- редактор личного профиля у зрителя --- */
.pe-modal {
  background: #fff; border-radius: 12px; padding: 18px 20px;
  width: min(620px, 94vw); max-height: 90vh; overflow: auto;
  box-shadow: 0 10px 40px rgba(10, 20, 40, .25);
}

/* --- крупный предпросмотр слайда в редакторе --- */
/* z-index ниже .toast (200), чтобы «Слайд перемещён…» был виден поверх лайтбокса */
.editor-lb {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(10, 16, 28, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 14px;
}
.editor-lb[hidden] { display: none; }
.editor-lb .lb-img {
  max-height: calc(93vh - 110px); max-width: min(96vw, 1600px);
  background: #fff; border-radius: 8px; box-shadow: 0 10px 44px rgba(0, 0, 0, .55);
}
.editor-lb-top {
  width: min(96vw, 1600px); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; color: #fff; font-size: 14.5px;
}
.editor-lb-label { font-weight: 600; }
.lb-smallflag {
  background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 600;
  border-radius: 10px; padding: 2px 8px; margin-left: 7px; vertical-align: 1px;
}
.editor-lb .lb-nav { display: flex; align-items: center; gap: 8px; }
.editor-lb .lb-count { font-size: 13px; color: rgba(255, 255, 255, .8); min-width: 58px; text-align: center; }
.editor-lb-bottom {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; flex-wrap: wrap; color: #fff; font-size: 14px;
}
.editor-lb-bottom .lb-hint { font-size: 12.5px; color: rgba(255, 255, 255, .65); }
.editor-lb select {
  font-size: 13.5px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text);
}
