:root {
  --font-default: ui-sans-serif, -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto,
    'Inter', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
  font-family: var(--font-default);
  font-size: 15px;
  font-weight: 300;
  color: #222222;
  background: transparent !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fa;
  color: #1f2933;
  caret-color: #111827;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  overflow: hidden;
  background: transparent;
}

.mobile-only {
  display: none;
}

.hidden {
  display: none !important;
}

/* Sidebar styles locked: do not change without explicit request */
/* Scrollbars (hidden, but scroll via wheel/trackpad still works) */
* {
  scrollbar-width: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: transparent;
}

html {
  height: 100%;
  background: transparent;
}


.search-results {
  background: white;
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(15, 30, 40, 0.2);
  border: 1px solid #e5e7eb;
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.search-results.hidden {
  display: none;
}

.search-result-empty {
  padding: 0.75rem 1rem;
  color: #475569;
  font-size: 0.9rem;
}

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.sidebar {
  width: 280px;
  background: #252526;
  color: #d4d4d4;
  padding: 0.5rem 0.7rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: none;
  position: relative;
  transition: width 0.25s ease, padding 0.25s ease;
  overflow: visible;
  box-sizing: border-box;
  border-right: 1px solid #3c3c3c;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
}

.sidebar-footer {
  font-size: 10px;
  text-align: left;
  padding-top: 4px;
  padding-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  margin-top: auto;
}

.sidebar.collapsed {
  width: 60px;
  padding: 1rem 0.85rem;
}

.sidebar.collapsed .sidebar-content {
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-header {
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .hint-control {
  opacity: 0;
  pointer-events: none;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
  align-items: stretch;
  padding-top: 1.2rem;
  margin-top: 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
}

.sidebar-header {
  position: absolute;
  top: 0.2rem;
  left: 1.1rem;
  right: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 1rem 0 1rem;
  align-items: center;
  pointer-events: none;
}

.app-logo {
  margin: 0;
  pointer-events: auto;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: #e5e5e5;
}

/* убираем наложение подзаголовка */
.sidebar-caption {
  display: none;
}

.hint-control {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #c5c5c5;
  pointer-events: auto;
}

.sidebar-caption {
  color: rgba(212, 212, 212, 0.65);
  margin: 0;
  font-size: 12px;
}

.sidebar-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0;
  border-radius: 10px;
  box-sizing: border-box;
}

.sidebar-section + .sidebar-section {
  margin-top: 0.4rem;
}

.quick-notes-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}
.quick-notes-row .round {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: transparent;
  border: none;
  color: #c5c5c5;
  font-size: 0.85rem;
}

.sidebar-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #c5c5c5;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  line-height: 1;
  z-index: 1300;
  pointer-events: auto;
}

.sidebar.collapsed .sidebar-toggle {
  right: 0.9rem;
}

.search-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-sizing: border-box;
}

#searchInput {
  width: 100%;
  border-radius: 3px;
  border: 1px solid #3c3c3c;
  padding: 0.3rem 0.5rem;
  background: #2d2d2d;
  color: #d4d4d4;
  font-size: 0.88rem;
  transition: border 0.15s ease;
  box-sizing: border-box;
}

#quickNoteAddBtn {
  height: 32px;
  padding: 0 0.7rem;
  border-radius: 4px;
  border: 1px solid #3c3c3c;
  background: #2d2d2d;
  color: #d4d4d4;
  font-size: 0.9rem;
  line-height: 1;
}

#searchInput:focus {
  border-color: #3794ff;
  outline: none;
}

#searchInput::placeholder {
  color: #8c8c8c;
}

.sidebar-articles {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.sidebar-articles__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #d4d4d4;
  margin-bottom: 0.12rem;
  font-size: 0.95rem;
}
.sidebar-articles__header button,
#quickNoteAddBtn {
  height: 22px;
  padding: 0 0.5rem;
  border-radius: 4px;
  border: 1px solid #3c3c3c;
  background: #2d2d2d;
  color: #d4d4d4;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  min-width: 78px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.sidebar-graph-btn {
  min-width: 32px;
  padding: 0;
}
.sidebar-articles__header button:hover,
#quickNoteAddBtn:hover {
  color: #e0e0e0;
}

