/* Notes module design system. Scoped entirely to .notes-page-shell (never body/site chrome), driven
   by CSS custom properties keyed off data-notes-theme, set server-side on every Notes/NoteGroups page
   by NotesBaseController so the whole module (not just the split-pane editor) shares one cohesive,
   distinct palette - separate from the site's own orange accent and dark tokens in site.css. */

.module-tone-notes {
  background: linear-gradient(100deg, rgba(20, 30, 48, 0.96), rgba(35, 58, 90, 0.86));
}

.notes-page-shell {
  --notes-bg: #f5f4f1;
  --notes-surface: #ffffff;
  --notes-surface-alt: #eeece6;
  --notes-border: rgba(20, 20, 25, 0.1);
  --notes-text: #22242b;
  --notes-text-muted: #6c7078;
  --notes-accent: #6d63e0;
  --notes-accent-strong: #5a4fd1;
  --notes-accent-contrast: #ffffff;
  --notes-danger: #d64545;
  --notes-danger-contrast: #ffffff;
  --notes-folder: #b8862f;
  --notes-group: #8b5cf6;
  --notes-radius: 20px;

  max-width: 1240px;
  margin: 1.25rem auto;
  padding: 1.75rem;
  border-radius: var(--notes-radius);
  background: var(--notes-bg);
  border: 1px solid var(--notes-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  color: var(--notes-text);
}

.notes-page-shell[data-notes-theme="material-darker"] {
  --notes-bg: #15161c;
  --notes-surface: #1d1f28;
  --notes-surface-alt: #262836;
  --notes-border: rgba(255, 255, 255, 0.08);
  --notes-text: #e8e8f0;
  --notes-text-muted: #9296a8;
  --notes-accent: #8b85ff;
  --notes-accent-strong: #a29cff;
  --notes-accent-contrast: #14141b;
  --notes-danger: #ff6b81;
  --notes-danger-contrast: #1c1116;
  --notes-folder: #f0b757;
  --notes-group: #b79bf0;
}

.notes-page-shell[data-notes-theme="dracula"] {
  --notes-bg: #11121e;
  --notes-surface: #191c2b;
  --notes-surface-alt: #21253c;
  --notes-border: rgba(255, 255, 255, 0.08);
  --notes-text: #ece9f7;
  --notes-text-muted: #9a9dc7;
  --notes-accent: #a08bff;
  --notes-accent-strong: #b6a3ff;
  --notes-accent-contrast: #14141b;
  --notes-danger: #ff7597;
  --notes-danger-contrast: #1c1116;
  --notes-folder: #ffb86c;
  --notes-group: #ff92df;
}

.notes-page-shell[data-notes-theme="sepia-custom"] {
  --notes-bg: #ede3cd;
  --notes-surface: #f8f1e2;
  --notes-surface-alt: #f0e5c8;
  --notes-border: rgba(91, 70, 54, 0.16);
  --notes-text: #4a3826;
  --notes-text-muted: #8a7355;
  --notes-accent: #a8663a;
  --notes-accent-strong: #8f5127;
  --notes-accent-contrast: #fff8ec;
  --notes-danger: #b1433a;
  --notes-danger-contrast: #fff8ec;
  --notes-folder: #b5651d;
  --notes-group: #7d5a9e;
}

.notes-page-shell a {
  color: var(--notes-accent);
}

.notes-page-shell a:hover {
  color: var(--notes-accent-strong);
}

/* --- Hero header ------------------------------------------------------------ */

.notes-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.notes-hero__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--notes-text);
  margin: 0;
}

.notes-hero__subtitle {
  margin: 0.15rem 0 0;
  color: var(--notes-text-muted);
  font-size: 0.9rem;
}

.notes-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* --- Buttons ----------------------------------------------------------------- */

.notes-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.notes-btn--primary {
  background: var(--notes-accent);
  color: var(--notes-accent-contrast);
}

.notes-btn--primary:hover {
  background: var(--notes-accent-strong);
  color: var(--notes-accent-contrast);
  transform: translateY(-1px);
}

.notes-btn--ghost {
  background: var(--notes-surface-alt);
  color: var(--notes-text);
  border-color: var(--notes-border);
}

.notes-btn--ghost:hover {
  border-color: var(--notes-accent);
  color: var(--notes-accent);
}

