/* ================= Design-Tokens ================= */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --text: #1f1e1b;
  --muted: #6f6d66;
  --border: #e1dfd8;
  --hover: rgba(0, 0, 0, .06);
  --chip: rgba(0, 0, 0, .07);
  --accent: #f2b53a;
  --accent-strong: #a86d06;
  --accent-soft: #fbe8c2;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 3px 10px rgba(0, 0, 0, .07);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .25);
  --radius: 14px;
  --topbar-h: 64px;

  --c-red: #f6d6d2; --c-orange: #f9e1c2; --c-yellow: #fbf0b4; --c-green: #dcefcf;
  --c-teal: #cdebe5; --c-blue: #d3e3f6; --c-purple: #e3daf3; --c-pink: #f6d8e5;
  --c-brown: #ebdfd2; --c-gray: #e5e5e1;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #141414;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --text: #ecebe8;
  --muted: #a3a19b;
  --border: #323232;
  --hover: rgba(255, 255, 255, .08);
  --chip: rgba(255, 255, 255, .11);
  --accent-strong: #f2b53a;
  --accent-soft: #3a2e14;
  --danger: #ff7b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 3px 10px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);

  --c-red: #5a2b28; --c-orange: #5e4219; --c-yellow: #5c5419; --c-green: #2f4f22;
  --c-teal: #1a4a45; --c-blue: #263f5c; --c-purple: #3f2b5c; --c-pink: #5a2445;
  --c-brown: #47331f; --c-gray: #3a3c3f;
  color-scheme: dark;
}

