/* Блокнот без входа (docs/WEB_LOCAL_NOTES_TZ.md). Цвета — как у веб-клиента (src/ui/styles.css), тема — как theme-boot.js. */
:root {
  --primary: #526ed3;
  --primary-hover: #445fc0;
  --primary-tint: #526ed31f;
  --bg: #f6f6f6;
  --surface: #ffffff;
  --text: #1b1c1f;
  --muted: #6b7075;
  --icon: #444a66;
  --border: #dfe5f6;
  --danger: #c62828;
  --brand-way: #1b1c1f;
  --brand-dex: #526ed3;
  --shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 4px 14px rgb(16 24 40 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --primary-tint: #526ed333;
    --bg: #10121c;
    --surface: #1b1e2e;
    --text: #e9ebf7;
    --muted: #9aa0b8;
    --icon: #b4b9cf;
    --border: rgb(255 255 255 / 10%);
    --danger: #ef6b6b;
    --brand-way: #e9ebf7;
    --brand-dex: #8ca0ea;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  --primary-tint: #526ed333;
  --bg: #10121c;
  --surface: #1b1e2e;
  --text: #e9ebf7;
  --muted: #9aa0b8;
  --icon: #b4b9cf;
  --border: rgb(255 255 255 / 10%);
  --danger: #ef6b6b;
  --brand-way: #e9ebf7;
  --brand-dex: #8ca0ea;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html {
  background: var(--bg);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.np-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
}

.np-brand {
  font-weight: 800;
  font-size: 18px;
  text-decoration: none;
}

.np-way {
  color: var(--brand-way);
}

.np-dex {
  color: var(--brand-dex);
}

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

.np-save {
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.np-save:hover:not(:disabled) {
  background: var(--primary-hover);
}

.np-save:disabled {
  opacity: 0.5;
  cursor: default;
}

.np-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.np-tab {
  flex: none;
  max-width: 200px;
  padding: 7px 12px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.np-tab:hover {
  color: var(--text);
}

.np-tab[aria-selected='true'] {
  border-color: var(--border);
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.np-tab-input {
  width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--primary);
  border-radius: 10px 10px 0 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
}

.np-add {
  flex: none;
  width: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--primary);
}

.np-add svg {
  display: block;
  width: 16px;
  height: 16px;
  margin: auto;
  fill: currentColor;
}

.np-add:hover:not(:disabled) {
  background: var(--primary-tint);
}

.np-add:disabled {
  opacity: 0.4;
  cursor: default;
}

.np-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 18px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 0 12px 0 0;
  background: var(--surface);
}

.np-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Действия со страницей — одним блоком справа: при переносе на узком экране группы не разъезжаются по строкам. */
.np-page-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.np-tools button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--icon);
}

.np-tools button:hover:not(:disabled) {
  background: var(--primary-tint);
  color: var(--text);
}

.np-tools button:disabled {
  opacity: 0.35;
  cursor: default;
}

.np-tools button[aria-pressed='true'] {
  background: var(--primary-tint);
  color: var(--primary);
}

.np-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
}

/* Значки — залитые контуры Waydex на сетке 24×24 (src/ui/icons.tsx, PathIcon приложения), цвет — от кнопки. */
.np-ico svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.np-tools .np-danger:hover:not(:disabled) {
  color: var(--danger);
}

.np-pop {
  position: relative;
}

.np-palette {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 24 40 / 16%);
}

.np-palette[hidden] {
  display: none;
}

.np-tools .np-swatch,
.np-tools .np-swatch:hover:not(:disabled) {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--sw);
}

.np-tools .np-swatch:hover:not(:disabled) {
  outline: 2px solid var(--primary);
}

/* «Без цвета» — перечёркнутый кружок. */
.np-tools .np-swatch.np-none,
.np-tools .np-swatch.np-none:hover:not(:disabled) {
  background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%);
}

.np-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.np-editor {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-top-color: transparent;
  border-radius: 0 0 12px 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  outline: none;
  overflow-wrap: anywhere;
}

.np-editor.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  color: var(--muted);
  pointer-events: none;
}

.np-editor ul,
.np-editor ol {
  margin: 0.2em 0;
  padding-left: 1.8em;
}

.np-editor ul.np-check {
  list-style: none;
}

.np-editor ul.np-check > li {
  position: relative;
}

