/* =========================================================
   База знаний — оформление
   ========================================================= */

:root {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #16212b;
  --text-soft: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --brand: #0f766e;
  --brand-dark: #0b5c56;
  --brand-soft: #e6f6f4;
  --accent: #14b8a6;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 8px 24px -12px rgba(15, 23, 42, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

img { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.container.narrow { max-width: 900px; }

.muted { color: var(--muted); }

.inline { display: inline; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-soft);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }

input, textarea, select, button { font-family: inherit; }

input[type="text"], input[type="search"], input[type="password"], select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  padding: 10px 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .18);
}

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--text);
  flex-shrink: 0;
}
.brand:hover { color: var(--brand); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), #14b8a6);
  color: #fff;
}

.header-search { flex: 1; max-width: 440px; margin-left: auto; }
.header-search input {
  height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border-color: transparent;
}
.header-search input:focus { background: #fff; border-color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---------- Полоса проектов ---------- */

.project-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.project-strip::-webkit-scrollbar { display: none; }

.project-strip-inner {
  display: flex;
  gap: 8px;
  padding-top: 9px;
  padding-bottom: 9px;
  min-width: max-content;
}

.project-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-2);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.project-chip:hover { background: var(--brand-soft); color: var(--brand); }

/* ---------- Hero ---------- */

.hero {
  background:
    radial-gradient(900px 280px at 12% -10%, rgba(20, 184, 166, .16), transparent 70%),
    radial-gradient(700px 240px at 90% 0%, rgba(15, 118, 110, .10), transparent 70%),
    var(--surface);
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 46px;
  padding-bottom: 42px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: -.02em;
}

.hero-sub {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 16.5px;
}

/* ---------- Проекты ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 32px 0 8px;
}

.project-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: hsl(var(--hue) 62% 48%);
  opacity: 0;
  transition: opacity .18s;
}
.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
  color: var(--text);
}
.project-card:hover::before { opacity: 1; }

.project-tile {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(140deg, hsl(var(--hue) 62% 48%), hsl(calc(var(--hue) + 24) 64% 42%));
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.project-tile-lg { width: 62px; height: 62px; font-size: 26px; border-radius: 16px; }

.project-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.project-card-title { font-size: 17.5px; font-weight: 700; letter-spacing: -.01em; }

.project-card-meta { color: var(--muted); font-size: 13.5px; }

.project-card-desc {
  color: var(--text-soft);
  font-size: 14px;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-arrow {
  margin-left: auto;
  align-self: center;
  color: var(--border-strong);
  font-size: 20px;
  transition: transform .18s, color .18s;
}
.project-card:hover .project-card-arrow { transform: translateX(3px); color: var(--brand); }

/* ---------- Последние изменения ---------- */

.recent { padding: 34px 0 10px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-head h2 { margin: 0 0 14px; font-size: 20px; letter-spacing: -.01em; }

.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.recent-item:hover { border-color: var(--accent); color: var(--text); }
.recent-title { font-weight: 600; font-size: 15px; }
.recent-meta { display: flex; gap: 8px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.recent-project { color: var(--brand); font-weight: 600; }

.admin-hint {
  margin: 30px 0 10px;
  padding: 14px 18px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 14.5px;
}

/* ---------- Хлебные крошки ---------- */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 18px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .sep { color: var(--border-strong); }
.breadcrumbs .current { color: var(--text-soft); font-weight: 600; }

/* ---------- Страница материала ---------- */

.node-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 34px;
  padding-top: 22px;
  padding-bottom: 64px;
  align-items: start;
}

.node-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 14px);
  max-height: calc(100vh - var(--header-h) - 30px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  scrollbar-width: thin;
}

.sidebar-head {
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sidebar-head a { font-weight: 700; color: var(--text); font-size: 14.5px; }

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { margin-left: 13px; border-left: 1px solid var(--border); padding-left: 4px; }

.tree-item { margin: 1px 0; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 7px;
  padding: 1px 2px;
}
.tree-row:hover { background: var(--surface-2); }

.tree-item.is-active > .tree-row { background: var(--brand-soft); }
.tree-item.is-active > .tree-row .tree-link { color: var(--brand-dark); font-weight: 700; }

.tree-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}
.tree-toggle:hover { color: var(--text); background: rgba(15, 23, 42, .06); }
.tree-toggle svg { transition: transform .15s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.tree-dot {
  flex-shrink: 0;
  width: 20px;
  height: 26px;
  position: relative;
}
.tree-dot::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border-strong);
}

.tree-link {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
  padding: 4px 3px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: 5px;
  line-height: 1.35;
}
.tree-link:hover { color: var(--brand); }

.tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
}

.tree-icon { flex-shrink: 0; color: var(--muted); }

.tree-edit {
  flex-shrink: 0;
  opacity: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  transition: opacity .12s;
}
.tree-row:hover .tree-edit { opacity: 1; }
.tree-edit:hover { background: #fff; color: var(--brand); }

.node-main { min-width: 0; }

.node-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.node-heading { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }

.node-kicker {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}

.node-header h1 {
  margin: 0;
  font-size: clamp(25px, 3.4vw, 34px);
  line-height: 1.2;
  letter-spacing: -.02em;
  overflow-wrap: break-word;
}

.node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.node-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; flex-shrink: 0; }

