/* Лист — стили. Трёхпанельный макет: сайдбар · список · редактор. */

:root {
  --font-ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-doc: "Literata", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sidebar-w: 248px;
  --list-w: 336px;
}

:root,
[data-theme="light"] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --line: #dde3ec;
  --line-strong: #c9d1de;
  --text: #1f2430;
  --text-2: #5a6272;
  --text-3: #8a92a1;
  --accent: #1f5fbf;
  --accent-hover: #194f9f;
  --accent-soft: #e3ecfa;
  --accent-ink: #ffffff;
  --danger: #b0413e;
  --danger-soft: #f6e3e0;
  --mark: #fbe7a1;
  --active-row: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 8px 24px rgba(20, 30, 50, 0.08);

  --sb-bg: #17213a;
  --sb-text: #d3dcec;
  --sb-text-2: #8b98b3;
  --sb-hover: rgba(255, 255, 255, 0.06);
  --sb-active: rgba(125, 170, 255, 0.16);
  --sb-active-text: #ffffff;
  --sb-line: rgba(255, 255, 255, 0.08);
  --sb-input: rgba(255, 255, 255, 0.07);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14171d;
  --surface: #1a1e26;
  --surface-2: #20252f;
  --line: #2a303c;
  --line-strong: #394152;
  --text: #e4e8ef;
  --text-2: #a5adbb;
  --text-3: #737c8c;
  --accent: #6ea8ff;
  --accent-hover: #8dbbff;
  --accent-soft: rgba(110, 168, 255, 0.14);
  --accent-ink: #0b1526;
  --danger: #e27d77;
  --danger-soft: rgba(226, 125, 119, 0.14);
  --mark: rgba(240, 200, 80, 0.32);
  --active-row: #232a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);

  --sb-bg: #0e121a;
  --sb-text: #cdd5e2;
  --sb-text-2: #7a8699;
  --sb-hover: rgba(255, 255, 255, 0.05);
  --sb-active: rgba(110, 168, 255, 0.14);
  --sb-active-text: #ffffff;
  --sb-line: rgba(255, 255, 255, 0.06);
  --sb-input: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; }

kbd {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
}

/* ---------- каркас ---------- */

.app {
  display: grid;
  grid-template-columns: var(--rail-w, 0px) var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  transition: grid-template-columns 0.2s var(--ease);
  height: 100vh;
  height: 100dvh;
}

/* ---------- сайдбар ---------- */

.sidebar {
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 6px;
}
.logo-mark { width: 26px; height: 26px; color: #8db8ff; }
.brand-name { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; color: #fff; flex: 1; }
.theme-toggle { color: var(--sb-text-2); }
.theme-toggle:hover { color: #fff; background: var(--sb-hover); }

.btn-new {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: #8db8ff;
  color: #0d1b33;
  font-weight: 600;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn-new:hover { background: #a8c9ff; }
.btn-new:active { transform: scale(0.985); }
.btn-new span { flex: 1; text-align: left; }
.btn-new kbd { background: rgba(13, 27, 51, 0.1); border-color: rgba(13, 27, 51, 0.15); color: #1b3666; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--sb-input);
  color: var(--sb-text-2);
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.search:focus-within { border-color: rgba(141, 184, 255, 0.5); }
.search input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: none;
  outline: none;
  color: #fff;
  font-size: var(--text-sm);
}
.search input::placeholder { color: var(--sb-text-2); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-line) transparent;
}

.nav-group { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--sb-text);
  transition: background 0.12s;
}
.nav-item .icon { width: 16px; height: 16px; color: var(--sb-text-2); }
.nav-item:hover { background: var(--sb-hover); }
.nav-item.is-active { background: var(--sb-active); color: var(--sb-active-text); font-weight: 500; }
.nav-item.is-active .icon { color: #8db8ff; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: var(--text-xs); color: var(--sb-text-2); font-variant-numeric: tabular-nums; }

.nav-section { margin-top: 18px; }
.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sb-text-2);
}

.nb-row { position: relative; }
.nb-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 2px;
  background: var(--sb-bg);
  border-radius: var(--radius-sm);
}
.nb-row:hover .nb-actions,
.nb-row:focus-within .nb-actions { display: flex; }
.nb-row:hover .nav-count { visibility: hidden; }
.nb-actions .icon-btn { color: var(--sb-text-2); }
.nb-actions .icon-btn:hover { color: #fff; background: var(--sb-hover); }

.inline-form { padding: 2px 0 6px; }
.inline-form input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(141, 184, 255, 0.5);
  background: var(--sb-input);
  color: #fff;
  font-size: var(--text-sm);
  outline: none;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--text-xs);
  background: var(--sb-input);
  color: var(--sb-text);
  transition: background 0.12s;
}
.tag-chip:hover { background: rgba(255, 255, 255, 0.12); }
.tag-chip.is-active { background: #8db8ff; color: #0d1b33; }
.tag-chip-count { opacity: 0.6; font-variant-numeric: tabular-nums; }

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

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn--sm { width: 24px; height: 24px; }
.icon-btn--sm .icon { width: 14px; height: 14px; }
.icon-btn--accent { background: var(--accent); color: var(--accent-ink); }
.icon-btn--accent:hover { background: var(--accent-hover); color: var(--accent-ink); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: var(--text-sm);
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn--sm { padding: 6px 12px; }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid:hover { filter: brightness(1.08); }

.only-mobile { display: none; }

/* ---------- список заметок ---------- */

.list-pane {
  background: var(--bg);
  border-right: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.note-list-wrap { display: flex; flex-direction: column; min-height: 0; height: 100%; }

.list-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px 20px;
  border-bottom: 1px solid var(--line);
}
.list-title { flex: 1; min-width: 0; }
.list-title h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-title p { margin: 2px 0 0; font-size: var(--text-xs); color: var(--text-3); }
.list-query { color: var(--text-2); }

.note-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  align-content: start;
  gap: 2px;
}

.note-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.note-item:hover { background: rgba(255, 255, 255, 0.45); }
[data-theme="dark"] .note-item:hover { background: rgba(255, 255, 255, 0.03); }
.note-item.is-active {
  background: var(--active-row);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.note-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--text-base);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.pin-dot { color: var(--accent); display: inline-flex; }
.pin-dot .icon { width: 14px; height: 14px; }
.note-item-excerpt {
  font-size: var(--text-sm);
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}
.note-item-meta {
  display: flex;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-3);
}
.note-item-nb::before { content: "·"; margin-right: 8px; }