/* Галочка — псевдоэлемент слева от пункта; клик по нему ловит notepad.js (по координате, не по цели). */
.np-editor ul.np-check > li::before {
  content: '';
  position: absolute;
  top: 0.32em;
  left: -1.55em;
  width: 0.95em;
  height: 0.95em;
  box-sizing: border-box;
  border: 1.6px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
}

.np-editor ul.np-check > li.done {
  color: var(--muted);
  text-decoration: line-through;
}

.np-editor ul.np-check > li.done::before {
  border-color: var(--primary);
  background: var(--primary)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 8.5 2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 100% no-repeat;
}

.np-foot {
  padding: 10px 2px 14px;
  color: var(--muted);
  font-size: 13px;
}

.np-foot.np-warn {
  color: var(--danger);
}

.np-dialog {
  max-width: 360px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}

.np-dialog::backdrop {
  background: rgb(0 0 0 / 40%);
}

html:has(dialog[open]) {
  overflow: hidden;
}

.np-dialog p {
  margin: 0 0 16px;
}

.np-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.np-dialog-actions button {
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary-tint);
}

.np-dialog-actions .np-danger-fill {
  background: var(--danger);
  color: #fff;
}

/* Цвет текста и маркер — атрибутами <font color>/<font face> из execCommand, а не инлайн-стилями: CSP сайта
   (style-src 'self') инлайн-стили не пускает. Сгенерировано по палитре TEXT_COLORS / MARKS в notepad.js —
   менять вместе (значение атрибута color = светлый оттенок; тёмная тема и печать подменяют переменные). */
:root {
  --c-red: #c62828;
  --c-orange: #e65100;
  --c-amber: #b28704;
  --c-green: #2e7d32;
  --c-teal: #00796b;
  --c-blue: #1565c0;
  --c-indigo: #3949ab;
  --c-purple: #6a1b9a;
  --c-pink: #ad1457;
  --c-brown: #6d4c41;
  --c-gray: #757575;
  --h-yellow: #fff59d;
  --h-orange: #ffe0b2;
  --h-red: #ffcdd2;
  --h-pink: #f8bbd0;
  --h-purple: #e1bee7;
  --h-blue: #bbdefb;
  --h-teal: #b2dfdb;
  --h-green: #c8e6c9;
  --h-gray: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --c-red: #ef7b7b;
    --c-orange: #ffab66;
    --c-amber: #ffd54f;
    --c-green: #7fd18a;
    --c-teal: #4fd1c5;
    --c-blue: #7fb8ff;
    --c-indigo: #9fa8ff;
    --c-purple: #c99bf0;
    --c-pink: #f48fb1;
    --c-brown: #c8a27c;
    --c-gray: #a3a7b0;
    --h-yellow: rgb(255 214 0 / 32%);
    --h-orange: rgb(255 152 0 / 32%);
    --h-red: rgb(244 67 54 / 30%);
    --h-pink: rgb(233 30 99 / 32%);
    --h-purple: rgb(156 39 176 / 32%);
    --h-blue: rgb(33 150 243 / 32%);
    --h-teal: rgb(0 150 136 / 32%);
    --h-green: rgb(76 175 80 / 32%);
    --h-gray: rgb(255 255 255 / 14%);
  }
}

:root[data-theme='dark'] {
  --c-red: #ef7b7b;
  --c-orange: #ffab66;
  --c-amber: #ffd54f;
  --c-green: #7fd18a;
  --c-teal: #4fd1c5;
  --c-blue: #7fb8ff;
  --c-indigo: #9fa8ff;
  --c-purple: #c99bf0;
  --c-pink: #f48fb1;
  --c-brown: #c8a27c;
  --c-gray: #a3a7b0;
  --h-yellow: rgb(255 214 0 / 32%);
  --h-orange: rgb(255 152 0 / 32%);
  --h-red: rgb(244 67 54 / 30%);
  --h-pink: rgb(233 30 99 / 32%);
  --h-purple: rgb(156 39 176 / 32%);
  --h-blue: rgb(33 150 243 / 32%);
  --h-teal: rgb(0 150 136 / 32%);
  --h-green: rgb(76 175 80 / 32%);
  --h-gray: rgb(255 255 255 / 14%);
}

