/* =====================================================================
   Notizen-App: Notizbücher | Liste | Editor
   ===================================================================== */
main.view-notizen { max-width: none; height: 100vh; height: 100dvh; padding: 0; overflow: hidden; }
.notes-app { display: grid; grid-template-columns: 240px 330px 1fr; height: 100%; }
.mobile-only { display: none !important; }

/* ---------------------------------------------------------------- Notizbücher */
.nb-pane { display: flex; flex-direction: column; gap: 4px; padding: 20px 12px 14px; background: var(--bg-2); border-right: 1px solid var(--border); overflow-y: auto; }
.nb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 12px; }
.nb-head h2 { font-size: 1.3rem; }
.nb-group { display: flex; flex-direction: column; gap: 2px; }
.nb-label { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 6px 10px; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.nb-spacer { flex: 1; min-height: 16px; }
.nb-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text); cursor: pointer; text-align: left; font-size: 0.92rem; transition: background 0.12s;
}
.nb-item:hover { background: var(--card-hover); }
.nb-item.on { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
.nb-item.drop { background: color-mix(in srgb, var(--accent) 25%, transparent); outline: 2px dashed var(--accent); }
.nb-icon { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 8px; font-size: 0.95rem; }
.nb-icon.plain { color: var(--muted); }
.nb-item.on .nb-icon.plain { color: var(--accent); }
.nb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-count { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.nb-tools { display: none; }
.nb-item:hover .nb-tools { display: inline-flex; }
.nb-item:hover .nb-count { display: none; }

/* ---------------------------------------------------------------- Liste */
.list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--bg); }
.list-head { display: flex; align-items: center; gap: 8px; padding: 20px 14px 10px 18px; }
.list-head h3 { font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { font-size: 0.8rem; color: var(--muted); }
.list-tools { display: flex; gap: 6px; padding: 0 14px 12px; }
.notes-search { flex: 1; padding: 8px 11px !important; }
.notes-sort { width: auto !important; padding: 8px !important; font-size: 0.82rem; }
.note-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; display: flex; flex-direction: column; gap: 2px; }
.note-item {
  display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; transition: background 0.12s; border-bottom: 1px solid var(--border);
}
.note-item:hover { background: var(--card-hover); }
.note-item.on { background: color-mix(in srgb, var(--accent) 14%, var(--card-solid)); border-bottom-color: transparent; }
.ni-top { display: flex; align-items: center; gap: 6px; }
.ni-title { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni-pin { color: #f5a623; }
.ni-pin svg { fill: currentColor; }
.ni-preview { font-size: 0.84rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.ni-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 0.72rem; color: var(--muted); }
.ni-nb { display: inline-flex; align-items: center; gap: 5px; }
.ni-nb .dot { width: 7px; height: 7px; }
.ni-tag { color: var(--accent); }
.notes-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 16px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- Editor */
.editor-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card-solid); }
.editor-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.editor-empty p { margin: 0 0 6px; }
.ed-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ed-nb { width: auto !important; max-width: 220px; padding: 6px 10px !important; font-size: 0.85rem; }
.ed-status { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.ed-head .icon-btn.on { color: #f5a623; background: rgba(245, 166, 35, 0.14); }
.ed-head .icon-btn.on svg { fill: currentColor; }
.trash-banner { padding: 10px 20px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 0.88rem; font-weight: 550; }

.ed-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.tb-btn { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.tb-btn:hover { background: var(--card-hover); color: var(--text); }
.tb-btn.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tb-block { width: auto !important; padding: 5px 8px !important; font-size: 0.84rem; background: transparent !important; border-color: transparent !important; }
.tb-block:hover { background: var(--card-hover) !important; }

.ed-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 28px clamp(20px, 5vw, 72px) 60px; }
.note-title {
  width: 100%; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important;
  font-size: 2rem !important; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 14px; color: var(--text);
}
.note-title::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.note-editor { min-height: 60vh; outline: none; font-size: 1.02rem; line-height: 1.7; max-width: 860px; word-wrap: break-word; }
.note-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.note-editor p { margin: 0 0 0.6em; }
.note-editor h1 { font-size: 1.65rem; margin: 1.1em 0 0.4em; }
.note-editor h2 { font-size: 1.35rem; margin: 1em 0 0.4em; }
.note-editor h3 { font-size: 1.12rem; margin: 0.9em 0 0.3em; }
.note-editor h1:first-child, .note-editor h2:first-child, .note-editor h3:first-child { margin-top: 0; }
.note-editor ul, .note-editor ol { margin: 0 0 0.7em; padding-left: 1.6em; }
.note-editor li { margin: 0.15em 0; }
.note-editor blockquote { margin: 0.8em 0; padding: 4px 16px; border-left: 4px solid var(--accent); color: var(--muted); background: var(--bg-2); border-radius: 0 8px 8px 0; }
.note-editor pre { margin: 0.8em 0; padding: 14px 16px; border-radius: 10px; background: #0d1117; color: #e6edf3; font: 0.9rem/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; }
.note-editor code { font: 0.88em ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.note-editor pre code { background: none; border: 0; padding: 0; }
.note-editor a { color: var(--accent); text-decoration: underline; cursor: pointer; }
.note-editor hr { border: 0; border-top: 2px solid var(--border); margin: 1.4em 0; }
.note-editor img { max-width: 100%; border-radius: 10px; margin: 6px 0; }
.note-editor table { border-collapse: collapse; margin: 0.8em 0; width: 100%; font-size: 0.95rem; }
.note-editor th, .note-editor td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; min-width: 60px; }
.note-editor th { background: var(--bg-2); font-weight: 650; }
.note-editor ul.checklist { list-style: none; padding-left: 0.2em; }
.note-editor ul.checklist > li { position: relative; padding-left: 30px; }
.note-editor ul.checklist > li::before {
  content: ""; position: absolute; left: 0; top: 0.28em; width: 18px; height: 18px; border-radius: 6px;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent); cursor: pointer; transition: all 0.15s; box-sizing: border-box;
}
.note-editor ul.checklist > li[data-checked="true"] { color: var(--muted); text-decoration: line-through; }
.note-editor ul.checklist > li[data-checked="true"]::before {
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--success);
}
.ed-foot { display: flex; align-items: center; gap: 8px; padding: 8px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; }
.note-tags { flex: 1; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 4px 0 !important; font-size: 0.84rem; }
.ed-count { white-space: nowrap; }

/* ---------------------------------------------------------------- Popups */
.popup-menu {
  position: fixed; z-index: 150; min-width: 200px; padding: 6px; border-radius: 12px;
  background: var(--card-solid); border: 1px solid var(--border); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); animation: pop 0.12s;
}
.popup-menu > button { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; color: var(--text); font-size: 0.9rem; }
.popup-menu > button:hover { background: var(--card-hover); }
.popup-menu > button.danger { color: var(--danger); }
.color-pop { min-width: 0; padding: 10px; }
.pop-label { font-size: 0.75rem; color: var(--muted); font-weight: 650; margin-bottom: 8px; }
.color-row { display: flex; flex-wrap: wrap; gap: 6px; max-width: 220px; }
.color-sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.color-sw.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.color-sw.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%) !important; }
.emoji-input { width: 110px !important; }