.sidebar-articles__filter input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #3c3c3c;
  background: #2d2d2d;
  color: #d4d4d4;
  padding: 0.55rem 0.9rem;
  box-sizing: border-box;
}

.sidebar-article-list {
  list-style: none;
  padding: 0;
  padding-top: 0.3rem;
  margin: 0;
  max-height: 44vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-article-item button {
  width: 100%;
  text-align: left;
  border-radius: 4px;
  padding: 0.22rem 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(212, 212, 212, 0.95);
  font-size: 0.9rem !important;
  line-height: 1.2;
  transition: border 0.2s ease, background 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 500;
}

.sidebar-article-item button:hover {
  border-color: #3c3c3c;
  background: #2a2d2e;
}

.sidebar-article-item button.active {
  border-color: #3794ff;
  background: #094771;
  color: #ffffff;
  box-shadow: none;
}
.sidebar-article-item .label {
  display: inline-block;
  margin-left: 0.35rem;
  color: #0ea5e9;
  font-weight: 600;
  font-size: 0.9rem;
}
.star-btn {
  border: none;
  background: transparent;
  color: #c5c5c5;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
}
.star-btn.active {
  color: #facc15;
}
.star-btn:hover {
  color: #facc15;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.25rem;
}
.sidebar-actions button {
  height: 32px;
  padding: 0 0.7rem;
  border-radius: 4px;
  background: #2d2d2d;
  color: #d4d4d4;
  border-color: #3c3c3c;
}

.sidebar button {
  padding: 0.35rem 0.65rem;
  font-size: 0.95rem;
  border-radius: 5px;
  border: 1px solid #3c3c3c;
  background: #2d2d2d;
  color: #d4d4d4;
  font-family: inherit;
  font-weight: 500;
}

.sidebar button.ghost {
  border-color: #3c3c3c;
  color: #d4d4d4;
  background: #2d2d2d;
  border-radius: 5px;
}

.sidebar button.primary {
  background: transparent;
  color: #c5c5c5;
  box-shadow: none;
  border: 1px solid #3c3c3c;
  border-radius: 5px;
}

.search-result-item:hover {
  background: #f5f7fb;
}

.search-result-item__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-start;
}

.search-result-item__badge {
  display: inline-block;
  background: #111c2c;
  color: #f8fafc;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.search-result-item__title {
  font-weight: 600;
  color: #111827;
}

.search-result-item__snippet {
  font-size: 0.9rem;
  color: #475569;
  margin-top: 0.25rem;
  line-height: 1.4;
}

.search-result-item mark {
  background: #fde68a;
  color: #92400e;
  padding: 0 0.15rem;
  border-radius: 3px;
}

main.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

.panel {
  background: #ffffff;
  border-radius: 14px;
  padding: 32px 28px 40px;
  border: none;
  width: 100%;
  max-width: 900px;
  margin: 32px auto 0px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.1);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.article-header {
  justify-content: space-between;
  align-items: center;
}

/* Article view overrides: compact sticky header like VS Code topbar */
#articleView.panel {
  padding: 0 0.3rem;
  margin-top: 0;
  border-radius: 0;
}

#articleView .panel-header.article-header {
  position: sticky;
  top: 0;
  z-index: 15;
  background: #f9fafb;
  border-bottom: 1px solid #dcdcdc;
  margin-bottom: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0;
}

#articleView .title-row h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #222;
}

.article-title--encrypted {
  color: #0f766e;
}

.article-title--encrypted::before {
  content: '🔒';
  display: inline-block;
  margin-right: 0.3rem;
}

#articleView .title-block .meta {
  color: #6a6a6a;
  font-size: 0.85rem;
  margin: 0;
}

.list-header {
  justify-content: flex-start;
}
.list-tabs {
  display: inline-flex;
  gap: 0.35rem;
}
.list-tabs button {
  padding: 0.25rem 0.6rem;
}
.list-tabs .active {
  background: #0ea5e9;
  color: #ffffff;
  border-color: #0ea5e9;
}

.list-header-actions {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

#articleList,
#blocksContainer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.35rem;
  overscroll-behavior: contain;
}
.drag-mode-enabled #blocksContainer .block:not(.editing) .block-surface,
.drag-mode-enabled #blocksContainer .block:not(.editing) .block-content,
.drag-mode-enabled #blocksContainer .block:not(.editing) .block-text {
  cursor: grab;
  touch-action: none;
}
.block-dnd-active #blocksContainer .block:not(.editing) .block-surface,
.block-dnd-active #blocksContainer .block:not(.editing) .block-content,
.block-dnd-active #blocksContainer .block:not(.editing) .block-text {
  cursor: grabbing;
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 auto;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  flex: 1 1 auto;
}

