/* Mnemo – Oberfläche
   Papier und Tinte: neutrale, leicht kühle Flächen; Links in Füllfederblau.
   Die Links sind das einzige auffällige Element – alles andere bleibt ruhig. */

:root {
  --bg: #eceeeb;
  --bg-side: #e6e8e4;
  --bg-editor: #fbfbf9;
  --bg-raised: #ffffff;
  --bg-hover: rgba(30, 34, 38, 0.06);
  --bg-active: rgba(43, 70, 196, 0.1);
  --ink: #1e2226;
  --muted: #5d646b;
  --faint: #9aa0a5;
  --line: #d8dbd6;
  --line-strong: #c4c8c2;
  --accent: #2b46c4;
  --accent-ink: #ffffff;
  --accent-soft: rgba(43, 70, 196, 0.12);
  --tag: #2f6b5b;
  --tag-bg: rgba(47, 107, 91, 0.1);
  --mark: #fbe9a0;
  --danger: #b3261e;
  --ok: #2f6b5b;
  --warn: #9a6400;
  --code-bg: #f0f1ee;
  --graph-line: #cfd2cc;
  --shadow: 0 1px 2px rgba(20, 24, 28, 0.06), 0 8px 24px rgba(20, 24, 28, 0.1);

  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Iowan Old Style", Cambria, "Noto Serif", Georgia, serif;
  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "JetBrains Mono", "Roboto Mono", ui-monospace, monospace;
  --editor-size: 16px;
  --editor-font: var(--font-serif);
  --measure: 42rem;
  color-scheme: light;
}

:root[data-font="sans"] {
  --editor-font: var(--font-sans);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --bg-side: #1a1d20;
    --bg-editor: #1d2023;
    --bg-raised: #24282c;
    --bg-hover: rgba(227, 229, 232, 0.06);
    --bg-active: rgba(142, 164, 255, 0.14);
    --ink: #e3e5e8;
    --muted: #a0a7ae;
    --faint: #6c737a;
    --line: #2c3034;
    --line-strong: #3a3f44;
    --accent: #8ea4ff;
    --accent-ink: #11131a;
    --accent-soft: rgba(142, 164, 255, 0.16);
    --tag: #86c9b5;
    --tag-bg: rgba(134, 201, 181, 0.12);
    --mark: #5c5021;
    --danger: #ff8a80;
    --ok: #86c9b5;
    --warn: #e0b45c;
    --code-bg: #25292d;
    --graph-line: #353a3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a;
  --bg-side: #1a1d20;
  --bg-editor: #1d2023;
  --bg-raised: #24282c;
  --bg-hover: rgba(227, 229, 232, 0.06);
  --bg-active: rgba(142, 164, 255, 0.14);
  --ink: #e3e5e8;
  --muted: #a0a7ae;
  --faint: #6c737a;
  --line: #2c3034;
  --line-strong: #3a3f44;
  --accent: #8ea4ff;
  --accent-ink: #11131a;
  --accent-soft: rgba(142, 164, 255, 0.16);
  --tag: #86c9b5;
  --tag-bg: rgba(134, 201, 181, 0.12);
  --mark: #5c5021;
  --danger: #ff8a80;
  --ok: #86c9b5;
  --warn: #e0b45c;
  --code-bg: #25292d;
  --graph-line: #353a3f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body,
#root {
  height: 100%;
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 4px;
}
code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------------------------------------------------------------- Grundgerüst */

.splash {
  height: 100%;
  background: var(--bg);
}
.app {
  display: flex;
  height: 100%;
  width: 100%;
}
.ribbon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 46px;
  flex: none;
  padding: 8px 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
}
.rb {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}
.rb:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.rb.on {
  color: var(--accent);
  background: var(--accent-soft);
}
.rb-sep {
  width: 18px;
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}
.rb-grow {
  flex: 1;
}
.left,
.right {
  flex: none;
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.left {
  border-right: 1px solid var(--line);
}
.right {
  border-left: 1px solid var(--line);
}
.resizer {
  width: 5px;
  margin: 0 -3px;
  cursor: col-resize;
  z-index: 3;
  flex: none;
  touch-action: none;
}
.resizer:hover,
.resizer:active {
  background: var(--accent-soft);
}
.center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-editor);
  position: relative;
}

/* ---------------------------------------------------------------- Kopfzeile */