.notes-btn--danger {
  background: transparent;
  color: var(--notes-danger);
  border-color: var(--notes-danger);
}

.notes-btn--danger:hover {
  background: var(--notes-danger);
  color: var(--notes-danger-contrast);
}

.notes-btn--icon-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--notes-danger);
  border: 1px solid var(--notes-border);
}

.notes-btn--icon-danger:hover {
  background: var(--notes-danger);
  color: var(--notes-danger-contrast);
  border-color: var(--notes-danger);
}

.notes-btn--sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.76rem;
}

.notes-btn--icon {
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
  flex: none;
}

/* --- Inputs ------------------------------------------------------------------ */

.notes-input {
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: var(--notes-text);
  min-width: 0;
}

.notes-input::placeholder {
  color: var(--notes-text-muted);
}

.notes-input:focus {
  outline: none;
  border-color: var(--notes-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--notes-accent) 25%, transparent);
}

.notes-input--lg {
  flex: 1 1 auto;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}

.notes-inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.notes-inline-form--wide {
  max-width: 480px;
  margin-bottom: 1.5rem;
}

.notes-inline-form .notes-input {
  flex: 1 1 auto;
  min-width: 120px;
}

/* --- Alerts ------------------------------------------------------------------- */

.notes-alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.notes-alert--danger {
  background: color-mix(in srgb, var(--notes-danger) 14%, var(--notes-surface));
  border-color: color-mix(in srgb, var(--notes-danger) 35%, transparent);
  color: var(--notes-danger);
}

.notes-alert--success {
  background: color-mix(in srgb, #35b06b 14%, var(--notes-surface));
  border-color: color-mix(in srgb, #35b06b 35%, transparent);
  color: #35b06b;
}

/* --- Breadcrumbs & pills ------------------------------------------------------ */

.notes-breadcrumb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.notes-breadcrumbs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  color: var(--notes-text-muted);
}

.notes-breadcrumbs a {
  font-weight: 500;
}

.notes-breadcrumbs .notes-breadcrumbs__sep {
  opacity: 0.4;
}

.notes-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--notes-group) 18%, var(--notes-surface));
  color: var(--notes-group);
  margin-left: 0.25rem;
}

.notes-pill--daily {
  background: color-mix(in srgb, var(--notes-accent) 18%, var(--notes-surface));
  color: var(--notes-accent);
}

/* --- Toolbar rows / grid layout ------------------------------------------------ */

.notes-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.notes-toolbar-row--tight {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--notes-border);
}

/* Icon button that expands into a text input on click (new folder / new document, next to the
   breadcrumbs) instead of permanently showing an empty text box. */
.notes-quickadd-group {
  display: flex;
  gap: 0.5rem;
  flex: none;
}

.notes-quickadd {
  display: flex;
  align-items: center;
}

.notes-quickadd__input {
  width: 0;
  min-width: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  margin-left: 0;
  transition: width 0.18s ease, opacity 0.15s ease, margin 0.18s ease, padding 0.18s ease;
}

.notes-quickadd--open .notes-quickadd__input {
  width: 190px;
  opacity: 1;
  margin-left: 0.5rem;
  padding: 0.5rem 0.85rem;
  border-width: 1px;
}

.notes-empty {
  color: var(--notes-text-muted);
  font-size: 0.9rem;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.notes-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.95rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--notes-border);
  background: var(--notes-surface);
  text-decoration: none;
  color: var(--notes-text);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.notes-card[draggable="true"] {
  cursor: grab;
}

.notes-card--dragging {
  opacity: 0.4;
}

.notes-drop-target--active {
  outline: 2px dashed var(--notes-accent);
  outline-offset: 2px;
  background: var(--notes-surface-alt);
}

.notes-breadcrumbs a.notes-drop-target--active {
  outline-offset: -2px;
  border-radius: 999px;
}

.notes-card:hover,
.notes-card:focus-visible {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
  border-color: var(--notes-accent);
  color: var(--notes-text);
}

.notes-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  font-size: 1rem;
  flex: none;
  background: color-mix(in srgb, var(--notes-accent) 16%, var(--notes-surface));
  color: var(--notes-accent);
}

.notes-card__icon--folder {
  background: color-mix(in srgb, var(--notes-folder) 18%, var(--notes-surface));
  color: var(--notes-folder);
}