.title-row h2 {
  margin: 0;
  flex: 1 1 auto;
}

.title-block .meta {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
}

.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.article-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  position: relative;
}

.article-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.article-toolbar .ghost.small {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
}

#articleToolbar #articleNewBlockBtn {
  margin-left: auto;
}

.article-toolbar .toolbar-label {
  white-space: nowrap;
}

.public-link-button {
  border-color: #0ea5e9;
  color: #0ea5e9;
  background: rgba(14, 165, 233, 0.08);
}

.public-link-button:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: #0284c7;
  color: #0369a1;
}

@media (max-width: 767px) {
  .article-toolbar .toolbar-label {
    display: none;
  }
}
.drag-mode-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  border: 1px solid #cdd5df;
  padding: 0.25rem 0.8rem;
  font-size: 0.85rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.drag-mode-toggle-btn.active {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #ffffff;
}
.drag-mode-toggle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.article-menu {
  position: absolute;
  right: 0;
  top: 115%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.2);
  min-width: 190px;
  padding: 0.35rem;
  z-index: 25;
}
.article-menu.hidden {
  display: none;
}
.article-menu .menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
.article-menu .menu-item:hover {
  background: #e8f3ff;
}
.article-menu .menu-item.danger {
  color: #b91c1c;
}

#articleTitleInput {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #d0d0d0;
  font-size: 1.25rem;
  font-weight: 600;
  width: 100%;
}

.hint-toggle-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 4px;
  font-weight: 600;
  line-height: 1;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint-toggle-btn.active {
  background: #e8f3ff;
  border-color: #3794ff;
  color: #1d4ed8;
}

.hint-popover {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: auto;
  left: 0;
  width: min(380px, 80vw);
  z-index: 10;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e1e1e1;
  box-shadow: 0 20px 45px rgba(15, 30, 40, 0.18);
}

.hint-popover .hint {
  margin: 0;
}

.ghost.small {
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

.panel.hidden {
  display: none;
}

.meta {
  color: #6b7280;
  margin: 0.25rem 0 0;
}

button {
  border: 1px solid #c7c7c7;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: #f5f5f5;
  color: #111827;
  transition: background 0.2s ease;
}

button.primary {
  background: #0e639c;
  border-color: #3794ff;
  color: white;
  font-weight: 600;
  box-shadow: none;
}

button.ghost {
  background: transparent;
  border: 1px solid #d1d5db;
}

button:hover {
  opacity: 0.9;
}

button.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  font-size: 0.9rem;
  line-height: 1;
}

button.icon-button.small {
  width: 26px;
  height: 26px;
  padding: 0;
}

#articleList {
  list-style: none;
  padding: 0;
  padding-top: 2px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#articleList li {
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

#articleList li:hover {
  border-color: #3794ff;
  transform: translateY(-2px);
}

.hint {
  border-radius: 12px;
  background: #e8f3ff;
  padding: 1rem 1.25rem;
  color: #1d4ed8;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.blocks {
  display: flex;
  flex-direction: column;
  /* gap: 0.35rem; */
  position: relative;
}

.block {
  display: grid;
  grid-template-areas:
    'surface'
    'children';
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  align-items: stretch;
  position: relative;
  box-sizing: border-box;
  /* gap: 0.15rem; */
}

/* Выравниваем высоту корневых блоков: у всех одинаковый бордер и паддинги,
   у выделенного меняем только цвет бордера, чтобы вёрстка не "прыгала". */
.blocks > .block {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.15rem 0.15rem 0.25rem;
}

.block:focus {
  outline: none;
}

.block .block-surface {
  grid-area: surface;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'collapse content drag';
  align-items: flex-start;
  /* column-gap: 0.5rem; */
  padding: 0.05rem 0;
  border-radius: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
  box-sizing: border-box;
  /* gap: 0.35rem; */
}

.block .block-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  padding: 0.3rem;
  grid-area: content;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  border-radius: 6px;
  /* background: #f7f7f7; */
  /* border: 1px solid #e0e0e0; */
  box-sizing: border-box;
}
.block.editing .block-content {
  background: #ffffff;
  border: 1px solid #3794ff;
}