.topbar {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-editor);
}
.crumbs {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.crumb-current {
  color: var(--ink);
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--ink);
}
.icon-btn.on {
  color: var(--accent);
}
.icon-btn.small {
  width: 22px;
  height: 22px;
  border-radius: 5px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}
.sync-badge:hover {
  background: var(--bg-hover);
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.sync-badge.syncing .sync-dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite alternate;
}
.sync-badge.offline .sync-dot {
  background: var(--warn);
}
.sync-badge.error .sync-dot {
  background: var(--danger);
}
.sync-badge.error {
  color: var(--danger);
}
.sync-badge.stopped .sync-dot {
  background: var(--faint);
}
@keyframes pulse {
  to {
    opacity: 0.35;
  }
}

/* ---------------------------------------------------------------- Seitenleiste */

.sidebar-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-panel > div {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 42px;
  padding: 0 8px 0 14px;
  flex: none;
}
.panel-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-actions {
  display: flex;
}
.panel-empty,
.rp-empty {
  color: var(--muted);
  padding: 4px 14px;
  font-size: 13px;
}
.panel-help {
  padding: 4px 14px;
  color: var(--muted);
  font-size: 12.5px;
}
.panel-help dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 8px 0;
}
.panel-help dt {
  color: var(--ink);
}
.panel-help dd {
  margin: 0;
}

.tree {
  overflow: auto;
}
.tree.drop-root {
  background: var(--accent-soft);
}
.tree-list,
.tree-list ul,
.tag-list,
.tag-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-list {
  padding-bottom: 40px;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding-right: 8px;
  margin: 0 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--ink);
}
.tree-row:hover {
  background: var(--bg-hover);
}
.tree-row.active {
  background: var(--bg-active);
  color: var(--accent);
}
.tree-row.drop {
  background: var(--accent-soft);
  outline: 1px dashed var(--accent);
}
.tree-file {
  padding-left: 28px;
}
.tree-file.attachment {
  color: var(--muted);
  cursor: default;
}
.tree-folder {
  font-weight: 500;
}
.tree-chevron {
  color: var(--faint);
  transition: transform 0.12s;
  flex: none;
}
.tree-chevron.open {
  transform: rotate(90deg);
}
.tree-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-ext {
  font-size: 11px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.tree-rename {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-raised);
  outline: none;
}
.tree-more {
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-right: -6px;
}