.np-editor font[color] {
  color: inherit;
}
.np-editor font[color='#c62828' i] {
  color: var(--c-red);
}
.np-editor font[color='#e65100' i] {
  color: var(--c-orange);
}
.np-editor font[color='#b28704' i] {
  color: var(--c-amber);
}
.np-editor font[color='#2e7d32' i] {
  color: var(--c-green);
}
.np-editor font[color='#00796b' i] {
  color: var(--c-teal);
}
.np-editor font[color='#1565c0' i] {
  color: var(--c-blue);
}
.np-editor font[color='#3949ab' i] {
  color: var(--c-indigo);
}
.np-editor font[color='#6a1b9a' i] {
  color: var(--c-purple);
}
.np-editor font[color='#ad1457' i] {
  color: var(--c-pink);
}
.np-editor font[color='#6d4c41' i] {
  color: var(--c-brown);
}
.np-editor font[color='#757575' i] {
  color: var(--c-gray);
}

.np-editor font[face] {
  font-family: inherit;
}
.np-editor font[face^='np-h-'] {
  border-radius: 3px;
  box-decoration-break: clone;
}
.np-editor font[face='np-h-yellow'] {
  background: var(--h-yellow);
}
.np-editor font[face='np-h-orange'] {
  background: var(--h-orange);
}
.np-editor font[face='np-h-red'] {
  background: var(--h-red);
}
.np-editor font[face='np-h-pink'] {
  background: var(--h-pink);
}
.np-editor font[face='np-h-purple'] {
  background: var(--h-purple);
}
.np-editor font[face='np-h-blue'] {
  background: var(--h-blue);
}
.np-editor font[face='np-h-teal'] {
  background: var(--h-teal);
}
.np-editor font[face='np-h-green'] {
  background: var(--h-green);
}
.np-editor font[face='np-h-gray'] {
  background: var(--h-gray);
}

/* Кружки палитры — классами: инлайн-стиль CSP не пустит. */
.sw-c-red {
  --sw: var(--c-red);
}
.sw-c-orange {
  --sw: var(--c-orange);
}
.sw-c-amber {
  --sw: var(--c-amber);
}
.sw-c-green {
  --sw: var(--c-green);
}
.sw-c-teal {
  --sw: var(--c-teal);
}
.sw-c-blue {
  --sw: var(--c-blue);
}
.sw-c-indigo {
  --sw: var(--c-indigo);
}
.sw-c-purple {
  --sw: var(--c-purple);
}
.sw-c-pink {
  --sw: var(--c-pink);
}
.sw-c-brown {
  --sw: var(--c-brown);
}
.sw-c-gray {
  --sw: var(--c-gray);
}
.sw-h-yellow {
  --sw: var(--h-yellow);
}
.sw-h-orange {
  --sw: var(--h-orange);
}
.sw-h-red {
  --sw: var(--h-red);
}
.sw-h-pink {
  --sw: var(--h-pink);
}
.sw-h-purple {
  --sw: var(--h-purple);
}
.sw-h-blue {
  --sw: var(--h-blue);
}
.sw-h-teal {
  --sw: var(--h-teal);
}
.sw-h-green {
  --sw: var(--h-green);
}
.sw-h-gray {
  --sw: var(--h-gray);
}

.np-palette {
  grid-template-columns: repeat(6, 28px);
}

.np-palette-label {
  grid-column: 1 / -1;
  margin: 2px 0 -2px;
  color: var(--muted);
  font-size: 12px;
}

.np-editor a {
  color: var(--primary);
  text-decoration: underline;
}

.np-linkbox {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 5;
  width: min(320px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 24 40 / 16%);
}

.np-linkbox[hidden],
.np-menu[hidden] {
  display: none;
}

.np-linkbox input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}

.np-linkbox input:focus {
  border-color: var(--primary);
}

.np-linkbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.np-tools .np-linkbox-actions button {
  padding: 6px 10px;
  font-size: 14px;
}

.np-tools .np-linkbox-actions .np-primary,
.np-tools .np-linkbox-actions .np-primary:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}

.np-linkbox-actions button[hidden] {
  display: none;
}

.np-linkbox-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.np-menu {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 24 40 / 16%);
}

.np-menu-right {
  right: 0;
}

.np-linkbox-right {
  right: 0;
  left: auto;
}

.np-linkbox input[hidden] {
  display: none;
}

/* Присланная страница: только чтение, вкладки и инструменты прячем, сверху — что это и что с ней сделать. */
.np-viewing .np-tabs,
.np-viewing .np-tools {
  display: none;
}