.block:focus > .block-surface {
  outline: #3794ff;
  /* outline-offset: 2px; */
}



.block.selected.block--no-title > .block-surface {
  box-shadow: none;
}

.block.selected[data-collapsed='true'] > .block-surface {
  box-shadow: none;
}

.block.selected:not(.editing) > .block-surface .block-content {
  background: #e8f3ff;
  border-color: #3794ff;
}

.blocks > .block.block--selected-root-ancestor {
  border-color: #d4ddf0;
}

.block.editing > .block-surface {
  background: transparent;
  position: relative;
}

.block.editing > .block-surface > .block-header {
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

.block-text {
  flex: 1;
  min-height: 1.5rem;
  margin-top: 0;
  padding: 0;
  white-space: pre-wrap;
  line-height: 1.5;
  overscroll-behavior: contain;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  /* padding-left: 3rem; */
  /* padding-right: 0.5rem; */
  box-sizing: border-box;
  transition: background-color 0.15s ease;
}
.block-text.block-body {
  margin-top: 0.3rem;
}
.block-text p {
  margin-top: 0;
  margin-bottom: 0;
}
.block-header p,
.block-title p {
  margin: 0;
  padding: 0;
}

.block-text.block-body.block-body--no-title {
  margin-top: 0;
  min-width: 100%;
}

.block-text[contenteditable='true'] {
  outline: none;
  overflow: visible;
  max-height: none;
}

.memus-table {
  border-collapse: collapse;
  width: 100% !important;
  max-width: 100%;
  table-layout: fixed;
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

.memus-table thead tr {
  background: #f3f4f6;
}

.memus-table th,
.memus-table td {
  border: 1px solid #e5e7eb;
  padding: 0.25rem 0.4rem;
  text-align: left;
  vertical-align: top;
  min-width: 3ch;
}

.memus-table tbody tr:nth-child(odd) {
  background: #f9fafb;
}

.memus-table tbody tr:hover {
  background: #eef2ff;
}

.block-text[contenteditable='true'] .memus-table {
  overflow: visible;
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.table-toolbar {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.1rem 0.2rem;
  background: #111827;
  color: #f9fafb;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
  z-index: 2000;
}

.table-toolbar button,
.table-toolbar-btn {
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  border: 1px solid #4b5563;
  background: transparent;
  color: #f9fafb;
  min-width: 2.2rem;
  text-align: center;
}

.table-col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 5;
  /* Небольшой визуальный индикатор, чтобы было за что "схватиться" */
  background: linear-gradient(
    to right,
    transparent,
    rgba(31, 41, 55, 0.45),
    transparent
  );
}

.block.editing > .block-surface > .block-text {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-sizing: border-box;
}

.block.editing > .block-surface > .block-text.block-body--no-title {
  padding-top: 0;
  margin-top: 0;
}

.block.block--no-title > .block-surface .block-content > .block-header {
  display: contents;
  margin: 0;
  padding: 0;
}

.block-header.block-header--no-title {
  display: contents;
}

.block.editing .block-content > .block-header {
  display: block;
  margin: 0 0 0.2rem 0;
  padding: 0;
}

.block.block--no-title > .block-surface .block-title-spacer {
  display: none;
}

.block.block--no-title > .block-surface .block-header__left {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.block.block--no-title > .block-surface .block-content {
  grid-area: content;
}

.block .block-surface > .collapse-btn {
  grid-area: collapse;
  justify-self: start;
  align-self: flex-start;
  margin-top: 0.3rem;
}

.block .block-surface > .block-add-btn {
  grid-area: drag;
  justify-self: end;
  align-self: flex-start;
  margin-top: 0.3rem;
}

.block.block--no-title > .block-surface {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'collapse content drag';
  align-items: flex-start;
  /* column-gap: 0.5rem; */
  padding-top: 0.1rem;
  padding-bottom: 0.1rem;
}

.block.block--no-title > .block-surface > .collapse-btn {
  grid-area: collapse;
}

.block.block--no-title > .block-surface > .block-add-btn {
  grid-area: drag;
}

.block.block--no-title > .block-surface .block-text {
  align-self: flex-start;
  margin-top: 0;
}

.block.block--no-title > .block-surface .collapse-btn,
.block.block--no-title > .block-surface .block-add-btn {
  align-self: flex-start;
  margin-top: 0.3rem;
  margin-left: 0.3rem;
}

.block.editing.block--no-title > .block-surface .block-content {
  padding-left: 0.4rem;
  padding-top: 0.25rem;
}

.block-text img {
  max-width: 100%;
  max-height: 15rem;
  object-fit: contain;
  border-radius: 12px;
  display: block;
  margin: 0.4rem 0;
  box-shadow: 0 6px 18px rgba(15, 30, 40, 0.1);
}
.block-text .attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  color: #111827;
  text-decoration: none;
}
.block-text .attachment-link:hover {
  border-color: #818cf8;
  text-decoration: underline;
}
.block-text .attachment-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-style: italic;
}
.block-text .attachment-upload--error {
  border-color: #ef4444;
  color: #b91c1c;
  background: #fef2f2;
}
.rich-context-menu {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem;
  max-width: min(360px, 96vw);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 30, 40, 0.16);
}
.rich-context-menu.hidden {
  display: none;
}
.rich-context-menu__col {
  min-width: 40px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rich-context-menu__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
}
.rich-context-menu button {
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 8px;
  padding: 0;
  font-size: 0.9rem;
  color: #0f172a;
  cursor: pointer;
  line-height: 1.1;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.08s ease;
}
.rich-context-menu__icon-btn {
  font-size: 1rem;
  font-weight: 600;
}
.rich-context-menu button:hover {
  border-color: #3794ff;
  background: #e8f3ff;
  transform: translateY(-1px);
}