.search-panel {
  overflow: hidden;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px;
  padding: 0 6px 0 9px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--muted);
  flex: none;
}
.search-box:focus-within {
  border-color: var(--accent);
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--ink);
}
.search-count {
  margin: 0 14px 6px;
  color: var(--muted);
  font-size: 12.5px;
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 0 6px 40px;
  overflow: auto;
  flex: 1;
}
.search-results li {
  margin-bottom: 8px;
}
.search-file {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border-radius: 6px;
}
.search-file:hover,
.search-match:hover {
  background: var(--bg-hover);
}
.search-title {
  font-weight: 600;
}
.search-path {
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-match {
  display: block;
  width: 100%;
  text-align: left;
  padding: 3px 8px 3px 16px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tags-panel {
  overflow: auto;
}
.tag-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  margin: 0 6px;
  padding-right: 10px;
  border-radius: 6px;
}
.tag-row:hover {
  background: var(--bg-hover);
}
.tag-spacer {
  width: 22px;
  flex: none;
}
.tag-name {
  flex: 1;
  text-align: left;
  color: var(--tag);
  padding: 3px 0;
}
.tag-count {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Rechte Leiste */

.right-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.rp-tabs {
  display: flex;
  gap: 4px;
  padding: 7px 8px;
  height: 42px;
  flex: none;
}
.rp-tabs button {
  flex: 1;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.rp-tabs button:hover {
  background: var(--bg-hover);
}
.rp-tabs button.on {
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}
.rp-scroll {
  flex: 1;
  overflow: auto;
  padding-bottom: 20px;
}
.rp-section-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 12px 6px 8px;
  font-weight: 600;
  font-size: 13px;
  text-align: left;
}
.rp-section-head span:nth-child(2) {
  flex: 1;
}
.rp-count {
  font-weight: 400;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.rp-section-body {
  padding: 0 8px 8px;
}
.rp-ref {
  margin: 0 0 10px;
  padding: 6px 0;
}
.rp-ref-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 5px;
}
.rp-ref-title:hover {
  background: var(--bg-hover);
}
.rp-ref-path {
  color: var(--faint);
  font-weight: 400;
  font-size: 12px;
}
.rp-ref-context {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  margin-top: 3px;
  border-radius: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.rp-ref-context:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.rp-mention {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.rp-mention .rp-ref-context {
  flex: 1;
}
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 12.5px;
  padding: 6px 6px;
  border-radius: 6px;
  white-space: nowrap;
}
.text-btn:hover {
  background: var(--bg-hover);
}
.rp-out {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rp-out button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--accent);
}
.rp-out button:hover {
  background: var(--bg-hover);
}
.rp-out button.unresolved {
  color: var(--faint);
}
.outline {
  padding: 4px 8px;
}
.outline-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outline-item:hover {
  background: var(--bg-hover);
}
.outline-item.lvl1 {
  font-weight: 600;
}
.outline-item.lvl2 {
  padding-left: 20px;
}
.outline-item.lvl3 {
  padding-left: 32px;
  color: var(--muted);
}
.outline-item.lvl4,
.outline-item.lvl5,
.outline-item.lvl6 {
  padding-left: 44px;
  color: var(--muted);
}
.rp-stats {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  flex: none;
}
.rp-stats dt {
  color: var(--faint);
  font-size: 11.5px;
}
.rp-stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Notiz und Editor */

.note-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.note-column {
  padding: 36px 48px 40vh;
  margin: 0 auto;
}
:root[data-readable="1"] .note-column {
  max-width: calc(var(--measure) + 96px);
}
.inline-title {
  display: block;
  width: 100%;
  border: 0;
  outline: none;
  background: none;
  padding: 0 0 14px;
  margin: 0 0 6px 0;
  font-family: var(--editor-font);
  font-size: calc(var(--editor-size) * 2);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.012em;
  color: var(--ink);
}
.inline-title:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--accent-soft);
}
.editor-host {
  min-height: 50vh;
}
.editor-host .cm-editor {
  background: transparent;
  font-family: var(--editor-font);
  font-size: var(--editor-size);
  line-height: 1.68;
  color: var(--ink);
}
.editor-host .cm-editor.cm-focused {
  outline: none;
}
.editor-host .cm-scroller {
  font-family: inherit;
  line-height: inherit;
  overflow: visible;
}
.editor-host .cm-content {
  padding: 0 0 2rem;
  caret-color: var(--accent);
}
.editor-host .cm-line {
  padding: 0;
}
.editor-host .cm-cursor {
  border-left: 2px solid var(--accent);
}
.editor-host .cm-selectionBackground,
.editor-host .cm-focused .cm-selectionBackground {
  background: var(--accent-soft) !important;
}
.editor-host .cm-activeLine {
  background: transparent;
}
.editor-host .cm-placeholder {
  color: var(--faint);
  font-style: italic;
}

/* Überschriften */
.cm-heading {
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.cm-h1 {
  font-size: 1.62em;
  padding-top: 0.7em !important;
  padding-bottom: 0.2em !important;
}
.cm-h2 {
  font-size: 1.34em;
  padding-top: 0.6em !important;
  padding-bottom: 0.15em !important;
}
.cm-h3 {
  font-size: 1.14em;
  padding-top: 0.45em !important;
}
.cm-h4,
.cm-h5,
.cm-h6 {
  font-size: 1em;
  padding-top: 0.35em !important;
}
.cm-h5,
.cm-h6 {
  color: var(--muted);
}
.tok-mark {
  color: var(--faint);
}
.tok-meta {
  color: var(--muted);
}

/* Inline */
.cm-strong {
  font-weight: 700;
}
.cm-em {
  font-style: italic;
}
.cm-strike {
  text-decoration: line-through;
  color: var(--muted);
}
.cm-highlight {
  background: var(--mark);
  border-radius: 2px;
}
.cm-inline-code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.3em;
}