/* ---------------------------------------------------------------- Drucken */
@media print {
  body.print-note .sidebar, body.print-note .bottom-nav, body.print-note .nb-pane, body.print-note .list-pane,
  body.print-note .ed-head, body.print-note .ed-toolbar, body.print-note .ed-foot, body.print-note #bg { display: none !important; }
  body.print-note main, body.print-note .notes-app, body.print-note .editor-pane, body.print-note .ed-scroll { display: block !important; height: auto !important; overflow: visible !important; margin: 0 !important; padding: 0 !important; background: #fff !important; color: #000 !important; }
}

/* ---------------------------------------------------------------- Responsiv */
@media (max-width: 1100px) {
  .notes-app { grid-template-columns: 210px 280px 1fr; }
  .ed-toolbar { gap: 0; }
}
@media (max-width: 760px) {
  main.view-notizen { height: auto; min-height: 100vh; padding: 0 0 calc(70px + env(safe-area-inset-bottom)); overflow: visible; }
  .notes-app { display: block; height: calc(100dvh - 70px - env(safe-area-inset-bottom)); }
  .mobile-only { display: inline-flex !important; }
  .notes-app > * { display: none; height: 100%; border: 0; }
  .notes-app[data-pane="nb"] .nb-pane, .notes-app[data-pane="list"] .list-pane, .notes-app[data-pane="editor"] .editor-pane { display: flex; }
  .list-head { padding: 16px 12px 10px; }
  .ed-head { padding: 8px 10px; }
  .ed-toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 4px 8px; scrollbar-width: none; }
  .ed-toolbar::-webkit-scrollbar { display: none; }
  .tb-btn { flex: none; }
  .ed-scroll { padding: 18px 16px 40px; }
  .note-title { font-size: 1.5rem !important; }
  .ed-status { display: none; }
}
