﻿/* Core palette */
:root {
  /* Dark neutral (yellow/black/gray) palette */
  --bg: #08090b;
  --panel: #101114;
  --panel-soft: #0c0d10;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --line: #26272b;
  --line-soft: #17181b;
  --accent: #f59e0b;
  --accent-2: #f97316;
  --accent-soft: #2a1906;
  --radius: 14px;
  --shadow: 0 16px 40px rgba(0,0,0,0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 15% 10%, rgba(245,158,11,0.06) 0, transparent 34%),
              radial-gradient(circle at 85% 0%, rgba(249,115,22,0.08) 0, transparent 38%),
              var(--bg);
  color: var(--text);
}

/* Top bar */
.topbar {
  display: block;
  padding: 12px 18px;
  border-bottom: 2px solid var(--line);
  background: rgba(8, 9, 11, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.brand { font-weight: 800; letter-spacing: 0.02em; }
.brand-link { color: var(--text); text-decoration: none; }
.brand-link--logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-top: 20px;
}
.brand-logo {
  height: 64px;
  width: auto;
  max-height: 64px;
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
}
.nav { display: flex; gap: 10px; align-items: center; }
.nav--inline { display: inline-flex; margin-left: 8px; gap: 6px; transform: translateY(-27px); }
.nav-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-soft);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.nav-link--ghost { border-color: var(--line-soft); background: transparent; }
.nav-link:hover { color: var(--accent); border-color: var(--accent); }
.nav-muted { color: var(--muted); }
.btn-ghost {
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  text-decoration: none;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}
.pill-ghost { border-color: var(--line-soft); }

.btn, .nav-link, .pill { cursor: pointer; }
.btn-danger {
  background: rgba(251, 113, 133, 0.18);
  border-color: rgba(251, 113, 133, 0.55);
  color: rgba(251, 113, 133, 0.95);
}
.btn-danger:hover {
  border-color: rgba(251, 113, 133, 0.9);
  background: rgba(251, 113, 133, 0.28);
}

.search {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--panel-soft);
  flex: 1 1 320px;
  position: relative;
  z-index: 1;
}
.search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
}
.search-icon { opacity: 0.7; }
.search-hint { font-size: 12px; color: var(--muted); }

/* Mobile header */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
  }
  .topbar-inner {
    gap: 10px;
  }
  .brand-link--logo {
    padding-top: 0;
  }
  .brand-logo {
    height: 44px;
    max-height: 44px;
  }
  .nav--inline {
    transform: none;
    margin-left: 0;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .nav--inline::-webkit-scrollbar {
    height: 8px;
  }
  .nav--inline::-webkit-scrollbar-track {
    background: transparent;
  }
  .nav--inline::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.25);
    border-radius: 999px;
  }
  .nav-link {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* iOS Safari: отключаем авто-zoom при фокусе (нужно >=16px) */
  input,
  textarea,
  select,
  .input,
  .textarea,
  .select,
  .search input {
    font-size: 16px;
  }
}

.avatar-menu { position: relative; }
.avatar-dropdown {
  position: absolute;
  right: 0;
  top: 120%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: none;
  min-width: 160px;
}
.avatar-dropdown.open { display: block; }
.dropdown-link {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
}
.dropdown-link:hover { background: var(--panel-soft); color: var(--accent); }

