/*
  FireWeek visual language for Safe Notes.
  Loaded after styles.css: monochrome surface, Onest, pill controls,
  2px black section rules, lined "paper" editor and an indigo accent.
*/

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/onest-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --fw-font: "Onest", "Helvetica Neue", Arial, sans-serif;
  --fw-bg: #ffffff;
  --fw-ink: #000000;
  --fw-inverse: #ffffff;
  --fw-muted: #52525b;
  --fw-chip: #f2f2f5;
  --fw-chip-hover: #e8e8ec;
  --fw-line: #e8e8ec;
  --fw-line-soft: #f3f3f6;
  --fw-card: #f6f6f8;
  --fw-chip-active: #e3e3e8;
  --fw-seg-active: #ffffff;
  --fw-accent: #4a55f0;
  --fw-ok: #2bf5a0;
  --fw-danger: #a61e36;
  --fw-shell-h: 100vh;
}

@supports (height: 100dvh) {
  :root { --fw-shell-h: 100dvh; }
}

body[data-theme="dark"] {
  --fw-bg: #0b0b0d;
  --fw-ink: #ffffff;
  --fw-inverse: #000000;
  --fw-muted: #a1a1aa;
  --fw-chip: #1c1c20;
  --fw-chip-hover: #2a2a30;
  --fw-line: #2a2a30;
  --fw-line-soft: #1c1c20;
  --fw-card: #141417;
  --fw-chip-active: #34343a;
  --fw-seg-active: #3a3a42;
  --fw-accent: #8b93ff;
  --fw-danger: #ff7a90;
}

/* ---------- Page & shell ---------- */

body,
body[data-theme] {
  display: block;
  padding: 0;
  color: var(--fw-ink);
  background: var(--fw-bg);
  font-family: var(--fw-font);
}

body .notebook-page {
  display: block;
  width: 100%;
  gap: 0;
}

body .background-settings-toggle,
body .background-settings {
  display: none;
}

body .notebook-shell,
body[data-theme] .notebook-shell {
  width: 100%;
  height: var(--fw-shell-h);
  color: var(--fw-ink);
  background: var(--fw-bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

@media (min-width: 721px) {
  body .notebook-shell,
  body[data-theme] .notebook-shell {
    grid-template-columns: 216px 300px minmax(0, 1fr);
  }

  body .notebook-shell.folders-collapsed {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  body .notebook-shell.focus-mode {
    grid-template-columns: minmax(0, 1fr);
  }
}

body .notebook-shell.fullscreen-mode {
  height: var(--fw-shell-h);
}

body button,
body input,
body textarea {
  font-family: var(--fw-font);
}

body button:focus-visible,
body input:focus-visible,
body a:focus-visible,
body textarea:focus-visible {
  outline: 2px solid var(--fw-accent);
  outline-offset: 2px;
}

body .title-input:focus-visible,
body .rich-editor:focus-visible,
body .html-source:focus-visible {
  outline: 0;
}

/* ---------- Panes ---------- */

body .folders-pane,
body[data-theme] .folders-pane {
  gap: 20px;
  padding: 24px 16px 20px;
  overflow-y: auto;
  background: var(--fw-bg);
  border-right: 1px solid var(--fw-line);
  scrollbar-width: thin;
}

body .notes-pane,
body[data-theme] .notes-pane {
  background: var(--fw-bg);
  border-right: 1px solid var(--fw-line);
}

body .editor-pane,
body[data-theme] .editor-pane {
  color: var(--fw-ink);
  background: var(--fw-bg);
}

/* ---------- Brand & section headers ---------- */

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding-left: 14px;
  color: var(--fw-ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--fw-ink);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--fw-inverse);
  background: var(--fw-ink);
  border-radius: 999px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 24px;
  letter-spacing: -0.01em;
}

body .folders-pane .pane-header,
body .labels-section .pane-header {
  min-height: 0;
  height: 24px;
  padding: 0 6px 0 14px;
  gap: 12px;
  border-bottom: 0;
}

body .folders-pane .pane-header h2,
body .labels-section .pane-header h2 {
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0;
}

body .folders-pane .pane-header p {
  display: none;
}

body .folders-pane,
body .labels-section {
  --section-gap: 2px;
}

body .folders-pane > .pane-header + .folders-list {
  padding-top: var(--section-gap);
}

/* ---------- Round icon buttons ---------- */

body .icon-button,
body[data-theme] .icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  color: var(--fw-ink);
  background: var(--fw-chip);
  border-radius: 999px;
  box-shadow: none;
}

body .icon-button:hover,
body[data-theme] .icon-button:hover {
  background: var(--fw-chip-hover);
}

body .icon-button.active,
body[data-theme] .icon-button.active,
body .icon-button[aria-expanded="true"] {
  color: var(--fw-ink);
  background: var(--fw-chip-active);
}

body .icon-mask {
  width: 16px;
  height: 16px;
  opacity: 1;
}

body .folders-pane .pane-header .icon-button,
body .labels-section .pane-header .icon-button,
body[data-theme] .labels-section .pane-header .icon-button {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  color: var(--fw-muted);
  background: transparent;
}