.list-empty { padding: 48px 28px; text-align: center; color: var(--text-2); font-size: var(--text-sm); }
.list-empty-title { font-weight: 600; color: var(--text); font-size: var(--text-base); margin: 0 0 4px; }
.list-empty p { margin: 0; }

/* ---------- редактор ---------- */

.editor-pane {
  background: var(--surface);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.editor-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 20px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
  flex-wrap: wrap;
}
.editor-top-spacer { flex: 1; }

.nb-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--text-sm);
}
.nb-picker .icon { width: 15px; height: 15px; }
.nb-picker select {
  border: 0;
  background: none;
  padding: 2px 4px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  outline: none;
  cursor: pointer;
  max-width: 180px;
}

.tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 500;
}
.tag-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  padding: 0;
  opacity: 0.6;
}
.tag-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
.tag-x .icon { width: 12px; height: 12px; }
.tag-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
}
.tag-add:focus-within { border-color: var(--accent); color: var(--accent); }
.tag-add .icon { width: 13px; height: 13px; }
.tag-add input {
  width: 72px;
  border: 0;
  background: none;
  outline: none;
  font-size: var(--text-xs);
  padding: 2px 0;
  color: var(--text);
}
.tag-add input::placeholder { color: var(--text-3); }

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); transition: background 0.2s; }
.save-status.is-fresh .save-dot { background: var(--accent); }
.save-status.is-fresh { color: var(--accent); }
.save-status.is-pending .save-dot { background: #d4a73a; animation: pulse 1s ease-in-out infinite; }
.save-status.is-error { color: var(--danger); }
.save-status.is-error .save-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }

.trash-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--danger-soft);
  color: var(--text);
  font-size: var(--text-sm);
}
.trash-banner span:first-child { flex: 1; }

.note-form { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* Панель инструментов */
.toolbar {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  padding: 6px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.tb-group { display: flex; flex: none; align-items: center; gap: 1px; padding: 0 5px; position: relative; }
.tb-group + .tb-group::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--line);
}
.tb {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  padding: 0;
}
.tb .icon { width: 17px; height: 17px; }
.tb:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.tb.is-active { background: var(--accent-soft); color: var(--accent); }
.tb:disabled { opacity: 0.35; cursor: default; }
.tb-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
}
.tb-group--table { background: var(--accent-soft); border-radius: var(--radius-sm); margin-left: 6px; }
.tb-group--table::before { display: none; }

.link-pop {
  position: absolute;
  z-index: 20;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  display: flex;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s var(--ease);
}
.link-pop.is-open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.link-pop input {
  width: 280px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  font-size: var(--text-sm);
}
.link-pop input:focus { border-color: var(--accent); }