/* Layout */
.page {
  min-height: 100vh;
  padding: 16px 24px 24px 24px;
  display: block;
}
.card {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* Buttons */
.btn {
  border: 2px solid var(--accent-2);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #111;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
}
.btn-secondary { 
  border: 2px solid var(--line); 
  background: var(--panel-soft); 
  color: var(--text); 
  transition: border-color 0.2s ease, color 0.2s ease;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.messages { margin: 0 0 16px; padding: 0; list-style: none; } 
.messages li { padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel-soft); margin-bottom: 8px; } 

/* Error pages */
.error-wrap {
  display: grid;
  gap: 10px;
  padding: 10px 0;
}
.error-badge {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.06em;
}
.error-title { margin: 0; font-size: 26px; line-height: 1.2; }
.error-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.error-details {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
  display: grid;
  gap: 8px;
}
.error-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.error-list { margin: 0; padding-left: 18px; color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.toolbar--space { justify-content: space-between; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.input, .select, .textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  margin-bottom: 12px;
}
.textarea { min-height: 220px; }

.grid { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.grid.notes-workspace {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}
.grid.notes-workspace > * {
  min-width: 0;
}
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.pane--raised { box-shadow: var(--shadow); }
.plain-list { list-style: none; padding: 0; margin: 0; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { color: #fff; }

.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chips--wrap { flex-wrap: wrap; }
.chip { background: var(--accent-soft); color: var(--accent); padding:4px 8px; border-radius:999px; font-size:12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.section-box {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
  background: var(--panel-soft);
}
.section-box--accent { border-left-color: var(--accent-2); box-shadow: 0 12px 28px rgba(0,0,0,0.16); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-box {
  border: 0;
  border-left: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  box-shadow: none;
}
.notes-sidebar.pane {
  padding: 12px;
}
.notes-sidebar {
  /* Большое дерево не должно ломать сетку: пусть скроллится внутри сайдбара */
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  overflow-x: hidden;
}
/* Scrollbar для списка заметок в сайдбаре */
.notes-sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.5) rgba(16, 17, 20, 0.35);
}
.notes-sidebar::-webkit-scrollbar {
  width: 10px;
}
.notes-sidebar::-webkit-scrollbar-track {
  background: rgba(16, 17, 20, 0.35);
  border-radius: 999px;
}
.notes-sidebar::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.45);
  border-radius: 999px;
  border: 2px solid rgba(16, 17, 20, 0.35);
}
.notes-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 158, 11, 0.65);
}
.notes-editor {
  min-height: calc(100vh - 180px);
}
.notes-sidebar .section-head {
  padding: 6px 6px 10px 6px;
}
.notes-sidebar .tree {
  padding: 0 6px 8px 6px;
}
.notes-sidebar .tree-item {
  padding-top: 6px;
  padding-bottom: 6px;
}
.stat-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-soft);
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.pill-label { display: inline-block; font-size: 12px; color: var(--muted); margin: 6px 0 4px 0; }