.notes-card__icon--group {
  background: color-mix(in srgb, var(--notes-group) 18%, var(--notes-surface));
  color: var(--notes-group);
}

.notes-card__icon--daily {
  background: color-mix(in srgb, var(--notes-accent) 18%, var(--notes-surface));
  color: var(--notes-accent);
}

/* Same height/padding as a regular .notes-card (it sits in the same grid row as the day's
   documents), just narrower and accent-tinted so it reads as an action rather than a file. */
.notes-daily-quickbtn {
  width: 88%;
  justify-self: start;
  background: color-mix(in srgb, var(--notes-accent) 10%, var(--notes-surface));
  border-color: color-mix(in srgb, var(--notes-accent) 40%, transparent);
}

.notes-daily-quickbtn:hover {
  border-color: var(--notes-accent);
}

.notes-card__body {
  min-width: 0;
}

.notes-card__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-card__meta {
  font-size: 0.78rem;
  color: var(--notes-text-muted);
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.15rem;
}

.notes-card--shared-item {
  align-items: center;
  justify-content: space-between;
}

.notes-card--shared-item .notes-card__link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.notes-card--shared-item .notes-card__leave {
  flex: none;
}

/* --- Tags --------------------------------------------------------------------- */

.notes-tag-chip,
.note-tag-chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--notes-accent) 14%, var(--notes-surface));
  color: var(--notes-accent);
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--notes-accent) 25%, transparent);
  transition: background 0.15s ease;
}

.notes-tag-chip:hover,
.note-tag-chip:hover {
  background: color-mix(in srgb, var(--notes-accent) 24%, var(--notes-surface));
  color: var(--notes-accent-strong);
}

.notes-tag-chip--lg {
  font-size: 0.95rem;
  padding: 0.4rem 1rem;
}

.notes-tag-chip__count {
  opacity: 0.7;
  font-weight: 400;
}

.notes-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.notes-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--notes-text-muted);
  margin: 2rem 0 0.75rem;
}

/* --- Editor toolbar ------------------------------------------------------------ */

.notes-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 16px;
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
}

.notes-editor-toolbar__info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.notes-editor-toolbar__title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--notes-text);
  margin: 0;
}

.notes-editor-toolbar__title--editable {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  margin: -0.1rem -0.35rem;
}

.notes-editor-toolbar__title--editable:hover {
  background: var(--notes-surface-alt);
}

.notes-title-edit-input {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--notes-text);
  background: var(--notes-surface);
  border: 1px solid var(--notes-accent);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  margin: -0.1rem -0.35rem;
  font-family: inherit;
  min-width: 12rem;
}

.notes-editor-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.notes-presence {
  display: flex;
  align-items: center;
}

.notes-presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border: 2px solid var(--notes-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  margin-left: -0.45rem;
}

.notes-presence-avatar:first-child {
  margin-left: 0;
}

.notes-typing-indicator {
  font-size: 0.8rem;
  color: var(--notes-text-muted);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.notes-typing-indicator--visible {
  opacity: 1;
}

.notes-connection-status {
  font-size: 0.75rem;
  color: var(--notes-danger);
}

/* --- Theme switcher -------------------------------------------------------------- */

.notes-theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--notes-surface-alt);
  border: 1px solid var(--notes-border);
}

.notes-theme-switcher__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--notes-text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.notes-theme-switcher__option:hover {
  color: var(--notes-text);
}

.notes-theme-switcher__option--active {
  background: var(--notes-accent);
  color: var(--notes-accent-contrast);
}

/* --- Editor with the preview stacked below it -------------------------------------- */

/* The editor is exactly as tall as the note, so typing pushes the preview down and the page itself
   is the only thing that scrolls. */
.notes-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

/* Bootstrap's smooth scrolling lags behind the caret while typing. */
html:has(.notes-split) {
  scroll-behavior: auto;
}

.notes-split--preview-hidden .notes-pane--preview {
  display: none;
}

#notes-preview-toggle.notes-preview-toggle--active {
  background: var(--notes-accent);
  color: var(--notes-accent-contrast);
  border-color: var(--notes-accent);
}

/* --- Markdown cheatsheet ----------------------------------------------------- */

.notes-cheatsheet-wrap {
  position: relative;
}