.more-menu { position: relative; }
.more-menu > summary {
  list-style: none;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  padding: 6px 11px;
}
.more-menu > summary::-webkit-details-marker { display: none; }

.more-menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.more-menu-body form { margin: 0; }
.menu-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.menu-link:hover { background: var(--surface-2); color: var(--text); }
.menu-link.danger { color: var(--danger); }
.menu-link.danger:hover { background: var(--danger-soft); }

/* ---------- Текст статьи ---------- */

.prose {
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--text-soft);
  overflow-wrap: break-word;
}

.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }

.prose h2 {
  margin: 1.7em 0 .55em;
  font-size: 25px;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -.015em;
}
.prose h3 {
  margin: 1.5em 0 .45em;
  font-size: 20px;
  line-height: 1.35;
  color: var(--text);
}
.prose h4 { margin: 1.3em 0 .4em; font-size: 17px; color: var(--text); }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.5em; }
.prose li { margin: .3em 0; }
.prose li > ul, .prose li > ol { margin: .3em 0; }
.prose a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.prose strong, .prose b { color: var(--text); font-weight: 700; }
.prose img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 1.4em 0;
  box-shadow: var(--shadow-sm);
}
.prose figure { margin: 1.4em 0; }
.prose figure img { margin: 0; }
.prose figcaption { color: var(--muted); font-size: 13.5px; margin-top: 6px; text-align: center; }
.prose blockquote {
  margin: 1.3em 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--brand-soft);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .38em;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.prose pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 15px 18px;
  border-radius: 12px;
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
  margin: 1.3em 0;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.3em 0; font-size: 15px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- Дети раздела ---------- */

.children { margin-top: 36px; }
.children-title { font-size: 19px; margin: 0 0 14px; letter-spacing: -.01em; }

.child-list { display: flex; flex-direction: column; gap: 9px; }

.child-card {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px 4px 0;
  transition: border-color .15s, box-shadow .15s;
}
.child-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.child-main {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  color: var(--text);
  border-radius: 8px;
}
.child-main:hover { color: var(--text); }

.child-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
}
.child-icon-article { background: #eef6ff; color: #2563eb; }
.child-icon-section { background: var(--brand-soft); color: var(--brand); }
.child-icon-project { background: #f5f3ff; color: #7c3aed; }

.child-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.child-title { font-weight: 600; font-size: 15.5px; line-height: 1.4; }
.child-desc { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.child-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.child-arrow {
  margin-left: auto;
  align-self: center;
  color: var(--border-strong);
  font-size: 17px;
  padding-right: 4px;
  transition: transform .15s, color .15s;
}
.child-main:hover .child-arrow { transform: translateX(2px); color: var(--brand); }

.child-controls {
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity .12s;
}
.child-card:hover .child-controls { opacity: 1; }

.add-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.empty-state {
  padding: 36px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-soft);
}
.empty-state p { margin: 0 0 6px; }

/* ---------- Формы / редактор ---------- */

.page-edit .container.narrow { max-width: 1020px; }

.edit-form {
  margin: 18px 0 60px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 24px;
  box-shadow: var(--shadow-sm);
}

.edit-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.edit-type { display: flex; align-items: center; gap: 10px; }
.edit-type .field-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.edit-type .field-inline select { width: auto; padding: 6px 10px; font-size: 14px; }

.type-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.edit-buttons { display: flex; gap: 8px; }

.title-input {
  border: 0 !important;
  border-bottom: 2px solid var(--border) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 6px 2px 12px !important;
  font-size: clamp(24px, 3vw, 32px) !important;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 16px;
  background: transparent !important;
}
.title-input:focus { border-bottom-color: var(--accent) !important; }
.title-input::placeholder { color: var(--border-strong); }

.parent-field { margin-bottom: 16px; }
.parent-field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.parent-field select { max-width: 460px; }

.editor-shell {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.editor-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20, 184, 166, .14); }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 5;
}

.tb-group {
  display: flex;
  gap: 2px;
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid var(--border);
}
.tb-group:last-child { border-right: 0; }
.tb-group-end { margin-left: auto; }

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tb-btn:hover { background: #fff; border-color: var(--border); color: var(--brand); }
.tb-btn:active { background: var(--brand-soft); }
.tb-btn.is-active { background: var(--brand-soft); color: var(--brand-dark); }

.editor-area {
  min-height: 58vh;
  padding: 22px 26px;
  outline: none;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--text-soft);
  overflow-wrap: break-word;
}
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.editor-area h2 { font-size: 25px; margin: .8em 0 .4em; color: var(--text); line-height: 1.3; }
.editor-area h3 { font-size: 20px; margin: .8em 0 .35em; color: var(--text); }
.editor-area p { margin: 0 0 .8em; }
.editor-area ul, .editor-area ol { padding-left: 1.5em; margin: 0 0 .8em; }
.editor-area blockquote {
  margin: .8em 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: var(--brand-soft);
}
.editor-area pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
}
.editor-area img {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 12px 0;
}
.editor-area img.is-uploading { opacity: .45; }