.note-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--panel-soft); margin-bottom: 12px; cursor: pointer; transition: border-color 0.2s ease, transform 0.1s ease; }
.note-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.note-head { display:flex; justify-content:space-between; align-items:center; gap: 12px; }
.note-actions { display:flex; gap:10px; flex-wrap: wrap; }
.note-meta { font-size: 12px; color: var(--muted); }
.note-body { margin-top: 8px; line-height: 1.6; }
.note-body--readonly {
  /* В режиме чтения выравниваем контент как в Editor.js (учитываем "гаттер" слева) */
  margin-top: 0;
  padding: 12px 12px 12px 64px;
  display: grid;
  gap: 10px;
}
.note-body--readonly > * { margin: 0; }
.note-body--readonly > p { margin: 0; }
.note-body--readonly > ul,
.note-body--readonly > ol { padding-left: 18px; }
.note-body--readonly h1 { font-size: 26px; font-weight: 800; line-height: 1.2; }
.note-body--readonly h2 { font-size: 22px; font-weight: 800; line-height: 1.2; }
.note-body--readonly h3 { font-size: 18px; font-weight: 800; line-height: 1.25; }
.note-body--readonly h4 { font-size: 16px; font-weight: 800; line-height: 1.3; }
.note-body--readonly h5 { font-size: 14px; font-weight: 800; line-height: 1.35; }
.note-body--readonly h6 { font-size: 13px; font-weight: 800; line-height: 1.35; opacity: 0.95; }
.note-body--readonly .checklist { display: grid; gap: 6px; }
.note-body--readonly .checklist-item { white-space: pre-wrap; }
.note-body h1, .note-body h2, .note-body h3 { margin: 0 0 8px 0; line-height: 1.2; }
.note-body p { margin: 0 0 10px 0; white-space: pre-wrap; }
.note-body ul, .note-body ol { margin: 0 0 10px 0; padding-left: 18px; }
.note-body li { white-space: pre-wrap; }
.note-body code { background: var(--line-soft); padding: 2px 6px; border-radius: 6px; }
.note-body pre { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow: auto; }
.note-body pre code { display: block; background: transparent; padding: 0; white-space: pre; }
.note-body blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: rgba(255,255,255,0.02); }
.note-body blockquote { white-space: pre-wrap; }
.note-body a,
.note-body a:link,
.note-body a:visited,
.note-body a:active {
  color: inherit !important;
  text-decoration: underline;
  text-decoration-color: rgba(249, 115, 22, 0.35);
  text-underline-offset: 3px;
}
.note-body a:hover {
  color: var(--accent) !important;
  text-decoration-color: rgba(249, 115, 22, 0.75);
}
.editor-raw.note-body--readonly a,
.editor-raw.note-body--readonly a:link,
.editor-raw.note-body--readonly a:visited,
.editor-raw.note-body--readonly a:active {
  color: inherit !important;
  text-decoration: underline;
  text-decoration-color: rgba(249, 115, 22, 0.35);
  text-underline-offset: 3px;
}
.editor-raw.note-body--readonly a:hover {
  color: var(--accent) !important;
  text-decoration-color: rgba(249, 115, 22, 0.75);
}
.note-preview { margin-top: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--panel-soft); }
.preview-pane { min-height: 220px; overflow: auto; border: 1px dashed var(--line); border-radius: 10px; padding: 10px; background: var(--panel-soft); }
.small { font-size: 12px; }
.note-body details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  background: var(--panel-soft);
}
.note-body summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}
.note-body table { width: 100%; border-collapse: collapse; }
.note-body td, .note-body th { border: 1px solid rgba(255, 255, 255, 0.08); padding: 8px 10px; vertical-align: top; white-space: pre-wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--line-soft);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.hover-badge:hover .badge { opacity: 1; }

.slash-menu {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  width: 220px;
  display: none;
  z-index: 20;
}
.slash-menu.open { display: block; }
.slash-item {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  color: var(--text);
}
.slash-item:hover { background: var(--panel-soft); color: var(--accent); }

.tree { display: flex; flex-direction: column; gap: 4px; }
.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
}
.tree-item .active { color: var(--accent); font-weight: 700; }
.tree-actions { display: inline-flex; gap: 6px; align-items: center; }