.rich-context-menu .divider {
  display: none;
}
.article-link {
  color: #2563eb;
  text-decoration: underline;
}
.article-link:hover {
  color: #1d4ed8;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
}
.modal-overlay--hide {
  opacity: 0;
  pointer-events: none;
}
.modal-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  width: min(420px, 92vw);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.image-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-modal__card {
  outline: none;
}
.image-modal__img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
}
.modal-header h3 {
  margin: 0;
}
.modal-body {
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.modal-body__text {
  margin: 0;
  color: inherit;
}
.modal-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  color: #0f172a;
}
.modal-input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #d0d0d0;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.modal-input:focus {
  outline: none;
  border-color: #3794ff;
  box-shadow: 0 0 0 4px rgba(55, 148, 255, 0.1);
}
.modal-suggestions {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
}
.modal-suggestions.hidden {
  display: none;
}
.modal-suggestion {
  text-align: left;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
}
.modal-suggestion:hover {
  border-color: #3794ff;
  background: #e8f3ff;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-footer.modal-footer--stacked {
  flex-direction: column !important;
  align-items: stretch;
  justify-content: flex-start;
}

.modal-footer.modal-footer--stacked > button {
  width: 100%;
}

/* Заголовки блоков по уровням вложенности */
h1.block-title,
h2.block-title,
h3.block-title,
h4.block-title,
h5.block-title,
h6.block-title {
  margin: 0;
  padding: 0;
  font-weight: 450;
  color: #111827;
  line-height: 1.3;
  transition: background-color 0.15s ease;
}

h1.block-title {
  font-size: 1.15rem;
}

h2.block-title {
  font-size: 1.05rem;
}

h3.block-title {
  font-size: 1rem;
}

h4.block-title {
  font-size: 0.95rem;
}

h5.block-title,
h6.block-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b5563;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.95));
  z-index: 3000;
}

.auth-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  width: min(420px, 92vw);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.auth-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #64748b;
}

.auth-tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 0.12rem;
  margin-top: 0.4rem;
}

.auth-tab {
  border-radius: 999px;
  border: none;
  background: transparent;
  padding: 0.3rem 0.85rem;
  font-size: 0.9rem;
  color: #4b5563;
}

.auth-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: #0f172a;
}

.auth-field input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #d0d0d0;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.auth-field input:focus {
  outline: none;
  border-color: #3794ff;
  box-shadow: 0 0 0 3px rgba(55, 148, 255, 0.28);
}

.auth-submit {
  margin-top: 0.4rem;
  width: 100%;
}

.auth-google-btn {
  background: #ffffff;
  color: #1f2933;
  border-radius: 999px;
  border: 1px solid #d0d0d0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-google-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.auth-google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.auth-google-label {
  white-space: nowrap;
}