/* Документ */
.doc {
  flex: 1;
  overflow-y: auto;
  padding: 36px 48px 120px;
}
.doc > * { max-width: none; margin-left: 0; margin-right: 0; } /* текст на всю ширину панели */
.doc-meta { margin-top: 0; margin-bottom: 6px; font-size: var(--text-xs); color: var(--text-3); }
.doc-title {
  display: block;
  width: 100%;
  resize: none;
  overflow: hidden;
  border: 0;
  outline: none;
  background: none;
  padding: 0;
  margin-bottom: 18px;
  font-family: var(--font-doc);
  font-size: 2.125rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 1.2em;
  letter-spacing: -0.015em;
  color: var(--text);
}
.doc-title::placeholder { color: var(--text-3); opacity: 0.6; }

.editor-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.editor-foot-hint kbd { font-size: 0.625rem; padding: 2px 4px; }

/* Типографика содержимого заметки */
.prose {
  outline: none;
  font-family: var(--font-doc);
  font-size: 1.0625rem;
  line-height: 1.72;
  color: var(--text);
  min-height: 40vh;
  caret-color: var(--accent);
}
.prose > * + * { margin-top: 0.75em; }
.prose p { margin: 0; }
.prose h1, .prose h2, .prose h3 {
  font-family: var(--font-ui);
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 1.4em 0 0.4em;
}
.prose h1 { font-size: 1.75rem; font-weight: 700; }
.prose h2 { font-size: 1.375rem; font-weight: 700; }
.prose h3 { font-size: 1.125rem; font-weight: 600; }
.prose > :first-child { margin-top: 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose mark { background: var(--mark); color: inherit; padding: 0.05em 0.15em; border-radius: 3px; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.12em 0.36em;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.prose pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: #1b2233;
  color: #dde5f2;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
  font-style: italic;
}
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: 0.2em; }
.prose li > p { margin: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line-strong); margin: 2em 0; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }
.prose img.ProseMirror-selectednode { outline: 3px solid var(--accent); outline-offset: 2px; }

.prose ul[data-type="taskList"] { list-style: none; padding-left: 0.2em; }
.prose ul[data-type="taskList"] li { display: flex; align-items: flex-start; gap: 10px; }
.prose ul[data-type="taskList"] li > label { flex: none; margin-top: 0.32em; user-select: none; }
.prose ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.prose ul[data-type="taskList"] input[type="checkbox"] {
  appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, border-color 0.12s;
}
.prose ul[data-type="taskList"] input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.prose ul[data-type="taskList"] input[type="checkbox"]:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border: 2px solid var(--accent-ink);
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.prose ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--text-3); text-decoration: line-through; }

.prose table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  overflow: hidden;
}
.prose th, .prose td {
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  vertical-align: top;
  text-align: left;
  position: relative;
}
.prose th { background: var(--surface-2); font-weight: 600; }
.prose .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  pointer-events: none;
}
.prose .tableWrapper { overflow-x: auto; }

.prose p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--text-3);
  pointer-events: none;
}
.prose .ProseMirror-gapcursor::after { border-top-color: var(--text); }

/* Пустое состояние */
.editor-empty {
  margin: auto;
  max-width: 400px;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-2);
}
.editor-empty-art {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--accent-soft);
  color: var(--accent);
}
.editor-empty-art .logo-mark { width: 36px; height: 36px; color: var(--accent); }
.editor-empty h2 { margin: 0 0 6px; color: var(--text); font-size: 1.25rem; letter-spacing: -0.01em; }
.editor-empty p { margin: 0 0 22px; font-size: var(--text-sm); }
.shortcut-list {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-3);
}
.shortcut-list kbd { margin-right: 2px; }