/* Дерево страниц (Notion-like) */
.tree--pages { gap: 6px; }
.tree-node { display: block; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  /* Ограничиваем отступ при глубокой вложенности, чтобы не ломалась адаптация */
  margin-left: min(calc(var(--depth, 0) * 14px), 112px);
  min-width: 0;
}
.tree-node.is-active > .tree-row {
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.tree-toggle {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  flex: 0 0 auto;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, color 0.2s ease;
}
.tree-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tree-toggle--spacer {
  border-color: transparent;
  background: transparent;
}
.tree-node.collapsed > .tree-row .tree-toggle {
  transform: rotate(-90deg);
}
.tree-link {
  flex: 1 1 auto;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tree-link:hover { color: #fff; }
.tree-link.active { color: var(--accent); font-weight: 800; }
.tree-children {
  /* Не накапливаем отступы контейнера: отступ задаётся по --depth на строке */
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
  display: grid;
  gap: 4px;
}
.tree-node.collapsed > .tree-children { display: none; }
.tree-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 10px;
  cursor: pointer;
}
.tree-action--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 10px;
}
.tree-action:hover { border-color: var(--accent); color: var(--accent); }
.tree-action--danger:hover { border-color: #fb7185; color: #fb7185; }

.page-editor {
  display: grid;
  gap: 10px;
}
.page-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 6px 0;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.page-title[contenteditable="true"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-soft);
}
.editor-raw {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--panel-soft);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--text);
  pointer-events: auto;
}
.editor-raw.note-body--readonly {
  /* В режиме чтения сохраняем такой же "гаттер" слева, как у Editor.js (кнопки + / ⋮⋮). */
  padding: 12px 12px 12px 64px;
  display: grid;
  gap: 10px;
}
.editor-raw:focus {
  outline: none;
  border-color: var(--accent);
}
.editorjs-wrapper {
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

/* Workspace: меньше "рамок в рамке" */
.notes-workspace .editor-raw {
  border: 1px dashed rgba(38, 39, 43, 0.9);
  background: transparent;
}
.codex-editor,
.codex-editor * {
  color: var(--text);
}
.codex-editor a,
.codex-editor a:link,
.codex-editor a:visited,
.codex-editor a:active {
  color: inherit !important;
  text-decoration: underline;
  text-decoration-color: rgba(249, 115, 22, 0.35);
  text-underline-offset: 3px;
}
.codex-editor a:hover {
  color: var(--accent) !important;
  text-decoration-color: rgba(249, 115, 22, 0.75);
}
.codex-editor .ce-block__content {
  max-width: 100%;
  /* Гаттер слева под toolbar (+ и ⋮⋮), чтобы он не наезжал на текст */
  padding-left: 64px;
  padding-right: 12px;
}
.codex-editor .ce-paragraph,
.codex-editor .ce-header,
.codex-editor .cdx-list__item,
.codex-editor blockquote {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.codex-editor .ce-block--focused .ce-block__content {
  background: rgba(255,255,255,0.02);
}
.ce-toolbar__plus,
.ce-toolbar__settings-btn,
.ce-toolbar__actions-btn {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  /* Одинаковый сдвиг, чтобы кнопки были на одной линии */
  transform: translateX(-22px);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ce-toolbar__plus {
  transform: translateX(-22px);
}
.ce-toolbar__plus,
.ce-toolbar__settings-btn,
.ce-toolbar__actions-btn {
  border-radius: 10px;
}
.ce-toolbar__plus,
.ce-toolbar__settings-btn,
.ce-toolbar__actions-btn,
.ce-toolbar__plus svg,
.ce-toolbar__settings-btn svg,
.ce-toolbar__actions-btn svg {
  fill: var(--text);
}
.ce-toolbar__plus:hover,
.ce-toolbar__settings-btn:hover,
.ce-toolbar__actions-btn:hover {
  background: var(--accent);
  color: #111;
}
.ce-toolbar__plus::before,
.ce-toolbar__settings-btn::before,
.ce-toolbar__actions-btn::before {
  filter: invert(1);
}
.ce-inline-toolbar,
.ce-settings,
.ce-popover {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 12px;
}
.ce-popover,
.ce-inline-toolbar {
  color: var(--text);
}
.ce-popover,
.ce-popover__dropdown,
.ce-popover__items,
.ce-popover__item {
  background: var(--panel);
}
.ce-popover__search {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
}
.ce-popover__search-input {
  color: var(--text);
  background: transparent;
}
.ce-popover__search svg {
  color: var(--text);
  fill: var(--text);
}
.ce-inline-toolbar .ce-inline-toolbar__buttons,
.ce-settings .ce-settings__buttons,
.ce-popover__items {
  background: transparent;
}
.ce-inline-toolbar button,
.ce-settings button,
.ce-popover__item {
  color: var(--text);
  border-radius: 10px;
}
.ce-popover__item-title {
  color: var(--text);
}
.ce-inline-toolbar button:hover,
.ce-settings button:hover,
.ce-popover__item:hover {
  background: var(--panel-soft);
  color: var(--accent);
}
.ce-toolbar__content-hider {
  background: var(--panel);
}
.ce-popover__item-icon {
  background: var(--line-soft);
  border: 1px solid var(--line);
  color: var(--text);
}

/* Editor.js 2.30+ popover (новые классы) */
.ce-popover__container {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  border-radius: 12px !important;
  color: var(--text) !important;
}
.ce-popover__container * {
  color: inherit;
}
.ce-popover-item {
  background: transparent !important;
  border-radius: 10px !important;
}
.ce-popover-item__title {
  color: var(--text) !important;
}
.ce-popover-item:hover,
.ce-popover-item--focused {
  background: var(--panel-soft) !important;
}
.ce-popover-item:hover .ce-popover-item__title,
.ce-popover-item--focused .ce-popover-item__title {
  color: var(--accent) !important;
}
.ce-popover-item__icon {
  background: var(--line-soft) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
}
.ce-popover__search {
  background: var(--panel-soft) !important;
  border: 1px solid var(--line) !important;
}
.ce-popover__search-input {
  color: var(--text) !important;
}
.ce-popover__search-input::placeholder {
  color: rgba(161, 161, 170, 0.8) !important;
}

/* Скролл в попапе инструментов (темный, аккуратный) */
.ce-popover__items,
.ce-popover__container {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.65) rgba(255, 255, 255, 0.06);
}
.ce-popover__items::-webkit-scrollbar,
.ce-popover__container::-webkit-scrollbar {
  width: 10px;
}
.ce-popover__items::-webkit-scrollbar-track,
.ce-popover__container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}
.ce-popover__items::-webkit-scrollbar-thumb,
.ce-popover__container::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}
.ce-popover__items::-webkit-scrollbar-thumb:hover,
.ce-popover__container::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 158, 11, 0.75);
}