/* ================= Basis ================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; flex: none; }
[hidden] { display: none !important; }
.grow { flex: 1; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn.on { color: var(--accent-strong); }
.text-btn {
  height: 40px; padding: 0 16px; border-radius: 20px; font-weight: 600; font-size: 14px;
}
.text-btn:hover { background: var(--hover); }
.text-btn.primary { background: var(--accent); color: #1f1e1b; }
.text-btn.primary:hover { filter: brightness(1.05); }
.text-btn.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* ================= Kopfleiste ================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  min-height: var(--topbar-h);
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: none; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; width: 196px; }
.brand .logo svg { width: 30px; height: 30px; }
.search {
  flex: 1; min-width: 0; max-width: 720px;
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 4px 0 14px;
  background: var(--surface-2); border-radius: 24px; color: var(--muted);
  transition: background .15s, box-shadow .15s;
}
.search svg { width: 22px; height: 22px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }

/* ================= Seitenleiste ================= */
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  width: 284px; max-width: 85vw;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 10px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg); overflow-y: auto;
  transform: translateX(-102%); transition: transform .22s ease;
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: none; }
.drawer-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; padding: 8px 14px 14px; }
.drawer-brand svg { width: 30px; height: 30px; }
.nav-item {
  display: flex; align-items: center; gap: 18px; width: 100%;
  min-height: 48px; padding: 0 16px; border-radius: 24px;
  text-align: left; font-size: 15px; color: var(--text);
}
.nav-item svg { color: var(--muted); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); font-weight: 600; }
.nav-item.active svg { color: var(--accent-strong); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--muted); }
.nav-section { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 14px 16px 6px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }
.drawer-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 16px; font-size: 12.5px; color: var(--muted); }
.drawer-foot svg { width: 18px; height: 18px; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ================= Hauptbereich ================= */
.main { padding: 14px 10px calc(130px + env(safe-area-inset-bottom)); }
.view-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: 2px 4px 14px; }
.view-head h1 { font-size: 22px; margin: 0; font-weight: 650; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.trash-info { display: flex; align-items: center; gap: 12px; width: 100%; color: var(--muted); font-size: 13.5px; }
.section-title { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 6px 6px 10px; }
.note-section + .note-section { margin-top: 26px; }

/* Festes Raster mit gleich hohen Vorschau-Karten */
.notes-grid {
  --card-h: 172px;
  position: relative; /* Bezugspunkt für offsetLeft/offsetTop der Karten (Ziehen) */
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.layout-list .notes-grid { grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; }
.layout-list .section-title { max-width: 640px; margin-left: auto; margin-right: auto; }
@media (min-width: 900px) {
  .notes-grid { --card-h: 200px; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

/* ================= Karten ================= */
.card {
  position: relative; overflow: hidden;
  padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer; outline: none;
  transition: box-shadow .15s, transform .15s;
}
.card.colored { border-color: transparent; }
.card:hover, .card:focus-visible { box-shadow: var(--shadow); }
.card-title { font-size: 16px; font-weight: 600; margin: 0 26px 6px 0; overflow-wrap: anywhere; line-height: 1.35; }
.card-text {
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 12; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title + .card-text { margin-top: 2px; }
.card-empty { color: var(--muted); font-size: 14px; font-style: italic; }
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.card-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; overflow-wrap: anywhere; }
.card-list li.more { color: var(--muted); font-size: 13px; padding-left: 26px; }
.card-list input { margin: 2px 0 0; width: 17px; height: 17px; flex: none; accent-color: var(--accent-strong); cursor: pointer; }
.card-done { margin-top: 8px; font-size: 13px; color: var(--muted); padding-left: 25px; }
.card-pin {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s;
}
.card-pin svg { width: 20px; height: 20px; }
.card:hover .card-pin, .card-pin:focus-visible { opacity: 1; }
.card-pin:hover { background: var(--hover); color: var(--text); }
.card-pin.on { opacity: 1; color: var(--text); }
@media (hover: none) { .card-pin:not(.on) { display: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; line-height: 1; padding: 5px 10px; border-radius: 12px; background: var(--chip);
}
.chip-x { width: 18px; height: 18px; margin-right: -4px; border-radius: 50%; display: grid; place-items: center; opacity: .7; }
.chip-x svg { width: 14px; height: 14px; }
.chip-x:hover { opacity: 1; background: var(--hover); }

.empty { text-align: center; color: var(--muted); margin-top: 12vh; }
.empty-ic svg { width: 110px; height: 110px; margin: 0 auto 10px; opacity: .22; }
.empty p { font-size: 16px; }

/* ================= Plus-Buttons ================= */
.fabs {
  position: fixed; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.fab {
  width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center;
  background: var(--accent); color: #1f1e1b; box-shadow: var(--shadow-lg);
  transition: transform .15s;
}
.fab svg { width: 28px; height: 28px; }
.fab:hover { transform: translateY(-1px); }
.fab:active { transform: scale(.96); }
.fab.small { width: 46px; height: 46px; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
.fab.small svg { width: 22px; height: 22px; }

/* ================= Editor ================= */
.editor-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease;
}
.editor {
  width: min(660px, 100%); max-height: 86vh; min-height: 260px;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 18px; box-shadow: var(--shadow-lg); background: var(--surface);
  animation: pop .18s ease;
}
.ed-top { display: flex; align-items: center; padding: 6px 6px 0; }
.ed-scroll { flex: 1; overflow-y: auto; padding: 0 22px 16px; overscroll-behavior: contain; }
.ed-title, .ed-text, .ed-item textarea {
  display: block; width: 100%; border: 0; outline: none; background: transparent; resize: none; padding: 6px 0;
  overflow: hidden;
}
.ed-title { font-size: 21px; font-weight: 600; line-height: 1.35; }
.ed-text { font-size: 16px; line-height: 1.55; min-height: 140px; }
.ed-title::placeholder, .ed-text::placeholder, .ed-item textarea::placeholder { color: var(--muted); opacity: .8; }
.ed-list { padding: 4px 0; }
.ed-item { display: flex; align-items: flex-start; gap: 8px; border-radius: 8px; }
.ed-item textarea { font-size: 16px; line-height: 1.45; padding: 7px 0; }
.ed-item input[type="checkbox"] { width: 20px; height: 20px; margin: 9px 2px 0; flex: none; accent-color: var(--accent-strong); cursor: pointer; }
.ed-item.done textarea { text-decoration: line-through; color: var(--muted); }
.ed-item .icon-btn { margin-top: 2px; opacity: 0; }
.ed-item:hover .icon-btn, .ed-item:focus-within .icon-btn { opacity: 1; }
.ed-add { color: var(--muted); }
.ed-add .add-ic { width: 24px; display: grid; place-items: center; margin-top: 7px; }
.ed-add .add-ic svg { width: 22px; height: 22px; }
.ed-done-head { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; font-size: 13.5px; color: var(--muted); padding: 4px 6px 4px 0; border-radius: 8px; }
.ed-done-head svg { width: 20px; height: 20px; }
.ed-meta { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: right; }
.ed-bar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 8px; padding-bottom: calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--chip);
}
.editor.colored .icon-btn { color: var(--text); opacity: .75; }
.editor.colored .icon-btn:hover { opacity: 1; }

/* ================= Popover (Farben, Labels) ================= */
.popover {
  position: fixed; z-index: 70; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pop .12s ease;
}
.swatches { display: grid; grid-template-columns: repeat(6, 36px); gap: 8px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border);
  display: grid; place-items: center; color: var(--text);
}
.swatch svg { width: 18px; height: 18px; }
.swatch.none { color: var(--muted); }
.swatch:hover { border-color: var(--muted); }
.swatch.sel { border-color: var(--accent-strong); }
.label-picker { width: 250px; }
.lp-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.lp-input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none; font-size: 15px;
}
.lp-input:focus { border-color: var(--accent-strong); }
.lp-list { margin-top: 8px; max-height: 260px; overflow-y: auto; }
.lp-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.lp-row:hover { background: var(--hover); }
.lp-row input { width: 18px; height: 18px; accent-color: var(--accent-strong); margin: 0; }
.lp-create { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 4px; border-radius: 8px; font-size: 15px; color: var(--accent-strong); text-align: left; }
.lp-create svg { width: 20px; height: 20px; }
.lp-create:hover { background: var(--hover); }
.lp-hint { color: var(--muted); font-size: 14px; padding: 6px 4px; }

/* ================= Dialoge ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.modal {
  width: min(460px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px; padding: 22px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
.modal h2 { margin: 0 0 14px; font-size: 19px; }
.modal p { margin: 0; color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.setting { padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting:last-of-type { border-bottom: 0; }
.setting-label { font-weight: 600; font-size: 14.5px; margin-bottom: 8px; }
.setting-hint { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.setting-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 14px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.outline-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.outline-btn svg { width: 19px; height: 19px; color: var(--muted); }
.outline-btn:hover { background: var(--hover); }
.lm-new { display: flex; gap: 8px; margin-bottom: 10px; }
.lm-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.lm-row svg { color: var(--muted); }
.lm-row > svg { width: 20px; height: 20px; margin: 0 6px; }
.lm-row input, .lm-new input {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; outline: none; font-size: 15px;
}
.lm-new input { border-color: var(--border); background: var(--surface-2); }
.lm-row input:hover { border-color: var(--border); }
.lm-row input:focus, .lm-new input:focus { border-color: var(--accent-strong); background: var(--surface-2); }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 10px 10px 10px 18px; border-radius: 12px; font-size: 14.5px;
  background: #2b2a27; color: #f3f2ee; box-shadow: var(--shadow-lg);
  transform: translate(-50%, 16px); opacity: 0; transition: transform .2s, opacity .2s;
}
[data-theme="dark"] .toast { background: #e9e7e1; color: #1f1e1b; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast { cursor: pointer; }
.toast-btn { color: var(--accent); font-weight: 700; padding: 8px 10px; border-radius: 8px; }
[data-theme="dark"] .toast-btn { color: #a86d06; }

/* ================= Konto / Sync ================= */
#btnSync.error { color: var(--danger); }
#btnSync.syncing svg { animation: spin 1s linear infinite; }
#btnSync.ok { color: var(--muted); }
.drawer-foot { cursor: pointer; border-radius: 12px; text-align: left; }
.drawer-foot:hover { background: var(--hover); }
.drawer-foot.error { color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); outline: none; font-size: 16px;
}
.field input:focus { border-color: var(--accent-strong); }
.form-msg { font-size: 14px; line-height: 1.45; margin-top: 4px; }
.form-msg:empty { display: none; }
.form-msg.err { color: var(--danger); }
.account-box { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; }
.account-box svg { width: 36px; height: 36px; padding: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); }
.account-mail { font-weight: 600; overflow-wrap: anywhere; }
.modal-actions.split { justify-content: space-between; flex-wrap: wrap; }
.modal-actions .grow { flex: 1; }
@keyframes spin { to { transform: rotate(-360deg); } }
.icon-btn:disabled { opacity: .3; pointer-events: none; }