.auth-error {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #b91c1c;
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
}

.sidebar-user-avatar__icon {
  pointer-events: none;
}

.sidebar-user-menu {
  display: flex;
  flex-direction: column;
  right: 0.5rem;
  left: auto;
  top: auto;
  bottom: 2.5rem;
}

.sidebar-user-menu__item {
  padding: 0.35rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #111827;
}

.sidebar-user-menu__name {
  font-size: 0.8rem;
  color: #111827;
  text-align: left;
}

.sidebar-user-menu-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #111827;
}

.sidebar-user-menu-label {
  flex: 1;
  text-align: left;
}

.users-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.users-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
}

.users-list-item__info {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #0f172a;
}

.users-list-item__badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #0f172a;
  color: #f9fafb;
  letter-spacing: 0.05em;
}

.users-list-item__delete {
  font-size: 0.8rem;
}

.block-trash-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.block-trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.block-trash-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.block-trash-item__title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
}

.block-trash-item__meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.block-title__placeholder {
  color: #94a3b8;
  font-style: italic;
}

.graph-container {
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  overflow: hidden;
  position: relative;
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-tooltip {
  padding: 0.2rem 0.4rem;
  background: #111827;
  color: #f9fafb;
  border-radius: 4px;
  font-size: 0.8rem;
  max-width: 260px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.4);
  pointer-events: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.block-body.collapsed {
  display: none;
}

.block-children {
  grid-area: children;
  position: relative;
  margin-left: 0.6rem;
  width: calc(100% - 0.6rem);
  /* padding-left: 1.25rem; */
  border-left: 1px solid #d8d8d8;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  /* gap: 0.35rem; */
  /* margin-top: 0.35rem; */
  padding-left: 0.5rem;
}

.block-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: nowrap;
  /* margin-bottom: 0.35rem; */
  justify-content: space-between;
  width: 100%;
}

.block-header__left {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.block-header + .block-text {
  margin-top: 0.3rem;
  width: 100%;
}

.block-header .move-block-btn {
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}

.block-add-btn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  box-sizing: border-box;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* border-radius: 8px;
  border: 1px solid transparent; */
  background: transparent;
  color: #7a7a7a;
  cursor: pointer;
  align-self: flex-start;
  margin: 0.3rem 0 0 0.3rem;
}
.block-add-btn.block-edit-save-btn {
  margin-top: 0.4rem;
}
.block.editing > .block-surface .block-add-btn.block-edit-save-btn {
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: 0.3rem;
}
.block > .block-surface:hover .block-add-btn {
  color: #333333;
  /* border-color: #e2e8f0; */
}

.block-edit-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
margin: 0.5rem 0 0.1rem;
}

.block.editing .block-edit-actions .ghost.small {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
}

.block-drop-line {
  position: fixed;
  height: 4px;
  background: #3794ff;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(55, 148, 255, 0.35);
  z-index: 1500;
  pointer-events: none;
}
.block-drop-line.hidden {
  display: none;
}
.drag-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.drag-layer__handle {
  position: absolute;
  right: 0.35rem;
  transform: translateY(-50%);
  pointer-events: auto;
}
.block-drag-preview {
  position: fixed;
  z-index: 1600;
  padding: 0.45rem 0.7rem;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  font-size: 0.9rem;
  max-width: min(320px, 80vw);
  opacity: 0.95;
}
.block.drop-inside-target > .block-surface {
  background: #e8f3ff;
  outline: 2px dashed #3794ff;
}
body.block-dnd-active {
  user-select: none;
}

.sidebar-backdrop {
  display: none;
}

.collapse-btn {
  border-radius: 6px;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 1;
  background: transparent;
  border: none;
  color: #777777;
  cursor: pointer;
  align-self: flex-start;
}
.collapse-btn--placeholder {
  border: none;
  background: transparent;
  color: transparent;
  box-shadow: none;
  pointer-events: none;
}
.collapse-btn--placeholder::before,
.collapse-btn--placeholder::after {
  display: none;
}

.block-edit-cancel-btn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  box-sizing: border-box;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #7a7a7a;
  cursor: pointer;
  grid-area: collapse;
  justify-self: start;
}
.block.editing > .block-surface .block-edit-cancel-btn {
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: 0.3rem;
  margin-right: 0.3rem;
}