/* Темизация инструментов, которые инжектят "светлые" стили */
.cdx-checklist__item-checkbox {
  background: var(--panel-soft) !important;
  border-color: var(--line) !important;
}
.cdx-checklist__item-checkbox:hover {
  border-color: rgba(245, 158, 11, 0.6) !important;
}
.cdx-checklist__item--checked .cdx-checklist__item-checkbox {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
.cdx-checklist__item-text {
  color: var(--text) !important;
}
.ce-code__textarea {
  background: var(--panel-soft) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
.ce-code__textarea::placeholder {
  color: rgba(161, 161, 170, 0.8) !important;
}
.ce-toolbar__content-hider,
.ce-block--selected .ce-block__content {
  background: rgba(247, 163, 26, 0.06);
}
.checklist .checklist-item {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}
.checklist input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.pyit-delimiter {
  padding: 10px 0;
}

/* Callout */
.pyit-callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px 12px;
}
.pyit-callout__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.pyit-callout__badge {
  font-size: 12px;
  color: rgba(161, 161, 170, 0.9);
}
.pyit-callout__tone {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 12px;
}
.pyit-callout__text {
  min-height: 22px;
  outline: none;
}
.pyit-callout__text:empty:before {
  content: attr(data-placeholder);
  color: rgba(161, 161, 170, 0.75);
}
.pyit-callout--warn { border-left-color: rgba(244, 63, 94, 0.9); }
.pyit-callout--ok { border-left-color: rgba(34, 197, 94, 0.9); }

/* Date block */
.pyit-date {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}
.pyit-date__text {
  font-size: 13px;
  color: rgba(244, 244, 245, 0.95);
}
.pyit-date__btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.pyit-date__btn:hover {
  border-color: rgba(245, 158, 11, 0.6);
}

/* Bookmark */
.pyit-bookmark {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
}
.pyit-bookmark__row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.pyit-bookmark__url {
  flex: 1 1 auto;
  min-width: 180px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}
.pyit-bookmark__host {
  font-size: 12px;
  color: rgba(161, 161, 170, 0.9);
  white-space: nowrap;
}
.pyit-bookmark__title {
  margin-top: 10px;
  font-weight: 700;
  outline: none;
}
.pyit-bookmark__title:empty:before {
  content: attr(data-placeholder);
  color: rgba(161, 161, 170, 0.75);
  font-weight: 600;
}
.pyit-bookmark__note {
  margin-top: 6px;
  color: rgba(210, 210, 220, 0.9);
  outline: none;
}
.pyit-bookmark__note:empty:before {
  content: attr(data-placeholder);
  color: rgba(161, 161, 170, 0.75);
}
.pyit-bookmark__link {
  color: var(--accent);
  text-decoration: none;
}
.pyit-bookmark__link:hover {
  text-decoration: underline;
}

/* Table */
.pyit-table {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}
.pyit-table__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--line);
}
.pyit-table__badge {
  font-size: 12px;
  color: rgba(161, 161, 170, 0.9);
}
.pyit-table__actions {
  display: inline-flex;
  gap: 8px;
}
.pyit-table__btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
}
.pyit-table__btn:hover {
  border-color: rgba(245, 158, 11, 0.6);
}
.pyit-table__table {
  width: 100%;
  border-collapse: collapse;
}
.pyit-table__cell {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
  vertical-align: top;
  outline: none;
  min-width: 80px;
}
.pyit-table__cell:focus {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.35);
}
.pyit-delimiter__hr {
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(247,163,26,0.35) 20%, rgba(249,115,22,0.55) 50%, rgba(247,163,26,0.35) 80%, transparent 100%);
  opacity: 0.9;
  border-radius: 999px;
}
.pyit-toggle__details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
}
.pyit-toggle__summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
  outline: none;
}
.pyit-toggle__summary[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: rgba(161, 161, 170, 0.8);
  font-weight: 700;
}
.pyit-toggle__body {
  margin-top: 8px;
  padding-left: 8px;
  border-left: 2px solid rgba(245, 158, 11, 0.35);
  outline: none;
  overflow-wrap: anywhere;
}
.pyit-toggle__body[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: rgba(161, 161, 170, 0.8);
}
.pyit-toggle__editor {
  padding: 6px 0 2px 0;
}
.pyit-toggle .ce-toolbar__plus,
.pyit-toggle .ce-toolbar__settings-btn,
.pyit-toggle .ce-toolbar__actions-btn {
  transform: scale(0.9);
}
.toast-editor {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}
.save-indicator {
  font-size: 12px;
  color: var(--muted);
}
.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}
.empty-icon { font-size: 32px; }