#notes-cheatsheet-toggle[aria-expanded="true"] {
  background: var(--notes-accent);
  color: var(--notes-accent-contrast);
  border-color: var(--notes-accent);
}

.notes-cheatsheet {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 2000;
  width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--notes-surface);
  color: var(--notes-text);
  border: 1px solid var(--notes-border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  padding: 0.75rem;
}

.notes-cheatsheet__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--notes-text-muted);
  padding: 0 0.25rem 0.5rem;
}

.notes-cheatsheet__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.notes-cheatsheet__table td {
  padding: 0.3rem 0.25rem;
  border-top: 1px solid var(--notes-border);
  vertical-align: top;
}

.notes-cheatsheet__table tr:first-child td {
  border-top: none;
}

.notes-cheatsheet__table td:first-child {
  white-space: nowrap;
  padding-right: 0.75rem;
}

.notes-cheatsheet__table td:last-child {
  color: var(--notes-text-muted);
}

.notes-cheatsheet__table code {
  background: var(--notes-surface-alt);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
}

@media (max-width: 480px) {
  .notes-cheatsheet {
    position: fixed;
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
  }
}

.notes-pane {
  background: var(--notes-surface);
  color: var(--notes-text);
  border-radius: 16px;
  border: 1px solid var(--notes-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notes-pane__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--notes-text-muted);
  background: var(--notes-surface-alt);
  border-bottom: 1px solid var(--notes-border);
}

.notes-pane .CodeMirror {
  flex: none;
  height: auto;
  font-size: 0.95rem;
  line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  background: transparent;
  color: inherit;
}

.notes-pane .CodeMirror-lines {
  padding: 1rem 0;
}

.notes-pane .CodeMirror pre.CodeMirror-line {
  padding: 0 1.25rem;
}

.notes-pane .CodeMirror-gutters {
  background: transparent;
  border-right: none;
}

.notes-pane .CodeMirror-cursor {
  border-left-color: var(--notes-text);
}

/* The vendored "default" CodeMirror theme has no cm-s-default overrides of its own (plain black on
   white) - warm it up to match the rest of the sheet instead of a stark, unstyled look. Same idea for
   material-darker.css/dracula.css, which only style code tokens (tag/comment/string), never markdown
   tokens (header/quote/link) - without this they'd render as plain bold text with no color. */