.collapse-btn {
  position: relative;
}

.collapse-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-right: 1px solid #9ca3af;
  border-bottom: 1px solid #9ca3af;
  transform-origin: center center;
  transform: translate(-50%, -50%) rotate(-135deg);
}

/* Свёрнутый блок: "галочка" вниз */
.collapse-btn[aria-expanded='false']::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.collapse-btn.block-edit-cancel-btn::before {
  display: none;
}

.collapse-btn.block-edit-cancel-btn::after {
  display: none;
}

.collapse-btn.block-edit-cancel-btn {
  font-size: 0.9rem;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 0.75rem 1.25rem;
  background: #111827;
  color: white;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.hidden {
  display: none;
}
.diff-inline {
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  padding: 0.5rem;
  background: #f8fafc;
}

.diff-inline__content {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.diff-inline__segment {
  padding: 0.05rem 0.1rem;
  border-radius: 4px;
  font-weight: 600;
}

.diff-inline__segment--added {
  background: #dcfce7;
  color: #166534;
}

.diff-inline__segment--removed {
  background: #fee2e2;
  color: #b91c1c;
  text-decoration: line-through;
}

.diff-inline__hint {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: #1d4ed8;
  font-weight: 600;
}

.diff-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diff-image-card {
  border: 1px solid #94a3b8;
  border-radius: 8px;
  padding: 0.5rem;
  width: 120px;
  text-align: center;
  background: white;
}

.diff-image-card--added {
  border-color: #4ade80;
  background: #ecfdf5;
}

.diff-image-card--removed {
  border-color: #f87171;
  background: #fef2f2;
}

.diff-image-card__label {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.diff-image-card img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: 4px;
}

/* Mobile-first layout (по умолчанию мобильный вид) */
.app-shell {
  flex-direction: column;
}
.sidebar {
  position: fixed;
  inset: 0;
  max-width: 360px;
  width: 90vw;
  transform: translateX(-100%);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: none;
  z-index: 1200;
}
.sidebar.mobile-open {
  transform: translateX(0);
}

.mobile-only {
  display: inline-flex;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1100;
  display: none;
}
.sidebar-backdrop.hidden {
  display: none;
}
.sidebar.collapsed {
  transform: translateX(-100%);
}
main.content {
}
.panel {
  padding: 20px 16px 32px;
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}
.blocks {
  padding: 0;
  /* gap: 0.35rem; */
}
.block .block-surface {
  /* padding: 0.25rem 0.4rem; */
}
.block-header {
  gap: 0.35rem;
}

@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
    height: 100vh;
  }
.sidebar {
    position: relative;
    width: 280px;
    max-width: 280px;
    transform: none;
    box-shadow: 0 20px 45px rgba(10, 15, 30, 0.35);
  }
  .sidebar.collapsed {
    width: 60px;
    padding: 1rem 0.85rem;
    transform: none;
  }
  .sidebar-backdrop {
    display: none !important;
  }
  .sidebar-toggle,
  .hint-control {
    display: flex;
  }
  .mobile-only {
    display: none;
  }
  main.content {
  }
  .panel {
    padding: 32px 28px 40px;
    max-width: 900px;
    margin: 32px auto 0px;
    border-radius: 14px;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.1);
  }
  .blocks {
    /* gap: 0.35rem; */
  }
  .block .block-surface {
    /* padding: 0.45rem 0.6rem; */
  }
  .block-header {
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  body {
    overflow-y: auto;
    height: auto;
  }
  .app-shell {
    flex-direction: column;
    height: auto;
  }
  .sidebar {
    position: fixed;
    inset: 0;
    max-width: 360px;
    width: 90vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    z-index: 1200;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1100;
    display: block;
  }
  .sidebar-backdrop.hidden {
    display: none;
  }
  .sidebar-toggle,
  .hint-control {
    display: inline-flex;
  }
  .content {
    width: 100%;
    overflow-x: hidden;
  }
  .panel {
    padding: 20px 16px 32px;
  }
  .blocks {
    padding: 0;
    /* gap: 0.35rem; */
  }
  .block .block-surface {
    /* padding: 0.25rem 0.4rem; */
  }
  .block-header {
    gap: 0.35rem;
  }
  .block .collapse-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin-top: 0.3rem;
    margin-left: 0rem;
  }
  .block .block-add-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    margin-top: 0.3rem;
  }
  .block-edit-actions {
    margin: 0.5rem 0 0.1rem;
  }
  .article-header .title-row {
    gap: 0.4rem;
  }
  .mobile-only {
    display: inline-flex;
  }
  /* В мобильном режиме скроллим body, а не внутренние контейнеры,
     чтобы sticky-заголовок статьи оставался на месте. */
  .app-shell,
  main.content,
  .panel {
    overflow: visible;
  }
  /* В мобильном режиме прокручиваем всю страницу,
     а не внутренние списки, чтобы sticky-заголовок статьи оставался на месте. */
  #articleList,
  #blocksContainer {
    overflow-y: visible;
    padding-right: 0;
  }
}