/* Тост и диалог */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: #17213a;
  color: #f1f4fa;
  font-size: var(--text-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s var(--ease);
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(14, 20, 34, 0.45);
  animation: fade 0.15s ease;
}
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise 0.18s var(--ease);
}
.dialog-text { margin: 0 0 20px; font-size: var(--text-base); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* Индикация запросов HTMX */
.htmx-request.note-item { opacity: 0.7; }
#note-list.htmx-swapping { opacity: 0.6; transition: opacity 0.1s; }

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

@media (max-width: 1180px) {
  :root { --sidebar-w: 220px; --list-w: 290px; }
  .doc { padding: 28px 32px 100px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: none; }
  .list-pane, .editor-pane { grid-column: 1; grid-row: 1; border-right: 0; }
  .editor-pane { display: none; }
  body.is-editing .editor-pane { display: flex; }
  body.is-editing .list-pane { display: none; }
  .list-head { padding: 14px 12px 12px; }
  .editor-top { padding: 8px 12px; gap: 6px 8px; }
  .editor-top .tags { order: 10; width: 100%; }
  .editor-top .save-text { display: none; }
  .editor-top .icon-btn { width: 30px; }
  .nb-picker select { max-width: 130px; }
  .toolbar { overflow-x: auto; flex-wrap: nowrap; padding: 6px 8px; scrollbar-width: none; }
  .tb-group { flex: none; }
  .doc { padding: 22px 18px 100px; }
  .doc-title { font-size: 1.625rem; }
  .editor-foot-hint { display: none; }
  .link-pop { left: 8px; right: 8px; transform: none; }
  .link-pop.is-open { transform: none; }
  .link-pop input { width: auto; flex: 1; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================= v1.1: авторизация, импорт, экспорт ================= */

/* Кнопка «из буфера» рядом с «Новая заметка» */
.new-row { display: flex; gap: 6px; }
.new-row .btn-new { flex: 1; min-width: 0; }
.btn-import {
  display: grid;
  place-items: center;
  width: 42px;
  flex: none;
  border: 0;
  border-radius: var(--radius);
  background: var(--sb-input);
  color: var(--sb-text);
  transition: background 0.15s;
}
.btn-import:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Профиль внизу сайдбара */
.user-block { position: relative; border-top: 1px solid var(--sb-line); padding-top: 10px; margin: 0 -4px; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--sb-text);
  text-align: left;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--sb-hover); }
.user-btn > .icon { width: 16px; height: 16px; color: var(--sb-text-2); transition: transform 0.15s; }
.user-btn[aria-expanded="false"] > .icon { transform: rotate(180deg); }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: #8db8ff;
  color: #0d1b33;
  font-weight: 700;
  font-size: var(--text-sm);
}
.user-meta { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.user-name { font-size: var(--text-sm); font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: var(--text-xs); color: var(--sb-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Выпадающие меню */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  z-index: 60;
  min-width: 250px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.14s var(--ease);
}
.menu--down { top: calc(100% + 6px); right: 0; }
.menu--up { bottom: calc(100% + 6px); left: 4px; right: 4px; min-width: 0; }
.menu-title { padding: 6px 10px 4px; font-size: var(--text-xs); color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: var(--text-sm);
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:hover { background: var(--surface-2); }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.menu-note { padding: 2px 10px 6px 36px; font-size: var(--text-xs); color: var(--text-3); }

/* Модальное окно импорта */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(14, 20, 34, 0.5);
  animation: fade 0.15s ease;
}
.modal-card {
  width: min(720px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise 0.18s var(--ease);
  overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 22px; }
.modal-head h2 { margin: 0; font-size: 1.0625rem; letter-spacing: -0.01em; }
.import-form { display: flex; flex-direction: column; min-height: 0; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 16px 22px;
  border-top: 1px solid var(--line);
}
.modal-hint { flex: 1; font-size: var(--text-xs); color: var(--text-3); }

.paste-zone {
  margin: 0 22px 18px;
  min-height: 240px;
  max-height: 56vh;
  overflow-y: auto;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.paste-zone:focus-visible, body.is-dragging .paste-zone { border-color: var(--accent); background: var(--accent-soft); }
.paste-zone.has-content { border-style: solid; border-color: var(--line); }
.paste-zone.has-content .paste-zone-idle { display: none; }
.paste-zone.is-loading .import-preview { opacity: 0.5; }
.paste-zone-idle {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 24px;
  text-align: center;
  color: var(--text-2);
  font-size: var(--text-sm);
}
.paste-zone-idle > .icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 6px; }
.paste-zone-idle p { margin: 0; max-width: 440px; }
.paste-zone-title { font-weight: 600; color: var(--text); font-size: var(--text-base); }
.paste-zone-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.import-preview:empty { display: none; }
.import-preview { padding: 18px 22px 22px; }
.import-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.import-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
}
.import-title { margin: 0 0 10px; font-family: var(--font-doc); font-size: 1.5rem; line-height: 1.25; }
.import-error { padding: 36px 24px; text-align: center; color: var(--text-2); }
.import-error p { margin: 0 0 8px; color: var(--danger); font-weight: 500; }
.muted { color: var(--text-3); }
.link-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose--preview { min-height: 0; font-size: 0.9375rem; pointer-events: none; }
.prose--preview img { max-height: 280px; width: auto; }
body.modal-open { overflow: hidden; }

/* Картинка, которая ещё загружается */
.prose img[src^="blob:"], .prose img[src^="data:"] { opacity: 0.55; animation: pulse 1.2s ease-in-out infinite; }

/* Экран входа */
.auth {
  display: grid;
  grid-template-columns: minmax(320px, 440px) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 40px;
  background: var(--sb-bg);
  color: var(--sb-text);
}
.auth-brand, .auth-card-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.125rem; color: #fff; }
.auth-brand .logo-mark { width: 30px; height: 30px; }
.auth-pitch h2 {
  margin: 0 0 22px;
  font-family: var(--font-doc);
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: #fff;
  text-wrap: balance;
}
.auth-pitch ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.auth-pitch li { position: relative; padding-left: 26px; font-size: var(--text-base); }
.auth-pitch li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 10px;
  height: 6px;
  border: 2px solid #8db8ff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
}
.auth-foot { margin: 0; font-size: var(--text-xs); color: var(--sb-text-2); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; overflow-y: auto; }
.auth-card { width: min(380px, 100%); display: grid; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.02em; }
.auth-sub { margin: -10px 0 4px; color: var(--text-2); font-size: var(--text-sm); }
.auth-card-logo { color: var(--accent); display: none; }
.auth-card-logo .logo-mark { color: var(--accent); width: 28px; height: 28px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: var(--text-sm); font-weight: 500; }
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: var(--text-base);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.has-error input { border-color: var(--danger); }
.field-error { font-size: var(--text-xs); color: var(--danger); }
.btn--block { width: 100%; padding: 12px 16px; font-size: var(--text-base); }
.btn:disabled { opacity: 0.55; cursor: default; }
.auth-alert, .auth-notice { padding: 10px 12px; border-radius: var(--radius); font-size: var(--text-sm); }
.auth-alert { background: var(--danger-soft); color: var(--danger); }
.auth-notice { background: var(--accent-soft); color: var(--accent); }
.auth-demo { margin: 0; font-size: var(--text-xs); color: var(--text-3); text-align: center; }
.auth-demo code { font-family: var(--font-mono); color: var(--text-2); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.auth-switch { margin: 0; text-align: center; font-size: var(--text-sm); color: var(--text-2); }
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-main { background: var(--bg); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card-logo.only-mobile-flex { display: flex; }
  .modal { padding: 0; align-items: end; }
  .modal-card { max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .paste-zone { margin: 0 14px 14px; }
  .modal-hint { display: none; }
  .menu--down { right: -40px; }
}

/* ================= v2: портал ================= */

/* --- сворачивание левых панелей --- */
.app > .rail { grid-column: 1; grid-row: 1; }
.app > .sidebar { grid-column: 2; grid-row: 1; }
.app > .list-pane { grid-column: 3; grid-row: 1; }
.app > .editor-pane { grid-column: 4; grid-row: 1; }
@media (max-width: 900px) {
  .app > .list-pane, .app > .editor-pane { grid-column: 1; }
}
.rail {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
  background: var(--sb-bg);
  color: var(--sb-text);
  overflow: hidden;
}
.rail-btn { color: var(--sb-text-2); }
.rail-btn:hover { color: #fff; background: var(--sb-hover); }
.app.collapsed-sidebar,
.app.collapsed-list { --rail-w: 52px; }
.app.collapsed-sidebar .rail,
.app.collapsed-list .rail { display: flex; }
.app.collapsed-sidebar { --sidebar-w: 0px; }
.app.collapsed-list { --list-w: 0px; }
.app.collapsed-sidebar .sidebar,
.app.collapsed-list .list-pane { overflow: hidden; visibility: hidden; padding: 0; border: 0; min-width: 0; }
.rail [data-action="expand-sidebar"] { display: none; }
.rail .rail-btn--list { display: none; }
.app.collapsed-sidebar .rail [data-action="expand-sidebar"] { display: inline-grid; }
.app.collapsed-list .rail .rail-btn--list { display: inline-grid; }
.brand .collapse-btn { margin-left: 2px; color: var(--sb-text-2); }
.brand .collapse-btn:hover { color: #fff; background: var(--sb-hover); }
.only-desktop { display: inline-grid; }
@media (max-width: 900px) {
  .only-desktop, .brand .collapse-btn, .rail { display: none !important; }
  .app.collapsed-sidebar, .app.collapsed-list { --rail-w: 0px; }
}

/* --- дерево блокнотов --- */
.nb-row[data-depth="1"] > .nav-item { padding-left: 26px; }
.nb-row[data-depth="2"] > .nav-item { padding-left: 42px; }
.nb-row[data-depth="3"] > .nav-item { padding-left: 58px; }
.nb-row[data-depth="1"] > .nb-caret { left: 2px; }
.nb-row[data-depth="2"] > .nb-caret { left: 18px; }
.nb-row[data-depth="3"] > .nb-caret { left: 34px; }
.nb-row .nb-caret {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: 0; background: none; padding: 0;
  color: var(--sb-text-2);
  border-radius: 4px;
  z-index: 1;
}
.nb-row .nb-caret .icon { width: 14px; height: 14px; transition: transform 0.15s; }
.nb-row .nb-caret:hover { color: #fff; background: var(--sb-hover); }
.nb-row.is-collapsed > .nb-caret .icon { transform: rotate(-90deg); }
.nb-row.is-branch-hidden { display: none; }
.nb-row .nb-sub-form { padding: 2px 0 6px 26px; }
.nb-move-form { padding: 0 0 6px; }
.nb-move-label { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--sb-text-2); }
.nb-move-label select {
  flex: 1; min-width: 0;
  background: var(--sb-input); color: var(--sb-text);
  border: 1px solid var(--sb-line); border-radius: var(--radius-sm);
  padding: 4px 6px; font-size: var(--text-xs);
}
.nb-move-label option { color: #1f2430; }

/* --- прикреплённые файлы --- */
.note-files {
  border-top: 1px solid var(--line);
  padding: 10px 20px 12px;
  background: var(--surface);
}
.note-files-head { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.note-files-head .icon { width: 14px; height: 14px; }
.note-files-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip {
  display: flex; align-items: center; gap: 8px;
  max-width: 340px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-sm);
}
.file-ext {
  flex: none;
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 5px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent);
}
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-name:hover { color: var(--accent); text-decoration: underline; }
.file-size { flex: none; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.note-files-drop {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--text-xs);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.note-files-drop .link-btn { display: inline-flex; align-items: center; gap: 6px; }
.note-files-drop .icon { width: 14px; height: 14px; }
.note-files-busy { display: none; color: var(--accent); }
.note-files.htmx-request .note-files-busy { display: inline; }
body.is-dragging .note-files-drop { border-color: var(--accent); background: var(--accent-soft); }
.muted { color: var(--text-3); }

/* --- подсветка кода (highlight.js-классы от lowlight) --- */
.tb-select--lang { min-width: 118px; }
.prose pre code .hljs-keyword,
.prose pre code .hljs-built_in,
.prose pre code .hljs-selector-tag { color: #82aaff; }
.prose pre code .hljs-string,
.prose pre code .hljs-attr + .hljs-string,
.prose pre code .hljs-template-string,
.prose pre code .hljs-regexp { color: #c3e88d; }
.prose pre code .hljs-number,
.prose pre code .hljs-literal { color: #f78c6c; }
.prose pre code .hljs-comment,
.prose pre code .hljs-quote { color: #7f8ba3; font-style: italic; }
.prose pre code .hljs-title,
.prose pre code .hljs-title.function_,
.prose pre code .hljs-function .hljs-title { color: #ffcb6b; }
.prose pre code .hljs-type,
.prose pre code .hljs-class .hljs-title,
.prose pre code .hljs-title.class_ { color: #ffcb6b; }
.prose pre code .hljs-attr,
.prose pre code .hljs-attribute,
.prose pre code .hljs-variable,
.prose pre code .hljs-params { color: #f07178; }
.prose pre code .hljs-tag,
.prose pre code .hljs-name { color: #89ddff; }
.prose pre code .hljs-meta,
.prose pre code .hljs-symbol,
.prose pre code .hljs-selector-class,
.prose pre code .hljs-selector-id { color: #c792ea; }
.prose pre code .hljs-punctuation,
.prose pre code .hljs-operator { color: #89ddff; }
.prose pre code .hljs-emphasis { font-style: italic; }
.prose pre code .hljs-strong { font-weight: 700; }

/* --- панель настроек --- */
.settings { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.settings-title { margin: 0; font-size: var(--text-lg); }
.settings-body { flex: 1; overflow-y: auto; padding: 24px 32px 80px; display: grid; gap: 20px; align-content: start; }
.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.settings-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 1rem; }
.settings-card h3 .icon { color: var(--accent); }
.settings-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.settings-form input {
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); min-width: 160px;
}
.settings-form input:focus { outline: none; border-color: var(--accent); }
.settings-actions { display: flex; gap: 8px; margin-top: 12px; }
.badge { font-size: var(--text-xs); font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line); }
.badge--on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.totp-setup { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; margin-top: 12px; }
.totp-qr { border-radius: var(--radius); background: #fff; padding: 8px; border: 1px solid var(--line); }
.totp-setup ol { margin: 0 0 8px; padding-left: 1.2em; display: grid; gap: 6px; }
.totp-secret, .token { display: inline-block; font-family: var(--font-mono); font-size: 0.8125rem; padding: 3px 6px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); word-break: break-all; }
.otp-input { font-family: var(--font-mono); letter-spacing: 0.2em; font-size: 1.05rem; }
.recovery { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.recovery p { margin: 0 0 8px; }
.recovery-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.recovery-list code { font-family: var(--font-mono); font-size: 0.875rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: var(--text-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.kv code { font-family: var(--font-mono); font-size: 0.8125rem; }

/* --- лист для PDF (рендерится вне экрана) --- */
.pdf-holder { position: fixed; left: -10000px; top: 0; width: 700px; background: #fff; }
.pdf-sheet {
  width: 700px;
  padding: 8px 4px;
  background: #fff;
  color: #1f2430;
  --text: #1f2430; --text-2: #5a6272; --surface-2: #f5f7fb; --line: #dde3ec; --accent: #1f5fbf; --mark: #fbe7a1;
}
.pdf-title { font-family: var(--font-ui); font-size: 26px; margin: 0 0 4px; line-height: 1.25; }
.pdf-meta { font-size: 11px; color: #8a92a1; margin: 0 0 16px; }
.pdf-sheet .prose { min-height: 0; font-size: 14px; }
.pdf-sheet .prose pre { white-space: pre-wrap; word-break: break-word; }
.pdf-files { margin-top: 18px; padding-top: 10px; border-top: 1px solid #dde3ec; font-size: 12px; color: #5a6272; }

/* --- печать (Ctrl+P) --- */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .list-pane, .rail, .toolbar, .editor-top, .editor-foot, .note-files-drop, .toast { display: none !important; }
  .app { display: block; height: auto; }
  .editor-pane, .doc { overflow: visible; height: auto; padding: 0; }
}
.note-files-drop { justify-content: flex-start; } .note-files-drop .link-btn { margin: 0; }

/* ================= v3: Диск, настройки, шифрование ================= */

/* --- переключатель разделов --- */
.section-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 3px; border-radius: var(--radius);
  background: var(--sb-input);
}
.section-switch a {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--sb-text-2);
}
.section-switch a .icon { width: 15px; height: 15px; }
.section-switch a:hover { color: var(--sb-text); background: var(--sb-hover); }
.section-switch a.is-active { background: var(--sb-active); color: var(--sb-active-text); font-weight: 600; }

/* --- Диск: каркас --- */
.app--drive { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.app--drive > .sidebar { grid-column: 1; }
.app--drive > .drive-pane { grid-column: 2; grid-row: 1; }
.drive-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.drive-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drive-main.htmx-request { opacity: 0.7; transition: opacity 0.15s; }
.drive { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.nav-item--btn { width: 100%; border: 0; background: none; text-align: left; }
.drive-dav { margin: 0; padding: 0 10px; font-size: var(--text-xs); color: var(--sb-text-2); display: grid; gap: 4px; }
.drive-dav code { font-family: var(--font-mono); color: var(--sb-text); word-break: break-all; }
.drive-dav a { color: #8db8ff; }

.drive-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
}
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 1.125rem; font-weight: 600; }
.crumb { color: var(--text-2); padding: 2px 6px; border-radius: var(--radius-sm); }
a.crumb:hover { background: var(--surface-2); color: var(--accent); }
.crumb--current { color: var(--text); }
.crumb-sep { color: var(--text-3); }
.drive-tools { display: flex; align-items: center; gap: 8px; }
.drive-tools .btn { display: inline-flex; align-items: center; gap: 6px; }
.drive-tools .btn .icon { width: 16px; height: 16px; }
.drive-filter { width: 200px; margin: 0; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.drive-filter input { color: var(--text); }
.drive-mkdir { display: flex; align-items: center; gap: 8px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--accent-soft); color: var(--accent); }
.drive-mkdir input[type=text] { flex: 1; max-width: 360px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }

.drive-drop { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 8px 16px 24px; }
.drive-drop-hint {
  display: none; position: absolute; inset: 8px; z-index: 5;
  border: 2px dashed var(--accent); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  color: var(--accent); font-weight: 600;
  place-items: center; text-align: center; padding: 20px;
}
.drive-drop.is-over .drive-drop-hint { display: grid; }
.drive-progress { display: none; align-items: center; gap: 10px; margin: 6px 8px 10px; font-size: var(--text-sm); color: var(--accent); }
.drive-progress span { display: block; width: 0; height: 4px; border-radius: 2px; background: var(--accent); transition: width 0.2s; flex: none; max-width: 60%; }
.drive-drop.is-uploading .drive-progress { display: flex; }
.drive-empty { padding-top: 80px; }
.drive-empty .icon { width: 40px; height: 40px; color: var(--text-3); }

.drive-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.drive-table th { text-align: left; font-weight: 600; font-size: var(--text-xs); color: var(--text-3); padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: -8px; background: var(--surface); z-index: 1; }
.drive-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.drive-row:hover { background: var(--surface-2); }
.drive-row[hidden] { display: none; }
.col-size, .col-date { white-space: nowrap; color: var(--text-2); width: 1%; font-variant-numeric: tabular-nums; }
.col-size { text-align: right; }
.col-act { width: 1%; text-align: right; }
.drive-name { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-width: 0; color: var(--text); }
.drive-name:hover .drive-label { color: var(--accent); text-decoration: underline; }
.drive-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-ico { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--text-2); }
.drive-ico--dir { background: var(--accent-soft); color: var(--accent); }
.drive-ico .icon { width: 17px; height: 17px; }
.menu--right { right: 0; left: auto; }
.menu-item--danger { color: var(--danger); }
.drive-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 24px; border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--text-3); }
.drive-usage { display: inline-flex; align-items: center; gap: 8px; }
.usage-bar { width: 120px; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--line); overflow: hidden; }
.usage-bar::-webkit-progress-bar { background: var(--line); }
.usage-bar::-webkit-progress-value { background: var(--accent); }
.usage-bar::-moz-progress-bar { background: var(--accent); }

/* предпросмотр */
.modal-card--wide { width: min(1100px, 94vw); max-height: 92vh; display: flex; flex-direction: column; }
.preview-title { flex: 1; min-width: 0; margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-card--wide .modal-head { gap: 8px; }
.modal-card--wide .modal-head .btn { display: inline-flex; align-items: center; gap: 6px; }
.preview-body { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; background: var(--surface-2); padding: 12px; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 74vh; border-radius: var(--radius); }
.preview-body iframe { width: 100%; height: 74vh; border: 0; background: #fff; border-radius: var(--radius); }
.preview-text { width: 100%; max-height: 74vh; margin: 0; overflow: auto; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--font-mono); font-size: 0.8125rem; white-space: pre-wrap; word-break: break-word; }

/* --- диалог с полями --- */
.dialog--form { display: grid; gap: 12px; width: min(440px, 92vw); }
.dialog-title { margin: 0; font-size: 1.0625rem; }
.dialog--form .dialog-text { margin: 0; color: var(--text-2); font-size: var(--text-sm); }
.dialog-fields { display: grid; gap: 8px; }
.dialog-input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.dialog-input:focus { outline: none; border-color: var(--accent); }
.btn--danger-solid { background: var(--danger); color: #fff; }

/* --- настройки --- */
.settings .editor-top { flex-wrap: wrap; gap: 8px 16px; }
.settings-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.settings-nav a { font-size: var(--text-sm); padding: 4px 10px; border-radius: 999px; color: var(--text-2); }
.settings-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.settings-card { scroll-margin-top: 16px; }
.settings-field { display: grid; gap: 4px; font-size: var(--text-xs); color: var(--text-3); }
.settings-field input { font-size: var(--text-sm); color: var(--text); }
.settings-field input:disabled { opacity: 0.7; }
.settings-form--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; }
.settings-form--grid .settings-actions { grid-column: 1 / -1; margin-top: 4px; align-items: center; }
.settings-help { margin-top: 14px; font-size: var(--text-sm); color: var(--text-2); }
.settings-help summary { cursor: pointer; color: var(--accent); }
.settings-help ol { padding-left: 1.2em; display: grid; gap: 6px; }
.settings-help code { font-family: var(--font-mono); font-size: 0.75rem; word-break: break-all; }

/* --- шифрованные заметки --- */
.lock-dot { color: var(--accent); }
.editor.is-locked .toolbar,
.editor.is-locked [data-editor-mount],
.editor.is-locked .note-files,
.editor.is-locked .editor-foot { display: none; }
.enc-lock { display: none; }
.editor.is-locked .enc-lock { display: block; padding: 24px 0; }
.enc-lock-card {
  max-width: 460px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface-2); text-align: center; display: grid; gap: 10px; justify-items: center;
}
.enc-lock-card > .icon { width: 36px; height: 36px; color: var(--accent); }
.enc-lock-card h3 { margin: 0; }
.enc-lock-card p { margin: 0; font-size: var(--text-sm); }
.enc-lock-row { display: flex; gap: 8px; width: 100%; }
.enc-lock-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.enc-lock-row input:focus { outline: none; border-color: var(--accent); }
.editor.is-encrypted:not(.is-locked) .doc-meta::after { content: " · зашифровано AES-256"; color: var(--accent); }

@media (max-width: 900px) {
  .app--drive { grid-template-columns: 1fr; }
  .app--drive > .drive-pane { grid-column: 1; }
  .drive-head { padding: 10px 12px; }
  .drive-filter { width: 100%; order: 5; }
  .col-date { display: none; }
}
.settings-check { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 8px; font-size: var(--text-sm); color: var(--text-2); }
.settings-check input { margin-top: 3px; accent-color: var(--accent); }