.notes-pane .cm-s-default.CodeMirror { color: var(--notes-text); }
.notes-pane .cm-s-default .cm-header { color: #8a5a2c; font-weight: 600; }
.notes-pane .cm-s-default .cm-quote { color: #6b8e5a; font-style: italic; }
.notes-pane .cm-s-default .cm-link { color: var(--notes-accent); }
.notes-pane .cm-s-default .cm-comment { color: var(--notes-text-muted); }

.notes-pane .cm-s-material-darker .cm-header { color: #ffcb6b; font-weight: 600; }
.notes-pane .cm-s-material-darker .cm-quote { color: #c3e88d; font-style: italic; }
.notes-pane .cm-s-material-darker .cm-link { color: #82aaff; }
.notes-pane .cm-s-material-darker .cm-strong { color: #f8f8f2; }

.notes-pane .cm-s-dracula .cm-header { color: #bd93f9; font-weight: 600; }
.notes-pane .cm-s-dracula .cm-quote { color: #50fa7b; font-style: italic; }
.notes-pane .cm-s-dracula .cm-link { color: #8be9fd; }
.notes-pane .cm-s-dracula .cm-strong { color: #f8f8f2; }

/* Reminder under the text of a note without tags, with suggestions to add in one click. */
.notes-tag-reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--notes-border);
  font-size: 0.8rem;
  color: var(--notes-text-muted);
}

.notes-tag-reminder[hidden] {
  display: none;
}

.notes-tag-reminder__label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.notes-tag-reminder__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

button.notes-tag-chip {
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 900px) {
  button.notes-tag-chip {
    font-size: 0.85rem;
    padding: 0.35rem 0.8rem;
  }
}

.notes-preview {
  flex: 1 1 auto;
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--notes-text);
}

.notes-preview h1,
.notes-preview h2,
.notes-preview h3,
.notes-preview h4 {
  /* site.css sets a global h1/h2-h6 { color: var(--heading-color) } (always white) - override it here
     so preview headings follow the sheet's own text color, or a light/sepia sheet renders
     near-invisible white-on-cream headings. */
  color: var(--notes-text);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.4em;
  margin-bottom: 0.5em;
}

.notes-preview h1:first-child,
.notes-preview h2:first-child,
.notes-preview h3:first-child {
  margin-top: 0;
}

.notes-preview p,
.notes-preview ul,
.notes-preview ol {
  margin-bottom: 0.9em;
}

.notes-preview li {
  margin-bottom: 0.25em;
}

/* marked's default listitem renderer emits task checkboxes as plain text inside a
   regular <li>, with no "task-list-item" class to hook into - drop the bullet marker
   for any <li> that contains one instead. */
.notes-preview li:has(input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.4em;
}

.notes-preview li:has(input[type="checkbox"]) input[type="checkbox"] {
  margin-right: 0.4em;
  vertical-align: middle;
}

.notes-preview img {
  max-width: 100%;
  border-radius: 8px;
}

.notes-preview blockquote {
  margin: 1em 0;
  padding: 0.4em 1em;
  border-left: 3px solid var(--notes-accent);
  color: var(--notes-text-muted);
}

.notes-preview code {
  background: var(--notes-surface-alt);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.88em;
}

.notes-preview pre {
  background: var(--notes-surface-alt);
  padding: 0.9rem 1rem;
  border-radius: 10px;
  overflow-x: auto;
}

.notes-preview pre code {
  background: none;
  padding: 0;
}

.notes-preview pre.mermaid {
  display: flex;
  justify-content: center;
}

.notes-preview pre.mermaid svg {
  max-width: 100%;
}

.notes-preview table {
  border-collapse: collapse;
  margin: 1em 0;
  max-width: 100%;
}

.notes-preview th,
.notes-preview td {
  border: 1px solid color-mix(in srgb, var(--notes-text-muted) 40%, transparent);
  padding: 0.35em 0.75em;
}

.notes-preview th {
  background: var(--notes-surface-alt);
  font-weight: 600;
}

.notes-preview hr {
  border: none;
  border-top: 1px solid var(--notes-border);
  margin: 1.5em 0;
}

.note-wiki-link {
  text-decoration: none;
  color: var(--notes-accent);
  border-bottom: 1px dashed currentColor;
}

.note-wiki-link--missing {
  color: var(--notes-danger);
}

/* --- Backlinks -------------------------------------------------------------------- */

.notes-backlinks {
  margin-top: 1.75rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
}

.notes-backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.notes-backlinks ul li a {
  font-weight: 500;
}

.notes-tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1.25rem;
}

/* --- Wiki-link autocomplete popup --------------------------------------------------- */

.notes-wikilink-popup {
  position: absolute;
  z-index: 2000;
  background: #1c1c22;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  min-width: 220px;
  max-height: 220px;
  overflow-y: auto;
  color: #d8d8e2;
}

.notes-wikilink-popup__item {
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.notes-wikilink-popup__item--active,
.notes-wikilink-popup__item:hover {
  background: rgba(139, 133, 255, 0.22);
  color: #fff;
}

/* --- Search --------------------------------------------------------------------------- */

.notes-search-form {
  display: flex;
  gap: 0.5rem;
  max-width: 520px;
  margin-bottom: 1.5rem;
}

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

.notes-list__item {
  display: block;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  text-decoration: none;
  color: var(--notes-text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.notes-list__item:hover {
  border-color: var(--notes-accent);
  transform: translateX(2px);
  color: var(--notes-text);
}

.notes-list__title {
  font-weight: 600;
}

.notes-list__meta {
  font-size: 0.82rem;
  color: var(--notes-text-muted);
  margin-top: 0.2rem;
}

/* --- Two-column panels (share requests) ------------------------------------------------ */

.notes-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .notes-two-col {
    grid-template-columns: 1fr;
  }
}

.notes-panel {
  border-radius: 16px;
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  overflow: hidden;
}

.notes-panel__header {
  padding: 0.75rem 1.1rem;
  font-weight: 600;
  background: var(--notes-surface-alt);
  border-bottom: 1px solid var(--notes-border);
}

.notes-panel__header--split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.notes-panel__body {
  padding: 1rem 1.1rem;
}

.notes-panel__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--notes-text-muted);
  margin-bottom: 0.5rem;
}

.notes-panel__empty {
  padding: 1rem 1.1rem;
  color: var(--notes-text-muted);
  font-size: 0.88rem;
}

.notes-panel__item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--notes-border);
}

.notes-panel__item:first-of-type {
  border-top: none;
}

.notes-panel__item-title {
  font-weight: 600;
}

.notes-panel__item-meta {
  font-size: 0.78rem;
  color: var(--notes-text-muted);
}

.notes-panel__item-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* --- Groups ------------------------------------------------------------------------------ */

.notes-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.notes-member-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.notes-member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--notes-border);
  font-size: 0.88rem;
}

.notes-member-list li:last-child {
  border-bottom: none;
}

.notes-shared-with-list {
  margin-top: 0.75rem;
}

/* --- Browse (workspace-style explorer) ---------------------------------------------------- */

.notes-explorer {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .notes-explorer {
    grid-template-columns: 1fr;
  }
}

.notes-explorer__sidebar {
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  padding: 0.75rem 0.5rem;
  min-height: 65vh;
  max-height: 78vh;
  overflow-y: auto;
}

.notes-explorer__loading,
.notes-explorer__empty {
  padding: 0.75rem;
  color: var(--notes-text-muted);
  font-size: 0.88rem;
}

.notes-explorer__section + .notes-explorer__section {
  margin-top: 1rem;
}

.notes-explorer__section-title {
  padding: 0.25rem 0.6rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--notes-text-muted);
}

.notes-explorer__viewer {
  min-width: 0;
}

.notes-tree,
.notes-tree__children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notes-tree__row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-left: calc(0.4rem + var(--notes-tree-depth, 0) * 1.15rem);
  border-radius: 8px;
}