ul {
  padding: 0;
  margin: 0;
  padding-left: 1.5rem;
}

/* Базовая типографика страницы и экспортированного HTML */
html,
body {
  margin: 0;
  padding: 0;
}

body.export-page {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1f2933;
  background: #f5f7fa;
  overflow: auto;
  height: auto;
}

/* Центрированный «лист» документа */
.page {
  max-width: 900px;
  margin: 32px auto 0px;
  padding: 32px 28px 40px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.1);
}

/* Заголовки */
h1,
h2,
h3,
h4 {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: #111827;
  margin-top: 1.8em;
  margin-bottom: 0.4em;
}

h1 {
  font-size: 2rem;
  margin-top: 0;
  margin-bottom: 0.75em;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.4rem;
  padding-left: 0.5em;
}

h3 {
  font-size: 1.15rem;
  color: #111827;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  text-transform: none;
}

/* Абзацы и текст */
body.export-page p {
  margin: 0 0 0;
  max-width: 72ch;
}

body.export-page p + p {
  margin-top: 0.2em;
}

body.export-page strong {
  font-weight: 600;
  color: #111827;
}

body.export-page em {
  font-style: italic;
}

/* Списки (в руководстве их много) */
body.export-page ul,
body.export-page ol {
  margin: 0.4em 0 0.8em 1.5em;
  padding: 0;
}

body.export-page li + li {
  margin-top: 0.2em;
}

/* Таблицы (сравнения, как про блоки vs обычный текст) */
body.export-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.95rem;
}

body.export-page th,
body.export-page td {
  padding: 0.55em 0.7em;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

body.export-page thead tr {
  background: #f3f4f6;
  font-weight: 600;
}

body.export-page tbody tr:nth-child(odd) {
  background: #fafbff;
}

body.export-page tbody tr:nth-child(even) {
  background: #ffffff;
}

/* Горячие клавиши и код */
body.export-page code,
body.export-page kbd {
  font-family: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  font-size: 0.88em;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.1em 0.35em;
  border: 1px solid #e5e7eb;
}

body.export-page kbd {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
  font-weight: 500;
}

body.export-page pre {
  background: #0b1120;
  color: #e5e7eb;
  padding: 0.85em 1em;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9em;
}

/* Ссылки */
body.export-page a {
  color: #2563eb;
  text-decoration: none;
}

body.export-page a:hover {
  text-decoration: underline;
}

/* Внутренние заметки / подсказки */
.note {
  margin: 1em 0;
  padding: 0.9em 1em;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.warning {
  margin: 1em 0;
  padding: 0.9em 1em;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

/* Визуальные разделители */
body.export-page hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1.8em 0;
}

/* Мелкий вторичный текст */
body.export-page .meta,
body.export-page .muted {
  font-size: 0.85rem;
  color: #6b7280;
}

/* Внутри блоков оставляем компактный текст как в ORI_ux:
   отступы абзацев задаются только line-height, без margin. */
body.export-page .block-text p {
  line-height: 1.5;
  margin-top: 0;
  margin-bottom: 0;
}

/* Адаптивность для экспортированной страницы */
@media (max-width: 768px) {
  body.export-page {
    background: #ffffff;
  }

  .page {
    margin: 0;
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding: 20px 16px 32px;
    box-shadow: none;
  }

  body.export-page h1 {
    font-size: 1.6rem;
  }

  body.export-page h2 {
    font-size: 1.25rem;
  }

  body.export-page h3 {
    font-size: 1.05rem;
  }
}