body .folders-pane .pane-header .icon-button:hover,
body .labels-section .pane-header .icon-button:hover {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .icon-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

/* ---------- Folders ---------- */

body .folders-list,
body[data-theme] .folders-list {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 2px;
  padding: var(--section-gap) 0 0;
  overflow: visible;
}

body .folder-item,
body[data-theme] .folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 14px;
  color: var(--fw-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

body .folder-item::before {
  content: none;
}

body .folder-item svg {
  display: block;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

body .folder-item svg path,
body[data-theme] .folder-item svg path {
  stroke: currentColor;
}

body .folder-item span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .folder-item.active span {
  font-weight: 600;
}

body .folder-item small {
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

body .folder-item:hover {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .folder-item.active,
body[data-theme] .folder-item.active {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

/* ---------- Labels (sidebar section) ---------- */

body .labels-section {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
}

body .color-tags,
body[data-theme] .color-tags {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--section-gap) 0 0;
}

body .color-tag-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

body .color-tags-empty {
  margin: 4px 14px 0;
  color: var(--fw-muted);
  font-size: 12px;
  line-height: 16px;
}

body .color-tag,
body[data-theme] .color-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  width: 0;
  height: 36px;
  min-height: 0;
  padding: 0 14px;
  color: var(--fw-ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-align: left;
}

body .color-tag:hover {
  background: var(--fw-chip);
}

body .color-tag.active,
body[data-theme] .color-tag.active {
  color: var(--fw-ink);
  font-weight: 600;
  background: var(--fw-chip);
}

body .color-tag-swatch {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  background: var(--swatch-color);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

body .color-tag-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .color-tag-edit,
body[data-theme] .color-tag-edit {
  display: grid;
  flex: 0 0 28px;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--fw-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
}

body .color-tag-edit:hover {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .color-tag-editor {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  height: 36px;
  padding: 0 6px 0 14px;
}

body .color-tag-input,
body[data-theme] .color-tag-input {
  flex: 1 1 auto;
  width: 0;
  height: 28px;
  min-width: 0;
  padding: 0 10px;
  color: var(--fw-ink);
  background: var(--fw-chip);
  border: 0;
  border-radius: 999px;
  font-family: var(--fw-font);
  font-size: 14px;
  font-weight: 500;
}

body .color-tag-input:focus-visible {
  outline: 2px solid var(--fw-accent);
  outline-offset: 1px;
}

/* ---------- Storage note ---------- */

body .storage-note,
body[data-theme] .storage-note {
  gap: 8px;
  height: 28px;
  margin: auto 0 0;
  padding: 0 6px 0 14px;
  color: var(--fw-muted);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body .storage-label,
body[data-theme] .storage-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body .status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  background: var(--fw-ok);
  border-radius: 999px;
  box-shadow: none;
}

body .storage-help {
  color: var(--fw-muted);
}

/* ---------- Notes column ---------- */

body .notes-pane .pane-header {
  align-items: flex-start;
  min-height: 0;
  padding: 24px 24px 0;
}

body .notes-pane .pane-header h1 {
  color: var(--fw-ink);
  font-size: 32px;
  font-weight: 700;
  line-height: 36px;
  letter-spacing: -0.02em;
}

body .notes-pane .pane-header p {
  margin: 2px 0 0;
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

body .color-filter-clear,
body[data-theme] .color-filter-clear {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .color-filter-clear:hover {
  background: var(--fw-chip-hover);
}

body #addNote,
body[data-theme] #addNote {
  width: auto;
  height: 40px;
  flex: 0 0 auto;
  gap: 8px;
  padding: 0 16px 0 12px;
  color: var(--fw-inverse);
  background: var(--fw-ink);
  border-radius: 999px;
  grid-auto-flow: column;
  place-items: center;
}

body #addNote:hover {
  background: var(--fw-ink);
  opacity: 0.86;
}

.add-note-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

body #addNote svg {
  stroke-width: 1.6;
}

body .search-box,
body[data-theme] .search-box {
  height: 40px;
  margin: 16px 24px;
  padding: 0 16px;
  gap: 10px;
  color: var(--fw-muted);
  background: var(--fw-chip);
  border: 0;
  border-radius: 999px;
}

body .search-box input,
body[data-theme] .search-box input {
  color: var(--fw-ink);
  font-size: 14px;
  line-height: 20px;
}

body .search-box input::placeholder,
body[data-theme] .search-box input::placeholder {
  color: var(--fw-muted);
}

body .notes-list,
body[data-theme] .notes-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 4px 16px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
}

body .note-group {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 8px;
}

body .note-group-title {
  margin: 0;
  padding: 0 0 0 8px;
  color: var(--fw-ink);
  border: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
}

body .note-group-card,
body[data-theme] .note-group-card {
  display: flex;
  flex-direction: column;
  padding: 0 14px;
  background: var(--fw-card);
  border-radius: 16px;
}

body .note-item,
body[data-theme] .note-item,
body .note-item:hover,
body[data-theme] .note-item:hover,
body .note-item.active,
body[data-theme] .note-item.active,
body .note-item[class*="note-color-"],
body[data-theme] .note-item[class*="note-color-"],
body .note-item[class*="note-color-"]:hover,
body .note-item[class*="note-color-"].active,
body[data-theme] .note-item[class*="note-color-"].active {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  margin: 0;
  padding: 10px 0;
  color: var(--fw-ink);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--fw-line);
  border-radius: 0;
  box-shadow: none;
}

body .note-item:first-child {
  border-top: 0;
}

/* The active-note indicator used to be a ::before pseudo-element pulled out
   into the row's outer gutter with a negative `left` offset. That offset was
   tuned against one specific padding value, so it either crowded/overlapped
   the title (too small an offset) or landed outside the card's own
   background on the plain page behind it, looking disconnected (too large
   an offset) -- it could never be right for every layout at once. The dot is
   now a real inline element (.note-item-active-dot, added in app.js right
   before the title text) that sits in normal flow, on the same background,
   with a fixed small gap -- see the rule below. */
body .note-item-active-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 7px 2px 0;
  vertical-align: middle;
  background: var(--fw-ink);
  border-radius: 999px;
}

body .note-item > .note-item-title,
body[data-theme] .note-item > .note-item-title {
  align-self: flex-start;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--fw-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Highlighter stroke behind the title of a coloured note. */
body .note-item[class*="note-color-"] > .note-item-title,
body[data-theme] .note-item[class*="note-color-"] > .note-item-title {
  max-width: calc(100% + 10px);
  margin: 0 -5px;
  padding: 0 5px;
  color: var(--fw-ink);
  background-image: linear-gradient(180deg, transparent 18%, var(--note-mark) 18%, var(--note-mark) 94%, transparent 94%);
  border-radius: 4px 8px 5px 9px / 8px 4px 9px 5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

body .note-item > .note-item-preview,
body[data-theme] .note-item > .note-item-preview,
body .note-item[class*="note-color-"] > .note-item-preview {
  display: block;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--fw-muted);
  box-shadow: none;
  font-size: 13px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .note-item > .note-item-meta {
  display: contents;
}

body .note-item-label,
body[data-theme] .note-item-label {
  align-self: flex-start;
  color: var(--fw-ink);
  background: var(--fw-bg);
  border: 1px solid var(--fw-line);
  border-radius: 999px;
}

body .note-item-label-text {
  color: inherit;
}

body .empty-state,
body[data-theme] .empty-state {
  padding: 32px 8px;
  color: var(--fw-muted);
}

body .empty-state strong,
body[data-theme] .empty-state strong {
  color: var(--fw-ink);
}

/* ---------- Note colours (FireWeek palette) ---------- */

.note-color-green { --note-bg: #1f9d6b; --note-ink: #ffffff; --note-mark: color-mix(in srgb, #1f9d6b 55%, transparent); }
.note-color-yellow { --note-bg: #fff266; --note-ink: #000000; --note-mark: color-mix(in srgb, #fff266 85%, transparent); }
.note-color-red { --note-bg: #d41e50; --note-ink: #ffffff; --note-mark: color-mix(in srgb, #d41e50 30%, transparent); }
.note-color-orange { --note-bg: #ffa62b; --note-ink: #000000; --note-mark: color-mix(in srgb, #ffa62b 55%, transparent); }
.note-color-powder { --note-bg: #ffd6e4; --note-ink: #000000; --note-mark: color-mix(in srgb, #ffd6e4 55%, transparent); }
.note-color-blue { --note-bg: #8fb8ff; --note-ink: #000000; --note-mark: color-mix(in srgb, #8fb8ff 55%, transparent); }
.note-color-purple { --note-bg: #000000; --note-ink: #ffffff; --note-mark: color-mix(in srgb, #000000 16%, transparent); }
.note-color-fuchsia { --note-bg: #d45cf5; --note-ink: #000000; --note-mark: color-mix(in srgb, #d45cf5 55%, transparent); }
.note-color-indigo { --note-bg: #4a55f0; --note-ink: #ffffff; --note-mark: color-mix(in srgb, #4a55f0 30%, transparent); }
.note-color-turquoise { --note-bg: #2dcdb2; --note-ink: #000000; --note-mark: color-mix(in srgb, #2dcdb2 55%, transparent); }
.note-color-acid { --note-bg: #2bf5a0; --note-ink: #000000; --note-mark: color-mix(in srgb, #2bf5a0 55%, transparent); }
.note-color-light-gray { --note-bg: #c7c7cc; --note-ink: #000000; --note-mark: color-mix(in srgb, #c7c7cc 60%, transparent); }

body[data-theme="dark"] .note-color-purple { --note-bg: #ffffff; --note-ink: #000000; --note-mark: color-mix(in srgb, #ffffff 22%, transparent); }

/* ---------- Editor top bar ---------- */
@media (min-width: 721px) {

  body .topbar,
  body[data-theme] .topbar {
    display: flex;
    flex: 0 0 auto;
    gap: 16px;
    height: 64px;
    min-height: 64px;
    padding: 0 24px;
    background: transparent;
    border-bottom: 1px solid var(--fw-line);
  }

  body .toolbar,
  body .toolbar-left,
  body .toolbar-actions {
    flex: 0 0 auto;
    width: auto;
    gap: 16px;
  }

  body .toolbar-actions {
    gap: 8px;
  }

  body .format-bar-header,
  body[data-theme] .format-bar-header {
    flex: 1 1 auto;
    justify-content: center;
    gap: 4px;
    min-height: 0;
    padding: 0;
  }
}

body[data-theme="dark"] .topbar .toolbar:not(.toolbar-left) .icon-button {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body[data-theme="dark"] .topbar .toolbar:not(.toolbar-left) .icon-button:hover {
  background: var(--fw-chip-hover);
}

body[data-theme="dark"] .topbar .toolbar:not(.toolbar-left) .icon-button[aria-expanded="true"],
body[data-theme="dark"] .topbar .toolbar:not(.toolbar-left) .icon-button.active {
  color: var(--fw-ink);
  background: var(--fw-chip-active);
}

/* Format buttons (shared by desktop top bar and mobile floating bar) */
body .format-button,
body[data-theme] .format-button,
body .editor-pane .format-button {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--fw-ink);
  background: transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

body .format-button:hover,
body[data-theme] .format-button:hover {
  background: var(--fw-chip);
}

body .format-button.active,
body[data-theme] .format-button.active,
body .editor-pane .format-button.active {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .format-button.heading-button {
  min-width: 36px;
  font-size: 13px;
  font-weight: 700;
}

body .format-button em {
  font-family: Georgia, serif;
  font-weight: 500;
}

body .format-button s {
  font-weight: 500;
}

body .format-button.history-button {
  color: var(--fw-muted);
}

body .format-button.history-button:disabled {
  opacity: 0.4;
}

body .format-button.text-mode-button,
body[data-theme] .format-button.text-mode-button {
  width: auto;
  min-width: 0;
  padding: 0 14px;
  background: transparent;
  font-size: 12px;
  letter-spacing: 0.02em;
}

body .format-button.text-mode-button:hover {
  background: var(--fw-chip);
}

body .format-button.text-mode-button[aria-pressed="true"] {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .format-button svg,
body .history-icon {
  width: 16px;
  height: 16px;
}

body .format-button::before {
  opacity: 1;
}

body .format-divider,
body[data-theme] .format-divider {
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: var(--fw-line);
}

/* ---------- Editor content ---------- */

body .editor-pane {
  --fw-line-h: 33px;
  --fw-col: min(1040px, calc(100% - 96px));
  /* Below 1136px, --fw-col already equals 100% - 96px, so the natural
     centering offset is exactly 48px on each side -- that IS the intended
     padding. The old formula added another +48px on top of that baseline
     unconditionally, silently doubling side padding (96px instead of 48px)
     on every screen narrower than 1136px, which is most editor-pane widths
     in a 3-column layout: huge empty gutters, less room for the actual
     text. Only screens wider than 1136px need extra padding, to keep the
     text column capped at 1040px instead of stretching edge to edge. */
  --fw-pad: calc(48px + max(0px, (100% - 1136px) / 2));
}

/* The title is a textarea; a transparent mirror behind it draws the highlighter stroke. */
.title-wrap {
  order: 2;
  display: grid;
  flex: 0 0 auto;
}

.title-wrap > * {
  grid-area: 1 / 1;
  min-width: 0;
}

body .title-input,
body[data-theme] .title-input,
body .title-mirror {
  margin: 4px 0 0;
  padding: 0 var(--fw-pad) 16px;
  font-family: var(--fw-font);
  font-size: 24px;
  font-weight: 700;
  line-height: 32px;
  letter-spacing: -0.01em;
}

body .title-input,
body[data-theme] .title-input {
  position: relative;
  color: var(--fw-ink);
  background-color: transparent;
  background-image: linear-gradient(var(--fw-ink), var(--fw-ink));
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: calc(100% - 2 * var(--fw-pad)) 2px;
}

body .title-mirror {
  overflow: hidden;
  color: transparent;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  pointer-events: none;
}

body .title-mirror span {
  padding: 0 5px;
  margin: 0 -5px;
  border-radius: 4px 8px 5px 9px / 8px 4px 9px 5px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

body .title-mirror[class*="note-color-"] span {
  background-image: linear-gradient(180deg, transparent 18%, var(--note-mark) 18%, var(--note-mark) 94%, transparent 94%);
}

body .mobile-note-date,
body[data-theme] .mobile-note-date {
  order: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 16px;
  margin: 20px 0 0;
  padding: 0 var(--fw-pad);
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

body .content-input,
body[data-theme] .content-input {
  order: 3;
  flex: 1 1 auto;
  margin: 0;
  padding: 10px var(--fw-pad) 24px;
  color: var(--fw-ink);
  border-top: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 32px, var(--fw-line-soft) 32px, var(--fw-line-soft) 33px);
  background-origin: content-box;
  background-clip: content-box;
  /* This element scrolls its own overflow (contenteditable), so the default
     `scroll` attachment paints the ruled lines fixed to the element's own box
     -- they stay put while the typed text scrolls past them. `local` ties the
     background to the element's contents instead, so the lines move with
     the text, like ruled paper. */
  background-attachment: local;
  font-size: 16px;
  line-height: var(--fw-line-h);
}

body .rich-editor p,
body .rich-editor h2,
body .rich-editor h3,
body .rich-editor ul,
body .rich-editor ol,
body .rich-editor blockquote,
body .rich-editor pre {
  margin: 0;
}

body .rich-editor h2 {
  margin-top: 33px;
  font-size: 20px;
  line-height: 33px;
  letter-spacing: -0.01em;
}

body .rich-editor h3 {
  font-size: 16px;
  line-height: 33px;
}

body .rich-editor > :first-child {
  margin-top: 0;
}

body .rich-editor li {
  margin: 0;
}

body .rich-editor ul,
body .rich-editor ol {
  padding-left: 24px;
}

body .rich-editor ul li::marker {
  font-weight: 700;
}

body .rich-editor:empty::before,
body[data-theme] .rich-editor:empty::before {
  color: var(--fw-muted);
}

body .rich-editor {
  caret-color: var(--fw-ink);
}

body .rich-editor a,
body[data-theme] .rich-editor a {
  color: var(--fw-accent);
}

body .rich-editor blockquote,
body[data-theme] .rich-editor blockquote {
  color: var(--fw-muted);
  border-left: 3px solid var(--fw-ink);
}

body .rich-editor ul[data-list="checkpoints"] li::before,
body[data-theme] .rich-editor ul[data-list="checkpoints"] li::before {
  top: 6px;
  background: var(--fw-bg);
  border: 1.5px solid var(--fw-ink);
}

body .rich-editor ul[data-list="checkpoints"] li[data-checked="true"],
body[data-theme] .rich-editor ul[data-list="checkpoints"] li[data-checked="true"] {
  color: var(--fw-muted);
}

body .rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::before,
body[data-theme] .rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::before {
  background: var(--fw-ink);
  border-color: var(--fw-ink);
}

body .rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::after,
body[data-theme] .rich-editor ul[data-list="checkpoints"] li[data-checked="true"]::after {
  top: 9px;
  border-color: var(--fw-inverse);
}

body .rich-editor mark,
body .rich-editor span[style*="background-color"] {
  color: #000000;
  background-color: #fff266;
}

body .html-source,
body[data-theme] .html-source {
  order: 3;
  padding: 16px var(--fw-pad) 24px;
  color: var(--fw-ink);
  background: var(--fw-chip);
  border-top: 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Editor footer ---------- */
@media (min-width: 721px) {

  body .note-stats,
  body[data-theme] .note-stats {
    order: 4;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 28px;
    height: 56px;
    min-height: 56px;
    padding: 0 24px 0 72px;
    color: var(--fw-ink);
    background: transparent;
    border-top: 1px solid var(--fw-line);
  }

  body .note-stats-group {
    display: flex;
    align-items: baseline;
    gap: 28px;
  }

  body .stat-item {
    display: flex;
    flex-direction: row-reverse;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
  }

  body .stat-item strong {
    color: var(--fw-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
  }

  body .stat-item span {
    color: var(--fw-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
  }

  body .note-meta-bottom {
    gap: 4px;
    margin-left: auto;
    color: var(--fw-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
  }

  body .note-meta-bottom #saveState::after {
    content: "";
  }

  body .save-check {
    background: var(--fw-ok);
    color: #000000;
  }
}

/* ---------- Menus & popovers ---------- */

body .more-menu,
body[data-theme] .more-menu,
body .label-manage-popover,
body[data-theme] .label-manage-popover {
  color: var(--fw-ink);
  background: var(--fw-bg);
  border: 1px solid var(--fw-ink);
  border-radius: 8px;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  font-family: var(--fw-font);
}

body .more-menu,
body[data-theme] .more-menu {
  width: min(288px, calc(100vw - 24px));
  padding: 8px;
  gap: 2px;
}

body .more-menu-actions,
body[data-theme] .more-menu-actions {
  gap: 2px;
  margin-bottom: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--fw-line);
}

body .more-menu-action,
body[data-theme] .more-menu-action {
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  color: var(--fw-ink);
  border-radius: 6px;
  font-family: var(--fw-font);
  font-size: 14px;
  font-weight: 600;
}

body .more-menu-action:hover,
body .more-menu-action:focus-visible,
body[data-theme] .more-menu-action:hover,
body[data-theme] .more-menu-action:focus-visible {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .more-menu-action.active,
body[data-theme] .more-menu-action.active {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .more-menu-action-danger,
body[data-theme] .more-menu-action-danger {
  color: var(--fw-danger);
}

body .more-menu-action .icon-mask,
body .more-menu-action::before {
  flex-basis: 16px;
  width: 16px;
  height: 16px;
  opacity: 1;
}

body .more-menu-title,
body[data-theme] .more-menu-title {
  padding: 10px 12px 4px;
  color: var(--fw-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

.notebook-view-switch {
  display: flex;
  gap: 4px;
  margin: 0 4px 4px;
  padding: 4px;
  background: var(--fw-chip);
  border-radius: 999px;
}

body .more-menu .notebook-view-switch a,
body[data-theme] .more-menu .notebook-view-switch a {
  flex: 1 1 0;
  justify-content: center;
  min-height: 32px;
  padding: 0;
  color: var(--fw-muted);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

body .more-menu .notebook-view-switch a:hover,
body .more-menu .notebook-view-switch a:focus-visible {
  color: var(--fw-ink);
  background: transparent;
}

body .more-menu .notebook-view-switch a[aria-current="page"],
body[data-theme] .more-menu .notebook-view-switch a[aria-current="page"] {
  color: var(--fw-ink);
  background: var(--fw-seg-active);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.note-color-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

body .note-color-title,
body[data-theme] .note-color-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--fw-ink);
  font-family: var(--fw-font);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.note-color-swatches {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding-left: 28px;
}

body .note-color-grid {
  display: contents;
}

body .note-color-option,
body .note-color-default,
body[data-theme] .note-color-default {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 0;
  aspect-ratio: auto;
  justify-self: center;
  border-radius: 999px;
  border-top: 0;
}

body .note-color-option {
  background: var(--swatch-color);
}

body .note-color-option:hover {
  transform: none;
  box-shadow: 0 0 0 2px var(--fw-line);
}

body .note-color-option.active,
body .note-color-default.active {
  box-shadow: 0 0 0 2px var(--fw-bg), 0 0 0 4px var(--fw-ink);
}

body .note-color-option.active::after {
  width: 5px;
  height: 9px;
  margin-top: -2px;
  border-color: #000000;
  border-width: 0 2px 2px 0;
}

body .note-color-option[aria-label="Красный"].active::after,
body .note-color-option[aria-label="Синий"].active::after,
body .note-color-option[aria-label="Зеленый"].active::after,
body .note-color-option[aria-label="Чёрный"].active::after {
  border-color: #ffffff;
}

body .note-color-default-icon {
  display: block;
  width: 24px;
  height: 24px;
  background: var(--fw-bg);
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px #c7c7cc;
}

body .note-color-default-icon::after {
  display: none;
}

body .note-color-default.active .note-color-default-icon,
body[data-theme] .note-color-default.active .note-color-default-icon {
  box-shadow: inset 0 0 0 1.5px #c7c7cc;
}

.more-menu-danger {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--fw-line);
}

/* Label management popover */

body .label-manage-title,
body[data-theme] .label-manage-title {
  color: var(--fw-ink);
  font-weight: 700;
}

body .label-manage-row + .label-manage-row,
body[data-theme] .label-manage-row + .label-manage-row {
  border-top-color: var(--fw-line);
}

body .label-manage-action,
body[data-theme] .label-manage-action {
  color: var(--fw-ink);
  border-radius: 999px;
}

body .label-manage-action:hover,
body[data-theme] .label-manage-action:hover {
  background: var(--fw-chip);
}

body .label-manage-action.danger,
body[data-theme] .label-manage-action.danger {
  color: var(--fw-danger);
}

/* ---------- Dialogs ---------- */

body .label-modal-backdrop,
body[data-theme] .label-modal-backdrop,
body .link-dialog-backdrop {
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

body .label-modal,
body[data-theme] .label-modal,
body .link-dialog {
  color: var(--fw-ink);
  background: var(--fw-bg);
  border: 1px solid var(--fw-ink);
  border-radius: 12px;
  box-shadow: none;
  font-family: var(--fw-font);
}

body .label-modal-title,
body .link-dialog-heading h2 {
  color: var(--fw-ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

body .label-name-input,
body .link-dialog-field input {
  color: var(--fw-ink);
  background: var(--fw-chip);
  border: 0;
  border-radius: 999px;
  font-family: var(--fw-font);
}

body .label-emoji-trigger {
  background: var(--fw-chip);
  border-radius: 999px;
}

body .label-modal-primary,
body .link-dialog-primary,
body .label-modal-danger,
body .label-modal-secondary,
body .link-dialog-secondary {
  height: 40px;
  border-radius: 999px;
  font-family: var(--fw-font);
  font-size: 14px;
  font-weight: 600;
}

body .label-modal-primary,
body .link-dialog-primary {
  color: var(--fw-inverse);
  background: var(--fw-ink);
  box-shadow: none;
}

body .label-modal-primary:disabled {
  opacity: 0.4;
}

body .label-modal-danger {
  color: #ffffff;
  background: var(--fw-danger);
}

body .label-modal-secondary,
body .link-dialog-secondary,
body[data-theme] .label-modal-secondary {
  color: var(--fw-ink);
  background: var(--fw-chip);
}

body .label-emoji-option.active {
  background: var(--fw-chip);
  box-shadow: inset 0 0 0 2px var(--fw-ink);
}

body .label-counter,
body .label-delete-message {
  color: var(--fw-muted);
}

/* Selection toolbar (floating) */

body .selection-toolbar,
body[data-theme] .selection-toolbar {
  color: var(--fw-inverse);
  background: var(--fw-ink);
  border-radius: 999px;
  box-shadow: none;
}

body .selection-toolbar::after,
body[data-theme] .selection-toolbar::after {
  background: var(--fw-ink);
}

body .selection-toolbar-button,
body[data-theme] .selection-toolbar-button {
  color: var(--fw-inverse);
  border-radius: 999px;
}

body .selection-toolbar-button:hover,
body[data-theme] .selection-toolbar-button:hover {
  background: rgba(128, 128, 128, 0.36);
}

body .selection-toolbar-button.active,
body[data-theme] .selection-toolbar-button.active {
  color: var(--fw-ink);
  background: var(--fw-bg);
}

body .selection-toolbar-divider,
body[data-theme] .selection-toolbar-divider {
  background: rgba(128, 128, 128, 0.5);
}

body .selection-toolbar,
body[data-theme] .selection-toolbar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 5px;
  border-radius: 22px;
}

body .selection-toolbar[hidden],
body[data-theme] .selection-toolbar[hidden] {
  display: none;
}

.selection-toolbar-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

body .selection-toolbar-button[data-block],
body[data-theme] .selection-toolbar-button[data-block] {
  flex: 0 1 auto;
  width: auto;
  min-width: 34px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

body .selection-toolbar-button.text-mode-button,
body[data-theme] .selection-toolbar-button.text-mode-button {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

body .selection-toolbar-button.text-mode-button[aria-pressed="true"] {
  color: var(--fw-ink);
  background: var(--fw-bg);
}

body .selection-toolbar-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Tablet ---------- */

@media (min-width: 721px) and (max-width: 1180px) {
  body .notebook-shell,
  body[data-theme] .notebook-shell {
    grid-template-columns: 208px 300px minmax(0, 1fr);
    width: 100%;
    height: var(--fw-shell-h);
  }

  body .notebook-shell.folders-collapsed {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  body .folders-pane {
    padding: 24px 14px 16px 18px;
  }

  body .topbar,
  body[data-theme] .topbar {
    gap: 8px;
    padding: 0 14px;
  }

  body .toolbar,
  body .toolbar-left {
    gap: 8px;
  }

  body .format-divider {
    margin: 0 2px;
  }

  body .note-stats,
  body[data-theme] .note-stats {
    gap: 16px;
    padding: 0 16px;
  }

  body .note-stats-group {
    gap: 16px;
  }
}

@media (min-width: 721px) and (max-width: 980px) {
  body .notebook-shell,
  body[data-theme] .notebook-shell {
    grid-template-columns: 192px 264px minmax(0, 1fr);
  }

  body #addNote,
  body[data-theme] #addNote {
    width: 40px;
    padding: 0;
  }

  body #addNote .add-note-text {
    display: none;
  }

  body .notes-pane .pane-header {
    padding: 20px 16px 0;
  }

  body .search-box,
  body[data-theme] .search-box {
    margin: 14px 16px;
  }

  body .notes-list,
  body[data-theme] .notes-list {
    padding: 0 8px 20px;
  }

  body .stat-item:nth-child(2) {
    display: none;
  }

  body .notebook-shell.folders-collapsed {
    grid-template-columns: 264px minmax(0, 1fr);
  }

  body .format-bar-header {
    justify-content: flex-start;
  }
}

/* ---------- Desktop-hidden mobile helpers ---------- */

.mobile-view-title,
.mobile-folder-tabs,
.mobile-search-toggle,
.pane-folder-name,
.mobile-note-folder,
.mobile-note-status,
.mobile-undo {
  display: none;
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  body,
  body[data-theme] {
    overflow: hidden;
  }

  body .notebook-page {
    overflow: hidden;
  }

  body .notebook-shell,
  body[data-theme] .notebook-shell,
  body .notes-pane,
  body[data-theme] .notes-pane,
  body .folders-pane,
  body[data-theme] .folders-pane,
  body .editor-pane,
  body[data-theme] .editor-pane {
    background: var(--fw-bg);
  }

  body .notebook-shell,
  body[data-theme] .notebook-shell {
    height: var(--fw-shell-h);
    min-height: 0;
  }

  body .notes-pane,
  body .folders-pane,
  body .editor-pane {
    min-height: 0;
  }

  body .editor-pane {
    --fw-pad: 16px;
  }

  /* View switch: back / folders chip in the top-left corner. */
  body .mobile-panel-toggle,
  body[data-theme] .mobile-panel-toggle {
    top: max(12px, env(safe-area-inset-top));
    left: 16px;
    width: 36px;
    height: 36px;
    color: var(--fw-ink);
    background: var(--fw-chip);
    border-radius: 999px;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body .mobile-panel-toggle.active,
  body[data-theme] .mobile-panel-toggle.active {
    color: var(--fw-ink);
    background: var(--fw-chip);
  }

  body .mobile-panel-toggle .icon-panels {
    width: 16px;
    height: 16px;
  }

  body .notebook-shell.mobile-view-notes .mobile-panel-toggle .icon-panels {
    --icon-url: url("/icons/coolicons/folder.svg?v=20260811");
  }

  /* Notes list header */
  body .notes-pane .pane-header,
  body[data-theme] .notes-pane .pane-header,
  body .notebook-shell.mobile-view-notes .notes-pane .pane-header {
    align-items: center;
    gap: 8px;
    height: calc(60px + max(0px, env(safe-area-inset-top)));
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px 64px;
    background: transparent;
  }

  body .notes-pane .pane-header > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  body .notes-pane .pane-header h1 {
    display: none;
  }

  body .notes-pane .pane-folder-name {
    display: block;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .notes-pane .pane-header p {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    overflow: hidden;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    white-space: nowrap;
  }

  body .notes-pane .pane-header p::before {
    content: "";
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    background: var(--fw-ok);
    border-radius: 999px;
  }

  body .notes-pane .pane-header p::after {
    content: "· сохранено в браузере";
  }

  body .notes-pane .mobile-search-toggle {
    display: inline-grid;
  }

  body .notes-pane .mobile-search-toggle[aria-pressed="true"] {
    background: var(--fw-chip-active);
  }

  /* Folder tabs */
  body .mobile-folder-tabs {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
    padding: 4px 16px 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body .mobile-folder-tabs::-webkit-scrollbar {
    display: none;
  }

  body .mobile-folder-tab {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    color: var(--fw-muted);
    background: transparent;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
  }

  body .mobile-folder-tab small {
    font-size: 12px;
    font-weight: 500;
  }

  body .mobile-folder-tab[aria-pressed="true"] {
    color: var(--fw-ink);
    background: var(--fw-chip);
  }

  body .mobile-folder-tab-add {
    width: 40px;
    padding: 0;
  }

  /* Search: hidden until the header button is pressed */
  body .notebook-shell.mobile-view-notes .search-box,
  body[data-theme] .notebook-shell.mobile-view-notes .search-box {
    position: static;
    display: none;
    z-index: auto;
    height: 40px;
    margin: 12px 16px 0;
    padding: 0 16px;
    color: var(--fw-muted);
    background: var(--fw-chip);
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body .notebook-shell.mobile-view-notes.mobile-search-open .search-box {
    display: flex;
  }

  body .notebook-shell.mobile-view-notes .search-box input,
  body[data-theme] .notebook-shell.mobile-view-notes .search-box input {
    color: var(--fw-ink);
    font-size: 16px;
  }

  body .notebook-shell.mobile-view-notes .search-box::before {
    width: 16px;
    height: 16px;
    opacity: 0.72;
  }

  /* Notes list */
  body .notes-list,
  body .notebook-shell.mobile-view-notes .notes-list,
  body[data-theme] .notes-list {
    gap: 20px;
    padding: 20px 16px calc(120px + env(safe-area-inset-bottom));
  }

  body .note-group {
    display: flex;
    gap: 8px;
  }

  body .note-group-title,
  body .note-group:first-child .note-group-title,
  body[data-theme] .note-group-title {
    margin: 0;
    padding: 0 0 0 4px;
    color: var(--fw-ink);
    font-size: 15px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: 0;
  }

  body .note-group-card,
  body[data-theme] .note-group-card {
    display: flex;
    padding: 0 16px;
    overflow: visible;
    background: var(--fw-card);
    border-radius: 20px;
  }

  body .note-group-card .note-item,
  body .note-group-card .note-item:hover,
  body .note-group-card .note-item.active,
  body .note-group-card .note-item[class*="note-color-"],
  body[data-theme] .note-group-card .note-item,
  body[data-theme] .note-group-card .note-item[class*="note-color-"] {
    margin: 0;
    padding: 12px 0;
    background: transparent;
    border: 0;
    border-top: 1px solid var(--fw-line);
    border-radius: 0;
    box-shadow: none;
  }

  body .note-group-card .note-item:first-child {
    border-top: 0;
  }

  body .note-item-active-dot {
    display: none;
  }

  body .note-item > .note-item-title,
  body[data-theme] .note-item > .note-item-title {
    font-size: 17px;
    line-height: 24px;
  }

  body .note-item > .note-item-preview,
  body[data-theme] .note-item > .note-item-preview {
    margin: 0;
    color: var(--fw-muted);
    font-size: 15px;
    line-height: 20px;
  }

  /* New-note pill */
  body .notebook-shell.mobile-view-notes .mobile-add-note,
  body[data-theme] .notebook-shell.mobile-view-notes .mobile-add-note {
    right: auto;
    left: 50%;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: auto;
    height: 56px;
    padding: 0 24px 0 20px;
    color: var(--fw-inverse);
    background: var(--fw-ink);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateX(-50%);
  }

  body .notebook-shell.mobile-view-notes .mobile-add-note:hover {
    background: var(--fw-ink);
  }

  body .notebook-shell.mobile-view-notes .mobile-add-note:active {
    transform: translateX(-50%) scale(0.97);
  }

  body .mobile-add-note-icon {
    width: 18px;
    height: 18px;
    -webkit-mask: url("/icons/coolicons/plus.svg?v=20260813") center / contain no-repeat;
    mask: url("/icons/coolicons/plus.svg?v=20260813") center / contain no-repeat;
  }

  body .mobile-add-note::after {
    content: "Новая заметка";
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
    letter-spacing: 0;
  }

  /* Folders & labels screen */
  body .folders-pane,
  body[data-theme] .folders-pane {
    gap: 24px;
    padding: max(12px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  }

  body .folders-pane .brand {
    display: none;
  }

  body .folders-pane .mobile-view-title {
    display: flex;
    align-items: center;
    flex: 0 0 36px;
    height: 36px;
    padding-left: 48px;
  }

  body .folders-pane .mobile-view-title h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
  }

  body .folders-pane .pane-header,
  body .labels-section .pane-header,
  body .notebook-shell.mobile-view-folders .folders-pane .pane-header {
    display: flex;
    align-items: center;
    height: 24px;
    min-height: 0;
    padding: 0 0 0 4px;
  }

  body .folders-pane .pane-header h2,
  body .labels-section .pane-header h2,
  body .notebook-shell.mobile-view-folders .folders-pane .pane-header h2 {
    color: var(--fw-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    letter-spacing: 0;
  }

  body .notebook-shell.mobile-view-folders #addFolder {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
  }

  body .notebook-shell.mobile-view-folders .folders-list,
  body .color-tags {
    padding: 0;
    background: var(--fw-chip);
    border-radius: 14px;
    overflow: hidden;
  }

  body .labels-section .pane-header + .color-tags {
    margin-top: 8px;
  }

  body .folders-pane > .pane-header + .folders-list {
    margin-top: -16px;
  }

  body .notebook-shell.mobile-view-folders .folder-item,
  body .color-tag-row {
    display: flex;
    min-height: 44px;
    height: 44px;
    color: var(--fw-ink);
    background: transparent;
    border-radius: 0;
  }

  body .notebook-shell.mobile-view-folders .folder-item {
    padding: 0 14px;
  }

  body .color-tag,
  body .color-tag-editor {
    height: 44px;
    padding: 0 4px 0 14px;
  }

  body .color-tag-edit {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  body .notebook-shell.mobile-view-folders .folder-item + .folder-item,
  body .color-tag-row + .color-tag-row {
    border-top: 1px solid var(--fw-line);
  }

  body .notebook-shell.mobile-view-folders .folder-item span {
    font-size: 15px;
    font-weight: 500;
  }

  body .notebook-shell.mobile-view-folders .folder-item small {
    font-size: 13px;
    text-align: right;
  }

  body .notebook-shell.mobile-view-folders .folder-item small::after {
    content: " ›";
  }

  body .notebook-shell.mobile-view-folders .folder-item.active,
  body .color-tag.active {
    background: transparent;
  }

  body .notebook-shell.mobile-view-folders .folder-item.active span,
  body .color-tag.active {
    font-weight: 700;
  }

  body .storage-note,
  body[data-theme] .storage-note {
    height: 44px;
    margin-top: 0;
    padding: 0 14px;
    background: var(--fw-chip);
    border-radius: 14px;
  }

  /* Editor */
  body .editor-pane .topbar,
  body[data-theme] .editor-pane .topbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    height: calc(60px + max(0px, env(safe-area-inset-top)));
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) 16px 12px 64px;
    background: transparent;
    border: 0;
  }

  body .editor-pane .topbar .toolbar-actions,
  body[data-theme] .editor-pane .topbar .toolbar-actions {
    gap: 8px;
    margin-left: auto;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body .editor-pane .topbar .toolbar-actions .icon-button,
  body[data-theme] .editor-pane .topbar .toolbar-actions .icon-button {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    color: var(--fw-ink);
    background: var(--fw-chip);
    border: 0;
  }

  body .editor-pane .topbar .toolbar-actions .icon-button[aria-expanded="true"] {
    background: var(--fw-chip-active);
  }

  body .editor-pane .topbar .mobile-undo {
    display: inline-grid;
  }

  body .editor-pane .more-menu-icon {
    width: 16px;
    height: 16px;
  }

  body .editor-pane .mobile-note-date,
  body[data-theme] .editor-pane .mobile-note-date {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 64px;
    z-index: 1;
    display: block;
    height: 20px;
    margin: 0;
    padding: 0;
    color: var(--fw-ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
  }

    body .editor-pane .mobile-note-folder {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 20px);
    left: 64px;
    z-index: 1;
    display: block;
    color: var(--fw-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
  }

  body .editor-pane .title-input,
  body[data-theme] .editor-pane .title-input,
  body .editor-pane .title-mirror {
    margin: 0;
    padding: 16px var(--fw-pad);
    font-size: 22px;
    font-weight: 700;
    line-height: 28px;
    letter-spacing: -0.01em;
  }

  body .editor-pane .content-input,
  body[data-theme] .editor-pane .content-input {
    padding: 10px var(--fw-pad) calc(24px + env(safe-area-inset-bottom));
    color: var(--fw-ink);
    font-size: 17px;
    line-height: 33px;
  }

  body .editor-pane .rich-editor h2 {
    font-size: 21px;
  }

  body .editor-pane .rich-editor h3 {
    font-size: 17px;
  }

  body .editor-pane .html-source,
  body[data-theme] .editor-pane .html-source {
    padding: 16px var(--fw-pad) calc(24px + env(safe-area-inset-bottom));
  }

  /* In normal flex flow (not position:fixed) so it always sits right after
     the scrollable note content, at the true bottom of the editor column --
     it used to float over the content with a viewport-relative `bottom`,
     which drifted out of sync with mobile Safari's own address-bar chrome
     resizing the visible viewport, alternately overlapping text or leaving
     a big gap depending on scroll position. */
  body .editor-pane .mobile-note-status {
    position: static;
    order: 4;
    flex: 0 0 auto;
    display: block;
    padding: 6px var(--fw-pad) calc(max(6px, env(safe-area-inset-bottom)));
    color: var(--fw-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
  }

  body .selection-toolbar,
  body[data-theme] .selection-toolbar {
    max-width: calc(100vw - 24px);
  }

  /* Note menu: popover anchored to the button, page dimmed */
  body .more-menu,
  body[data-theme] .more-menu {
    width: min(288px, calc(100vw - 24px));
    padding: 8px;
    border: 0;
    border-radius: 20px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.1), 0 8px 32px rgba(0, 0, 0, 0.14);
  }

  body .more-menu-action,
  body[data-theme] .more-menu-action {
    min-height: 44px;
  }

  /* Label dialog: bottom sheet */
  body .label-modal-backdrop,
  body[data-theme] .label-modal-backdrop,
  body .label-modal-backdrop.is-centered-modal {
    background: rgba(0, 0, 0, 0.32);
  }

  body .label-modal-backdrop.is-centered-modal {
    place-items: end stretch;
    padding: 0;
  }

  body .label-modal,
  body[data-theme] .label-modal,
  body .label-modal.is-centered-modal {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 88vh;
    margin: 0;
    padding: 24px 16px calc(20px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    transform: none;
  }
}