.notes-tree__row:hover {
  background: var(--notes-surface-alt);
}

.notes-tree__toggle,
.notes-tree__label,
.notes-tree__doc-link {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  text-align: left;
}

.notes-tree__toggle {
  width: 1.4rem;
  height: 2rem;
  flex: none;
  justify-content: center;
  color: var(--notes-text-muted);
  font-size: 0.72rem;
}

.notes-tree__toggle--empty {
  cursor: default;
}

.notes-tree__label,
.notes-tree__doc-link {
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.4rem 0.1rem;
  font-size: 0.9rem;
  border-radius: 8px;
}

.notes-tree__label span,
.notes-tree__doc-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-tree__icon {
  flex: none;
  color: var(--notes-folder);
  width: 1rem;
  text-align: center;
}

.notes-tree__doc-link .notes-tree__icon {
  color: var(--notes-text-muted);
}

.notes-tree__shared-badge {
  flex: none;
  font-size: 0.68rem;
  color: var(--notes-group);
  margin-left: auto;
  padding-left: 0.4rem;
}

.notes-tree__doc-link:hover,
.notes-tree__doc-link:focus-visible {
  color: var(--notes-accent);
}

.notes-tree__doc-link--active {
  background: var(--notes-accent);
  color: var(--notes-accent-contrast);
}

.notes-tree__doc-link--active .notes-tree__icon,
.notes-tree__doc-link--active .notes-tree__shared-badge {
  color: inherit;
}

/* :hover alone outweighs the single-class --active selector on specificity, so without this the
   text/icon on a just-clicked (and therefore still-hovered) item would render in --notes-accent on
   an --notes-accent background - i.e. invisible. */
.notes-tree__doc-link--active:hover,
.notes-tree__doc-link--active:focus-visible {
  color: var(--notes-accent-contrast);
}

.notes-viewer {
  background: var(--notes-surface);
  border: 1px solid var(--notes-border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  min-height: 65vh;
  max-height: 78vh;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
}

.notes-viewer__empty {
  height: 100%;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--notes-text-muted);
  text-align: center;
}

.notes-viewer__empty i {
  font-size: 2rem;
  opacity: 0.6;
}

.notes-viewer__header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--notes-border);
}

.notes-viewer__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.3rem 0;
}

.notes-viewer__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  overflow-wrap: break-word;
}

.notes-viewer__meta {
  font-size: 0.8rem;
  color: var(--notes-text-muted);
}

.notes-viewer__content {
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  background: transparent;
}

.note-wiki-link--missing {
  color: var(--notes-text-muted);
  border-bottom: 1px dashed var(--notes-text-muted);
}