.np-shared {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--primary-tint);
}

.np-shared[hidden] {
  display: none;
}

.np-shared p {
  flex: 1 1 240px;
  margin: 0;
}

.np-shared-actions {
  display: flex;
  gap: 8px;
}

.np-shared-actions button {
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.np-shared-actions .np-primary,
.np-shared-actions .np-primary:hover {
  background: var(--primary);
  color: #fff;
}

.np-shared-actions button[hidden] {
  display: none;
}

.np-tools .np-menu button {
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

/* Печать — только текст страницы, всегда светлыми цветами. Селектор с :not(#…) перебивает тёмную тему по специфичности. */
@media print {
  html:not(#np-print),
  html:not(#np-print) body {
    height: auto;
    background: #fff;
  }

  html:not(#np-print) {
    --surface: #fff;
    --text: #000;
    --muted: #555;
    --primary: #1a49b8;
    --c-red: #c62828;
    --c-orange: #e65100;
    --c-amber: #b28704;
    --c-green: #2e7d32;
    --c-teal: #00796b;
    --c-blue: #1565c0;
    --c-indigo: #3949ab;
    --c-purple: #6a1b9a;
    --c-pink: #ad1457;
    --c-brown: #6d4c41;
    --c-gray: #757575;
    --h-yellow: #fff59d;
    --h-orange: #ffe0b2;
    --h-red: #ffcdd2;
    --h-pink: #f8bbd0;
    --h-purple: #e1bee7;
    --h-blue: #bbdefb;
    --h-teal: #b2dfdb;
    --h-green: #c8e6c9;
    --h-gray: #e0e0e0;
  }

  body {
    display: block;
    max-width: none;
    padding: 0;
  }

  .np-top,
  .np-tabs,
  .np-tools,
  .np-foot,
  .np-dialog {
    display: none !important;
  }

  .np-editor {
    overflow: visible;
    padding: 0;
    border: 0;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.np-linkbox input.np-bad {
  border-color: var(--danger);
}

/* Переключатель темы: в светлой — луна (сделать тёмной), в тёмной — солнце. */
.np-theme {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.np-theme:hover {
  border-color: var(--primary);
}

.np-theme svg {
  width: 19px;
  height: 19px;
}

.np-moon {
  fill: currentColor;
}

.np-sun {
  display: none;
  fill: currentColor;
}

.np-dark .np-moon {
  display: none;
}

.np-dark .np-sun {
  display: block;
}

/* Редактор — на весь первый экран; текст «о блокноте» — ниже, прокруткой. */
.np-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.np-about {
  max-width: 720px;
  padding: 32px 2px 48px;
  color: var(--text);
  line-height: 1.6;
}

.np-about h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.25;
}

.np-about h2 {
  margin: 24px 0 6px;
  font-size: 17px;
}

.np-about p {
  margin: 0;
  color: var(--muted);
}

.np-about > p {
  font-size: 16px;
}

@media print {
  .np-about {
    display: none !important;
  }

  .np-app {
    display: block;
    height: auto;
  }
}

/* Орфография (spell.js): подчёркивание — CSS Custom Highlight, разметка редактора не меняется. */
::highlight(np-spell) {
  text-decoration: underline wavy var(--danger);
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
}

.np-spell-panel {
  left: 0;
  min-width: 240px;
}

.np-spell-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.np-spell-row:hover {
  background: var(--primary-tint);
}

.np-spell-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.np-spell-caption {
  margin: 6px 10px 2px;
  color: var(--muted);
  font-size: 12px;
}

.np-spell-langs {
  max-height: min(50vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Проверка выключена — языки видны, но приглушены: понятно, что они ждут включения. */
.np-spell-off {
  opacity: 0.5;
}

.np-spell-failed {
  color: var(--danger);
}

.np-spell-note {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
}

.np-spellmenu {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 24 40 / 16%);
}

.np-spellmenu[hidden] {
  display: none;
}

.np-spellmenu button {
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.np-spellmenu button:hover {
  background: var(--primary-tint);
}

.np-spellmenu .np-spell-option {
  font-weight: 600;
}

.np-spell-sugg {
  display: flex;
  flex-direction: column;
}

.np-spell-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

@media print {
  ::highlight(np-spell) {
    text-decoration: none;
  }

  .np-spellmenu {
    display: none !important;
  }
}