/* Links – das Erkennungszeichen */
.cm-wikilink,
.cm-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.cm-wikilink:hover,
.cm-link:hover {
  text-decoration-color: var(--accent);
}
.cm-wikilink.cm-unresolved,
.cm-link.cm-unresolved {
  color: var(--muted);
  text-decoration-style: dashed;
  text-decoration-color: var(--faint);
}
.cm-wikilink-src {
  text-decoration: none;
  cursor: text;
}
.cm-wikimark,
.cm-url-src {
  color: var(--faint);
}
.cm-link-src {
  color: var(--accent);
}
.cm-external::after {
  content: "↗";
  font-size: 0.7em;
  vertical-align: 0.35em;
  margin-left: 0.1em;
  color: var(--faint);
}
.cm-tag {
  color: var(--tag);
  background: var(--tag-bg);
  border-radius: 0.6em;
  padding: 0.05em 0.42em;
  font-family: var(--font-ui);
  font-size: 0.86em;
  cursor: pointer;
}

/* Listen und Aufgaben */
.cm-bullet {
  color: var(--muted);
  display: inline-block;
  width: 0.9em;
  text-align: center;
}
.cm-listmark {
  color: var(--muted);
}
.cm-task-box {
  appearance: none;
  -webkit-appearance: none;
  width: 1em;
  height: 1em;
  margin: 0 0.4em 0 0;
  vertical-align: -0.12em;
  border: 1.5px solid var(--faint);
  border-radius: 0.22em;
  cursor: pointer;
  background: var(--bg-editor);
  position: relative;
}
.cm-task-box:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.cm-task-box:checked::after {
  content: "";
  position: absolute;
  left: 0.29em;
  top: 0.08em;
  width: 0.26em;
  height: 0.52em;
  border: solid var(--accent-ink);
  border-width: 0 0.13em 0.13em 0;
  transform: rotate(45deg);
}
.cm-task-done {
  color: var(--muted);
}
.cm-task-done .cm-strong,
.cm-task-done .cm-em {
  color: var(--muted);
}

/* Blöcke */
.cm-quote {
  border-left: 3px solid var(--line-strong);
  padding-left: 14px !important;
  color: var(--muted);
}
.cm-hr {
  display: inline-block;
  width: 100%;
  height: 1px;
  background: var(--line-strong);
  vertical-align: middle;
}
.cm-codeblock {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0 14px !important;
  line-height: 1.55;
}
.cm-cb-first {
  border-radius: 6px 6px 0 0;
  padding-top: 6px !important;
}
.cm-cb-last {
  border-radius: 0 0 6px 6px;
  padding-bottom: 6px !important;
}
.cm-cb-first.cm-cb-last {
  border-radius: 6px;
}
.cm-fence {
  color: var(--faint);
  font-size: 0.85em;
}
.cm-frontmatter {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--muted);
  background: var(--code-bg);
  padding: 0 12px !important;
}
.cm-fm-first {
  border-radius: 6px 6px 0 0;
  padding-top: 4px !important;
}
.cm-fm-last {
  border-radius: 0 0 6px 6px;
  padding-bottom: 4px !important;
  margin-bottom: 0.6em;
}
.cm-table {
  font-family: var(--font-mono);
  font-size: 0.86em;
  white-space: pre;
}
.cm-table-head {
  font-weight: 600;
}
.tok-code {
  font-family: var(--font-mono);
}
.tok-keyword {
  color: var(--accent);
}
.tok-string {
  color: var(--tag);
}
.tok-comment {
  color: var(--faint);
}

/* Einbettungen */
.cm-image {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
  margin: 4px 0;
}
.cm-image img {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}
.cm-image-missing {
  font-family: var(--font-ui);
  font-size: 0.85em;
  color: var(--danger);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 6px 10px;
}
.cm-embed {
  display: block;
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  border-radius: 0 6px 6px 0;
  padding: 8px 14px;
  margin: 4px 0;
  white-space: pre-wrap;
}
.cm-embed-title {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8em;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-bottom: 4px;
}
.cm-embed-body {
  display: block;
  color: var(--muted);
  font-size: 0.94em;
}