.hero { width: 100%; display: grid; gap: 16px; }
.hero-card { position: relative; overflow: hidden; background: radial-gradient(circle at 20% 20%, rgba(247,163,26,0.08) 0, transparent 40%), radial-gradient(circle at 80% 0%, rgba(249,115,22,0.12) 0, transparent 45%), var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); transform: translateY(8px); opacity: 0; transition: all 0.6s ease; }
.hero-card.visible { transform: translateY(0); opacity: 1; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; letter-spacing: 0.03em; }
.hero-title { margin: 8px 0 6px 0; font-size: 28px; }
.hero-text { color: var(--muted); margin: 0 0 14px 0; }
.hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pill-muted { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted); font-size: 12px; }
.landing { width: 100%; display: grid; gap: 16px; }
.landing-hero { padding: 26px; }
.hero-split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; align-items: center; }
.hero-left { min-width: 0; }
.hero-right { min-width: 0; display: grid; gap: 10px; justify-items: end; }
.hero-points { display: grid; gap: 8px; margin: 14px 0 16px 0; }
.hero-point { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); line-height: 1.45; }
.hero-dot { width: 8px; height: 8px; border-radius: 999px; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); margin-top: 6px; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
.hero-hint { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.landing-section { display: grid; gap: 10px; }
.section-title { margin: 6px 0 0 0; font-size: 18px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.step-card { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); padding: 14px; display: flex; gap: 12px; align-items: flex-start; box-shadow: 0 10px 22px rgba(0,0,0,0.18); }
.step-num { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; font-weight: 900; color: #111; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); border: 2px solid var(--accent-2); flex: 0 0 auto; }
.step-title { font-weight: 800; margin: 0 0 4px 0; }
.landing-footer { margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.landing-footer-actions { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.landing-note { max-width: 520px; text-align: right; }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.mock-window {
  width: 100%;
  max-width: 520px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 30% 10%, rgba(247,163,26,0.10), transparent 45%), var(--panel-soft);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  overflow: hidden;
}
.mock-top {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
}
.mock-dot { width: 10px; height: 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.10); background: rgba(255,255,255,0.10); }
.mock-title { justify-self: end; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.mock-body { display: grid; grid-template-columns: 170px 1fr; min-height: 240px; }
.mock-sidebar { border-right: 1px solid var(--line); padding: 12px; display: grid; gap: 8px; }
.mock-editor { padding: 12px; display: grid; gap: 8px; align-content: start; }
.mock-item { color: var(--muted); font-size: 13px; }
.mock-item.active { color: var(--accent); font-weight: 900; }
.mock-item.indent { padding-left: 10px; }
.mock-item.indent2 { padding-left: 22px; }
.mock-breadcrumb { color: var(--muted); font-size: 12px; }
.mock-h1 { font-size: 20px; font-weight: 900; margin-top: 4px; }
.mock-line { color: var(--text); font-size: 13px; }

@media (max-width: 980px) {
  .hero-split { grid-template-columns: 1fr; }
  .hero-right { justify-items: stretch; }
  .landing-note { text-align: left; }
  .mock-body { grid-template-columns: 1fr; }
  .mock-sidebar { display: none; }
  .steps-grid { grid-template-columns: 1fr; }
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card-feature { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel-soft); box-shadow: 0 10px 22px rgba(0,0,0,0.18); }
.card-title { margin: 0 0 6px 0; }

@media (max-width: 960px) {
  .topbar-inner { grid-template-columns: 1fr; }
  .nav { flex-wrap: wrap; }
  .nav-actions { justify-content: flex-start; flex-wrap: wrap; }
  .search { width: 100%; flex: 1 1 100%; }
  .grid { grid-template-columns: 1fr; }
  .grid.notes-workspace { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .toolbar { flex-wrap: wrap; }
  .nav { flex-wrap: wrap; justify-content: flex-end; }
  .brand-logo { height: 52px; max-height: 52px; }
  .notes-sidebar .tree--pages {
    max-height: 38vh;
    overflow: auto;
    padding-right: 6px;
  }
  .notes-workspace .editor-raw {
    min-height: 360px;
  }
  .codex-editor .ce-block__content {
    padding-left: 56px;
    padding-right: 10px;
  }
  .note-body--readonly {
    padding-left: 56px;
    padding-right: 10px;
  }
  .ce-toolbar__plus,
  .ce-toolbar__settings-btn,
  .ce-toolbar__actions-btn {
    transform: translateX(-20px);
  }
}

@media (max-width: 640px) {
  .page { padding: 12px; }
  .card { padding: 16px; }

  .grid.notes-workspace { gap: 12px; }
  .notes-sidebar { max-height: 34vh; }
  .notes-workspace .editor-raw { min-height: 44vh; }

  .tree-action,
  .tree-action--disabled {
    width: 24px;
    height: 24px;
    border-radius: 9px;
  }

  .codex-editor .ce-block__content {
    padding-left: 52px;
    padding-right: 10px;
  }

  .note-body--readonly,
  .editor-raw.note-body--readonly {
    padding-left: 52px;
    padding-right: 10px;
  }

  .ce-toolbar__plus,
  .ce-toolbar__settings-btn,
  .ce-toolbar__actions-btn {
    width: 26px;
    height: 26px;
    transform: translateX(-18px);
  }

  /* Editor.js popover: жёстко выключаем "белые окна" на мобиле */
  .ce-popover,
  .ce-inline-toolbar,
  .ce-popover__container,
  .ce-popover__items {
    background: rgba(16, 17, 20, 0.98) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
  }
  .ce-popover__search-input {
    font-size: 16px;
  }
}