/* ================= Anhänge auf Karten ================= */
.card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.card-media { position: relative; margin: -14px -16px 12px; background: var(--chip); }
.card-media img { display: block; width: 100%; max-height: 300px; object-fit: cover; }
.card-media.drawing, .media-tile.drawing, .viewer-stage.drawing img { background: #fff; }
.card-media.missing img, .media-tile.missing img { visibility: hidden; min-height: 90px; }
.media-more {
  position: absolute; right: 8px; bottom: 8px; padding: 3px 9px; border-radius: 10px;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 12.5px; font-weight: 600;
}
.card-pin.over-media { background: rgba(0, 0, 0, .35); color: #fff; }
.card-pin.over-media:hover { background: rgba(0, 0, 0, .55); color: #fff; }
.card-audio { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.audio-chip {
  display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 11px 0 5px;
  border-radius: 15px; background: var(--chip); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.audio-chip svg { width: 19px; height: 19px; }
.audio-chip .ac-mic svg { width: 15px; height: 15px; opacity: .6; margin-right: 2px; }
.audio-chip.playing { background: var(--accent); color: #1f1e1b; }

/* ================= Anhänge im Editor ================= */
.ed-media { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; margin: 0 -22px 10px; }
.ed-media.empty { display: none; }
.ed-media.single { grid-template-columns: 1fr; }
.media-tile { display: block; aspect-ratio: 1; overflow: hidden; background: var(--chip); padding: 0; }
.media-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ed-media.single .media-tile { aspect-ratio: auto; width: 100%; }
.ed-media.single .media-tile img { height: auto; max-height: 440px; object-fit: contain; }
.ed-audios { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ed-audios:empty { display: none; }
.ed-audio { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: 14px; background: var(--chip); }
.ed-audio audio { flex: 1; min-width: 0; height: 40px; }
.ea-ic svg { width: 20px; height: 20px; color: var(--muted); }
.ea-dur { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.menu-list { display: flex; flex-direction: column; min-width: 210px; margin: -4px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 11px 10px; border-radius: 9px; font-size: 15px; text-align: left; }
.menu-item svg { color: var(--muted); }
.menu-item:hover { background: var(--hover); }

/* ================= Bildbetrachter ================= */
.viewer { position: fixed; inset: 0; z-index: 85; background: #000; display: flex; flex-direction: column; animation: fade .15s ease; }
.viewer-top { display: flex; align-items: center; padding: 6px; padding-top: calc(6px + env(safe-area-inset-top)); }
.viewer-top .icon-btn { color: #fff; }
.viewer-top .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding-bottom: env(safe-area-inset-bottom); }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ================= Skizzen-Editor ================= */
.sketch { position: fixed; inset: 0; z-index: 88; background: var(--bg); display: flex; flex-direction: column; }
.sk-top {
  display: flex; align-items: center; gap: 2px; padding: 6px 8px;
  padding-top: calc(6px + env(safe-area-inset-top)); border-bottom: 1px solid var(--border);
}
.sk-title { font-weight: 650; margin-left: 4px; }
.sk-top .text-btn { margin-left: 6px; }
.sk-stage { flex: 1; min-height: 0; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.sk-paper { position: relative; box-shadow: var(--shadow); }
.sk-paper.blank { background: #fff; }
.sk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sk-ink { touch-action: none; cursor: crosshair; }
.sk-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.sk-colors { display: flex; gap: 7px; flex: none; }
.sk-color { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.sk-color.sel { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
.sk-sep { width: 1px; height: 28px; background: var(--border); flex: none; margin: 0 4px; }
.sk-sizes { display: flex; flex: none; }
.sk-size { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.sk-size span { display: block; border-radius: 50%; background: var(--text); }
.sk-size.sel { background: var(--accent-soft); }
.sk-bar .icon-btn.on { background: var(--accent-soft); color: var(--accent-strong); }
.sk-text-input {
  position: absolute; z-index: 2; min-width: 140px; max-width: 90%;
  height: 1.35em; line-height: 1.2; padding: 0 4px; margin: 0;
  font-weight: 600; background: rgba(255, 255, 255, .55); border: 1.5px dashed var(--accent-strong);
  border-radius: 6px; outline: none;
}

/* ================= Tonaufnahme ================= */
.rec-backdrop {
  position: fixed; inset: 0; z-index: 86; background: rgba(0, 0, 0, .45);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease;
}
.rec-sheet { width: min(420px, 100%); background: var(--surface); border-radius: 18px; padding: 20px 22px; box-shadow: var(--shadow-lg); }
.rec-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; }
.rec-title svg { color: var(--accent-strong); }
.rec-main { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0 16px; }
.rec-dot { width: 16px; height: 16px; border-radius: 50%; background: #e53935; animation: pulse 1.2s ease infinite; }
.rec-dot.paused { animation: none; opacity: .3; }
.rec-time { font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; }
.rec-level { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rec-level span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
@keyframes pulse { 50% { opacity: .25; } }

/* ================= Neue-Notiz-Menü ================= */
.fab-menu { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .4); animation: fade .15s ease; }
.fab-items {
  position: fixed; right: 20px; bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.fab-item { display: flex; align-items: center; gap: 12px; animation: pop .18s ease both; }
.fab-item .lbl { background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 10px; font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow); }
.fab-item .ic { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--surface); color: var(--text); box-shadow: var(--shadow); margin-right: 5px; }
.fab-item:hover .ic, .fab-item:hover .lbl { background: var(--accent-soft); }
body.fab-open .fabs { z-index: 46; }
body.fab-open #fabNote svg { transform: rotate(45deg); }
#fabNote svg { transition: transform .2s; }
.fab { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ================= Ziehen ================= */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lg); opacity: .95; transition: none !important; will-change: transform;
}
.card.drag-src { opacity: .35; outline: 2px dashed var(--accent-strong); outline-offset: -2px; box-shadow: none; }
body.dragging .notes-grid { min-height: 90px; }

/* ================= Label-Symbole, Erinnerungen, Einstellungen ================= */
.chip-ic svg { width: 13px; height: 13px; margin-right: 4px; opacity: .8; }
.chip.label-chip, .chip.rem-chip { display: inline-flex; align-items: center; }
.chip.rem-chip { background: var(--accent-soft); }
.chip.rem-chip.past { background: var(--chip); opacity: .65; text-decoration: line-through; }
.chip.clickable { cursor: pointer; }
.lp-ic svg { width: 18px; height: 18px; color: var(--muted); }
.lm-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  color: var(--accent-strong); background: var(--accent-soft);
}
.lm-icon svg { width: 21px; height: 21px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; margin-top: 4px; }
.icon-pick { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--text); }
.icon-pick svg { width: 22px; height: 22px; }
.icon-pick:hover { background: var(--hover); }
.icon-pick.sel { background: var(--accent-soft); color: var(--accent-strong); outline: 2px solid var(--accent-strong); }
.reminder-menu { min-width: 250px; }
.rem-custom { display: flex; gap: 6px; align-items: center; padding: 8px 6px 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.rem-input {
  flex: 1; min-width: 0; height: 38px; padding: 0 8px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
}
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.ed-ocr:empty { display: none; }
.ed-ocr details { margin-top: 10px; border-radius: 12px; background: var(--chip); padding: 4px 12px; }
.ed-ocr summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 0; font-size: 13.5px; color: var(--muted); list-style: none; }
.ed-ocr summary::-webkit-details-marker { display: none; }
.ed-ocr summary svg { width: 18px; height: 18px; }
.ocr-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; user-select: text; -webkit-user-select: text; max-height: 260px; overflow-y: auto; padding: 4px 0; }
.ocr-text.big { max-height: 55vh; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.ocr-actions { display: flex; gap: 4px; justify-content: flex-end; padding-bottom: 4px; }
.howto { margin: 4px 0 8px; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.howto li { margin-bottom: 4px; }
.howto code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }

/* ================= Vorschau-Karten (überschreibt die Grundwerte oben) ================= */
.card {
  display: flex; flex-direction: column; padding: 0;
  height: var(--card-h); overflow: hidden;
}
.layout-list .card { height: auto; max-height: 190px; }
.card-thumb { position: relative; flex: none; height: 46%; background: var(--chip); overflow: hidden; }
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-thumb.drawing { background: #fff; }
.card-thumb.drawing img { object-fit: contain; }
.card.media-only .card-thumb { flex: 1; height: auto; }
.layout-list .card-thumb { height: 110px; }
.card-body {
  flex: 1; min-height: 0; overflow: hidden; padding: 12px 14px 0;
  -webkit-mask-image: linear-gradient(#000 78%, transparent);
  mask-image: linear-gradient(#000 78%, transparent);
}
.card .card-title {
  margin: 0 22px 4px 0; font-size: 15px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card.has-media .card-title { margin-right: 0; }
.card .card-text { font-size: 14px; line-height: 1.45; -webkit-line-clamp: 5; color: var(--text); opacity: .88; }
.card .card-title + .card-text { -webkit-line-clamp: 4; }
.card.has-media .card-text { -webkit-line-clamp: 2; }
.card .card-list { gap: 3px; }
.card .card-list li { font-size: 14px; }
.card .card-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .card-done { margin-top: 4px; padding-left: 0; font-size: 12.5px; }
.card-hint { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.card-hint svg { width: 22px; height: 22px; }
.card-empty { font-size: 13.5px; }
.card-foot {
  flex: none; display: flex; align-items: center; gap: 6px; overflow: hidden;
  padding: 6px 12px 10px;
}
.card-foot .chip { flex: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .audio-chip { flex: none; height: 26px; }
.card-pin { z-index: 1; }
.card-pin.over-media { top: 6px; right: 6px; }
body.dragging .note-section { transition: none; }
body.dragging, body.dragging * { cursor: grabbing !important; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

/* ================= Handy ================= */
@media (max-width: 599px) {
  .editor-backdrop { padding: 0; background: var(--bg); }
  .editor { width: 100%; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; animation: none; }
  .ed-top { padding-top: calc(6px + env(safe-area-inset-top)); }
  .ed-scroll { padding: 0 18px 16px; }
  .ed-item .icon-btn { opacity: 0; }
  .ed-item:focus-within .icon-btn { opacity: 1; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 20px 20px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .ed-media { margin: 0 -18px 10px; }
  .rec-backdrop { align-items: end; padding: 0; }
  .rec-sheet { width: 100%; border-radius: 20px 20px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .toast { left: 12px; right: 96px; max-width: none; transform: translateY(16px); }
  .toast.show { transform: none; }
  .toast span { flex: 1; }
}

/* ================= Desktop ================= */
@media (min-width: 900px) {
  .brand { display: flex; }
  .topbar { padding: 8px 16px; }
  .drawer {
    top: calc(var(--topbar-h) + 1px); z-index: 10; width: 272px;
    transform: none; box-shadow: none; background: transparent; padding-top: 10px;
    transition: width .2s ease;
  }
  .drawer-brand { display: none; }
  .main { margin-left: 272px; padding: 22px 32px 120px; transition: margin-left .2s ease; }
  body.drawer-collapsed .drawer { width: 76px; overflow-x: hidden; }
  body.drawer-collapsed .main { margin-left: 76px; }
  body.drawer-collapsed .nav-item { width: 56px; padding: 0 16px; }
  body.drawer-collapsed .nav-label,
  body.drawer-collapsed .nav-count,
  body.drawer-collapsed .nav-section,
  body.drawer-collapsed .drawer-foot { display: none; }
  .scrim { display: none; }
  .fabs { right: 32px; bottom: 32px; }
  .fab-items { right: 32px; bottom: 108px; }
}