/* Autovervollständigung und Suche */
.cm-tooltip {
  border: 1px solid var(--line) !important;
  background: var(--bg-raised) !important;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cm-tooltip-autocomplete > ul {
  font-family: var(--font-ui) !important;
  font-size: 13.5px;
  max-height: 18em !important;
  min-width: 240px;
}
.cm-tooltip-autocomplete > ul > li {
  padding: 5px 10px !important;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.cm-tooltip-autocomplete > ul > li[aria-selected] {
  background: var(--accent-soft) !important;
  color: var(--ink) !important;
}
.cm-completionDetail {
  margin-left: auto;
  color: var(--faint);
  font-style: normal !important;
  font-size: 12px;
}
.cm-completionMatchedText {
  text-decoration: none !important;
  font-weight: 600;
}
.cm-panels {
  background: var(--bg-side) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
  font-family: var(--font-ui);
}
.cm-panel.cm-search {
  padding: 6px 10px !important;
}
.cm-panel.cm-search input,
.cm-panel.cm-search button {
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  padding: 2px 8px;
  font-size: 13px;
}
.cm-searchMatch {
  background: var(--mark) !important;
}
.cm-selectionMatch {
  background: var(--accent-soft) !important;
}
.cm-matchingBracket {
  background: transparent !important;
  outline: 1px solid var(--line-strong);
}

.statusbar {
  position: absolute;
  right: 12px;
  bottom: 8px;
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--faint);
  background: var(--bg-editor);
  padding: 2px 8px;
  border-radius: 6px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.empty-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 8px;
}

/* ---------------------------------------------------------------- Graph */

.graph-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.graph-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.graph-canvas {
  flex: 1;
  position: relative;
  min-height: 0;
  touch-action: none;
}
.graph-canvas canvas {
  display: block;
  cursor: grab;
}
.graph-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  margin: 0;
  padding: 20px;
  text-align: center;
}
.graph-filter {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--bg-raised);
  width: 150px;
}
.graph-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.graph-depth {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
}
.seg button {
  padding: 4px 10px;
  color: var(--muted);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg button + button {
  border-left: 1px solid var(--line-strong);
}
.seg button.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* ---------------------------------------------------------------- Menüs, Dialoge */

.context-menu {
  position: fixed;
  z-index: 50;
  min-width: 200px;
  padding: 5px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  text-align: left;
  color: var(--ink);
}
.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.context-menu button .icon {
  color: var(--muted);
}
.context-menu .danger,
.context-menu .danger .icon {
  color: var(--danger);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 18, 22, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade 0.12s ease-out;
}
.overlay.top {
  align-items: flex-start;
  padding-top: 12vh;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.dialog {
  width: 100%;
  max-width: 440px;
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dialog.wide {
  max-width: 820px;
}
.dialog.palette {
  max-width: 600px;
}
.dialog-head {
  display: flex;
  align-items: center;
  padding: 14px 12px 6px 20px;
}
.dialog-head h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}
.dialog > form,
.dialog > .dialog-text,
.dialog > .note,
.dialog > .history {
  padding: 4px 20px 20px;
}
.dialog-text {
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.5;
}
.dialog.palette > .dialog-text {
  padding: 18px 20px;
  margin: 0;
}
.picker {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.picker-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
  font-size: 15px;
  background: transparent;
  outline: none;
}
.picker-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  max-height: 50vh;
}
.picker-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.picker-list li.sel {
  background: var(--accent-soft);
}
.picker-label {
  flex: none;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-detail {
  flex: 1;
  color: var(--faint);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.picker-list kbd {
  margin-left: auto;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11.5px;
  white-space: nowrap;
}
.picker-empty {
  color: var(--muted);
  cursor: default !important;
}
.picker-footer {
  border-top: 1px solid var(--line);
  padding: 8px 18px;
  font-size: 12px;
  color: var(--faint);
}

.settings-layout {
  display: flex;
  min-height: 420px;
  max-height: 70vh;
}
.settings-nav {
  width: 170px;
  flex: none;
  padding: 8px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav button {
  text-align: left;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--muted);
}
.settings-nav button:hover {
  background: var(--bg-hover);
}
.settings-nav button.on {
  background: var(--accent-soft);
  color: var(--accent);
}
.settings-body {
  flex: 1;
  overflow: auto;
  padding: 8px 22px 24px;
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-label {
  font-weight: 600;
  font-size: 13px;
}
.field-hint {
  color: var(--faint);
  font-size: 12px;
}
.field input:not([type="range"]):not([type="checkbox"]),
.field select {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 10px;
  background: var(--bg-editor);
  outline: none;
  width: 100%;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field input[type="range"] {
  accent-color: var(--accent);
}
.vault-path {
  display: flex;
  gap: 8px;
  align-items: center;
}
.vault-path code {
  flex: 1;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions.end {
  justify-content: flex-end;
  margin-top: 18px;
}
.row-actions.center {
  justify-content: center;
}
.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  border-color: var(--faint);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.big {
  height: 42px;
  padding: 0 22px;
  font-size: 15px;
}
.note {
  margin: 0;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
}
.note.ok {
  background: var(--tag-bg);
  color: var(--ok);
}
.note.err {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  overflow-wrap: anywhere;
}
.sync-state {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.sync-state p {
  margin: 0;
}

.history {
  display: flex;
  gap: 14px;
  min-height: 360px;
  max-height: 65vh;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 230px;
  flex: none;
  overflow: auto;
}
.history-list button {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 7px;
}
.history-list button:hover:not(:disabled) {
  background: var(--bg-hover);
}
.history-list button.on {
  background: var(--accent-soft);
}
.history-meta {
  font-size: 12px;
  color: var(--faint);
}
.history-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-preview pre {
  flex: 1;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  background: var(--bg-editor);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--editor-font);
  font-size: 14px;
  line-height: 1.55;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: min(92vw, 520px);
}
.toast {
  background: var(--ink);
  color: var(--bg-editor);
  padding: 9px 16px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: toast-in 0.18s ease-out;
  max-width: 100%;
}
.toast.error {
  background: var(--danger);
  color: #fff;
}
@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- Vault wählen */

.vault-picker {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.vault-picker-card {
  width: 100%;
  max-width: 480px;
}
.vault-picker h1 {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.vault-picker p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 22px;
}
.vault-picker h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 32px 0 8px;
  color: var(--muted);
}
.recent-vaults {
  list-style: none;
  margin: 0;
  padding: 0;
}
.recent-vaults button {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  align-items: center;
}
.recent-vaults button:hover {
  background: var(--bg-hover);
}
.rv-path {
  grid-column: 2;
  color: var(--faint);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Handy */

.app.mobile .topbar {
  height: calc(48px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
.app.mobile .icon-btn {
  width: 42px;
  height: 42px;
}
.app.mobile .note-column {
  padding: 18px 18px 40vh;
}
.app.mobile .inline-title {
  font-size: calc(var(--editor-size) * 1.7);
}
.app.mobile .left,
.app.mobile .right {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 30;
  width: min(86vw, 360px);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow);
  animation: slide-left 0.18s ease-out;
}
.app.mobile .left {
  left: 0;
}
.app.mobile .right {
  right: 0;
  animation-name: slide-right;
}
@keyframes slide-left {
  from {
    transform: translateX(-100%);
  }
}
@keyframes slide-right {
  from {
    transform: translateX(100%);
  }
}
.scrim {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(16, 18, 22, 0.35);
  animation: fade 0.18s;
}
.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  flex: none;
}
.drawer-tabs button {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
}
.drawer-tabs button.on {
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}
.drawer-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  flex: none;
}
.app.mobile .tree-row {
  min-height: 40px;
  font-size: 15px;
}
.app.mobile .tree-file {
  padding-left: 30px;
}
.mobile-toolbar {
  display: flex;
  overflow-x: auto;
  flex: none;
  gap: 2px;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-side);
  scrollbar-width: none;
}
.mobile-toolbar::-webkit-scrollbar {
  display: none;
}
.mobile-toolbar button {
  flex: none;
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
}
.mobile-toolbar button:active {
  background: var(--bg-hover);
  color: var(--ink);
}
.app.mobile .dialog {
  max-width: none;
}
.app.mobile .overlay.top {
  padding-top: calc(12px + env(safe-area-inset-top));
}
.app.mobile .picker-list {
  max-height: 60vh;
}
.app.mobile .picker-list li {
  padding: 11px 12px;
}

@media (max-width: 720px) {
  .settings-layout {
    flex-direction: column;
    max-height: none;
  }
  .settings-nav {
    width: auto;
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .settings-nav button {
    flex: 1;
    text-align: center;
  }
  .settings-body {
    padding: 12px 16px 20px;
  }
  .dialog.settings {
    height: calc(100% - 16px);
    max-height: none;
  }
  .settings-layout {
    flex: 1;
    min-height: 0;
  }
  .history {
    flex-direction: column;
  }
  .history-list {
    width: auto;
    max-height: 30vh;
  }
  .note-column {
    padding-left: 22px;
    padding-right: 22px;
  }
  .graph-count {
    margin-left: 0;
  }
}