.editor-status { min-height: 0; font-size: 13px; color: var(--muted); padding: 0 14px; }
.editor-status:not(:empty) { padding: 8px 14px; border-top: 1px solid var(--border); }
.editor-status error { color: var(--danger); }

.edit-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.edit-footer .muted { font-size: 13px; }

/* ---------- Логин ---------- */

.auth-wrap { display: flex; justify-content: center; padding-top: 60px; padding-bottom: 80px; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px 32px 28px;
  text-align: center;
}
.auth-icon { font-size: 34px; margin-bottom: 8px; }
.auth-card h1 { margin: 0 0 8px; font-size: 23px; letter-spacing: -.01em; }
.auth-card .muted { font-size: 14px; margin: 0 0 22px; }

.auth-form { text-align: left; }
.auth-form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.auth-form input { margin-bottom: 14px; }

.auth-back { display: inline-block; margin-top: 20px; font-size: 14px; color: var(--muted); }
.auth-back:hover { color: var(--brand); }

/* ---------- Настройки ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin: 20px 0 60px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel h3 { margin: 24px 0 8px; font-size: 15px; }
.panel p { font-size: 14px; }

.stack-form { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.stack-form label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.stack-form .btn { margin-top: 10px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.stats > div { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stats dt { font-size: 12.5px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; color: var(--text); }

/* ---------- Поиск ---------- */

.search-page-head { margin: 18px 0 22px; }
.search-page-head h1 { margin: 0 0 14px; font-size: 28px; letter-spacing: -.02em; }

.search-form-lg { display: flex; gap: 10px; max-width: 620px; }
.search-form-lg input { height: 46px; }

.search-count { margin: 0 0 12px; font-size: 14px; }

.search-results { display: flex; flex-direction: column; gap: 10px; margin-bottom: 60px; }

.search-result {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text);
}
.search-result:hover { border-color: var(--accent); color: var(--text); }
.search-result-title { display: block; font-size: 16.5px; font-weight: 700; margin-bottom: 3px; }
.search-result-meta { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.search-result-snippet { display: block; font-size: 14px; color: var(--text-soft); line-height: 1.55; }

/* ---------- История ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 18px 0 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 2px; font-size: 27px; letter-spacing: -.02em; }
.page-head p { margin: 0; }

.history-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 60px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.history-item > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}
.history-item > summary::-webkit-details-marker { display: none; }
.history-item > summary:hover { background: var(--surface-2); }
.history-num { font-weight: 800; color: var(--accent); font-size: 13px; flex-shrink: 0; }
.history-title { font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-date { color: var(--muted); font-size: 13px; }
.history-author { color: var(--muted); font-size: 13px; }
.history-body { border-top: 1px solid var(--border); padding: 16px 18px; }
.prose-preview { max-height: 420px; overflow: auto; font-size: 15px; margin-bottom: 14px; }

/* ---------- Флеши ---------- */

.flash-wrap { padding-top: 14px; }
.flash {
  padding: 11px 16px;
  border-radius: 9px;
  font-size: 14.5px;
  margin-bottom: 8px;
  border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---------- 404 ---------- */

.error-page { text-align: center; padding: 90px 0; }
.error-code { font-size: 84px; font-weight: 900; color: var(--border-strong); line-height: 1; letter-spacing: -.04em; }
.error-page h1 { margin: 10px 0 6px; font-size: 26px; }
.error-page .btn { margin-top: 18px; }

/* ---------- Подвал ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
  font-size: 13.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ---------- Адаптив ---------- */

@media (max-width: 980px) {
  .node-layout { grid-template-columns: 1fr; gap: 20px; }
  .node-sidebar {
    position: static;
    max-height: 320px;
    border-radius: var(--radius-sm);
  }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 760px) {
  .container { padding: 0 16px; }
  .header-inner { flex-wrap: wrap; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .brand-text { display: none; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .header-search input { height: 36px; }
  .hero-inner { flex-direction: column; align-items: flex-start; padding-top: 32px; padding-bottom: 30px; gap: 18px; }
  .project-grid { grid-template-columns: 1fr; padding-top: 20px; }
  .recent-list { grid-template-columns: 1fr; }
  .node-header { flex-direction: column; }
  .node-actions { justify-content: flex-start; }
  .child-controls { opacity: 1; }
  .edit-form { padding: 16px 14px 18px; }
  .edit-topbar { flex-wrap: wrap; }
  .editor-area { padding: 16px; min-height: 52vh; }
  .editor-toolbar { position: static; }
  .search-form-lg { flex-direction: column; }
  .history-author { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Печать ---------- */

@media print {
  .site-header, .project-strip, .site-footer, .node-sidebar, .node-actions, .add-row, .child-controls, .flash-wrap { display: none !important; }
  .node-layout { display: block; }
  body { background: #fff; }
  .prose { font-size: 12pt; }
}
